Skip to content

Commit 69ee28a

Browse files
committed
deploy: 851cfff
1 parent 38c2110 commit 69ee28a

30 files changed

Lines changed: 579 additions & 78 deletions

File tree

‎assets/default-project/en.zip‎

0 Bytes
Binary file not shown.

‎assets/sample-projects/HTML5.zip‎

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

‎assets/sample-projects/explore.zip‎

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

‎cacheManifest.json‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"assets/default-project/en.zip": "c2236757cf18ba7eb753590c85f821b0",
2+
"assets/default-project/en.zip": "b29d92a0a481abcc6352eb87e3114f9a",
33
"assets/default-project/en/Feature Highlights.markdown": "89f75b12d577829b19f2db4fbbc4b5dc",
44
"assets/default-project/en/Features.md": "05fa1291228099ed14f8d3848c1caaeb",
55
"assets/default-project/en/images/cloud1.svg": "aca7bba84a2237f1c1988caea54a67a9",
@@ -116,7 +116,7 @@
116116
"assets/phoenix-splash/no-preview.html": "e62c3e83f0dfa1abb595e8e4ad67ff92",
117117
"assets/phoenix-splash/safari.html": "dbe3e156bb436b14f4c41888b5d1f2cf",
118118
"assets/phoenix-splash/styles.css": "6779a4e26a1f27a64035c8b67f9ce729",
119-
"assets/sample-projects/bootstrap-blog.zip": "2c6d25beb479cabe2f45657f89ebe9ef",
119+
"assets/sample-projects/bootstrap-blog.zip": "db2ced37b783cf075cd094f945dd7a07",
120120
"assets/sample-projects/bootstrap-blog/assets/brand/bootstrap-logo-white.svg": "2e642df55357162ad28519305c8fd4fe",
121121
"assets/sample-projects/bootstrap-blog/assets/brand/bootstrap-logo.svg": "88eef7f3c2bcf988457a0e6d123c3f1d",
122122
"assets/sample-projects/bootstrap-blog/assets/dist/css/bootstrap.min.css": "6d9c6fda1e7087224431cc8068bb998f",
@@ -126,7 +126,7 @@
126126
"assets/sample-projects/bootstrap-blog/blog.rtl.css": "c6c275bf0b804d3dec264ec7fb3d7677",
127127
"assets/sample-projects/bootstrap-blog/index-rtl.html": "506e2d3fd1c4bb3651377144a62d5e82",
128128
"assets/sample-projects/bootstrap-blog/index.html": "dd8824ad3c9520dc0a825176d20eb694",
129-
"assets/sample-projects/dashboard.zip": "5945c21a9ddb502053012a245e9397dc",
129+
"assets/sample-projects/dashboard.zip": "dfa5ee5562b7515430e380b0e30c5fc7",
130130
"assets/sample-projects/dashboard/assets/brand/bootstrap-logo-white.svg": "2e642df55357162ad28519305c8fd4fe",
131131
"assets/sample-projects/dashboard/assets/brand/bootstrap-logo.svg": "88eef7f3c2bcf988457a0e6d123c3f1d",
132132
"assets/sample-projects/dashboard/assets/dist/css/bootstrap.min.css": "6d9c6fda1e7087224431cc8068bb998f",
@@ -138,7 +138,7 @@
138138
"assets/sample-projects/dashboard/index.html": "ddfda6ea9dfc8e12a8dcbbf065c804de",
139139
"assets/sample-projects/dashboard/signin.css": "a71ff2b493f230e0d6585793c2115809",
140140
"assets/sample-projects/dashboard/signin.html": "b108c183dfa7e2da3d88ec79bee79509",
141-
"assets/sample-projects/explore.zip": "0eb7e7edd04031b61857f6ecd5429e65",
141+
"assets/sample-projects/explore.zip": "d27308282dbdc469baa030bdd856d195",
142142
"assets/sample-projects/explore/A-tribute-page.html": "007699e85177db3d1cd87d0d47440b36",
143143
"assets/sample-projects/explore/adjustable-fireworks.html": "706a0995d00d8ae009b5426cf7ee69be",
144144
"assets/sample-projects/explore/ant_colony.html": "d0885229e57caecc83049b50ee98560c",
@@ -228,7 +228,7 @@
228228
"assets/sample-projects/explore/watermelon-pixel.html": "6f6754e8073436bb823807a10a0446ea",
229229
"assets/sample-projects/explore/webmine.html": "9879458a48c757dc6671d408e940da4d",
230230
"assets/sample-projects/explore/whack-a-mole.html": "827f15c53657350b9c898fa27ecf15ac",
231-
"assets/sample-projects/home-pages.zip": "699c4a49799a238ead227e4bc2ae9138",
231+
"assets/sample-projects/home-pages.zip": "e30e241c9dbaecc35d1b8f41c89c21e6",
232232
"assets/sample-projects/home-pages/album/index.html": "df20e4a479659463ab9d3f6b4ca4dbd1",
233233
"assets/sample-projects/home-pages/assets/brand/bootstrap-logo-white.svg": "2e642df55357162ad28519305c8fd4fe",
234234
"assets/sample-projects/home-pages/assets/brand/bootstrap-logo.svg": "88eef7f3c2bcf988457a0e6d123c3f1d",
@@ -240,7 +240,7 @@
240240
"assets/sample-projects/home-pages/carousel/index.html": "fc5bf7b2d8640a2c393f465294210e7c",
241241
"assets/sample-projects/home-pages/cover/cover.css": "3738586a82dd90263617020e7f1db82e",
242242
"assets/sample-projects/home-pages/cover/index.html": "a0ae1a11224672532b3466df93ce0821",
243-
"assets/sample-projects/HTML5.zip": "db7508e7f86d41657aa60b312bad48e7",
243+
"assets/sample-projects/HTML5.zip": "a70bbce882c3a618933e3917ce8424e9",
244244
"assets/sample-projects/HTML5/index.html": "ca318e370d63b3e083d3bd63052b8252",
245245
"assets/sample-projects/HTML5/script.js": "47de56d88cd6d866c4f77027128c0dd7",
246246
"assets/sample-projects/HTML5/styles.css": "8c798c8b3bba7e4d49dfe99b4deccd47",
@@ -250,10 +250,10 @@
250250
"brackets.config.dist.json": "067654f0936d60f59d5fa493c6b3ed1c",
251251
"brackets.config.staging.json": "53d44a23a939eaaaea05e072c8780584",
252252
"brackets.js": "bb2687b34745876749beff06fc1bd2b4",
253-
"cacheManifest.json": "6a226289b0c9cfda1dbb60c48987a88c",
253+
"cacheManifest.json": "22f855cf8a806255e62d18196b88d878",
254254
"command/CommandManager.js": "ebbc15626600575d2dfe2a97da2993a0",
255255
"command/Commands.js": "d1b78cbe3e6272c06e442d8c3441838c",
256-
"command/DefaultMenus.js": "584a9294b73f2eeb4c15c97186b0e765",
256+
"command/DefaultMenus.js": "082f4dc2fb1cfc6212195e651bd58d0e",
257257
"command/KeyBindingManager.js": "217d8614e1fb33918dbca0c452fa319a",
258258
"command/Menus.js": "7c0cfc8ef89ea0ea52317c57b155f6a9",
259259
"config.json": "c3804e70717ff0d491c2f9263535056d",
@@ -353,11 +353,13 @@
353353
"extensions/default/HealthData/styles.css": "3a0ee296a52d5c1c55ae9166abb70bfd",
354354
"extensions/default/HealthData/unittests.js": "44b42b2fa3d29fd52818e646840009ed",
355355
"extensions/default/HTMLCodeHints/HtmlAttributes.json": "c628a0ec43448808404fc89dd09ca9e3",
356+
"extensions/default/HTMLCodeHints/HTMLJumpToDef.js": "3647152c4b99640ab7eed7b7b25d0bb4",
356357
"extensions/default/HTMLCodeHints/HtmlTags.json": "7f6a3c00b2aca17855bd19c810674232",
357-
"extensions/default/HTMLCodeHints/main.js": "7296f44c4632409c9c85f90acaeb1f8a",
358+
"extensions/default/HTMLCodeHints/integ-tests.js": "1af454c364a990f4a801e2ff987468fc",
359+
"extensions/default/HTMLCodeHints/main.js": "059b9cd5ff67e5384a12b59aeab9df5c",
358360
"extensions/default/HTMLCodeHints/package.json": "ac9f6b1673846bdf58266c7becdcc3bb",
359361
"extensions/default/HTMLCodeHints/requirejs-config.json": "d41d8cd98f00b204e9800998ecf8427e",
360-
"extensions/default/HTMLCodeHints/unittests.js": "6e287a266632f974e69b2cc1741de4e1",
362+
"extensions/default/HTMLCodeHints/unittests.js": "d108c60abd00c82ea1f4beb14455215a",
361363
"extensions/default/HtmlEntityCodeHints/main.js": "85d2c1b84d286bee5d6207be91784ac0",
362364
"extensions/default/HtmlEntityCodeHints/package.json": "0f08d4b8539d14facd6108e3b52ae30f",
363365
"extensions/default/HtmlEntityCodeHints/requirejs-config.json": "d41d8cd98f00b204e9800998ecf8427e",
@@ -408,7 +410,7 @@
408410
"extensions/default/InlineTimingFunctionEditor/unittests.js": "55802ad011c607a916ecbda5b1a91630",
409411
"extensions/default/JavaScriptCodeHints/fix-acorn.js": "5807c667d67bc594ce74f0130c8577a1",
410412
"extensions/default/JavaScriptCodeHints/HintUtils2.js": "002cdbb7ca7e2a1ad351fba9c7e7af1b",
411-
"extensions/default/JavaScriptCodeHints/main.js": "898840599bcc32f970c936c9cde619d3",
413+
"extensions/default/JavaScriptCodeHints/main.js": "ae75f71fbc9bd606b0aefb8f9bbf1caa",
412414
"extensions/default/JavaScriptCodeHints/npm-shrinkwrap.json": "a0cd24ba855e453ee6629dbc75eda7c6",
413415
"extensions/default/JavaScriptCodeHints/package.json": "fdef4b6787369d97a78196160153ca87",
414416
"extensions/default/JavaScriptCodeHints/ParameterHintsProvider.js": "8abd9698df44ee93615aa74ec0ea5e07",
@@ -635,7 +637,7 @@
635637
"extensions/samples/TypingSpeedLogger/main.js": "77e5dc1f043cefd551a7dcc644668644",
636638
"features/BeautificationManager.js": "aab4868d73defa5d4232802539f7ecab",
637639
"features/FindReferencesManager.js": "f3d8e8833736a3a978956e54c6df8a8f",
638-
"features/JumpToDefManager.js": "d8d9d6d5051bb9543b03d495646f8295",
640+
"features/JumpToDefManager.js": "15a7f7bd017fbc4b55a55bd62dd88f0b",
639641
"features/ParameterHintsManager.js": "f884165c7245e20b8325974fb84e99c3",
640642
"features/PriorityBasedRegistration.js": "64d119ee01c0a4a6e61737f1423364a7",
641643
"features/QuickViewManager.js": "596feb72a229c51e2e34423c95506211",

‎command/DefaultMenus.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ define(function (require, exports, module) {
268268
// editor_cmenu.addMenuItem(Commands.NAVIGATE_JUMPTO_DEFINITION);
269269
editor_cmenu.addMenuItem(Commands.TOGGLE_QUICK_EDIT);
270270
editor_cmenu.addMenuItem(Commands.TOGGLE_QUICK_DOCS);
271+
editor_cmenu.addMenuItem(Commands.NAVIGATE_JUMPTO_DEFINITION);
271272
editor_cmenu.addMenuItem(Commands.CMD_FIND_ALL_REFERENCES);
272273
editor_cmenu.addMenuDivider();
273274
editor_cmenu.addMenuItem(Commands.EDIT_CUT);
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* GNU AGPL-3.0 License
3+
*
4+
* Copyright (c) 2021 - present core.ai . All rights reserved.
5+
*
6+
* This program is free software: you can redistribute it and/or modify it
7+
* under the terms of the GNU Affero General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
14+
* for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see https://opensource.org/licenses/AGPL-3.0.
18+
*
19+
*/
20+
21+
/*global path */
22+
23+
define(function (require, exports, module) {
24+
25+
const AppInit = brackets.getModule("utils/AppInit"),
26+
JumpToDefManager = brackets.getModule("features/JumpToDefManager"),
27+
CommandManager = brackets.getModule("command/CommandManager"),
28+
Commands = brackets.getModule("command/Commands"),
29+
FileViewController = brackets.getModule("project/FileViewController");
30+
31+
function HTMLJumpToDefProvider() {
32+
}
33+
34+
/**
35+
* Check to see if the html token under token os of the form href="file" or src="file"
36+
* @param editor
37+
* @param token
38+
* @private
39+
*/
40+
function _isSrcOrHrefString(editor, token) {
41+
if(token.type !== "string"){
42+
return false;
43+
}
44+
const equalsToken = editor.getPreviousToken({line: token.line, ch: token.start+1}); // possble = token
45+
const hrefOrSrcToken = editor.getPreviousToken({line: equalsToken.line, ch: equalsToken.start+1});
46+
return (equalsToken.string === "=" && ["href", "src"].includes(hrefOrSrcToken.string));
47+
}
48+
49+
const jumpTokenTypes = ["tag", "string"];
50+
51+
HTMLJumpToDefProvider.prototype.canJumpToDef = function (editor, optionalPosition) {
52+
let pos = optionalPosition || editor.getCursorPos();
53+
let token = editor.getToken(pos);
54+
if(token && token.type && jumpTokenTypes.includes(token.type)){
55+
return true;
56+
}
57+
return false;
58+
};
59+
60+
function _openFile(fileRelativePath, mainDocPath) {
61+
if(fileRelativePath.startsWith("http://") || fileRelativePath.startsWith("https://")){
62+
return FileViewController.openAndSelectDocument(fileRelativePath, FileViewController.PROJECT_MANAGER);
63+
}
64+
const targetPath = path.resolve(mainDocPath, fileRelativePath);
65+
return FileViewController.openAndSelectDocument(targetPath, FileViewController.PROJECT_MANAGER);
66+
}
67+
68+
/**
69+
* Method to handle jump to definition feature.
70+
*/
71+
HTMLJumpToDefProvider.prototype.doJumpToDef = function (editor) {
72+
if(!this.canJumpToDef(editor)){
73+
return new $.Deferred().reject().promise();
74+
}
75+
const token = editor.getToken();
76+
if(_isSrcOrHrefString(editor, token)) {
77+
return _openFile(token.string.replace(/['"]+/g, ''), editor.document.file.parentPath);
78+
}
79+
return CommandManager.execute(Commands.TOGGLE_QUICK_EDIT);
80+
};
81+
82+
AppInit.appReady(function () {
83+
var jdProvider = new HTMLJumpToDefProvider();
84+
JumpToDefManager.registerJumpToDefProvider(jdProvider, ["html"], 0);
85+
});
86+
87+
});
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
/*
2+
* GNU AGPL-3.0 License
3+
*
4+
* Copyright (c) 2021 - present core.ai . All rights reserved.
5+
* Original work Copyright (c) 2012 - 2021 Adobe Systems Incorporated. All rights reserved.
6+
*
7+
* This program is free software: you can redistribute it and/or modify it
8+
* under the terms of the GNU Affero General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful, but WITHOUT
13+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
15+
* for more details.
16+
*
17+
* You should have received a copy of the GNU Affero General Public License
18+
* along with this program. If not, see https://opensource.org/licenses/AGPL-3.0.
19+
*
20+
*/
21+
22+
/*global describe, it, expect, beforeAll, afterAll, awaitsForDone, awaitsForFail */
23+
24+
define(function (require, exports, module) {
25+
// Recommended to avoid reloading the integration test window Phoenix instance for each test.
26+
27+
const SpecRunnerUtils = brackets.getModule("spec/SpecRunnerUtils");
28+
29+
describe("integration:HTML Code Hints integration tests", function () {
30+
31+
const testPath = SpecRunnerUtils.getTestPath("/spec/LiveDevelopment-MultiBrowser-test-files");
32+
33+
let FileViewController, // loaded from brackets.test
34+
ProjectManager, // loaded from brackets.test;
35+
CommandManager,
36+
Commands,
37+
testWindow,
38+
EditorManager,
39+
MainViewManager,
40+
brackets;
41+
42+
43+
beforeAll(async function () {
44+
testWindow = await SpecRunnerUtils.createTestWindowAndRun();
45+
brackets = testWindow.brackets;
46+
FileViewController = brackets.test.FileViewController;
47+
ProjectManager = brackets.test.ProjectManager;
48+
CommandManager = brackets.test.CommandManager;
49+
Commands = brackets.test.Commands;
50+
EditorManager = brackets.test.EditorManager;
51+
MainViewManager = brackets.test.MainViewManager;
52+
53+
await SpecRunnerUtils.loadProjectInTestWindow(testPath);
54+
}, 30000);
55+
56+
afterAll(function () {
57+
FileViewController = null;
58+
ProjectManager = null;
59+
testWindow = null;
60+
brackets = null;
61+
// comment out below line if you want to debug the test window post running tests
62+
//SpecRunnerUtils.closeTestWindow();
63+
});
64+
65+
async function closeSession() {
66+
await awaitsForDone(CommandManager.execute(Commands.FILE_CLOSE_ALL, { _forceClose: true }),
67+
"closing all file");
68+
}
69+
70+
it("Should jump to definition on div tag", async function () {
71+
await awaitsForDone(
72+
FileViewController.openAndSelectDocument(
73+
testPath + "/jumpToDef.html",
74+
FileViewController.PROJECT_MANAGER
75+
));
76+
const selected = ProjectManager.getSelectedItem();
77+
expect(selected.fullPath).toBe(testPath + "/jumpToDef.html");
78+
79+
let editor = EditorManager.getActiveEditor();
80+
editor.setCursorPos({ line: 5, ch: 6 });
81+
82+
await awaitsForDone(CommandManager.execute(Commands.NAVIGATE_JUMPTO_DEFINITION),
83+
"jump to def on div");
84+
85+
editor = EditorManager.getFocusedInlineEditor();
86+
expect(editor.document.file.fullPath.endsWith("LiveDevelopment-MultiBrowser-test-files/simpleShared.css"))
87+
.toBeTrue();
88+
await closeSession();
89+
});
90+
91+
it("Should jump to definition on css class", async function () {
92+
await awaitsForDone(
93+
FileViewController.openAndSelectDocument(
94+
testPath + "/jumpToDef.html",
95+
FileViewController.PROJECT_MANAGER
96+
));
97+
const selected = ProjectManager.getSelectedItem();
98+
expect(selected.fullPath).toBe(testPath + "/jumpToDef.html");
99+
100+
let editor = EditorManager.getActiveEditor();
101+
editor.setCursorPos({ line: 6, ch: 23 });
102+
103+
await awaitsForDone(CommandManager.execute(Commands.NAVIGATE_JUMPTO_DEFINITION),
104+
"jump to def on div");
105+
106+
editor = EditorManager.getFocusedInlineEditor();
107+
expect(editor.document.file.fullPath.endsWith("LiveDevelopment-MultiBrowser-test-files/sub/test.css"))
108+
.toBeTrue();
109+
await closeSession();
110+
});
111+
112+
async function verifySrcJumpToDef(location, targetFileName, jumpShouldFail) {
113+
await awaitsForDone(
114+
FileViewController.openAndSelectDocument(
115+
testPath + "/jumpToDef.html",
116+
FileViewController.PROJECT_MANAGER
117+
));
118+
const selected = ProjectManager.getSelectedItem();
119+
expect(selected.fullPath).toBe(testPath + "/jumpToDef.html");
120+
121+
let editor = EditorManager.getActiveEditor();
122+
editor.setCursorPos(location);
123+
124+
if(jumpShouldFail){
125+
await awaitsForFail(CommandManager.execute(Commands.NAVIGATE_JUMPTO_DEFINITION),
126+
"jump to def on div");
127+
} else {
128+
await awaitsForDone(CommandManager.execute(Commands.NAVIGATE_JUMPTO_DEFINITION),
129+
"jump to def on div");
130+
}
131+
132+
let currentFile = MainViewManager.getCurrentlyViewedFile();
133+
expect(currentFile.fullPath.endsWith(targetFileName))
134+
.toBeTrue();
135+
await closeSession();
136+
}
137+
138+
it("Should jump to files on href/src attributes", async function () {
139+
await verifySrcJumpToDef({ line: 3, ch: 44 }, "sub/test.css");
140+
await verifySrcJumpToDef({ line: 13, ch: 29 }, "blank.css");
141+
await verifySrcJumpToDef({ line: 11, ch: 32 }, "sub/icon_chevron.png");
142+
await closeSession();
143+
});
144+
145+
it("Should not jump to files on non href/src attributes", async function () {
146+
await verifySrcJumpToDef({ line: 14, ch: 47 }, "jumpToDef.html", true);
147+
await verifySrcJumpToDef({ line: 7, ch: 20 }, "jumpToDef.html", true);
148+
await verifySrcJumpToDef({ line: 3, ch: 22 }, "jumpToDef.html", true);
149+
await closeSession();
150+
});
151+
152+
});
153+
});

0 commit comments

Comments
 (0)