Skip to content

Commit 143689d

Browse files
committed
deploy: baafd09
0 parents  commit 143689d

File tree

5,242 files changed

+1487761
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,242 files changed

+1487761
-0
lines changed

.nojekyll

Whitespace-only changes.

CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
create.phcode.dev

JSUtils/HintUtils.js

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
/*
2+
* GNU AGPL-3.0 License
3+
*
4+
* Copyright (c) 2021 - present core.ai . All rights reserved.
5+
* Original work Copyright (c) 2013 - 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+
/*jslint regexp: true */
23+
24+
define(function (require, exports, module) {
25+
26+
27+
var Acorn = require("thirdparty/acorn/dist/acorn");
28+
29+
var LANGUAGE_ID = "javascript",
30+
JSX_LANGUAGE_ID = "jsx",
31+
HTML_LANGUAGE_ID = "html",
32+
PHP_LANGUAGE_ID = "php",
33+
SUPPORTED_LANGUAGES = [LANGUAGE_ID, JSX_LANGUAGE_ID, HTML_LANGUAGE_ID, PHP_LANGUAGE_ID],
34+
SINGLE_QUOTE = "'",
35+
DOUBLE_QUOTE = "\"";
36+
37+
/**
38+
* Create a hint token with name value that occurs at the given list of
39+
* positions.
40+
*
41+
* @param {string} value - name of the new hint token
42+
* @param {?Array.<number>=} positions - optional list of positions at which
43+
* the token occurs
44+
* @return {Object} - a new hint token
45+
*/
46+
function makeToken(value, positions) {
47+
positions = positions || [];
48+
49+
return {
50+
value: value,
51+
positions: positions
52+
};
53+
}
54+
55+
/**
56+
* Is the string key perhaps a valid JavaScript identifier?
57+
*
58+
* @param {string} key - string to test.
59+
* @return {boolean} - could key be a valid identifier?
60+
*/
61+
function maybeIdentifier(key) {
62+
var result = false,
63+
i;
64+
65+
for (i = 0; i < key.length; i++) {
66+
result = Acorn.isIdentifierChar(key.charCodeAt(i));
67+
if (!result) {
68+
break;
69+
}
70+
}
71+
72+
return result;
73+
}
74+
75+
/**
76+
* Is the token's class hintable? (A very conservative test.)
77+
*
78+
* @param {Object} token - the token to test for hintability
79+
* @return {boolean} - could the token be hintable?
80+
*/
81+
function hintable(token) {
82+
83+
function _isInsideRegExp(token) {
84+
return token.state && (token.state.lastType === "regexp" ||
85+
(token.state.localState && token.state.localState.lastType === "regexp"));
86+
}
87+
88+
switch (token.type) {
89+
case "comment":
90+
case "number":
91+
case "regexp":
92+
case "string":
93+
case "def": // exclude variable & param decls
94+
return false;
95+
case "string-2":
96+
// exclude strings inside a regexp
97+
return !_isInsideRegExp(token);
98+
default:
99+
return true;
100+
}
101+
}
102+
103+
/**
104+
* Determine if hints should be displayed for the given key.
105+
*
106+
* @param {string} key - key entered by the user
107+
* @param {boolean} showOnDot - show hints on dot (".").
108+
* @return {boolean} true if the hints should be shown for the key,
109+
* false otherwise.
110+
*/
111+
function hintableKey(key, showOnDot) {
112+
return (key === null || (showOnDot && key === ".") || maybeIdentifier(key));
113+
}
114+
115+
/*
116+
* Get a JS-hints-specific event name. Used to prevent event namespace
117+
* pollution.
118+
*
119+
* @param {string} name - the unqualified event name
120+
* @return {string} - the qualified event name
121+
*/
122+
function eventName(name) {
123+
var EVENT_TAG = "brackets-js-hints";
124+
return name + "." + EVENT_TAG;
125+
}
126+
127+
/*
128+
* Annotate a list of tokens as literals of a particular kind;
129+
* if string literals, annotate with an appropriate delimiter.
130+
*
131+
* @param {Array.<Object>} literals - list of hint tokens
132+
* @param {string} kind - the kind of literals in the list (e.g., "string")
133+
* @return {Array.<Object>} - the input array; to each object in the array a
134+
* new literal {boolean} property has been added to indicate that it
135+
* is a literal hint, and also a new kind {string} property to indicate
136+
* the literal kind. For string literals, a delimiter property is also
137+
* added to indicate what the default delimiter should be (viz. a
138+
* single or double quotation mark).
139+
*/
140+
function annotateLiterals(literals, kind) {
141+
return literals.map(function (t) {
142+
t.literal = true;
143+
t.kind = kind;
144+
t.origin = "ecmascript";
145+
if (kind === "string") {
146+
if (/[^\\]"/.test(t.value)) {
147+
t.delimiter = SINGLE_QUOTE;
148+
} else {
149+
t.delimiter = DOUBLE_QUOTE;
150+
}
151+
}
152+
return t;
153+
});
154+
}
155+
156+
/*
157+
* Annotate a list of tokens as keywords
158+
*
159+
* @param {Array.<Object>} keyword - list of keyword tokens
160+
* @return {Array.<Object>} - the input array; to each object in the array a
161+
* new keyword {boolean} property has been added to indicate that the
162+
* hint is a keyword.
163+
*/
164+
function annotateKeywords(keywords) {
165+
return keywords.map(function (t) {
166+
t.keyword = true;
167+
t.origin = "ecmascript";
168+
return t;
169+
});
170+
}
171+
172+
function isSupportedLanguage(languageId) {
173+
return SUPPORTED_LANGUAGES.indexOf(languageId) !== -1;
174+
}
175+
176+
var KEYWORD_NAMES = [
177+
"break", "case", "catch", "class", "const", "continue", "debugger",
178+
"default", "delete", "do", "else", "export", "extends", "finally",
179+
"for", "function", "if", "import", "in", "instanceof", "let", "new",
180+
"return", "super", "switch", "this", "throw", "try", "typeof", "var",
181+
"void", "while", "with", "yield"
182+
],
183+
KEYWORD_TOKENS = KEYWORD_NAMES.map(function (t) {
184+
return makeToken(t, []);
185+
}),
186+
KEYWORDS = annotateKeywords(KEYWORD_TOKENS);
187+
188+
var LITERAL_NAMES = [
189+
"true", "false", "null"
190+
],
191+
LITERAL_TOKENS = LITERAL_NAMES.map(function (t) {
192+
return makeToken(t, []);
193+
}),
194+
LITERALS = annotateLiterals(LITERAL_TOKENS);
195+
196+
exports.makeToken = makeToken;
197+
exports.hintable = hintable;
198+
exports.hintableKey = hintableKey;
199+
exports.maybeIdentifier = maybeIdentifier;
200+
exports.eventName = eventName;
201+
exports.annotateLiterals = annotateLiterals;
202+
exports.isSupportedLanguage = isSupportedLanguage;
203+
exports.KEYWORDS = KEYWORDS;
204+
exports.LITERALS = LITERALS;
205+
exports.LANGUAGE_ID = LANGUAGE_ID;
206+
exports.SINGLE_QUOTE = SINGLE_QUOTE;
207+
exports.DOUBLE_QUOTE = DOUBLE_QUOTE;
208+
exports.SUPPORTED_LANGUAGES = SUPPORTED_LANGUAGES;
209+
});

JSUtils/MessageIds.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"TERN_ADD_FILES_MSG": "AddFiles",
3+
"TERN_UPDATE_FILE_MSG": "UpdateFile",
4+
"TERN_INIT_MSG": "Init",
5+
"TERN_JUMPTODEF_MSG": "JumptoDef",
6+
"TERN_COMPLETIONS_MSG": "Completions",
7+
"TERN_GET_FILE_MSG": "GetFile",
8+
"TERN_SCOPEDATA_MSG": "ScopeData",
9+
"TERN_CALLED_FUNC_TYPE_MSG": "FunctionType",
10+
"TERN_PRIME_PUMP_MSG": "PrimePump",
11+
"TERN_GET_GUESSES_MSG": "GetGuesses",
12+
"TERN_WORKER_READY": "WorkerReady",
13+
"TERN_INFERENCE_TIMEDOUT": "InferenceTimedOut",
14+
"SET_CONFIG": "SetConfig",
15+
"TERN_UPDATE_DIRTY_FILE": "UpdateDirtyFileEntry",
16+
"TERN_REFS": "getRefs",
17+
"TERN_CLEAR_DIRTY_FILES_LIST": "ClearDirtyFilesList",
18+
"TERN_FILE_INFO_TYPE_PART": "part",
19+
"TERN_FILE_INFO_TYPE_FULL": "full",
20+
"TERN_FILE_INFO_TYPE_EMPTY": "empty"
21+
}

0 commit comments

Comments
 (0)