id
int32 0
58k
| repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
sequence | docstring
stringlengths 4
11.8k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 86
226
|
---|---|---|---|---|---|---|---|---|---|---|---|
2,100 | adobe/brackets | src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js | performCleanup | function performCleanup(requester, filesToCache, notifyBack) {
var currentRequester = requester || "";
function filterFilesAndNotify(files, filesToCacheArr, notifyBackToBrackets) {
files.forEach(function (file) {
var fileExt = path.extname(path.basename(file));
if (filesToCacheArr.indexOf(fileExt) < 0) {
var fileFullPath = updateDir + '/' + file;
try {
fs.removeSync(fileFullPath);
} catch (e) {
console.log("AutoUpdate : Exception occured in removing ", fileFullPath, e);
}
}
});
if (notifyBackToBrackets) {
postMessageToBrackets(MessageIds.NOTIFY_SAFE_TO_DOWNLOAD, currentRequester);
}
}
fs.stat(updateDir)
.then(function (stats) {
if (stats) {
if (filesToCache) {
fs.readdir(updateDir)
.then(function (files) {
filterFilesAndNotify(files, filesToCache, notifyBack);
})
.catch(function (err) {
console.log("AutoUpdate : Error in Reading Update Dir for Cleanup : " + err.toString());
postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
currentRequester, nodeErrorMessages.UPDATEDIR_READ_FAILED);
});
} else {
fs.remove(updateDir)
.then(function () {
console.log('AutoUpdate : Update Directory in AppData Cleaned: Complete');
})
.catch(function (err) {
console.log("AutoUpdate : Error in Cleaning Update Dir : " + err.toString());
postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
currentRequester, nodeErrorMessages.UPDATEDIR_CLEAN_FAILED);
});
}
}
})
.catch(function (err) {
console.log("AutoUpdate : Error in Reading Update Dir stats for Cleanup : " + err.toString());
postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
currentRequester, nodeErrorMessages.UPDATEDIR_CLEAN_FAILED);
});
} | javascript | function performCleanup(requester, filesToCache, notifyBack) {
var currentRequester = requester || "";
function filterFilesAndNotify(files, filesToCacheArr, notifyBackToBrackets) {
files.forEach(function (file) {
var fileExt = path.extname(path.basename(file));
if (filesToCacheArr.indexOf(fileExt) < 0) {
var fileFullPath = updateDir + '/' + file;
try {
fs.removeSync(fileFullPath);
} catch (e) {
console.log("AutoUpdate : Exception occured in removing ", fileFullPath, e);
}
}
});
if (notifyBackToBrackets) {
postMessageToBrackets(MessageIds.NOTIFY_SAFE_TO_DOWNLOAD, currentRequester);
}
}
fs.stat(updateDir)
.then(function (stats) {
if (stats) {
if (filesToCache) {
fs.readdir(updateDir)
.then(function (files) {
filterFilesAndNotify(files, filesToCache, notifyBack);
})
.catch(function (err) {
console.log("AutoUpdate : Error in Reading Update Dir for Cleanup : " + err.toString());
postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
currentRequester, nodeErrorMessages.UPDATEDIR_READ_FAILED);
});
} else {
fs.remove(updateDir)
.then(function () {
console.log('AutoUpdate : Update Directory in AppData Cleaned: Complete');
})
.catch(function (err) {
console.log("AutoUpdate : Error in Cleaning Update Dir : " + err.toString());
postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
currentRequester, nodeErrorMessages.UPDATEDIR_CLEAN_FAILED);
});
}
}
})
.catch(function (err) {
console.log("AutoUpdate : Error in Reading Update Dir stats for Cleanup : " + err.toString());
postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
currentRequester, nodeErrorMessages.UPDATEDIR_CLEAN_FAILED);
});
} | [
"function",
"performCleanup",
"(",
"requester",
",",
"filesToCache",
",",
"notifyBack",
")",
"{",
"var",
"currentRequester",
"=",
"requester",
"||",
"\"\"",
";",
"function",
"filterFilesAndNotify",
"(",
"files",
",",
"filesToCacheArr",
",",
"notifyBackToBrackets",
")",
"{",
"files",
".",
"forEach",
"(",
"function",
"(",
"file",
")",
"{",
"var",
"fileExt",
"=",
"path",
".",
"extname",
"(",
"path",
".",
"basename",
"(",
"file",
")",
")",
";",
"if",
"(",
"filesToCacheArr",
".",
"indexOf",
"(",
"fileExt",
")",
"<",
"0",
")",
"{",
"var",
"fileFullPath",
"=",
"updateDir",
"+",
"'/'",
"+",
"file",
";",
"try",
"{",
"fs",
".",
"removeSync",
"(",
"fileFullPath",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"console",
".",
"log",
"(",
"\"AutoUpdate : Exception occured in removing \"",
",",
"fileFullPath",
",",
"e",
")",
";",
"}",
"}",
"}",
")",
";",
"if",
"(",
"notifyBackToBrackets",
")",
"{",
"postMessageToBrackets",
"(",
"MessageIds",
".",
"NOTIFY_SAFE_TO_DOWNLOAD",
",",
"currentRequester",
")",
";",
"}",
"}",
"fs",
".",
"stat",
"(",
"updateDir",
")",
".",
"then",
"(",
"function",
"(",
"stats",
")",
"{",
"if",
"(",
"stats",
")",
"{",
"if",
"(",
"filesToCache",
")",
"{",
"fs",
".",
"readdir",
"(",
"updateDir",
")",
".",
"then",
"(",
"function",
"(",
"files",
")",
"{",
"filterFilesAndNotify",
"(",
"files",
",",
"filesToCache",
",",
"notifyBack",
")",
";",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"\"AutoUpdate : Error in Reading Update Dir for Cleanup : \"",
"+",
"err",
".",
"toString",
"(",
")",
")",
";",
"postMessageToBrackets",
"(",
"MessageIds",
".",
"SHOW_ERROR_MESSAGE",
",",
"currentRequester",
",",
"nodeErrorMessages",
".",
"UPDATEDIR_READ_FAILED",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"fs",
".",
"remove",
"(",
"updateDir",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"console",
".",
"log",
"(",
"'AutoUpdate : Update Directory in AppData Cleaned: Complete'",
")",
";",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"\"AutoUpdate : Error in Cleaning Update Dir : \"",
"+",
"err",
".",
"toString",
"(",
")",
")",
";",
"postMessageToBrackets",
"(",
"MessageIds",
".",
"SHOW_ERROR_MESSAGE",
",",
"currentRequester",
",",
"nodeErrorMessages",
".",
"UPDATEDIR_CLEAN_FAILED",
")",
";",
"}",
")",
";",
"}",
"}",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"\"AutoUpdate : Error in Reading Update Dir stats for Cleanup : \"",
"+",
"err",
".",
"toString",
"(",
")",
")",
";",
"postMessageToBrackets",
"(",
"MessageIds",
".",
"SHOW_ERROR_MESSAGE",
",",
"currentRequester",
",",
"nodeErrorMessages",
".",
"UPDATEDIR_CLEAN_FAILED",
")",
";",
"}",
")",
";",
"}"
] | Performs clean up for the contents in Update Directory in AppData
@param {Array} filesToCache - array of file types to cache
@param {boolean} notifyBack - true if Brackets needs to be
notified post cleanup, false otherwise | [
"Performs",
"clean",
"up",
"for",
"the",
"contents",
"in",
"Update",
"Directory",
"in",
"AppData"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js#L332-L382 |
2,101 | adobe/brackets | src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js | initializeState | function initializeState(requester, updateParams) {
var currentRequester = requester || "";
_updateParams = updateParams;
installerPath = path.resolve(updateDir, updateParams.installerName);
postMessageToBrackets(MessageIds.NOTIFY_INITIALIZATION_COMPLETE, currentRequester);
} | javascript | function initializeState(requester, updateParams) {
var currentRequester = requester || "";
_updateParams = updateParams;
installerPath = path.resolve(updateDir, updateParams.installerName);
postMessageToBrackets(MessageIds.NOTIFY_INITIALIZATION_COMPLETE, currentRequester);
} | [
"function",
"initializeState",
"(",
"requester",
",",
"updateParams",
")",
"{",
"var",
"currentRequester",
"=",
"requester",
"||",
"\"\"",
";",
"_updateParams",
"=",
"updateParams",
";",
"installerPath",
"=",
"path",
".",
"resolve",
"(",
"updateDir",
",",
"updateParams",
".",
"installerName",
")",
";",
"postMessageToBrackets",
"(",
"MessageIds",
".",
"NOTIFY_INITIALIZATION_COMPLETE",
",",
"currentRequester",
")",
";",
"}"
] | Initializes the node with update parameters
@param {object} updateParams - json containing update parameters | [
"Initializes",
"the",
"node",
"with",
"update",
"parameters"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js#L388-L393 |
2,102 | adobe/brackets | src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js | registerNodeFunctions | function registerNodeFunctions() {
functionMap["node.downloadInstaller"] = downloadInstaller;
functionMap["node.performCleanup"] = performCleanup;
functionMap["node.validateInstaller"] = validateChecksum;
functionMap["node.initializeState"] = initializeState;
functionMap["node.checkInstallerStatus"] = checkInstallerStatus;
functionMap["node.removeFromRequesters"] = removeFromRequesters;
} | javascript | function registerNodeFunctions() {
functionMap["node.downloadInstaller"] = downloadInstaller;
functionMap["node.performCleanup"] = performCleanup;
functionMap["node.validateInstaller"] = validateChecksum;
functionMap["node.initializeState"] = initializeState;
functionMap["node.checkInstallerStatus"] = checkInstallerStatus;
functionMap["node.removeFromRequesters"] = removeFromRequesters;
} | [
"function",
"registerNodeFunctions",
"(",
")",
"{",
"functionMap",
"[",
"\"node.downloadInstaller\"",
"]",
"=",
"downloadInstaller",
";",
"functionMap",
"[",
"\"node.performCleanup\"",
"]",
"=",
"performCleanup",
";",
"functionMap",
"[",
"\"node.validateInstaller\"",
"]",
"=",
"validateChecksum",
";",
"functionMap",
"[",
"\"node.initializeState\"",
"]",
"=",
"initializeState",
";",
"functionMap",
"[",
"\"node.checkInstallerStatus\"",
"]",
"=",
"checkInstallerStatus",
";",
"functionMap",
"[",
"\"node.removeFromRequesters\"",
"]",
"=",
"removeFromRequesters",
";",
"}"
] | Generates a map for node side functions | [
"Generates",
"a",
"map",
"for",
"node",
"side",
"functions"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js#L405-L412 |
2,103 | adobe/brackets | src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js | initNode | function initNode(initObj) {
var resetUpdateProgres = false;
if (!isNodeDomainInitialized) {
MessageIds = initObj.messageIds;
updateDir = path.resolve(initObj.updateDir);
logFilePath = path.resolve(updateDir, logFile);
installStatusFilePath = path.resolve(updateDir, installStatusFile);
registerNodeFunctions();
isNodeDomainInitialized = true;
resetUpdateProgres = true;
}
postMessageToBrackets(MessageIds.NODE_DOMAIN_INITIALIZED, initObj.requester.toString(), resetUpdateProgres);
requesters[initObj.requester.toString()] = true;
postMessageToBrackets(MessageIds.REGISTER_BRACKETS_FUNCTIONS, initObj.requester.toString());
} | javascript | function initNode(initObj) {
var resetUpdateProgres = false;
if (!isNodeDomainInitialized) {
MessageIds = initObj.messageIds;
updateDir = path.resolve(initObj.updateDir);
logFilePath = path.resolve(updateDir, logFile);
installStatusFilePath = path.resolve(updateDir, installStatusFile);
registerNodeFunctions();
isNodeDomainInitialized = true;
resetUpdateProgres = true;
}
postMessageToBrackets(MessageIds.NODE_DOMAIN_INITIALIZED, initObj.requester.toString(), resetUpdateProgres);
requesters[initObj.requester.toString()] = true;
postMessageToBrackets(MessageIds.REGISTER_BRACKETS_FUNCTIONS, initObj.requester.toString());
} | [
"function",
"initNode",
"(",
"initObj",
")",
"{",
"var",
"resetUpdateProgres",
"=",
"false",
";",
"if",
"(",
"!",
"isNodeDomainInitialized",
")",
"{",
"MessageIds",
"=",
"initObj",
".",
"messageIds",
";",
"updateDir",
"=",
"path",
".",
"resolve",
"(",
"initObj",
".",
"updateDir",
")",
";",
"logFilePath",
"=",
"path",
".",
"resolve",
"(",
"updateDir",
",",
"logFile",
")",
";",
"installStatusFilePath",
"=",
"path",
".",
"resolve",
"(",
"updateDir",
",",
"installStatusFile",
")",
";",
"registerNodeFunctions",
"(",
")",
";",
"isNodeDomainInitialized",
"=",
"true",
";",
"resetUpdateProgres",
"=",
"true",
";",
"}",
"postMessageToBrackets",
"(",
"MessageIds",
".",
"NODE_DOMAIN_INITIALIZED",
",",
"initObj",
".",
"requester",
".",
"toString",
"(",
")",
",",
"resetUpdateProgres",
")",
";",
"requesters",
"[",
"initObj",
".",
"requester",
".",
"toString",
"(",
")",
"]",
"=",
"true",
";",
"postMessageToBrackets",
"(",
"MessageIds",
".",
"REGISTER_BRACKETS_FUNCTIONS",
",",
"initObj",
".",
"requester",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Initializes node for the auto update, registers messages and node side funtions
@param {object} initObj - json containing init information {
messageIds : Messages for brackets and node communication
updateDir : update directory in Appdata
requester : ID of the current requester domain} | [
"Initializes",
"node",
"for",
"the",
"auto",
"update",
"registers",
"messages",
"and",
"node",
"side",
"funtions"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js#L421-L435 |
2,104 | adobe/brackets | src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js | receiveMessageFromBrackets | function receiveMessageFromBrackets(msgObj) {
var argList = msgObj.args;
argList.unshift(msgObj.requester || "");
functionMap[msgObj.fn].apply(null, argList);
} | javascript | function receiveMessageFromBrackets(msgObj) {
var argList = msgObj.args;
argList.unshift(msgObj.requester || "");
functionMap[msgObj.fn].apply(null, argList);
} | [
"function",
"receiveMessageFromBrackets",
"(",
"msgObj",
")",
"{",
"var",
"argList",
"=",
"msgObj",
".",
"args",
";",
"argList",
".",
"unshift",
"(",
"msgObj",
".",
"requester",
"||",
"\"\"",
")",
";",
"functionMap",
"[",
"msgObj",
".",
"fn",
"]",
".",
"apply",
"(",
"null",
",",
"argList",
")",
";",
"}"
] | Receives messages from brackets
@param {object} msgObj - json containing - {
fn - function to execute on node side
args - arguments to the above function } | [
"Receives",
"messages",
"from",
"brackets"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js#L444-L448 |
2,105 | adobe/brackets | src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js | init | function init(domainManager) {
if (!domainManager.hasDomain("AutoUpdate")) {
domainManager.registerDomain("AutoUpdate", {
major: 0,
minor: 1
});
}
_domainManager = domainManager;
domainManager.registerCommand(
"AutoUpdate",
"initNode",
initNode,
true,
"Initializes node for the auto update",
[
{
name: "initObj",
type: "object",
description: "json object containing init information"
}
],
[]
);
domainManager.registerCommand(
"AutoUpdate",
"data",
receiveMessageFromBrackets,
true,
"Receives messages from brackets",
[
{
name: "msgObj",
type: "object",
description: "json object containing message info"
}
],
[]
);
domainManager.registerEvent(
"AutoUpdate",
"data",
[
{
name: "msgObj",
type: "object",
description: "json object containing message info to pass to brackets"
}
]
);
} | javascript | function init(domainManager) {
if (!domainManager.hasDomain("AutoUpdate")) {
domainManager.registerDomain("AutoUpdate", {
major: 0,
minor: 1
});
}
_domainManager = domainManager;
domainManager.registerCommand(
"AutoUpdate",
"initNode",
initNode,
true,
"Initializes node for the auto update",
[
{
name: "initObj",
type: "object",
description: "json object containing init information"
}
],
[]
);
domainManager.registerCommand(
"AutoUpdate",
"data",
receiveMessageFromBrackets,
true,
"Receives messages from brackets",
[
{
name: "msgObj",
type: "object",
description: "json object containing message info"
}
],
[]
);
domainManager.registerEvent(
"AutoUpdate",
"data",
[
{
name: "msgObj",
type: "object",
description: "json object containing message info to pass to brackets"
}
]
);
} | [
"function",
"init",
"(",
"domainManager",
")",
"{",
"if",
"(",
"!",
"domainManager",
".",
"hasDomain",
"(",
"\"AutoUpdate\"",
")",
")",
"{",
"domainManager",
".",
"registerDomain",
"(",
"\"AutoUpdate\"",
",",
"{",
"major",
":",
"0",
",",
"minor",
":",
"1",
"}",
")",
";",
"}",
"_domainManager",
"=",
"domainManager",
";",
"domainManager",
".",
"registerCommand",
"(",
"\"AutoUpdate\"",
",",
"\"initNode\"",
",",
"initNode",
",",
"true",
",",
"\"Initializes node for the auto update\"",
",",
"[",
"{",
"name",
":",
"\"initObj\"",
",",
"type",
":",
"\"object\"",
",",
"description",
":",
"\"json object containing init information\"",
"}",
"]",
",",
"[",
"]",
")",
";",
"domainManager",
".",
"registerCommand",
"(",
"\"AutoUpdate\"",
",",
"\"data\"",
",",
"receiveMessageFromBrackets",
",",
"true",
",",
"\"Receives messages from brackets\"",
",",
"[",
"{",
"name",
":",
"\"msgObj\"",
",",
"type",
":",
"\"object\"",
",",
"description",
":",
"\"json object containing message info\"",
"}",
"]",
",",
"[",
"]",
")",
";",
"domainManager",
".",
"registerEvent",
"(",
"\"AutoUpdate\"",
",",
"\"data\"",
",",
"[",
"{",
"name",
":",
"\"msgObj\"",
",",
"type",
":",
"\"object\"",
",",
"description",
":",
"\"json object containing message info to pass to brackets\"",
"}",
"]",
")",
";",
"}"
] | Initialize the domain with commands and events related to AutoUpdate
@param {DomainManager} domainManager - The DomainManager for AutoUpdateDomain | [
"Initialize",
"the",
"domain",
"with",
"commands",
"and",
"events",
"related",
"to",
"AutoUpdate"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js#L455-L507 |
2,106 | adobe/brackets | src/editor/Editor.js | _buildPreferencesContext | function _buildPreferencesContext(fullPath) {
return PreferencesManager._buildContext(fullPath,
fullPath ? LanguageManager.getLanguageForPath(fullPath).getId() : undefined);
} | javascript | function _buildPreferencesContext(fullPath) {
return PreferencesManager._buildContext(fullPath,
fullPath ? LanguageManager.getLanguageForPath(fullPath).getId() : undefined);
} | [
"function",
"_buildPreferencesContext",
"(",
"fullPath",
")",
"{",
"return",
"PreferencesManager",
".",
"_buildContext",
"(",
"fullPath",
",",
"fullPath",
"?",
"LanguageManager",
".",
"getLanguageForPath",
"(",
"fullPath",
")",
".",
"getId",
"(",
")",
":",
"undefined",
")",
";",
"}"
] | Helper function to build preferences context based on the full path of
the file.
@param {string} fullPath Full path of the file
@return {*} A context for the specified file name | [
"Helper",
"function",
"to",
"build",
"preferences",
"context",
"based",
"on",
"the",
"full",
"path",
"of",
"the",
"file",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/Editor.js#L292-L295 |
2,107 | adobe/brackets | src/editor/Editor.js | _onKeyEvent | function _onKeyEvent(instance, event) {
self.trigger("keyEvent", self, event); // deprecated
self.trigger(event.type, self, event);
return event.defaultPrevented; // false tells CodeMirror we didn't eat the event
} | javascript | function _onKeyEvent(instance, event) {
self.trigger("keyEvent", self, event); // deprecated
self.trigger(event.type, self, event);
return event.defaultPrevented; // false tells CodeMirror we didn't eat the event
} | [
"function",
"_onKeyEvent",
"(",
"instance",
",",
"event",
")",
"{",
"self",
".",
"trigger",
"(",
"\"keyEvent\"",
",",
"self",
",",
"event",
")",
";",
"// deprecated",
"self",
".",
"trigger",
"(",
"event",
".",
"type",
",",
"self",
",",
"event",
")",
";",
"return",
"event",
".",
"defaultPrevented",
";",
"// false tells CodeMirror we didn't eat the event",
"}"
] | Redispatch these CodeMirror key events as Editor events | [
"Redispatch",
"these",
"CodeMirror",
"key",
"events",
"as",
"Editor",
"events"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/Editor.js#L1004-L1008 |
2,108 | adobe/brackets | src/utils/StringUtils.js | format | function format(str) {
// arguments[0] is the base string, so we need to adjust index values here
var args = [].slice.call(arguments, 1);
return str.replace(/\{(\d+)\}/g, function (match, num) {
return typeof args[num] !== "undefined" ? args[num] : match;
});
} | javascript | function format(str) {
// arguments[0] is the base string, so we need to adjust index values here
var args = [].slice.call(arguments, 1);
return str.replace(/\{(\d+)\}/g, function (match, num) {
return typeof args[num] !== "undefined" ? args[num] : match;
});
} | [
"function",
"format",
"(",
"str",
")",
"{",
"// arguments[0] is the base string, so we need to adjust index values here",
"var",
"args",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"return",
"str",
".",
"replace",
"(",
"/",
"\\{(\\d+)\\}",
"/",
"g",
",",
"function",
"(",
"match",
",",
"num",
")",
"{",
"return",
"typeof",
"args",
"[",
"num",
"]",
"!==",
"\"undefined\"",
"?",
"args",
"[",
"num",
"]",
":",
"match",
";",
"}",
")",
";",
"}"
] | Format a string by replacing placeholder symbols with passed in arguments.
Example: var formatted = StringUtils.format("Hello {0}", "World");
@param {string} str The base string
@param {...} Arguments to be substituted into the string
@return {string} Formatted string | [
"Format",
"a",
"string",
"by",
"replacing",
"placeholder",
"symbols",
"with",
"passed",
"in",
"arguments",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/StringUtils.js#L50-L56 |
2,109 | adobe/brackets | src/utils/StringUtils.js | breakableUrl | function breakableUrl(url) {
// This is for displaying in UI, so always want it escaped
var escUrl = _.escape(url);
// Inject zero-width space character (U+200B) near path separators (/) to allow line breaking there
return escUrl.replace(
new RegExp(regexEscape("/"), "g"),
"/" + "​"
);
} | javascript | function breakableUrl(url) {
// This is for displaying in UI, so always want it escaped
var escUrl = _.escape(url);
// Inject zero-width space character (U+200B) near path separators (/) to allow line breaking there
return escUrl.replace(
new RegExp(regexEscape("/"), "g"),
"/" + "​"
);
} | [
"function",
"breakableUrl",
"(",
"url",
")",
"{",
"// This is for displaying in UI, so always want it escaped",
"var",
"escUrl",
"=",
"_",
".",
"escape",
"(",
"url",
")",
";",
"// Inject zero-width space character (U+200B) near path separators (/) to allow line breaking there",
"return",
"escUrl",
".",
"replace",
"(",
"new",
"RegExp",
"(",
"regexEscape",
"(",
"\"/\"",
")",
",",
"\"g\"",
")",
",",
"\"/\"",
"+",
"\"​\"",
")",
";",
"}"
] | Return an escaped path or URL string that can be broken near path separators.
@param {string} url the path or URL to format
@return {string} the formatted path or URL | [
"Return",
"an",
"escaped",
"path",
"or",
"URL",
"string",
"that",
"can",
"be",
"broken",
"near",
"path",
"separators",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/StringUtils.js#L166-L175 |
2,110 | adobe/brackets | src/utils/StringUtils.js | prettyPrintBytes | function prettyPrintBytes(bytes, precision) {
var kilobyte = 1024,
megabyte = kilobyte * 1024,
gigabyte = megabyte * 1024,
terabyte = gigabyte * 1024,
returnVal = bytes;
if ((bytes >= 0) && (bytes < kilobyte)) {
returnVal = bytes + " B";
} else if (bytes < megabyte) {
returnVal = (bytes / kilobyte).toFixed(precision) + " KB";
} else if (bytes < gigabyte) {
returnVal = (bytes / megabyte).toFixed(precision) + " MB";
} else if (bytes < terabyte) {
returnVal = (bytes / gigabyte).toFixed(precision) + " GB";
} else if (bytes >= terabyte) {
return (bytes / terabyte).toFixed(precision) + " TB";
}
return returnVal;
} | javascript | function prettyPrintBytes(bytes, precision) {
var kilobyte = 1024,
megabyte = kilobyte * 1024,
gigabyte = megabyte * 1024,
terabyte = gigabyte * 1024,
returnVal = bytes;
if ((bytes >= 0) && (bytes < kilobyte)) {
returnVal = bytes + " B";
} else if (bytes < megabyte) {
returnVal = (bytes / kilobyte).toFixed(precision) + " KB";
} else if (bytes < gigabyte) {
returnVal = (bytes / megabyte).toFixed(precision) + " MB";
} else if (bytes < terabyte) {
returnVal = (bytes / gigabyte).toFixed(precision) + " GB";
} else if (bytes >= terabyte) {
return (bytes / terabyte).toFixed(precision) + " TB";
}
return returnVal;
} | [
"function",
"prettyPrintBytes",
"(",
"bytes",
",",
"precision",
")",
"{",
"var",
"kilobyte",
"=",
"1024",
",",
"megabyte",
"=",
"kilobyte",
"*",
"1024",
",",
"gigabyte",
"=",
"megabyte",
"*",
"1024",
",",
"terabyte",
"=",
"gigabyte",
"*",
"1024",
",",
"returnVal",
"=",
"bytes",
";",
"if",
"(",
"(",
"bytes",
">=",
"0",
")",
"&&",
"(",
"bytes",
"<",
"kilobyte",
")",
")",
"{",
"returnVal",
"=",
"bytes",
"+",
"\" B\"",
";",
"}",
"else",
"if",
"(",
"bytes",
"<",
"megabyte",
")",
"{",
"returnVal",
"=",
"(",
"bytes",
"/",
"kilobyte",
")",
".",
"toFixed",
"(",
"precision",
")",
"+",
"\" KB\"",
";",
"}",
"else",
"if",
"(",
"bytes",
"<",
"gigabyte",
")",
"{",
"returnVal",
"=",
"(",
"bytes",
"/",
"megabyte",
")",
".",
"toFixed",
"(",
"precision",
")",
"+",
"\" MB\"",
";",
"}",
"else",
"if",
"(",
"bytes",
"<",
"terabyte",
")",
"{",
"returnVal",
"=",
"(",
"bytes",
"/",
"gigabyte",
")",
".",
"toFixed",
"(",
"precision",
")",
"+",
"\" GB\"",
";",
"}",
"else",
"if",
"(",
"bytes",
">=",
"terabyte",
")",
"{",
"return",
"(",
"bytes",
"/",
"terabyte",
")",
".",
"toFixed",
"(",
"precision",
")",
"+",
"\" TB\"",
";",
"}",
"return",
"returnVal",
";",
"}"
] | Converts number of bytes into human readable format.
If param bytes is negative it returns the number without any changes.
@param {number} bytes Number of bytes to convert
@param {number} precision Number of digits after the decimal separator
@return {string} | [
"Converts",
"number",
"of",
"bytes",
"into",
"human",
"readable",
"format",
".",
"If",
"param",
"bytes",
"is",
"negative",
"it",
"returns",
"the",
"number",
"without",
"any",
"changes",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/StringUtils.js#L185-L205 |
2,111 | adobe/brackets | src/utils/StringUtils.js | truncate | function truncate(str, len) {
// Truncate text to specified length
if (str.length > len) {
str = str.substr(0, len);
// To prevent awkwardly truncating in the middle of a word,
// attempt to truncate at the end of the last whole word
var lastSpaceChar = str.lastIndexOf(" ");
if (lastSpaceChar < len && lastSpaceChar > -1) {
str = str.substr(0, lastSpaceChar);
}
return str;
}
} | javascript | function truncate(str, len) {
// Truncate text to specified length
if (str.length > len) {
str = str.substr(0, len);
// To prevent awkwardly truncating in the middle of a word,
// attempt to truncate at the end of the last whole word
var lastSpaceChar = str.lastIndexOf(" ");
if (lastSpaceChar < len && lastSpaceChar > -1) {
str = str.substr(0, lastSpaceChar);
}
return str;
}
} | [
"function",
"truncate",
"(",
"str",
",",
"len",
")",
"{",
"// Truncate text to specified length",
"if",
"(",
"str",
".",
"length",
">",
"len",
")",
"{",
"str",
"=",
"str",
".",
"substr",
"(",
"0",
",",
"len",
")",
";",
"// To prevent awkwardly truncating in the middle of a word,",
"// attempt to truncate at the end of the last whole word",
"var",
"lastSpaceChar",
"=",
"str",
".",
"lastIndexOf",
"(",
"\" \"",
")",
";",
"if",
"(",
"lastSpaceChar",
"<",
"len",
"&&",
"lastSpaceChar",
">",
"-",
"1",
")",
"{",
"str",
"=",
"str",
".",
"substr",
"(",
"0",
",",
"lastSpaceChar",
")",
";",
"}",
"return",
"str",
";",
"}",
"}"
] | Truncate text to specified length.
@param {string} str Text to be truncated.
@param {number} len Length to which text should be truncated
@return {?string} Returns truncated text only if it was changed | [
"Truncate",
"text",
"to",
"specified",
"length",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/StringUtils.js#L213-L226 |
2,112 | adobe/brackets | src/utils/ValidationUtils.js | isInteger | function isInteger(value) {
// Validate value is a number
if (typeof (value) !== "number" || isNaN(parseInt(value, 10))) {
return false;
}
// Validate number is an integer
if (Math.floor(value) !== value) {
return false;
}
// Validate number is finite
if (!isFinite(value)) {
return false;
}
return true;
} | javascript | function isInteger(value) {
// Validate value is a number
if (typeof (value) !== "number" || isNaN(parseInt(value, 10))) {
return false;
}
// Validate number is an integer
if (Math.floor(value) !== value) {
return false;
}
// Validate number is finite
if (!isFinite(value)) {
return false;
}
return true;
} | [
"function",
"isInteger",
"(",
"value",
")",
"{",
"// Validate value is a number",
"if",
"(",
"typeof",
"(",
"value",
")",
"!==",
"\"number\"",
"||",
"isNaN",
"(",
"parseInt",
"(",
"value",
",",
"10",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Validate number is an integer",
"if",
"(",
"Math",
".",
"floor",
"(",
"value",
")",
"!==",
"value",
")",
"{",
"return",
"false",
";",
"}",
"// Validate number is finite",
"if",
"(",
"!",
"isFinite",
"(",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Used to validate whether type of unknown value is an integer.
@param {*} value Value for which to validate its type
@return {boolean} true if value is a finite integer | [
"Used",
"to",
"validate",
"whether",
"type",
"of",
"unknown",
"value",
"is",
"an",
"integer",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ValidationUtils.js#L34-L51 |
2,113 | adobe/brackets | src/utils/ValidationUtils.js | isIntegerInRange | function isIntegerInRange(value, lowerLimit, upperLimit) {
// Validate value is an integer
if (!isInteger(value)) {
return false;
}
// Validate integer is in range
var hasLowerLimt = (typeof (lowerLimit) === "number"),
hasUpperLimt = (typeof (upperLimit) === "number");
return ((!hasLowerLimt || value >= lowerLimit) && (!hasUpperLimt || value <= upperLimit));
} | javascript | function isIntegerInRange(value, lowerLimit, upperLimit) {
// Validate value is an integer
if (!isInteger(value)) {
return false;
}
// Validate integer is in range
var hasLowerLimt = (typeof (lowerLimit) === "number"),
hasUpperLimt = (typeof (upperLimit) === "number");
return ((!hasLowerLimt || value >= lowerLimit) && (!hasUpperLimt || value <= upperLimit));
} | [
"function",
"isIntegerInRange",
"(",
"value",
",",
"lowerLimit",
",",
"upperLimit",
")",
"{",
"// Validate value is an integer",
"if",
"(",
"!",
"isInteger",
"(",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Validate integer is in range",
"var",
"hasLowerLimt",
"=",
"(",
"typeof",
"(",
"lowerLimit",
")",
"===",
"\"number\"",
")",
",",
"hasUpperLimt",
"=",
"(",
"typeof",
"(",
"upperLimit",
")",
"===",
"\"number\"",
")",
";",
"return",
"(",
"(",
"!",
"hasLowerLimt",
"||",
"value",
">=",
"lowerLimit",
")",
"&&",
"(",
"!",
"hasUpperLimt",
"||",
"value",
"<=",
"upperLimit",
")",
")",
";",
"}"
] | Used to validate whether type of unknown value is an integer, and, if so,
is it within the option lower and upper limits.
@param {*} value Value for which to validate its type
@param {number=} lowerLimit Optional lower limit (inclusive)
@param {number=} upperLimit Optional upper limit (inclusive)
@return {boolean} true if value is an interger, and optionally in specified range. | [
"Used",
"to",
"validate",
"whether",
"type",
"of",
"unknown",
"value",
"is",
"an",
"integer",
"and",
"if",
"so",
"is",
"it",
"within",
"the",
"option",
"lower",
"and",
"upper",
"limits",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ValidationUtils.js#L62-L73 |
2,114 | adobe/brackets | src/document/TextRange.js | TextRange | function TextRange(document, startLine, endLine) {
this.startLine = startLine;
this.endLine = endLine;
this.document = document;
document.addRef();
// store this-bound versions of listeners so we can remove them later
this._handleDocumentChange = this._handleDocumentChange.bind(this);
this._handleDocumentDeleted = this._handleDocumentDeleted.bind(this);
document.on("change", this._handleDocumentChange);
document.on("deleted", this._handleDocumentDeleted);
} | javascript | function TextRange(document, startLine, endLine) {
this.startLine = startLine;
this.endLine = endLine;
this.document = document;
document.addRef();
// store this-bound versions of listeners so we can remove them later
this._handleDocumentChange = this._handleDocumentChange.bind(this);
this._handleDocumentDeleted = this._handleDocumentDeleted.bind(this);
document.on("change", this._handleDocumentChange);
document.on("deleted", this._handleDocumentDeleted);
} | [
"function",
"TextRange",
"(",
"document",
",",
"startLine",
",",
"endLine",
")",
"{",
"this",
".",
"startLine",
"=",
"startLine",
";",
"this",
".",
"endLine",
"=",
"endLine",
";",
"this",
".",
"document",
"=",
"document",
";",
"document",
".",
"addRef",
"(",
")",
";",
"// store this-bound versions of listeners so we can remove them later",
"this",
".",
"_handleDocumentChange",
"=",
"this",
".",
"_handleDocumentChange",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_handleDocumentDeleted",
"=",
"this",
".",
"_handleDocumentDeleted",
".",
"bind",
"(",
"this",
")",
";",
"document",
".",
"on",
"(",
"\"change\"",
",",
"this",
".",
"_handleDocumentChange",
")",
";",
"document",
".",
"on",
"(",
"\"deleted\"",
",",
"this",
".",
"_handleDocumentDeleted",
")",
";",
"}"
] | Stores a range of lines that is automatically maintained as the Document changes. The range
MAY drop out of sync with the Document in certain edge cases; startLine & endLine will become
null when that happens.
Important: you must dispose() a TextRange when you're done with it. Because TextRange addRef()s
the Document (in order to listen to it), you will leak Documents otherwise.
TextRange dispatches these events:
- change -- When the range boundary line numbers change (due to a Document change)
- contentChange -- When the actual content of the range changes. This might or might not
be accompanied by a change in the boundary line numbers.
- lostSync -- When the backing Document changes in such a way that the range can no longer
accurately be maintained. Generally, occurs whenever an edit spans a range boundary.
After this, startLine & endLine will be unusable (set to null).
Also occurs when the document is deleted, though startLine & endLine won't be modified
These events only ever occur in response to Document changes, so if you are already listening
to the Document, you could ignore the TextRange events and just read its updated value in your
own Document change handler.
@constructor
@param {!Document} document
@param {number} startLine First line in range (0-based, inclusive)
@param {number} endLine Last line in range (0-based, inclusive) | [
"Stores",
"a",
"range",
"of",
"lines",
"that",
"is",
"automatically",
"maintained",
"as",
"the",
"Document",
"changes",
".",
"The",
"range",
"MAY",
"drop",
"out",
"of",
"sync",
"with",
"the",
"Document",
"in",
"certain",
"edge",
"cases",
";",
"startLine",
"&",
"endLine",
"will",
"become",
"null",
"when",
"that",
"happens",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/TextRange.js#L58-L69 |
2,115 | adobe/brackets | src/language/CSSUtils.js | getInfoAtPos | function getInfoAtPos(editor, constPos) {
// We're going to be changing pos a lot, but we don't want to mess up
// the pos the caller passed in so we use extend to make a safe copy of it.
var pos = $.extend({}, constPos),
ctx = TokenUtils.getInitialContext(editor._codeMirror, pos),
mode = editor.getModeForSelection();
// Check if this is inside a style block or in a css/less document.
if (mode !== "css" && mode !== "text/x-scss" && mode !== "text/x-less") {
return createInfo();
}
// Context from the current editor will have htmlState if we are in css mode
// and in attribute value state of a tag with attribute name style
if (ctx.token.state.htmlState && (!ctx.token.state.localMode || ctx.token.state.localMode.name !== "css")) {
// tagInfo is required to aquire the style attr value
var tagInfo = HTMLUtils.getTagInfo(editor, pos, true),
// To be used as relative character position
offset = tagInfo.position.offset;
/**
* We will use this CM to cook css context in case of style attribute value
* as CM in htmlmixed mode doesn't yet identify this as css context. We provide
* a no-op display function to run CM without a DOM head.
*/
var _contextCM = new CodeMirror(function () {}, {
value: "{" + tagInfo.attr.value.replace(/(^")|("$)/g, ""),
mode: "css"
});
ctx = TokenUtils.getInitialContext(_contextCM, {line: 0, ch: offset + 1});
}
if (_isInPropName(ctx)) {
return _getPropNameInfo(ctx);
}
if (_isInPropValue(ctx)) {
return _getRuleInfoStartingFromPropValue(ctx, ctx.editor);
}
if (_isInAtRule(ctx)) {
return _getImportUrlInfo(ctx, editor);
}
return createInfo();
} | javascript | function getInfoAtPos(editor, constPos) {
// We're going to be changing pos a lot, but we don't want to mess up
// the pos the caller passed in so we use extend to make a safe copy of it.
var pos = $.extend({}, constPos),
ctx = TokenUtils.getInitialContext(editor._codeMirror, pos),
mode = editor.getModeForSelection();
// Check if this is inside a style block or in a css/less document.
if (mode !== "css" && mode !== "text/x-scss" && mode !== "text/x-less") {
return createInfo();
}
// Context from the current editor will have htmlState if we are in css mode
// and in attribute value state of a tag with attribute name style
if (ctx.token.state.htmlState && (!ctx.token.state.localMode || ctx.token.state.localMode.name !== "css")) {
// tagInfo is required to aquire the style attr value
var tagInfo = HTMLUtils.getTagInfo(editor, pos, true),
// To be used as relative character position
offset = tagInfo.position.offset;
/**
* We will use this CM to cook css context in case of style attribute value
* as CM in htmlmixed mode doesn't yet identify this as css context. We provide
* a no-op display function to run CM without a DOM head.
*/
var _contextCM = new CodeMirror(function () {}, {
value: "{" + tagInfo.attr.value.replace(/(^")|("$)/g, ""),
mode: "css"
});
ctx = TokenUtils.getInitialContext(_contextCM, {line: 0, ch: offset + 1});
}
if (_isInPropName(ctx)) {
return _getPropNameInfo(ctx);
}
if (_isInPropValue(ctx)) {
return _getRuleInfoStartingFromPropValue(ctx, ctx.editor);
}
if (_isInAtRule(ctx)) {
return _getImportUrlInfo(ctx, editor);
}
return createInfo();
} | [
"function",
"getInfoAtPos",
"(",
"editor",
",",
"constPos",
")",
"{",
"// We're going to be changing pos a lot, but we don't want to mess up",
"// the pos the caller passed in so we use extend to make a safe copy of it.",
"var",
"pos",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"constPos",
")",
",",
"ctx",
"=",
"TokenUtils",
".",
"getInitialContext",
"(",
"editor",
".",
"_codeMirror",
",",
"pos",
")",
",",
"mode",
"=",
"editor",
".",
"getModeForSelection",
"(",
")",
";",
"// Check if this is inside a style block or in a css/less document.",
"if",
"(",
"mode",
"!==",
"\"css\"",
"&&",
"mode",
"!==",
"\"text/x-scss\"",
"&&",
"mode",
"!==",
"\"text/x-less\"",
")",
"{",
"return",
"createInfo",
"(",
")",
";",
"}",
"// Context from the current editor will have htmlState if we are in css mode",
"// and in attribute value state of a tag with attribute name style",
"if",
"(",
"ctx",
".",
"token",
".",
"state",
".",
"htmlState",
"&&",
"(",
"!",
"ctx",
".",
"token",
".",
"state",
".",
"localMode",
"||",
"ctx",
".",
"token",
".",
"state",
".",
"localMode",
".",
"name",
"!==",
"\"css\"",
")",
")",
"{",
"// tagInfo is required to aquire the style attr value",
"var",
"tagInfo",
"=",
"HTMLUtils",
".",
"getTagInfo",
"(",
"editor",
",",
"pos",
",",
"true",
")",
",",
"// To be used as relative character position",
"offset",
"=",
"tagInfo",
".",
"position",
".",
"offset",
";",
"/**\n * We will use this CM to cook css context in case of style attribute value\n * as CM in htmlmixed mode doesn't yet identify this as css context. We provide\n * a no-op display function to run CM without a DOM head.\n */",
"var",
"_contextCM",
"=",
"new",
"CodeMirror",
"(",
"function",
"(",
")",
"{",
"}",
",",
"{",
"value",
":",
"\"{\"",
"+",
"tagInfo",
".",
"attr",
".",
"value",
".",
"replace",
"(",
"/",
"(^\")|(\"$)",
"/",
"g",
",",
"\"\"",
")",
",",
"mode",
":",
"\"css\"",
"}",
")",
";",
"ctx",
"=",
"TokenUtils",
".",
"getInitialContext",
"(",
"_contextCM",
",",
"{",
"line",
":",
"0",
",",
"ch",
":",
"offset",
"+",
"1",
"}",
")",
";",
"}",
"if",
"(",
"_isInPropName",
"(",
"ctx",
")",
")",
"{",
"return",
"_getPropNameInfo",
"(",
"ctx",
")",
";",
"}",
"if",
"(",
"_isInPropValue",
"(",
"ctx",
")",
")",
"{",
"return",
"_getRuleInfoStartingFromPropValue",
"(",
"ctx",
",",
"ctx",
".",
"editor",
")",
";",
"}",
"if",
"(",
"_isInAtRule",
"(",
"ctx",
")",
")",
"{",
"return",
"_getImportUrlInfo",
"(",
"ctx",
",",
"editor",
")",
";",
"}",
"return",
"createInfo",
"(",
")",
";",
"}"
] | Returns a context info object for the given cursor position
@param {!Editor} editor
@param {{ch: number, line: number}} constPos A CM pos (likely from editor.getCursorPos())
@return {{context: string,
offset: number,
name: string,
index: number,
values: Array.<string>,
isNewItem: boolean,
range: {start: {line: number, ch: number},
end: {line: number, ch: number}}}} A CSS context info object. | [
"Returns",
"a",
"context",
"info",
"object",
"for",
"the",
"given",
"cursor",
"position"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CSSUtils.js#L611-L658 |
2,116 | adobe/brackets | src/language/CSSUtils.js | getCompleteSelectors | function getCompleteSelectors(info, useGroup) {
if (info.parentSelectors) {
// Show parents with / separators.
var completeSelectors = info.parentSelectors + " / ";
if (useGroup && info.selectorGroup) {
completeSelectors += info.selectorGroup;
} else {
completeSelectors += info.selector;
}
return completeSelectors;
} else if (useGroup && info.selectorGroup) {
return info.selectorGroup;
}
return info.selector;
} | javascript | function getCompleteSelectors(info, useGroup) {
if (info.parentSelectors) {
// Show parents with / separators.
var completeSelectors = info.parentSelectors + " / ";
if (useGroup && info.selectorGroup) {
completeSelectors += info.selectorGroup;
} else {
completeSelectors += info.selector;
}
return completeSelectors;
} else if (useGroup && info.selectorGroup) {
return info.selectorGroup;
}
return info.selector;
} | [
"function",
"getCompleteSelectors",
"(",
"info",
",",
"useGroup",
")",
"{",
"if",
"(",
"info",
".",
"parentSelectors",
")",
"{",
"// Show parents with / separators.",
"var",
"completeSelectors",
"=",
"info",
".",
"parentSelectors",
"+",
"\" / \"",
";",
"if",
"(",
"useGroup",
"&&",
"info",
".",
"selectorGroup",
")",
"{",
"completeSelectors",
"+=",
"info",
".",
"selectorGroup",
";",
"}",
"else",
"{",
"completeSelectors",
"+=",
"info",
".",
"selector",
";",
"}",
"return",
"completeSelectors",
";",
"}",
"else",
"if",
"(",
"useGroup",
"&&",
"info",
".",
"selectorGroup",
")",
"{",
"return",
"info",
".",
"selectorGroup",
";",
"}",
"return",
"info",
".",
"selector",
";",
"}"
] | Return a string that shows the literal parent hierarchy of the selector
in info.
@param {!SelectorInfo} info
@param {boolean=} useGroup true to append selectorGroup instead of selector
@return {string} the literal parent hierarchy of the selector | [
"Return",
"a",
"string",
"that",
"shows",
"the",
"literal",
"parent",
"hierarchy",
"of",
"the",
"selector",
"in",
"info",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CSSUtils.js#L668-L683 |
2,117 | adobe/brackets | src/language/CSSUtils.js | _getSelectorInFinalCSSForm | function _getSelectorInFinalCSSForm(selectorArray) {
var finalSelectorArray = [""],
parentSelectorArray = [],
group = [];
_.forEach(selectorArray, function (selector) {
selector = _stripAtRules(selector);
group = selector.split(",");
parentSelectorArray = [];
_.forEach(group, function (cs) {
var ampersandIndex = cs.indexOf("&");
_.forEach(finalSelectorArray, function (ps) {
if (ampersandIndex === -1) {
cs = _stripAtRules(cs);
if (ps.length && cs.length) {
ps += " ";
}
ps += cs;
} else {
// Replace all instances of & with regexp
ps = _stripAtRules(cs.replace(/&/g, ps));
}
parentSelectorArray.push(ps);
});
});
finalSelectorArray = parentSelectorArray;
});
return finalSelectorArray.join(", ");
} | javascript | function _getSelectorInFinalCSSForm(selectorArray) {
var finalSelectorArray = [""],
parentSelectorArray = [],
group = [];
_.forEach(selectorArray, function (selector) {
selector = _stripAtRules(selector);
group = selector.split(",");
parentSelectorArray = [];
_.forEach(group, function (cs) {
var ampersandIndex = cs.indexOf("&");
_.forEach(finalSelectorArray, function (ps) {
if (ampersandIndex === -1) {
cs = _stripAtRules(cs);
if (ps.length && cs.length) {
ps += " ";
}
ps += cs;
} else {
// Replace all instances of & with regexp
ps = _stripAtRules(cs.replace(/&/g, ps));
}
parentSelectorArray.push(ps);
});
});
finalSelectorArray = parentSelectorArray;
});
return finalSelectorArray.join(", ");
} | [
"function",
"_getSelectorInFinalCSSForm",
"(",
"selectorArray",
")",
"{",
"var",
"finalSelectorArray",
"=",
"[",
"\"\"",
"]",
",",
"parentSelectorArray",
"=",
"[",
"]",
",",
"group",
"=",
"[",
"]",
";",
"_",
".",
"forEach",
"(",
"selectorArray",
",",
"function",
"(",
"selector",
")",
"{",
"selector",
"=",
"_stripAtRules",
"(",
"selector",
")",
";",
"group",
"=",
"selector",
".",
"split",
"(",
"\",\"",
")",
";",
"parentSelectorArray",
"=",
"[",
"]",
";",
"_",
".",
"forEach",
"(",
"group",
",",
"function",
"(",
"cs",
")",
"{",
"var",
"ampersandIndex",
"=",
"cs",
".",
"indexOf",
"(",
"\"&\"",
")",
";",
"_",
".",
"forEach",
"(",
"finalSelectorArray",
",",
"function",
"(",
"ps",
")",
"{",
"if",
"(",
"ampersandIndex",
"===",
"-",
"1",
")",
"{",
"cs",
"=",
"_stripAtRules",
"(",
"cs",
")",
";",
"if",
"(",
"ps",
".",
"length",
"&&",
"cs",
".",
"length",
")",
"{",
"ps",
"+=",
"\" \"",
";",
"}",
"ps",
"+=",
"cs",
";",
"}",
"else",
"{",
"// Replace all instances of & with regexp",
"ps",
"=",
"_stripAtRules",
"(",
"cs",
".",
"replace",
"(",
"/",
"&",
"/",
"g",
",",
"ps",
")",
")",
";",
"}",
"parentSelectorArray",
".",
"push",
"(",
"ps",
")",
";",
"}",
")",
";",
"}",
")",
";",
"finalSelectorArray",
"=",
"parentSelectorArray",
";",
"}",
")",
";",
"return",
"finalSelectorArray",
".",
"join",
"(",
"\", \"",
")",
";",
"}"
] | Converts the given selector array into the actual CSS selectors similar to
those generated by a CSS preprocessor.
@param {Array.<string>} selectorArray
@return {string} | [
"Converts",
"the",
"given",
"selector",
"array",
"into",
"the",
"actual",
"CSS",
"selectors",
"similar",
"to",
"those",
"generated",
"by",
"a",
"CSS",
"preprocessor",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CSSUtils.js#L1314-L1341 |
2,118 | adobe/brackets | src/language/CSSUtils.js | _findAllMatchingSelectorsInText | function _findAllMatchingSelectorsInText(text, selector, mode) {
var allSelectors = extractAllSelectors(text, mode);
var result = [];
// For now, we only match the rightmost simple selector, and ignore
// attribute selectors and pseudo selectors
var classOrIdSelector = selector[0] === "." || selector[0] === "#";
// Escape initial "." in selector, if present.
if (selector[0] === ".") {
selector = "\\" + selector;
}
if (!classOrIdSelector) {
// Tag selectors must have nothing, whitespace, or a combinator before it.
selector = "(^|[\\s>+~])" + selector;
}
var re = new RegExp(selector + "(\\[[^\\]]*\\]|:{1,2}[\\w-()]+|\\.[\\w-]+|#[\\w-]+)*\\s*$", classOrIdSelector ? "" : "i");
allSelectors.forEach(function (entry) {
var actualSelector = entry.selector;
if (entry.selector.indexOf("&") !== -1 && entry.parentSelectors) {
var selectorArray = entry.parentSelectors.split(" / ");
selectorArray.push(entry.selector);
actualSelector = _getSelectorInFinalCSSForm(selectorArray);
}
if (actualSelector.search(re) !== -1) {
result.push(entry);
} else if (!classOrIdSelector) {
// Special case for tag selectors - match "*" as the rightmost character
if (/\*\s*$/.test(actualSelector)) {
result.push(entry);
}
}
});
return result;
} | javascript | function _findAllMatchingSelectorsInText(text, selector, mode) {
var allSelectors = extractAllSelectors(text, mode);
var result = [];
// For now, we only match the rightmost simple selector, and ignore
// attribute selectors and pseudo selectors
var classOrIdSelector = selector[0] === "." || selector[0] === "#";
// Escape initial "." in selector, if present.
if (selector[0] === ".") {
selector = "\\" + selector;
}
if (!classOrIdSelector) {
// Tag selectors must have nothing, whitespace, or a combinator before it.
selector = "(^|[\\s>+~])" + selector;
}
var re = new RegExp(selector + "(\\[[^\\]]*\\]|:{1,2}[\\w-()]+|\\.[\\w-]+|#[\\w-]+)*\\s*$", classOrIdSelector ? "" : "i");
allSelectors.forEach(function (entry) {
var actualSelector = entry.selector;
if (entry.selector.indexOf("&") !== -1 && entry.parentSelectors) {
var selectorArray = entry.parentSelectors.split(" / ");
selectorArray.push(entry.selector);
actualSelector = _getSelectorInFinalCSSForm(selectorArray);
}
if (actualSelector.search(re) !== -1) {
result.push(entry);
} else if (!classOrIdSelector) {
// Special case for tag selectors - match "*" as the rightmost character
if (/\*\s*$/.test(actualSelector)) {
result.push(entry);
}
}
});
return result;
} | [
"function",
"_findAllMatchingSelectorsInText",
"(",
"text",
",",
"selector",
",",
"mode",
")",
"{",
"var",
"allSelectors",
"=",
"extractAllSelectors",
"(",
"text",
",",
"mode",
")",
";",
"var",
"result",
"=",
"[",
"]",
";",
"// For now, we only match the rightmost simple selector, and ignore",
"// attribute selectors and pseudo selectors",
"var",
"classOrIdSelector",
"=",
"selector",
"[",
"0",
"]",
"===",
"\".\"",
"||",
"selector",
"[",
"0",
"]",
"===",
"\"#\"",
";",
"// Escape initial \".\" in selector, if present.",
"if",
"(",
"selector",
"[",
"0",
"]",
"===",
"\".\"",
")",
"{",
"selector",
"=",
"\"\\\\\"",
"+",
"selector",
";",
"}",
"if",
"(",
"!",
"classOrIdSelector",
")",
"{",
"// Tag selectors must have nothing, whitespace, or a combinator before it.",
"selector",
"=",
"\"(^|[\\\\s>+~])\"",
"+",
"selector",
";",
"}",
"var",
"re",
"=",
"new",
"RegExp",
"(",
"selector",
"+",
"\"(\\\\[[^\\\\]]*\\\\]|:{1,2}[\\\\w-()]+|\\\\.[\\\\w-]+|#[\\\\w-]+)*\\\\s*$\"",
",",
"classOrIdSelector",
"?",
"\"\"",
":",
"\"i\"",
")",
";",
"allSelectors",
".",
"forEach",
"(",
"function",
"(",
"entry",
")",
"{",
"var",
"actualSelector",
"=",
"entry",
".",
"selector",
";",
"if",
"(",
"entry",
".",
"selector",
".",
"indexOf",
"(",
"\"&\"",
")",
"!==",
"-",
"1",
"&&",
"entry",
".",
"parentSelectors",
")",
"{",
"var",
"selectorArray",
"=",
"entry",
".",
"parentSelectors",
".",
"split",
"(",
"\" / \"",
")",
";",
"selectorArray",
".",
"push",
"(",
"entry",
".",
"selector",
")",
";",
"actualSelector",
"=",
"_getSelectorInFinalCSSForm",
"(",
"selectorArray",
")",
";",
"}",
"if",
"(",
"actualSelector",
".",
"search",
"(",
"re",
")",
"!==",
"-",
"1",
")",
"{",
"result",
".",
"push",
"(",
"entry",
")",
";",
"}",
"else",
"if",
"(",
"!",
"classOrIdSelector",
")",
"{",
"// Special case for tag selectors - match \"*\" as the rightmost character",
"if",
"(",
"/",
"\\*\\s*$",
"/",
".",
"test",
"(",
"actualSelector",
")",
")",
"{",
"result",
".",
"push",
"(",
"entry",
")",
";",
"}",
"}",
"}",
")",
";",
"return",
"result",
";",
"}"
] | Finds all instances of the specified selector in "text".
Returns an Array of Objects with start and end properties.
For now, we only support simple selectors. This function will need to change
dramatically to support full selectors.
FUTURE: (JRB) It would be nice to eventually use the browser/jquery to do the selector evaluation.
One way to do this would be to take the user's HTML, add a special attribute to every tag with a UID,
and then construct a DOM (using the commented out code above). Then, give this DOM and the selector to
jquery and ask what matches. If the node that the user's cursor is in comes back from jquery, then
we know the selector applies.
@param {!string} text CSS text to search
@param {!string} selector selector to search for
@param {!string} mode language mode of the document that text belongs to
@return {Array.<{selectorGroupStartLine:number, declListEndLine:number, selector:string}>}
Array of objects containing the start and end line numbers (0-based, inclusive range) for each
matched selector. | [
"Finds",
"all",
"instances",
"of",
"the",
"specified",
"selector",
"in",
"text",
".",
"Returns",
"an",
"Array",
"of",
"Objects",
"with",
"start",
"and",
"end",
"properties",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CSSUtils.js#L1363-L1400 |
2,119 | adobe/brackets | src/language/CSSUtils.js | _findMatchingRulesInCSSFiles | function _findMatchingRulesInCSSFiles(selector, resultSelectors) {
var result = new $.Deferred();
// Load one CSS file and search its contents
function _loadFileAndScan(fullPath, selector) {
var oneFileResult = new $.Deferred();
DocumentManager.getDocumentForPath(fullPath)
.done(function (doc) {
// Find all matching rules for the given CSS file's content, and add them to the
// overall search result
var oneCSSFileMatches = _findAllMatchingSelectorsInText(doc.getText(), selector, doc.getLanguage().getMode());
_addSelectorsToResults(resultSelectors, oneCSSFileMatches, doc, 0);
oneFileResult.resolve();
})
.fail(function (error) {
console.warn("Unable to read " + fullPath + " during CSS rule search:", error);
oneFileResult.resolve(); // still resolve, so the overall result doesn't reject
});
return oneFileResult.promise();
}
ProjectManager.getAllFiles(ProjectManager.getLanguageFilter(["css", "less", "scss"]))
.done(function (cssFiles) {
// Load index of all CSS files; then process each CSS file in turn (see above)
Async.doInParallel(cssFiles, function (fileInfo, number) {
return _loadFileAndScan(fileInfo.fullPath, selector);
})
.then(result.resolve, result.reject);
});
return result.promise();
} | javascript | function _findMatchingRulesInCSSFiles(selector, resultSelectors) {
var result = new $.Deferred();
// Load one CSS file and search its contents
function _loadFileAndScan(fullPath, selector) {
var oneFileResult = new $.Deferred();
DocumentManager.getDocumentForPath(fullPath)
.done(function (doc) {
// Find all matching rules for the given CSS file's content, and add them to the
// overall search result
var oneCSSFileMatches = _findAllMatchingSelectorsInText(doc.getText(), selector, doc.getLanguage().getMode());
_addSelectorsToResults(resultSelectors, oneCSSFileMatches, doc, 0);
oneFileResult.resolve();
})
.fail(function (error) {
console.warn("Unable to read " + fullPath + " during CSS rule search:", error);
oneFileResult.resolve(); // still resolve, so the overall result doesn't reject
});
return oneFileResult.promise();
}
ProjectManager.getAllFiles(ProjectManager.getLanguageFilter(["css", "less", "scss"]))
.done(function (cssFiles) {
// Load index of all CSS files; then process each CSS file in turn (see above)
Async.doInParallel(cssFiles, function (fileInfo, number) {
return _loadFileAndScan(fileInfo.fullPath, selector);
})
.then(result.resolve, result.reject);
});
return result.promise();
} | [
"function",
"_findMatchingRulesInCSSFiles",
"(",
"selector",
",",
"resultSelectors",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"// Load one CSS file and search its contents",
"function",
"_loadFileAndScan",
"(",
"fullPath",
",",
"selector",
")",
"{",
"var",
"oneFileResult",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"DocumentManager",
".",
"getDocumentForPath",
"(",
"fullPath",
")",
".",
"done",
"(",
"function",
"(",
"doc",
")",
"{",
"// Find all matching rules for the given CSS file's content, and add them to the",
"// overall search result",
"var",
"oneCSSFileMatches",
"=",
"_findAllMatchingSelectorsInText",
"(",
"doc",
".",
"getText",
"(",
")",
",",
"selector",
",",
"doc",
".",
"getLanguage",
"(",
")",
".",
"getMode",
"(",
")",
")",
";",
"_addSelectorsToResults",
"(",
"resultSelectors",
",",
"oneCSSFileMatches",
",",
"doc",
",",
"0",
")",
";",
"oneFileResult",
".",
"resolve",
"(",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"error",
")",
"{",
"console",
".",
"warn",
"(",
"\"Unable to read \"",
"+",
"fullPath",
"+",
"\" during CSS rule search:\"",
",",
"error",
")",
";",
"oneFileResult",
".",
"resolve",
"(",
")",
";",
"// still resolve, so the overall result doesn't reject",
"}",
")",
";",
"return",
"oneFileResult",
".",
"promise",
"(",
")",
";",
"}",
"ProjectManager",
".",
"getAllFiles",
"(",
"ProjectManager",
".",
"getLanguageFilter",
"(",
"[",
"\"css\"",
",",
"\"less\"",
",",
"\"scss\"",
"]",
")",
")",
".",
"done",
"(",
"function",
"(",
"cssFiles",
")",
"{",
"// Load index of all CSS files; then process each CSS file in turn (see above)",
"Async",
".",
"doInParallel",
"(",
"cssFiles",
",",
"function",
"(",
"fileInfo",
",",
"number",
")",
"{",
"return",
"_loadFileAndScan",
"(",
"fileInfo",
".",
"fullPath",
",",
"selector",
")",
";",
"}",
")",
".",
"then",
"(",
"result",
".",
"resolve",
",",
"result",
".",
"reject",
")",
";",
"}",
")",
";",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] | Finds matching selectors in CSS files; adds them to 'resultSelectors' | [
"Finds",
"matching",
"selectors",
"in",
"CSS",
"files",
";",
"adds",
"them",
"to",
"resultSelectors"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CSSUtils.js#L1424-L1458 |
2,120 | adobe/brackets | src/language/CSSUtils.js | _loadFileAndScan | function _loadFileAndScan(fullPath, selector) {
var oneFileResult = new $.Deferred();
DocumentManager.getDocumentForPath(fullPath)
.done(function (doc) {
// Find all matching rules for the given CSS file's content, and add them to the
// overall search result
var oneCSSFileMatches = _findAllMatchingSelectorsInText(doc.getText(), selector, doc.getLanguage().getMode());
_addSelectorsToResults(resultSelectors, oneCSSFileMatches, doc, 0);
oneFileResult.resolve();
})
.fail(function (error) {
console.warn("Unable to read " + fullPath + " during CSS rule search:", error);
oneFileResult.resolve(); // still resolve, so the overall result doesn't reject
});
return oneFileResult.promise();
} | javascript | function _loadFileAndScan(fullPath, selector) {
var oneFileResult = new $.Deferred();
DocumentManager.getDocumentForPath(fullPath)
.done(function (doc) {
// Find all matching rules for the given CSS file's content, and add them to the
// overall search result
var oneCSSFileMatches = _findAllMatchingSelectorsInText(doc.getText(), selector, doc.getLanguage().getMode());
_addSelectorsToResults(resultSelectors, oneCSSFileMatches, doc, 0);
oneFileResult.resolve();
})
.fail(function (error) {
console.warn("Unable to read " + fullPath + " during CSS rule search:", error);
oneFileResult.resolve(); // still resolve, so the overall result doesn't reject
});
return oneFileResult.promise();
} | [
"function",
"_loadFileAndScan",
"(",
"fullPath",
",",
"selector",
")",
"{",
"var",
"oneFileResult",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"DocumentManager",
".",
"getDocumentForPath",
"(",
"fullPath",
")",
".",
"done",
"(",
"function",
"(",
"doc",
")",
"{",
"// Find all matching rules for the given CSS file's content, and add them to the",
"// overall search result",
"var",
"oneCSSFileMatches",
"=",
"_findAllMatchingSelectorsInText",
"(",
"doc",
".",
"getText",
"(",
")",
",",
"selector",
",",
"doc",
".",
"getLanguage",
"(",
")",
".",
"getMode",
"(",
")",
")",
";",
"_addSelectorsToResults",
"(",
"resultSelectors",
",",
"oneCSSFileMatches",
",",
"doc",
",",
"0",
")",
";",
"oneFileResult",
".",
"resolve",
"(",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"error",
")",
"{",
"console",
".",
"warn",
"(",
"\"Unable to read \"",
"+",
"fullPath",
"+",
"\" during CSS rule search:\"",
",",
"error",
")",
";",
"oneFileResult",
".",
"resolve",
"(",
")",
";",
"// still resolve, so the overall result doesn't reject",
"}",
")",
";",
"return",
"oneFileResult",
".",
"promise",
"(",
")",
";",
"}"
] | Load one CSS file and search its contents | [
"Load",
"one",
"CSS",
"file",
"and",
"search",
"its",
"contents"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CSSUtils.js#L1428-L1446 |
2,121 | adobe/brackets | src/language/CSSUtils.js | _parseSelector | function _parseSelector(ctx) {
var selector = "";
// Skip over {
TokenUtils.movePrevToken(ctx);
while (true) {
if (ctx.token.type !== "comment") {
// Stop once we've reached a {, }, or ;
if (/[\{\}\;]/.test(ctx.token.string)) {
break;
}
// Stop once we've reached a <style ...> tag
if (ctx.token.string === "style" && ctx.token.type === "tag") {
// Remove everything up to end-of-tag from selector
var eotIndex = selector.indexOf(">");
if (eotIndex !== -1) {
selector = selector.substring(eotIndex + 1);
}
break;
}
selector = ctx.token.string + selector;
}
if (!TokenUtils.movePrevToken(ctx)) {
break;
}
}
return selector;
} | javascript | function _parseSelector(ctx) {
var selector = "";
// Skip over {
TokenUtils.movePrevToken(ctx);
while (true) {
if (ctx.token.type !== "comment") {
// Stop once we've reached a {, }, or ;
if (/[\{\}\;]/.test(ctx.token.string)) {
break;
}
// Stop once we've reached a <style ...> tag
if (ctx.token.string === "style" && ctx.token.type === "tag") {
// Remove everything up to end-of-tag from selector
var eotIndex = selector.indexOf(">");
if (eotIndex !== -1) {
selector = selector.substring(eotIndex + 1);
}
break;
}
selector = ctx.token.string + selector;
}
if (!TokenUtils.movePrevToken(ctx)) {
break;
}
}
return selector;
} | [
"function",
"_parseSelector",
"(",
"ctx",
")",
"{",
"var",
"selector",
"=",
"\"\"",
";",
"// Skip over {",
"TokenUtils",
".",
"movePrevToken",
"(",
"ctx",
")",
";",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"ctx",
".",
"token",
".",
"type",
"!==",
"\"comment\"",
")",
"{",
"// Stop once we've reached a {, }, or ;",
"if",
"(",
"/",
"[\\{\\}\\;]",
"/",
".",
"test",
"(",
"ctx",
".",
"token",
".",
"string",
")",
")",
"{",
"break",
";",
"}",
"// Stop once we've reached a <style ...> tag",
"if",
"(",
"ctx",
".",
"token",
".",
"string",
"===",
"\"style\"",
"&&",
"ctx",
".",
"token",
".",
"type",
"===",
"\"tag\"",
")",
"{",
"// Remove everything up to end-of-tag from selector",
"var",
"eotIndex",
"=",
"selector",
".",
"indexOf",
"(",
"\">\"",
")",
";",
"if",
"(",
"eotIndex",
"!==",
"-",
"1",
")",
"{",
"selector",
"=",
"selector",
".",
"substring",
"(",
"eotIndex",
"+",
"1",
")",
";",
"}",
"break",
";",
"}",
"selector",
"=",
"ctx",
".",
"token",
".",
"string",
"+",
"selector",
";",
"}",
"if",
"(",
"!",
"TokenUtils",
".",
"movePrevToken",
"(",
"ctx",
")",
")",
"{",
"break",
";",
"}",
"}",
"return",
"selector",
";",
"}"
] | Parse a selector. Assumes ctx is pointing at the opening { that is after the selector name. | [
"Parse",
"a",
"selector",
".",
"Assumes",
"ctx",
"is",
"pointing",
"at",
"the",
"opening",
"{",
"that",
"is",
"after",
"the",
"selector",
"name",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CSSUtils.js#L1563-L1594 |
2,122 | adobe/brackets | src/language/CSSUtils.js | extractAllNamedFlows | function extractAllNamedFlows(text) {
var namedFlowRegEx = /(?:flow\-(into|from)\:\s*)([\w\-]+)(?:\s*;)/gi,
result = [],
names = {},
thisMatch;
// Reduce the content so that matches
// inside strings and comments are ignored
text = reduceStyleSheetForRegExParsing(text);
// Find the first match
thisMatch = namedFlowRegEx.exec(text);
// Iterate over the matches and add them to result
while (thisMatch) {
var thisName = thisMatch[2];
if (IGNORED_FLOW_NAMES.indexOf(thisName) === -1 && !names.hasOwnProperty(thisName)) {
names[thisName] = result.push(thisName);
}
thisMatch = namedFlowRegEx.exec(text);
}
return result;
} | javascript | function extractAllNamedFlows(text) {
var namedFlowRegEx = /(?:flow\-(into|from)\:\s*)([\w\-]+)(?:\s*;)/gi,
result = [],
names = {},
thisMatch;
// Reduce the content so that matches
// inside strings and comments are ignored
text = reduceStyleSheetForRegExParsing(text);
// Find the first match
thisMatch = namedFlowRegEx.exec(text);
// Iterate over the matches and add them to result
while (thisMatch) {
var thisName = thisMatch[2];
if (IGNORED_FLOW_NAMES.indexOf(thisName) === -1 && !names.hasOwnProperty(thisName)) {
names[thisName] = result.push(thisName);
}
thisMatch = namedFlowRegEx.exec(text);
}
return result;
} | [
"function",
"extractAllNamedFlows",
"(",
"text",
")",
"{",
"var",
"namedFlowRegEx",
"=",
"/",
"(?:flow\\-(into|from)\\:\\s*)([\\w\\-]+)(?:\\s*;)",
"/",
"gi",
",",
"result",
"=",
"[",
"]",
",",
"names",
"=",
"{",
"}",
",",
"thisMatch",
";",
"// Reduce the content so that matches",
"// inside strings and comments are ignored",
"text",
"=",
"reduceStyleSheetForRegExParsing",
"(",
"text",
")",
";",
"// Find the first match",
"thisMatch",
"=",
"namedFlowRegEx",
".",
"exec",
"(",
"text",
")",
";",
"// Iterate over the matches and add them to result",
"while",
"(",
"thisMatch",
")",
"{",
"var",
"thisName",
"=",
"thisMatch",
"[",
"2",
"]",
";",
"if",
"(",
"IGNORED_FLOW_NAMES",
".",
"indexOf",
"(",
"thisName",
")",
"===",
"-",
"1",
"&&",
"!",
"names",
".",
"hasOwnProperty",
"(",
"thisName",
")",
")",
"{",
"names",
"[",
"thisName",
"]",
"=",
"result",
".",
"push",
"(",
"thisName",
")",
";",
"}",
"thisMatch",
"=",
"namedFlowRegEx",
".",
"exec",
"(",
"text",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Extracts all named flow instances
@param {!string} text to extract from
@return {Array.<string>} array of unique flow names found in the content (empty if none) | [
"Extracts",
"all",
"named",
"flow",
"instances"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CSSUtils.js#L1729-L1753 |
2,123 | adobe/brackets | src/document/ChangedDocumentTracker.js | ChangedDocumentTracker | function ChangedDocumentTracker() {
var self = this;
this._changedPaths = {};
this._windowFocus = true;
this._addListener = this._addListener.bind(this);
this._removeListener = this._removeListener.bind(this);
this._onChange = this._onChange.bind(this);
this._onWindowFocus = this._onWindowFocus.bind(this);
DocumentManager.on("afterDocumentCreate", function (event, doc) {
// Only track documents in the current project
if (ProjectManager.isWithinProject(doc.file.fullPath)) {
self._addListener(doc);
}
});
DocumentManager.on("beforeDocumentDelete", function (event, doc) {
// In case a document somehow remains loaded after its project
// has been closed, unconditionally attempt to remove the listener.
self._removeListener(doc);
});
$(window).focus(this._onWindowFocus);
} | javascript | function ChangedDocumentTracker() {
var self = this;
this._changedPaths = {};
this._windowFocus = true;
this._addListener = this._addListener.bind(this);
this._removeListener = this._removeListener.bind(this);
this._onChange = this._onChange.bind(this);
this._onWindowFocus = this._onWindowFocus.bind(this);
DocumentManager.on("afterDocumentCreate", function (event, doc) {
// Only track documents in the current project
if (ProjectManager.isWithinProject(doc.file.fullPath)) {
self._addListener(doc);
}
});
DocumentManager.on("beforeDocumentDelete", function (event, doc) {
// In case a document somehow remains loaded after its project
// has been closed, unconditionally attempt to remove the listener.
self._removeListener(doc);
});
$(window).focus(this._onWindowFocus);
} | [
"function",
"ChangedDocumentTracker",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"_changedPaths",
"=",
"{",
"}",
";",
"this",
".",
"_windowFocus",
"=",
"true",
";",
"this",
".",
"_addListener",
"=",
"this",
".",
"_addListener",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_removeListener",
"=",
"this",
".",
"_removeListener",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_onChange",
"=",
"this",
".",
"_onChange",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_onWindowFocus",
"=",
"this",
".",
"_onWindowFocus",
".",
"bind",
"(",
"this",
")",
";",
"DocumentManager",
".",
"on",
"(",
"\"afterDocumentCreate\"",
",",
"function",
"(",
"event",
",",
"doc",
")",
"{",
"// Only track documents in the current project",
"if",
"(",
"ProjectManager",
".",
"isWithinProject",
"(",
"doc",
".",
"file",
".",
"fullPath",
")",
")",
"{",
"self",
".",
"_addListener",
"(",
"doc",
")",
";",
"}",
"}",
")",
";",
"DocumentManager",
".",
"on",
"(",
"\"beforeDocumentDelete\"",
",",
"function",
"(",
"event",
",",
"doc",
")",
"{",
"// In case a document somehow remains loaded after its project",
"// has been closed, unconditionally attempt to remove the listener.",
"self",
".",
"_removeListener",
"(",
"doc",
")",
";",
"}",
")",
";",
"$",
"(",
"window",
")",
".",
"focus",
"(",
"this",
".",
"_onWindowFocus",
")",
";",
"}"
] | Tracks "change" events on opened Documents. Used to monitor changes
to documents in-memory and update caches. Assumes all documents have
changed when the Brackets window loses and regains focus. Does not
read timestamps of files on disk. Clients may optionally track file
timestamps on disk independently.
@constructor | [
"Tracks",
"change",
"events",
"on",
"opened",
"Documents",
".",
"Used",
"to",
"monitor",
"changes",
"to",
"documents",
"in",
"-",
"memory",
"and",
"update",
"caches",
".",
"Assumes",
"all",
"documents",
"have",
"changed",
"when",
"the",
"Brackets",
"window",
"loses",
"and",
"regains",
"focus",
".",
"Does",
"not",
"read",
"timestamps",
"of",
"files",
"on",
"disk",
".",
"Clients",
"may",
"optionally",
"track",
"file",
"timestamps",
"on",
"disk",
"independently",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/ChangedDocumentTracker.js#L41-L65 |
2,124 | adobe/brackets | src/search/FindReplace.js | _findAllAndSelect | function _findAllAndSelect(editor) {
editor = editor || EditorManager.getActiveEditor();
if (!editor) {
return;
}
var sel = editor.getSelection(),
newSelections = [];
if (CodeMirror.cmpPos(sel.start, sel.end) === 0) {
sel = _getWordAt(editor, sel.start);
}
if (CodeMirror.cmpPos(sel.start, sel.end) !== 0) {
var searchStart = {line: 0, ch: 0},
state = getSearchState(editor._codeMirror),
nextMatch;
setQueryInfo(state, { query: editor.document.getRange(sel.start, sel.end), isCaseSensitive: false, isRegexp: false });
while ((nextMatch = _getNextMatch(editor, false, searchStart, false)) !== null) {
if (_selEq(sel, nextMatch)) {
nextMatch.primary = true;
}
newSelections.push(nextMatch);
searchStart = nextMatch.end;
}
// This should find at least the original selection, but just in case...
if (newSelections.length) {
// Don't change the scroll position.
editor.setSelections(newSelections, false);
}
}
} | javascript | function _findAllAndSelect(editor) {
editor = editor || EditorManager.getActiveEditor();
if (!editor) {
return;
}
var sel = editor.getSelection(),
newSelections = [];
if (CodeMirror.cmpPos(sel.start, sel.end) === 0) {
sel = _getWordAt(editor, sel.start);
}
if (CodeMirror.cmpPos(sel.start, sel.end) !== 0) {
var searchStart = {line: 0, ch: 0},
state = getSearchState(editor._codeMirror),
nextMatch;
setQueryInfo(state, { query: editor.document.getRange(sel.start, sel.end), isCaseSensitive: false, isRegexp: false });
while ((nextMatch = _getNextMatch(editor, false, searchStart, false)) !== null) {
if (_selEq(sel, nextMatch)) {
nextMatch.primary = true;
}
newSelections.push(nextMatch);
searchStart = nextMatch.end;
}
// This should find at least the original selection, but just in case...
if (newSelections.length) {
// Don't change the scroll position.
editor.setSelections(newSelections, false);
}
}
} | [
"function",
"_findAllAndSelect",
"(",
"editor",
")",
"{",
"editor",
"=",
"editor",
"||",
"EditorManager",
".",
"getActiveEditor",
"(",
")",
";",
"if",
"(",
"!",
"editor",
")",
"{",
"return",
";",
"}",
"var",
"sel",
"=",
"editor",
".",
"getSelection",
"(",
")",
",",
"newSelections",
"=",
"[",
"]",
";",
"if",
"(",
"CodeMirror",
".",
"cmpPos",
"(",
"sel",
".",
"start",
",",
"sel",
".",
"end",
")",
"===",
"0",
")",
"{",
"sel",
"=",
"_getWordAt",
"(",
"editor",
",",
"sel",
".",
"start",
")",
";",
"}",
"if",
"(",
"CodeMirror",
".",
"cmpPos",
"(",
"sel",
".",
"start",
",",
"sel",
".",
"end",
")",
"!==",
"0",
")",
"{",
"var",
"searchStart",
"=",
"{",
"line",
":",
"0",
",",
"ch",
":",
"0",
"}",
",",
"state",
"=",
"getSearchState",
"(",
"editor",
".",
"_codeMirror",
")",
",",
"nextMatch",
";",
"setQueryInfo",
"(",
"state",
",",
"{",
"query",
":",
"editor",
".",
"document",
".",
"getRange",
"(",
"sel",
".",
"start",
",",
"sel",
".",
"end",
")",
",",
"isCaseSensitive",
":",
"false",
",",
"isRegexp",
":",
"false",
"}",
")",
";",
"while",
"(",
"(",
"nextMatch",
"=",
"_getNextMatch",
"(",
"editor",
",",
"false",
",",
"searchStart",
",",
"false",
")",
")",
"!==",
"null",
")",
"{",
"if",
"(",
"_selEq",
"(",
"sel",
",",
"nextMatch",
")",
")",
"{",
"nextMatch",
".",
"primary",
"=",
"true",
";",
"}",
"newSelections",
".",
"push",
"(",
"nextMatch",
")",
";",
"searchStart",
"=",
"nextMatch",
".",
"end",
";",
"}",
"// This should find at least the original selection, but just in case...",
"if",
"(",
"newSelections",
".",
"length",
")",
"{",
"// Don't change the scroll position.",
"editor",
".",
"setSelections",
"(",
"newSelections",
",",
"false",
")",
";",
"}",
"}",
"}"
] | Takes the primary selection, expands it to a word range if necessary, then sets the selection to
include all instances of that range. Removes all other selections. Does nothing if the selection
is not a range after expansion. | [
"Takes",
"the",
"primary",
"selection",
"expands",
"it",
"to",
"a",
"word",
"range",
"if",
"necessary",
"then",
"sets",
"the",
"selection",
"to",
"include",
"all",
"instances",
"of",
"that",
"range",
".",
"Removes",
"all",
"other",
"selections",
".",
"Does",
"nothing",
"if",
"the",
"selection",
"is",
"not",
"a",
"range",
"after",
"expansion",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindReplace.js#L364-L395 |
2,125 | adobe/brackets | src/search/FindReplace.js | clearCurrentMatchHighlight | function clearCurrentMatchHighlight(cm, state) {
if (state.markedCurrent) {
state.markedCurrent.clear();
ScrollTrackMarkers.markCurrent(-1);
}
} | javascript | function clearCurrentMatchHighlight(cm, state) {
if (state.markedCurrent) {
state.markedCurrent.clear();
ScrollTrackMarkers.markCurrent(-1);
}
} | [
"function",
"clearCurrentMatchHighlight",
"(",
"cm",
",",
"state",
")",
"{",
"if",
"(",
"state",
".",
"markedCurrent",
")",
"{",
"state",
".",
"markedCurrent",
".",
"clear",
"(",
")",
";",
"ScrollTrackMarkers",
".",
"markCurrent",
"(",
"-",
"1",
")",
";",
"}",
"}"
] | Removes the current-match highlight, leaving all matches marked in the generic highlight style | [
"Removes",
"the",
"current",
"-",
"match",
"highlight",
"leaving",
"all",
"matches",
"marked",
"in",
"the",
"generic",
"highlight",
"style"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindReplace.js#L398-L403 |
2,126 | adobe/brackets | src/search/FindReplace.js | clearHighlights | function clearHighlights(cm, state) {
cm.operation(function () {
state.marked.forEach(function (markedRange) {
markedRange.clear();
});
clearCurrentMatchHighlight(cm, state);
});
state.marked.length = 0;
state.markedCurrent = null;
ScrollTrackMarkers.clear();
state.resultSet = [];
state.matchIndex = -1;
} | javascript | function clearHighlights(cm, state) {
cm.operation(function () {
state.marked.forEach(function (markedRange) {
markedRange.clear();
});
clearCurrentMatchHighlight(cm, state);
});
state.marked.length = 0;
state.markedCurrent = null;
ScrollTrackMarkers.clear();
state.resultSet = [];
state.matchIndex = -1;
} | [
"function",
"clearHighlights",
"(",
"cm",
",",
"state",
")",
"{",
"cm",
".",
"operation",
"(",
"function",
"(",
")",
"{",
"state",
".",
"marked",
".",
"forEach",
"(",
"function",
"(",
"markedRange",
")",
"{",
"markedRange",
".",
"clear",
"(",
")",
";",
"}",
")",
";",
"clearCurrentMatchHighlight",
"(",
"cm",
",",
"state",
")",
";",
"}",
")",
";",
"state",
".",
"marked",
".",
"length",
"=",
"0",
";",
"state",
".",
"markedCurrent",
"=",
"null",
";",
"ScrollTrackMarkers",
".",
"clear",
"(",
")",
";",
"state",
".",
"resultSet",
"=",
"[",
"]",
";",
"state",
".",
"matchIndex",
"=",
"-",
"1",
";",
"}"
] | Clears all match highlights, including the current match | [
"Clears",
"all",
"match",
"highlights",
"including",
"the",
"current",
"match"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindReplace.js#L451-L465 |
2,127 | adobe/brackets | src/search/FindReplace.js | openSearchBar | function openSearchBar(editor, replace) {
var cm = editor._codeMirror,
state = getSearchState(cm);
// Use the selection start as the searchStartPos. This way if you
// start with a pre-populated search and enter an additional character,
// it will extend the initial selection instead of jumping to the next
// occurrence.
state.searchStartPos = editor.getCursorPos(false, "start");
// Prepopulate the search field
var initialQuery = FindBar.getInitialQuery(findBar, editor);
if (initialQuery.query === "" && editor.lastParsedQuery !== "") {
initialQuery.query = editor.lastParsedQuery;
}
// Close our previous find bar, if any. (The open() of the new findBar will
// take care of closing any other find bar instances.)
if (findBar) {
findBar.close();
}
// Create the search bar UI (closing any previous find bar in the process)
findBar = new FindBar({
multifile: false,
replace: replace,
initialQuery: initialQuery.query,
initialReplaceText: initialQuery.replaceText,
queryPlaceholder: Strings.FIND_QUERY_PLACEHOLDER
});
findBar.open();
findBar
.on("queryChange.FindReplace", function (e) {
handleQueryChange(editor, state);
})
.on("doFind.FindReplace", function (e, searchBackwards) {
findNext(editor, searchBackwards);
})
.on("close.FindReplace", function (e) {
editor.lastParsedQuery = state.parsedQuery;
// Clear highlights but leave search state in place so Find Next/Previous work after closing
clearHighlights(cm, state);
// Dispose highlighting UI (important to restore normal selection color as soon as focus goes back to the editor)
toggleHighlighting(editor, false);
findBar.off(".FindReplace");
findBar = null;
});
handleQueryChange(editor, state, true);
} | javascript | function openSearchBar(editor, replace) {
var cm = editor._codeMirror,
state = getSearchState(cm);
// Use the selection start as the searchStartPos. This way if you
// start with a pre-populated search and enter an additional character,
// it will extend the initial selection instead of jumping to the next
// occurrence.
state.searchStartPos = editor.getCursorPos(false, "start");
// Prepopulate the search field
var initialQuery = FindBar.getInitialQuery(findBar, editor);
if (initialQuery.query === "" && editor.lastParsedQuery !== "") {
initialQuery.query = editor.lastParsedQuery;
}
// Close our previous find bar, if any. (The open() of the new findBar will
// take care of closing any other find bar instances.)
if (findBar) {
findBar.close();
}
// Create the search bar UI (closing any previous find bar in the process)
findBar = new FindBar({
multifile: false,
replace: replace,
initialQuery: initialQuery.query,
initialReplaceText: initialQuery.replaceText,
queryPlaceholder: Strings.FIND_QUERY_PLACEHOLDER
});
findBar.open();
findBar
.on("queryChange.FindReplace", function (e) {
handleQueryChange(editor, state);
})
.on("doFind.FindReplace", function (e, searchBackwards) {
findNext(editor, searchBackwards);
})
.on("close.FindReplace", function (e) {
editor.lastParsedQuery = state.parsedQuery;
// Clear highlights but leave search state in place so Find Next/Previous work after closing
clearHighlights(cm, state);
// Dispose highlighting UI (important to restore normal selection color as soon as focus goes back to the editor)
toggleHighlighting(editor, false);
findBar.off(".FindReplace");
findBar = null;
});
handleQueryChange(editor, state, true);
} | [
"function",
"openSearchBar",
"(",
"editor",
",",
"replace",
")",
"{",
"var",
"cm",
"=",
"editor",
".",
"_codeMirror",
",",
"state",
"=",
"getSearchState",
"(",
"cm",
")",
";",
"// Use the selection start as the searchStartPos. This way if you",
"// start with a pre-populated search and enter an additional character,",
"// it will extend the initial selection instead of jumping to the next",
"// occurrence.",
"state",
".",
"searchStartPos",
"=",
"editor",
".",
"getCursorPos",
"(",
"false",
",",
"\"start\"",
")",
";",
"// Prepopulate the search field",
"var",
"initialQuery",
"=",
"FindBar",
".",
"getInitialQuery",
"(",
"findBar",
",",
"editor",
")",
";",
"if",
"(",
"initialQuery",
".",
"query",
"===",
"\"\"",
"&&",
"editor",
".",
"lastParsedQuery",
"!==",
"\"\"",
")",
"{",
"initialQuery",
".",
"query",
"=",
"editor",
".",
"lastParsedQuery",
";",
"}",
"// Close our previous find bar, if any. (The open() of the new findBar will",
"// take care of closing any other find bar instances.)",
"if",
"(",
"findBar",
")",
"{",
"findBar",
".",
"close",
"(",
")",
";",
"}",
"// Create the search bar UI (closing any previous find bar in the process)",
"findBar",
"=",
"new",
"FindBar",
"(",
"{",
"multifile",
":",
"false",
",",
"replace",
":",
"replace",
",",
"initialQuery",
":",
"initialQuery",
".",
"query",
",",
"initialReplaceText",
":",
"initialQuery",
".",
"replaceText",
",",
"queryPlaceholder",
":",
"Strings",
".",
"FIND_QUERY_PLACEHOLDER",
"}",
")",
";",
"findBar",
".",
"open",
"(",
")",
";",
"findBar",
".",
"on",
"(",
"\"queryChange.FindReplace\"",
",",
"function",
"(",
"e",
")",
"{",
"handleQueryChange",
"(",
"editor",
",",
"state",
")",
";",
"}",
")",
".",
"on",
"(",
"\"doFind.FindReplace\"",
",",
"function",
"(",
"e",
",",
"searchBackwards",
")",
"{",
"findNext",
"(",
"editor",
",",
"searchBackwards",
")",
";",
"}",
")",
".",
"on",
"(",
"\"close.FindReplace\"",
",",
"function",
"(",
"e",
")",
"{",
"editor",
".",
"lastParsedQuery",
"=",
"state",
".",
"parsedQuery",
";",
"// Clear highlights but leave search state in place so Find Next/Previous work after closing",
"clearHighlights",
"(",
"cm",
",",
"state",
")",
";",
"// Dispose highlighting UI (important to restore normal selection color as soon as focus goes back to the editor)",
"toggleHighlighting",
"(",
"editor",
",",
"false",
")",
";",
"findBar",
".",
"off",
"(",
"\".FindReplace\"",
")",
";",
"findBar",
"=",
"null",
";",
"}",
")",
";",
"handleQueryChange",
"(",
"editor",
",",
"state",
",",
"true",
")",
";",
"}"
] | Creates a Find bar for the current search session.
@param {!Editor} editor
@param {boolean} replace Whether to show the Replace UI; default false | [
"Creates",
"a",
"Find",
"bar",
"for",
"the",
"current",
"search",
"session",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindReplace.js#L597-L649 |
2,128 | adobe/brackets | src/extensions/default/JSLint/main.js | _getIndentSize | function _getIndentSize(fullPath) {
return Editor.getUseTabChar(fullPath) ? Editor.getTabSize(fullPath) : Editor.getSpaceUnits(fullPath);
} | javascript | function _getIndentSize(fullPath) {
return Editor.getUseTabChar(fullPath) ? Editor.getTabSize(fullPath) : Editor.getSpaceUnits(fullPath);
} | [
"function",
"_getIndentSize",
"(",
"fullPath",
")",
"{",
"return",
"Editor",
".",
"getUseTabChar",
"(",
"fullPath",
")",
"?",
"Editor",
".",
"getTabSize",
"(",
"fullPath",
")",
":",
"Editor",
".",
"getSpaceUnits",
"(",
"fullPath",
")",
";",
"}"
] | gets indentation size depending whether the tabs or spaces are used | [
"gets",
"indentation",
"size",
"depending",
"whether",
"the",
"tabs",
"or",
"spaces",
"are",
"used"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JSLint/main.js#L210-L212 |
2,129 | adobe/brackets | src/extensions/default/JSLint/main.js | lintOneFile | function lintOneFile(text, fullPath) {
// If a line contains only whitespace (here spaces or tabs), remove the whitespace
text = text.replace(/^[ \t]+$/gm, "");
var options = prefs.get("options");
_lastRunOptions = _.clone(options);
if (!options) {
options = {};
} else {
options = _.clone(options);
}
if (!options.indent) {
// default to using the same indentation value that the editor is using
options.indent = _getIndentSize(fullPath);
}
// If the user has not defined the environment, we use browser by default.
var hasEnvironment = _.some(ENVIRONMENTS, function (env) {
return options[env] !== undefined;
});
if (!hasEnvironment) {
options.browser = true;
}
var jslintResult = JSLINT(text, options);
if (!jslintResult) {
// Remove any trailing null placeholder (early-abort indicator)
var errors = JSLINT.errors.filter(function (err) { return err !== null; });
errors = errors.map(function (jslintError) {
return {
// JSLint returns 1-based line/col numbers
pos: { line: jslintError.line - 1, ch: jslintError.character - 1 },
message: jslintError.reason,
type: CodeInspection.Type.WARNING
};
});
var result = { errors: errors };
// If array terminated in a null it means there was a stop notice
if (errors.length !== JSLINT.errors.length) {
result.aborted = true;
errors[errors.length - 1].type = CodeInspection.Type.META;
}
return result;
}
return null;
} | javascript | function lintOneFile(text, fullPath) {
// If a line contains only whitespace (here spaces or tabs), remove the whitespace
text = text.replace(/^[ \t]+$/gm, "");
var options = prefs.get("options");
_lastRunOptions = _.clone(options);
if (!options) {
options = {};
} else {
options = _.clone(options);
}
if (!options.indent) {
// default to using the same indentation value that the editor is using
options.indent = _getIndentSize(fullPath);
}
// If the user has not defined the environment, we use browser by default.
var hasEnvironment = _.some(ENVIRONMENTS, function (env) {
return options[env] !== undefined;
});
if (!hasEnvironment) {
options.browser = true;
}
var jslintResult = JSLINT(text, options);
if (!jslintResult) {
// Remove any trailing null placeholder (early-abort indicator)
var errors = JSLINT.errors.filter(function (err) { return err !== null; });
errors = errors.map(function (jslintError) {
return {
// JSLint returns 1-based line/col numbers
pos: { line: jslintError.line - 1, ch: jslintError.character - 1 },
message: jslintError.reason,
type: CodeInspection.Type.WARNING
};
});
var result = { errors: errors };
// If array terminated in a null it means there was a stop notice
if (errors.length !== JSLINT.errors.length) {
result.aborted = true;
errors[errors.length - 1].type = CodeInspection.Type.META;
}
return result;
}
return null;
} | [
"function",
"lintOneFile",
"(",
"text",
",",
"fullPath",
")",
"{",
"// If a line contains only whitespace (here spaces or tabs), remove the whitespace",
"text",
"=",
"text",
".",
"replace",
"(",
"/",
"^[ \\t]+$",
"/",
"gm",
",",
"\"\"",
")",
";",
"var",
"options",
"=",
"prefs",
".",
"get",
"(",
"\"options\"",
")",
";",
"_lastRunOptions",
"=",
"_",
".",
"clone",
"(",
"options",
")",
";",
"if",
"(",
"!",
"options",
")",
"{",
"options",
"=",
"{",
"}",
";",
"}",
"else",
"{",
"options",
"=",
"_",
".",
"clone",
"(",
"options",
")",
";",
"}",
"if",
"(",
"!",
"options",
".",
"indent",
")",
"{",
"// default to using the same indentation value that the editor is using",
"options",
".",
"indent",
"=",
"_getIndentSize",
"(",
"fullPath",
")",
";",
"}",
"// If the user has not defined the environment, we use browser by default.",
"var",
"hasEnvironment",
"=",
"_",
".",
"some",
"(",
"ENVIRONMENTS",
",",
"function",
"(",
"env",
")",
"{",
"return",
"options",
"[",
"env",
"]",
"!==",
"undefined",
";",
"}",
")",
";",
"if",
"(",
"!",
"hasEnvironment",
")",
"{",
"options",
".",
"browser",
"=",
"true",
";",
"}",
"var",
"jslintResult",
"=",
"JSLINT",
"(",
"text",
",",
"options",
")",
";",
"if",
"(",
"!",
"jslintResult",
")",
"{",
"// Remove any trailing null placeholder (early-abort indicator)",
"var",
"errors",
"=",
"JSLINT",
".",
"errors",
".",
"filter",
"(",
"function",
"(",
"err",
")",
"{",
"return",
"err",
"!==",
"null",
";",
"}",
")",
";",
"errors",
"=",
"errors",
".",
"map",
"(",
"function",
"(",
"jslintError",
")",
"{",
"return",
"{",
"// JSLint returns 1-based line/col numbers",
"pos",
":",
"{",
"line",
":",
"jslintError",
".",
"line",
"-",
"1",
",",
"ch",
":",
"jslintError",
".",
"character",
"-",
"1",
"}",
",",
"message",
":",
"jslintError",
".",
"reason",
",",
"type",
":",
"CodeInspection",
".",
"Type",
".",
"WARNING",
"}",
";",
"}",
")",
";",
"var",
"result",
"=",
"{",
"errors",
":",
"errors",
"}",
";",
"// If array terminated in a null it means there was a stop notice",
"if",
"(",
"errors",
".",
"length",
"!==",
"JSLINT",
".",
"errors",
".",
"length",
")",
"{",
"result",
".",
"aborted",
"=",
"true",
";",
"errors",
"[",
"errors",
".",
"length",
"-",
"1",
"]",
".",
"type",
"=",
"CodeInspection",
".",
"Type",
".",
"META",
";",
"}",
"return",
"result",
";",
"}",
"return",
"null",
";",
"}"
] | Run JSLint on the current document. Reports results to the main UI. Displays
a gold star when no errors are found. | [
"Run",
"JSLint",
"on",
"the",
"current",
"document",
".",
"Reports",
"results",
"to",
"the",
"main",
"UI",
".",
"Displays",
"a",
"gold",
"star",
"when",
"no",
"errors",
"are",
"found",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JSLint/main.js#L218-L272 |
2,130 | adobe/brackets | src/extensions/default/InlineColorEditor/main.js | prepareEditorForProvider | function prepareEditorForProvider(hostEditor, pos) {
var colorRegEx, cursorLine, match, sel, start, end, endPos, marker;
sel = hostEditor.getSelection();
if (sel.start.line !== sel.end.line) {
return null;
}
colorRegEx = new RegExp(ColorUtils.COLOR_REGEX);
cursorLine = hostEditor.document.getLine(pos.line);
// Loop through each match of colorRegEx and stop when the one that contains pos is found.
do {
match = colorRegEx.exec(cursorLine);
if (match) {
start = match.index;
end = start + match[0].length;
}
} while (match && (pos.ch < start || pos.ch > end));
if (!match) {
return null;
}
// Adjust pos to the beginning of the match so that the inline editor won't get
// dismissed while we're updating the color with the new values from user's inline editing.
pos.ch = start;
endPos = {line: pos.line, ch: end};
marker = hostEditor._codeMirror.markText(pos, endPos);
hostEditor.setSelection(pos, endPos);
return {
color: match[0],
marker: marker
};
} | javascript | function prepareEditorForProvider(hostEditor, pos) {
var colorRegEx, cursorLine, match, sel, start, end, endPos, marker;
sel = hostEditor.getSelection();
if (sel.start.line !== sel.end.line) {
return null;
}
colorRegEx = new RegExp(ColorUtils.COLOR_REGEX);
cursorLine = hostEditor.document.getLine(pos.line);
// Loop through each match of colorRegEx and stop when the one that contains pos is found.
do {
match = colorRegEx.exec(cursorLine);
if (match) {
start = match.index;
end = start + match[0].length;
}
} while (match && (pos.ch < start || pos.ch > end));
if (!match) {
return null;
}
// Adjust pos to the beginning of the match so that the inline editor won't get
// dismissed while we're updating the color with the new values from user's inline editing.
pos.ch = start;
endPos = {line: pos.line, ch: end};
marker = hostEditor._codeMirror.markText(pos, endPos);
hostEditor.setSelection(pos, endPos);
return {
color: match[0],
marker: marker
};
} | [
"function",
"prepareEditorForProvider",
"(",
"hostEditor",
",",
"pos",
")",
"{",
"var",
"colorRegEx",
",",
"cursorLine",
",",
"match",
",",
"sel",
",",
"start",
",",
"end",
",",
"endPos",
",",
"marker",
";",
"sel",
"=",
"hostEditor",
".",
"getSelection",
"(",
")",
";",
"if",
"(",
"sel",
".",
"start",
".",
"line",
"!==",
"sel",
".",
"end",
".",
"line",
")",
"{",
"return",
"null",
";",
"}",
"colorRegEx",
"=",
"new",
"RegExp",
"(",
"ColorUtils",
".",
"COLOR_REGEX",
")",
";",
"cursorLine",
"=",
"hostEditor",
".",
"document",
".",
"getLine",
"(",
"pos",
".",
"line",
")",
";",
"// Loop through each match of colorRegEx and stop when the one that contains pos is found.",
"do",
"{",
"match",
"=",
"colorRegEx",
".",
"exec",
"(",
"cursorLine",
")",
";",
"if",
"(",
"match",
")",
"{",
"start",
"=",
"match",
".",
"index",
";",
"end",
"=",
"start",
"+",
"match",
"[",
"0",
"]",
".",
"length",
";",
"}",
"}",
"while",
"(",
"match",
"&&",
"(",
"pos",
".",
"ch",
"<",
"start",
"||",
"pos",
".",
"ch",
">",
"end",
")",
")",
";",
"if",
"(",
"!",
"match",
")",
"{",
"return",
"null",
";",
"}",
"// Adjust pos to the beginning of the match so that the inline editor won't get",
"// dismissed while we're updating the color with the new values from user's inline editing.",
"pos",
".",
"ch",
"=",
"start",
";",
"endPos",
"=",
"{",
"line",
":",
"pos",
".",
"line",
",",
"ch",
":",
"end",
"}",
";",
"marker",
"=",
"hostEditor",
".",
"_codeMirror",
".",
"markText",
"(",
"pos",
",",
"endPos",
")",
";",
"hostEditor",
".",
"setSelection",
"(",
"pos",
",",
"endPos",
")",
";",
"return",
"{",
"color",
":",
"match",
"[",
"0",
"]",
",",
"marker",
":",
"marker",
"}",
";",
"}"
] | Prepare hostEditor for an InlineColorEditor at pos if possible. Return
editor context if so; otherwise null.
@param {Editor} hostEditor
@param {{line:Number, ch:Number}} pos
@return {?{color:String, marker:TextMarker}} | [
"Prepare",
"hostEditor",
"for",
"an",
"InlineColorEditor",
"at",
"pos",
"if",
"possible",
".",
"Return",
"editor",
"context",
"if",
"so",
";",
"otherwise",
"null",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineColorEditor/main.js#L41-L77 |
2,131 | adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js | function (msg) {
var msgHandlers;
if (!msg.method) {
// no message type, ignoring it
// TODO: should we trigger a generic event?
console.log("[Brackets LiveDev] Received message without method.");
return;
}
// get handlers for msg.method
msgHandlers = this.handlers[msg.method];
if (msgHandlers && msgHandlers.length > 0) {
// invoke handlers with the received message
msgHandlers.forEach(function (handler) {
try {
// TODO: check which context should be used to call handlers here.
handler(msg);
return;
} catch (e) {
console.log("[Brackets LiveDev] Error executing a handler for " + msg.method);
console.log(e.stack);
return;
}
});
} else {
// no subscribers, ignore it.
// TODO: any other default handling? (eg. specific respond, trigger as a generic event, etc.);
console.log("[Brackets LiveDev] No subscribers for message " + msg.method);
return;
}
} | javascript | function (msg) {
var msgHandlers;
if (!msg.method) {
// no message type, ignoring it
// TODO: should we trigger a generic event?
console.log("[Brackets LiveDev] Received message without method.");
return;
}
// get handlers for msg.method
msgHandlers = this.handlers[msg.method];
if (msgHandlers && msgHandlers.length > 0) {
// invoke handlers with the received message
msgHandlers.forEach(function (handler) {
try {
// TODO: check which context should be used to call handlers here.
handler(msg);
return;
} catch (e) {
console.log("[Brackets LiveDev] Error executing a handler for " + msg.method);
console.log(e.stack);
return;
}
});
} else {
// no subscribers, ignore it.
// TODO: any other default handling? (eg. specific respond, trigger as a generic event, etc.);
console.log("[Brackets LiveDev] No subscribers for message " + msg.method);
return;
}
} | [
"function",
"(",
"msg",
")",
"{",
"var",
"msgHandlers",
";",
"if",
"(",
"!",
"msg",
".",
"method",
")",
"{",
"// no message type, ignoring it",
"// TODO: should we trigger a generic event?",
"console",
".",
"log",
"(",
"\"[Brackets LiveDev] Received message without method.\"",
")",
";",
"return",
";",
"}",
"// get handlers for msg.method",
"msgHandlers",
"=",
"this",
".",
"handlers",
"[",
"msg",
".",
"method",
"]",
";",
"if",
"(",
"msgHandlers",
"&&",
"msgHandlers",
".",
"length",
">",
"0",
")",
"{",
"// invoke handlers with the received message",
"msgHandlers",
".",
"forEach",
"(",
"function",
"(",
"handler",
")",
"{",
"try",
"{",
"// TODO: check which context should be used to call handlers here.",
"handler",
"(",
"msg",
")",
";",
"return",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"console",
".",
"log",
"(",
"\"[Brackets LiveDev] Error executing a handler for \"",
"+",
"msg",
".",
"method",
")",
";",
"console",
".",
"log",
"(",
"e",
".",
"stack",
")",
";",
"return",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"// no subscribers, ignore it.",
"// TODO: any other default handling? (eg. specific respond, trigger as a generic event, etc.);",
"console",
".",
"log",
"(",
"\"[Brackets LiveDev] No subscribers for message \"",
"+",
"msg",
".",
"method",
")",
";",
"return",
";",
"}",
"}"
] | Dispatch messages to handlers according to msg.method value.
@param {Object} msg Message to be dispatched. | [
"Dispatch",
"messages",
"to",
"handlers",
"according",
"to",
"msg",
".",
"method",
"value",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js#L60-L90 |
|
2,132 | adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js | function (orig, response) {
if (!orig.id) {
console.log("[Brackets LiveDev] Trying to send a response for a message with no ID");
return;
}
response.id = orig.id;
this.send(response);
} | javascript | function (orig, response) {
if (!orig.id) {
console.log("[Brackets LiveDev] Trying to send a response for a message with no ID");
return;
}
response.id = orig.id;
this.send(response);
} | [
"function",
"(",
"orig",
",",
"response",
")",
"{",
"if",
"(",
"!",
"orig",
".",
"id",
")",
"{",
"console",
".",
"log",
"(",
"\"[Brackets LiveDev] Trying to send a response for a message with no ID\"",
")",
";",
"return",
";",
"}",
"response",
".",
"id",
"=",
"orig",
".",
"id",
";",
"this",
".",
"send",
"(",
"response",
")",
";",
"}"
] | Send a response of a particular message to the Editor.
Original message must provide an 'id' property
@param {Object} orig Original message.
@param {Object} response Message to be sent as the response. | [
"Send",
"a",
"response",
"of",
"a",
"particular",
"message",
"to",
"the",
"Editor",
".",
"Original",
"message",
"must",
"provide",
"an",
"id",
"property"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js#L98-L105 |
|
2,133 | adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js | function (method, handler) {
if (!method || !handler) {
return;
}
if (!this.handlers[method]) {
//initialize array
this.handlers[method] = [];
}
// add handler to the stack
this.handlers[method].push(handler);
} | javascript | function (method, handler) {
if (!method || !handler) {
return;
}
if (!this.handlers[method]) {
//initialize array
this.handlers[method] = [];
}
// add handler to the stack
this.handlers[method].push(handler);
} | [
"function",
"(",
"method",
",",
"handler",
")",
"{",
"if",
"(",
"!",
"method",
"||",
"!",
"handler",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"this",
".",
"handlers",
"[",
"method",
"]",
")",
"{",
"//initialize array",
"this",
".",
"handlers",
"[",
"method",
"]",
"=",
"[",
"]",
";",
"}",
"// add handler to the stack",
"this",
".",
"handlers",
"[",
"method",
"]",
".",
"push",
"(",
"handler",
")",
";",
"}"
] | Subscribe handlers to specific messages.
@param {string} method Message type.
@param {function} handler.
TODO: add handler name or any identification mechanism to then implement 'off'? | [
"Subscribe",
"handlers",
"to",
"specific",
"messages",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js#L113-L123 |
|
2,134 | adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js | function (msg) {
console.log("Runtime.evaluate");
var result = eval(msg.params.expression);
MessageBroker.respond(msg, {
result: JSON.stringify(result) // TODO: in original protocol this is an object handle
});
} | javascript | function (msg) {
console.log("Runtime.evaluate");
var result = eval(msg.params.expression);
MessageBroker.respond(msg, {
result: JSON.stringify(result) // TODO: in original protocol this is an object handle
});
} | [
"function",
"(",
"msg",
")",
"{",
"console",
".",
"log",
"(",
"\"Runtime.evaluate\"",
")",
";",
"var",
"result",
"=",
"eval",
"(",
"msg",
".",
"params",
".",
"expression",
")",
";",
"MessageBroker",
".",
"respond",
"(",
"msg",
",",
"{",
"result",
":",
"JSON",
".",
"stringify",
"(",
"result",
")",
"// TODO: in original protocol this is an object handle",
"}",
")",
";",
"}"
] | Evaluate an expresion and return its result. | [
"Evaluate",
"an",
"expresion",
"and",
"return",
"its",
"result",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js#L141-L147 |
|
2,135 | adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js | function (msg) {
if (msg.params.url) {
// navigate to a new page.
window.location.replace(msg.params.url);
}
} | javascript | function (msg) {
if (msg.params.url) {
// navigate to a new page.
window.location.replace(msg.params.url);
}
} | [
"function",
"(",
"msg",
")",
"{",
"if",
"(",
"msg",
".",
"params",
".",
"url",
")",
"{",
"// navigate to a new page.",
"window",
".",
"location",
".",
"replace",
"(",
"msg",
".",
"params",
".",
"url",
")",
";",
"}",
"}"
] | Navigate to a different page.
@param {Object} msg | [
"Navigate",
"to",
"a",
"different",
"page",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js#L251-L256 |
|
2,136 | adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js | function (msgStr) {
var msg;
try {
msg = JSON.parse(msgStr);
} catch (e) {
console.log("[Brackets LiveDev] Malformed message received: ", msgStr);
return;
}
// delegates handling/routing to MessageBroker.
MessageBroker.trigger(msg);
} | javascript | function (msgStr) {
var msg;
try {
msg = JSON.parse(msgStr);
} catch (e) {
console.log("[Brackets LiveDev] Malformed message received: ", msgStr);
return;
}
// delegates handling/routing to MessageBroker.
MessageBroker.trigger(msg);
} | [
"function",
"(",
"msgStr",
")",
"{",
"var",
"msg",
";",
"try",
"{",
"msg",
"=",
"JSON",
".",
"parse",
"(",
"msgStr",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"console",
".",
"log",
"(",
"\"[Brackets LiveDev] Malformed message received: \"",
",",
"msgStr",
")",
";",
"return",
";",
"}",
"// delegates handling/routing to MessageBroker.",
"MessageBroker",
".",
"trigger",
"(",
"msg",
")",
";",
"}"
] | Handles a message from the transport. Parses it as JSON and delegates
to MessageBroker who is in charge of routing them to handlers.
@param {string} msgStr The protocol message as stringified JSON. | [
"Handles",
"a",
"message",
"from",
"the",
"transport",
".",
"Parses",
"it",
"as",
"JSON",
"and",
"delegates",
"to",
"MessageBroker",
"who",
"is",
"in",
"charge",
"of",
"routing",
"them",
"to",
"handlers",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js#L353-L363 |
|
2,137 | adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js | onDocumentClick | function onDocumentClick(event) {
var element = event.target;
if (element && element.hasAttribute('data-brackets-id')) {
MessageBroker.send({"tagId": element.getAttribute('data-brackets-id')});
}
} | javascript | function onDocumentClick(event) {
var element = event.target;
if (element && element.hasAttribute('data-brackets-id')) {
MessageBroker.send({"tagId": element.getAttribute('data-brackets-id')});
}
} | [
"function",
"onDocumentClick",
"(",
"event",
")",
"{",
"var",
"element",
"=",
"event",
".",
"target",
";",
"if",
"(",
"element",
"&&",
"element",
".",
"hasAttribute",
"(",
"'data-brackets-id'",
")",
")",
"{",
"MessageBroker",
".",
"send",
"(",
"{",
"\"tagId\"",
":",
"element",
".",
"getAttribute",
"(",
"'data-brackets-id'",
")",
"}",
")",
";",
"}",
"}"
] | Sends the message containing tagID which is being clicked
to the editor in order to change the cursor position to
the HTML tag corresponding to the clicked element. | [
"Sends",
"the",
"message",
"containing",
"tagID",
"which",
"is",
"being",
"clicked",
"to",
"the",
"editor",
"in",
"order",
"to",
"change",
"the",
"cursor",
"position",
"to",
"the",
"HTML",
"tag",
"corresponding",
"to",
"the",
"clicked",
"element",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js#L385-L390 |
2,138 | adobe/brackets | src/extensions/default/HealthData/HealthDataPreview.js | previewHealthData | function previewHealthData() {
var result = new $.Deferred();
HealthDataManager.getHealthData().done(function (healthDataObject) {
var combinedHealthAnalyticsData = HealthDataManager.getAnalyticsData(),
content;
combinedHealthAnalyticsData = [healthDataObject, combinedHealthAnalyticsData ];
content = JSON.stringify(combinedHealthAnalyticsData, null, 4);
content = _.escape(content);
content = content.replace(/ /g, " ");
content = content.replace(/(?:\r\n|\r|\n)/g, "<br />");
var hdPref = prefs.get("healthDataTracking"),
template = Mustache.render(HealthDataPreviewDialog, {Strings: Strings, content: content, hdPref: hdPref}),
$template = $(template);
Dialogs.addLinkTooltips($template);
Dialogs.showModalDialogUsingTemplate($template).done(function (id) {
if (id === "save") {
var newHDPref = $template.find("[data-target]:checkbox").is(":checked");
if (hdPref !== newHDPref) {
prefs.set("healthDataTracking", newHDPref);
}
}
});
return result.resolve();
});
return result.promise();
} | javascript | function previewHealthData() {
var result = new $.Deferred();
HealthDataManager.getHealthData().done(function (healthDataObject) {
var combinedHealthAnalyticsData = HealthDataManager.getAnalyticsData(),
content;
combinedHealthAnalyticsData = [healthDataObject, combinedHealthAnalyticsData ];
content = JSON.stringify(combinedHealthAnalyticsData, null, 4);
content = _.escape(content);
content = content.replace(/ /g, " ");
content = content.replace(/(?:\r\n|\r|\n)/g, "<br />");
var hdPref = prefs.get("healthDataTracking"),
template = Mustache.render(HealthDataPreviewDialog, {Strings: Strings, content: content, hdPref: hdPref}),
$template = $(template);
Dialogs.addLinkTooltips($template);
Dialogs.showModalDialogUsingTemplate($template).done(function (id) {
if (id === "save") {
var newHDPref = $template.find("[data-target]:checkbox").is(":checked");
if (hdPref !== newHDPref) {
prefs.set("healthDataTracking", newHDPref);
}
}
});
return result.resolve();
});
return result.promise();
} | [
"function",
"previewHealthData",
"(",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"HealthDataManager",
".",
"getHealthData",
"(",
")",
".",
"done",
"(",
"function",
"(",
"healthDataObject",
")",
"{",
"var",
"combinedHealthAnalyticsData",
"=",
"HealthDataManager",
".",
"getAnalyticsData",
"(",
")",
",",
"content",
";",
"combinedHealthAnalyticsData",
"=",
"[",
"healthDataObject",
",",
"combinedHealthAnalyticsData",
"]",
";",
"content",
"=",
"JSON",
".",
"stringify",
"(",
"combinedHealthAnalyticsData",
",",
"null",
",",
"4",
")",
";",
"content",
"=",
"_",
".",
"escape",
"(",
"content",
")",
";",
"content",
"=",
"content",
".",
"replace",
"(",
"/",
" ",
"/",
"g",
",",
"\" \"",
")",
";",
"content",
"=",
"content",
".",
"replace",
"(",
"/",
"(?:\\r\\n|\\r|\\n)",
"/",
"g",
",",
"\"<br />\"",
")",
";",
"var",
"hdPref",
"=",
"prefs",
".",
"get",
"(",
"\"healthDataTracking\"",
")",
",",
"template",
"=",
"Mustache",
".",
"render",
"(",
"HealthDataPreviewDialog",
",",
"{",
"Strings",
":",
"Strings",
",",
"content",
":",
"content",
",",
"hdPref",
":",
"hdPref",
"}",
")",
",",
"$template",
"=",
"$",
"(",
"template",
")",
";",
"Dialogs",
".",
"addLinkTooltips",
"(",
"$template",
")",
";",
"Dialogs",
".",
"showModalDialogUsingTemplate",
"(",
"$template",
")",
".",
"done",
"(",
"function",
"(",
"id",
")",
"{",
"if",
"(",
"id",
"===",
"\"save\"",
")",
"{",
"var",
"newHDPref",
"=",
"$template",
".",
"find",
"(",
"\"[data-target]:checkbox\"",
")",
".",
"is",
"(",
"\":checked\"",
")",
";",
"if",
"(",
"hdPref",
"!==",
"newHDPref",
")",
"{",
"prefs",
".",
"set",
"(",
"\"healthDataTracking\"",
",",
"newHDPref",
")",
";",
"}",
"}",
"}",
")",
";",
"return",
"result",
".",
"resolve",
"(",
")",
";",
"}",
")",
";",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] | Show the dialog for previewing the Health Data that will be sent. | [
"Show",
"the",
"dialog",
"for",
"previewing",
"the",
"Health",
"Data",
"that",
"will",
"be",
"sent",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/HealthData/HealthDataPreview.js#L44-L76 |
2,139 | adobe/brackets | src/extensions/default/NavigationAndHistory/main.js | _openEditorForContext | function _openEditorForContext(contextData) {
// Open the file in the current active pane to prevent unwanted scenarios if we are not in split view, fallback
// to the persisted paneId when specified and we are in split view or unable to determine the paneid
var activePaneId = MainViewManager.getActivePaneId(),
targetPaneId = contextData.paneId; // Assume we are going to use the last associated paneID
// Detect if we are not in split mode
if (MainViewManager.getPaneCount() === 1) {
// Override the targetPaneId with activePaneId as we are not yet in split mode
targetPaneId = activePaneId;
}
// If hide of MROF list is a context parameter, hide the MROF list on successful file open
if (contextData.hideOnOpenFile) {
_hideMROFList();
}
return CommandManager
.execute(Commands.FILE_OPEN,
{ fullPath: contextData.path,
paneId: targetPaneId
}
)
.done(function () {
if (contextData.cursor) {
activeEditor = EditorManager.getActiveEditor();
activeEditor.setCursorPos(contextData.cursor);
activeEditor.centerOnCursor();
}
});
} | javascript | function _openEditorForContext(contextData) {
// Open the file in the current active pane to prevent unwanted scenarios if we are not in split view, fallback
// to the persisted paneId when specified and we are in split view or unable to determine the paneid
var activePaneId = MainViewManager.getActivePaneId(),
targetPaneId = contextData.paneId; // Assume we are going to use the last associated paneID
// Detect if we are not in split mode
if (MainViewManager.getPaneCount() === 1) {
// Override the targetPaneId with activePaneId as we are not yet in split mode
targetPaneId = activePaneId;
}
// If hide of MROF list is a context parameter, hide the MROF list on successful file open
if (contextData.hideOnOpenFile) {
_hideMROFList();
}
return CommandManager
.execute(Commands.FILE_OPEN,
{ fullPath: contextData.path,
paneId: targetPaneId
}
)
.done(function () {
if (contextData.cursor) {
activeEditor = EditorManager.getActiveEditor();
activeEditor.setCursorPos(contextData.cursor);
activeEditor.centerOnCursor();
}
});
} | [
"function",
"_openEditorForContext",
"(",
"contextData",
")",
"{",
"// Open the file in the current active pane to prevent unwanted scenarios if we are not in split view, fallback",
"// to the persisted paneId when specified and we are in split view or unable to determine the paneid",
"var",
"activePaneId",
"=",
"MainViewManager",
".",
"getActivePaneId",
"(",
")",
",",
"targetPaneId",
"=",
"contextData",
".",
"paneId",
";",
"// Assume we are going to use the last associated paneID",
"// Detect if we are not in split mode",
"if",
"(",
"MainViewManager",
".",
"getPaneCount",
"(",
")",
"===",
"1",
")",
"{",
"// Override the targetPaneId with activePaneId as we are not yet in split mode",
"targetPaneId",
"=",
"activePaneId",
";",
"}",
"// If hide of MROF list is a context parameter, hide the MROF list on successful file open",
"if",
"(",
"contextData",
".",
"hideOnOpenFile",
")",
"{",
"_hideMROFList",
"(",
")",
";",
"}",
"return",
"CommandManager",
".",
"execute",
"(",
"Commands",
".",
"FILE_OPEN",
",",
"{",
"fullPath",
":",
"contextData",
".",
"path",
",",
"paneId",
":",
"targetPaneId",
"}",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"contextData",
".",
"cursor",
")",
"{",
"activeEditor",
"=",
"EditorManager",
".",
"getActiveEditor",
"(",
")",
";",
"activeEditor",
".",
"setCursorPos",
"(",
"contextData",
".",
"cursor",
")",
";",
"activeEditor",
".",
"centerOnCursor",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Opens a full editor for the given context
@private
@param {Object.<path, paneId, cursor>} contextData - wrapper to provide the information required to open a full editor
@return {$.Promise} - from the commandmanager | [
"Opens",
"a",
"full",
"editor",
"for",
"the",
"given",
"context"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NavigationAndHistory/main.js#L99-L129 |
2,140 | adobe/brackets | src/extensions/default/NavigationAndHistory/main.js | _makeMROFListEntry | function _makeMROFListEntry(path, pane, cursorPos) {
return {
file: path,
paneId: pane,
cursor: cursorPos
};
} | javascript | function _makeMROFListEntry(path, pane, cursorPos) {
return {
file: path,
paneId: pane,
cursor: cursorPos
};
} | [
"function",
"_makeMROFListEntry",
"(",
"path",
",",
"pane",
",",
"cursorPos",
")",
"{",
"return",
"{",
"file",
":",
"path",
",",
"paneId",
":",
"pane",
",",
"cursor",
":",
"cursorPos",
"}",
";",
"}"
] | Creates an entry for MROF list
@private
@param {String} path - full path of a doc
@param {String} pane - the pane holding the editor for the doc
@param {Object} cursorPos - current cursor position
@return {Object} a frame containing file path, pane and last known cursor | [
"Creates",
"an",
"entry",
"for",
"MROF",
"list"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NavigationAndHistory/main.js#L139-L145 |
2,141 | adobe/brackets | src/extensions/default/NavigationAndHistory/main.js | _syncWithFileSystem | function _syncWithFileSystem() {
_mrofList = _mrofList.filter(function (e) {return e; });
return Async.doSequentially(_mrofList, _checkExt, false);
} | javascript | function _syncWithFileSystem() {
_mrofList = _mrofList.filter(function (e) {return e; });
return Async.doSequentially(_mrofList, _checkExt, false);
} | [
"function",
"_syncWithFileSystem",
"(",
")",
"{",
"_mrofList",
"=",
"_mrofList",
".",
"filter",
"(",
"function",
"(",
"e",
")",
"{",
"return",
"e",
";",
"}",
")",
";",
"return",
"Async",
".",
"doSequentially",
"(",
"_mrofList",
",",
"_checkExt",
",",
"false",
")",
";",
"}"
] | Checks whether entries in MROF list actually exists in fileSystem to prevent access to deleted files
@private | [
"Checks",
"whether",
"entries",
"in",
"MROF",
"list",
"actually",
"exists",
"in",
"fileSystem",
"to",
"prevent",
"access",
"to",
"deleted",
"files"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NavigationAndHistory/main.js#L190-L193 |
2,142 | adobe/brackets | src/extensions/default/NavigationAndHistory/main.js | _createMROFList | function _createMROFList() {
var paneList = MainViewManager.getPaneIdList(),
mrofList = [],
fileList,
index;
var pane, file, mrofEntry, paneCount, fileCount;
// Iterate over the pane ID list
for (paneCount = 0; paneCount < paneList.length; paneCount++) {
pane = paneList[paneCount];
fileList = MainViewManager.getWorkingSet(pane);
// Iterate over the file list for this pane
for (fileCount = 0; fileCount < fileList.length; fileCount++) {
file = fileList[fileCount];
mrofEntry = _makeMROFListEntry(file.fullPath, pane, null);
// Add it in the MRU list order
index = MainViewManager.findInGlobalMRUList(pane, file);
mrofList[index] = mrofEntry;
}
}
return mrofList;
} | javascript | function _createMROFList() {
var paneList = MainViewManager.getPaneIdList(),
mrofList = [],
fileList,
index;
var pane, file, mrofEntry, paneCount, fileCount;
// Iterate over the pane ID list
for (paneCount = 0; paneCount < paneList.length; paneCount++) {
pane = paneList[paneCount];
fileList = MainViewManager.getWorkingSet(pane);
// Iterate over the file list for this pane
for (fileCount = 0; fileCount < fileList.length; fileCount++) {
file = fileList[fileCount];
mrofEntry = _makeMROFListEntry(file.fullPath, pane, null);
// Add it in the MRU list order
index = MainViewManager.findInGlobalMRUList(pane, file);
mrofList[index] = mrofEntry;
}
}
return mrofList;
} | [
"function",
"_createMROFList",
"(",
")",
"{",
"var",
"paneList",
"=",
"MainViewManager",
".",
"getPaneIdList",
"(",
")",
",",
"mrofList",
"=",
"[",
"]",
",",
"fileList",
",",
"index",
";",
"var",
"pane",
",",
"file",
",",
"mrofEntry",
",",
"paneCount",
",",
"fileCount",
";",
"// Iterate over the pane ID list",
"for",
"(",
"paneCount",
"=",
"0",
";",
"paneCount",
"<",
"paneList",
".",
"length",
";",
"paneCount",
"++",
")",
"{",
"pane",
"=",
"paneList",
"[",
"paneCount",
"]",
";",
"fileList",
"=",
"MainViewManager",
".",
"getWorkingSet",
"(",
"pane",
")",
";",
"// Iterate over the file list for this pane",
"for",
"(",
"fileCount",
"=",
"0",
";",
"fileCount",
"<",
"fileList",
".",
"length",
";",
"fileCount",
"++",
")",
"{",
"file",
"=",
"fileList",
"[",
"fileCount",
"]",
";",
"mrofEntry",
"=",
"_makeMROFListEntry",
"(",
"file",
".",
"fullPath",
",",
"pane",
",",
"null",
")",
";",
"// Add it in the MRU list order",
"index",
"=",
"MainViewManager",
".",
"findInGlobalMRUList",
"(",
"pane",
",",
"file",
")",
";",
"mrofList",
"[",
"index",
"]",
"=",
"mrofEntry",
";",
"}",
"}",
"return",
"mrofList",
";",
"}"
] | This function is used to create mrof when a project is opened for the firt time with the recent files feature
This routine acts as a logic to migrate existing viewlist to mrof structure
@private | [
"This",
"function",
"is",
"used",
"to",
"create",
"mrof",
"when",
"a",
"project",
"is",
"opened",
"for",
"the",
"firt",
"time",
"with",
"the",
"recent",
"files",
"feature",
"This",
"routine",
"acts",
"as",
"a",
"logic",
"to",
"migrate",
"existing",
"viewlist",
"to",
"mrof",
"structure"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NavigationAndHistory/main.js#L320-L343 |
2,143 | adobe/brackets | src/extensions/default/NavigationAndHistory/main.js | _createMROFDisplayList | function _createMROFDisplayList(refresh) {
var $def = $.Deferred();
var $mrofList, $link, $newItem;
/**
* Clears the MROF list in memory and pop over but retains the working set entries
* @private
*/
function _purgeAllExceptWorkingSet() {
_mrofList = _createMROFList();
$mrofList.empty();
_createMROFDisplayList(true);
$currentContext = null;
PreferencesManager.setViewState(OPEN_FILES_VIEW_STATE, _mrofList, _getPrefsContext(), true);
}
if (!refresh) {
// Call hide first to make sure we are not creating duplicate lists
_hideMROFList();
$mrofContainer = $(Mustache.render(htmlTemplate, {Strings: Strings})).appendTo('body');
$("#mrof-list-close").one("click", _hideMROFList);
// Attach clear list handler to the 'Clear All' button
$("#mrof-container .footer > div#clear-mrof-list").on("click", _purgeAllExceptWorkingSet);
$(window).on("keydown", _handleArrowKeys);
$(window).on("keyup", _hideMROFListOnEscape);
}
$mrofList = $mrofContainer.find("#mrof-list");
/**
* Focus handler for the link in list item
* @private
*/
function _onFocus(event) {
var $scope = $(event.target).parent();
$("#mrof-container #mrof-list > li.highlight").removeClass("highlight");
$(event.target).parent().addClass("highlight");
$mrofContainer.find("#recent-file-path").text($scope.data("path"));
$mrofContainer.find("#recent-file-path").attr('title', ($scope.data("path")));
$currentContext = $scope;
}
/**
* Click handler for the link in list item
* @private
*/
function _onClick(event) {
var $scope = $(event.delegateTarget).parent();
_openEditorForContext({
path: $scope.data("path"),
paneId: $scope.data("paneId"),
cursor: $scope.data("cursor"),
hideOnOpenFile: true
});
}
var data, fileEntry;
_syncWithFileSystem().always(function () {
_mrofList = _mrofList.filter(function (e) {return e; });
_createFileEntries($mrofList);
var $fileLinks = $("#mrof-container #mrof-list > li > a.mroitem");
// Handlers for mouse events on the list items
$fileLinks.on("focus", _onFocus);
$fileLinks.on("click", _onClick);
$fileLinks.on("select", _onClick);
// Put focus on the Most recent file link in the list
$fileLinks.first().trigger("focus");
$def.resolve();
});
return $def.promise();
} | javascript | function _createMROFDisplayList(refresh) {
var $def = $.Deferred();
var $mrofList, $link, $newItem;
/**
* Clears the MROF list in memory and pop over but retains the working set entries
* @private
*/
function _purgeAllExceptWorkingSet() {
_mrofList = _createMROFList();
$mrofList.empty();
_createMROFDisplayList(true);
$currentContext = null;
PreferencesManager.setViewState(OPEN_FILES_VIEW_STATE, _mrofList, _getPrefsContext(), true);
}
if (!refresh) {
// Call hide first to make sure we are not creating duplicate lists
_hideMROFList();
$mrofContainer = $(Mustache.render(htmlTemplate, {Strings: Strings})).appendTo('body');
$("#mrof-list-close").one("click", _hideMROFList);
// Attach clear list handler to the 'Clear All' button
$("#mrof-container .footer > div#clear-mrof-list").on("click", _purgeAllExceptWorkingSet);
$(window).on("keydown", _handleArrowKeys);
$(window).on("keyup", _hideMROFListOnEscape);
}
$mrofList = $mrofContainer.find("#mrof-list");
/**
* Focus handler for the link in list item
* @private
*/
function _onFocus(event) {
var $scope = $(event.target).parent();
$("#mrof-container #mrof-list > li.highlight").removeClass("highlight");
$(event.target).parent().addClass("highlight");
$mrofContainer.find("#recent-file-path").text($scope.data("path"));
$mrofContainer.find("#recent-file-path").attr('title', ($scope.data("path")));
$currentContext = $scope;
}
/**
* Click handler for the link in list item
* @private
*/
function _onClick(event) {
var $scope = $(event.delegateTarget).parent();
_openEditorForContext({
path: $scope.data("path"),
paneId: $scope.data("paneId"),
cursor: $scope.data("cursor"),
hideOnOpenFile: true
});
}
var data, fileEntry;
_syncWithFileSystem().always(function () {
_mrofList = _mrofList.filter(function (e) {return e; });
_createFileEntries($mrofList);
var $fileLinks = $("#mrof-container #mrof-list > li > a.mroitem");
// Handlers for mouse events on the list items
$fileLinks.on("focus", _onFocus);
$fileLinks.on("click", _onClick);
$fileLinks.on("select", _onClick);
// Put focus on the Most recent file link in the list
$fileLinks.first().trigger("focus");
$def.resolve();
});
return $def.promise();
} | [
"function",
"_createMROFDisplayList",
"(",
"refresh",
")",
"{",
"var",
"$def",
"=",
"$",
".",
"Deferred",
"(",
")",
";",
"var",
"$mrofList",
",",
"$link",
",",
"$newItem",
";",
"/**\n * Clears the MROF list in memory and pop over but retains the working set entries\n * @private\n */",
"function",
"_purgeAllExceptWorkingSet",
"(",
")",
"{",
"_mrofList",
"=",
"_createMROFList",
"(",
")",
";",
"$mrofList",
".",
"empty",
"(",
")",
";",
"_createMROFDisplayList",
"(",
"true",
")",
";",
"$currentContext",
"=",
"null",
";",
"PreferencesManager",
".",
"setViewState",
"(",
"OPEN_FILES_VIEW_STATE",
",",
"_mrofList",
",",
"_getPrefsContext",
"(",
")",
",",
"true",
")",
";",
"}",
"if",
"(",
"!",
"refresh",
")",
"{",
"// Call hide first to make sure we are not creating duplicate lists",
"_hideMROFList",
"(",
")",
";",
"$mrofContainer",
"=",
"$",
"(",
"Mustache",
".",
"render",
"(",
"htmlTemplate",
",",
"{",
"Strings",
":",
"Strings",
"}",
")",
")",
".",
"appendTo",
"(",
"'body'",
")",
";",
"$",
"(",
"\"#mrof-list-close\"",
")",
".",
"one",
"(",
"\"click\"",
",",
"_hideMROFList",
")",
";",
"// Attach clear list handler to the 'Clear All' button",
"$",
"(",
"\"#mrof-container .footer > div#clear-mrof-list\"",
")",
".",
"on",
"(",
"\"click\"",
",",
"_purgeAllExceptWorkingSet",
")",
";",
"$",
"(",
"window",
")",
".",
"on",
"(",
"\"keydown\"",
",",
"_handleArrowKeys",
")",
";",
"$",
"(",
"window",
")",
".",
"on",
"(",
"\"keyup\"",
",",
"_hideMROFListOnEscape",
")",
";",
"}",
"$mrofList",
"=",
"$mrofContainer",
".",
"find",
"(",
"\"#mrof-list\"",
")",
";",
"/**\n * Focus handler for the link in list item \n * @private\n */",
"function",
"_onFocus",
"(",
"event",
")",
"{",
"var",
"$scope",
"=",
"$",
"(",
"event",
".",
"target",
")",
".",
"parent",
"(",
")",
";",
"$",
"(",
"\"#mrof-container #mrof-list > li.highlight\"",
")",
".",
"removeClass",
"(",
"\"highlight\"",
")",
";",
"$",
"(",
"event",
".",
"target",
")",
".",
"parent",
"(",
")",
".",
"addClass",
"(",
"\"highlight\"",
")",
";",
"$mrofContainer",
".",
"find",
"(",
"\"#recent-file-path\"",
")",
".",
"text",
"(",
"$scope",
".",
"data",
"(",
"\"path\"",
")",
")",
";",
"$mrofContainer",
".",
"find",
"(",
"\"#recent-file-path\"",
")",
".",
"attr",
"(",
"'title'",
",",
"(",
"$scope",
".",
"data",
"(",
"\"path\"",
")",
")",
")",
";",
"$currentContext",
"=",
"$scope",
";",
"}",
"/**\n * Click handler for the link in list item \n * @private\n */",
"function",
"_onClick",
"(",
"event",
")",
"{",
"var",
"$scope",
"=",
"$",
"(",
"event",
".",
"delegateTarget",
")",
".",
"parent",
"(",
")",
";",
"_openEditorForContext",
"(",
"{",
"path",
":",
"$scope",
".",
"data",
"(",
"\"path\"",
")",
",",
"paneId",
":",
"$scope",
".",
"data",
"(",
"\"paneId\"",
")",
",",
"cursor",
":",
"$scope",
".",
"data",
"(",
"\"cursor\"",
")",
",",
"hideOnOpenFile",
":",
"true",
"}",
")",
";",
"}",
"var",
"data",
",",
"fileEntry",
";",
"_syncWithFileSystem",
"(",
")",
".",
"always",
"(",
"function",
"(",
")",
"{",
"_mrofList",
"=",
"_mrofList",
".",
"filter",
"(",
"function",
"(",
"e",
")",
"{",
"return",
"e",
";",
"}",
")",
";",
"_createFileEntries",
"(",
"$mrofList",
")",
";",
"var",
"$fileLinks",
"=",
"$",
"(",
"\"#mrof-container #mrof-list > li > a.mroitem\"",
")",
";",
"// Handlers for mouse events on the list items",
"$fileLinks",
".",
"on",
"(",
"\"focus\"",
",",
"_onFocus",
")",
";",
"$fileLinks",
".",
"on",
"(",
"\"click\"",
",",
"_onClick",
")",
";",
"$fileLinks",
".",
"on",
"(",
"\"select\"",
",",
"_onClick",
")",
";",
"// Put focus on the Most recent file link in the list",
"$fileLinks",
".",
"first",
"(",
")",
".",
"trigger",
"(",
"\"focus\"",
")",
";",
"$def",
".",
"resolve",
"(",
")",
";",
"}",
")",
";",
"return",
"$def",
".",
"promise",
"(",
")",
";",
"}"
] | Shows the current MROF list
@private | [
"Shows",
"the",
"current",
"MROF",
"list"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NavigationAndHistory/main.js#L380-L455 |
2,144 | adobe/brackets | src/extensions/default/NavigationAndHistory/main.js | _purgeAllExceptWorkingSet | function _purgeAllExceptWorkingSet() {
_mrofList = _createMROFList();
$mrofList.empty();
_createMROFDisplayList(true);
$currentContext = null;
PreferencesManager.setViewState(OPEN_FILES_VIEW_STATE, _mrofList, _getPrefsContext(), true);
} | javascript | function _purgeAllExceptWorkingSet() {
_mrofList = _createMROFList();
$mrofList.empty();
_createMROFDisplayList(true);
$currentContext = null;
PreferencesManager.setViewState(OPEN_FILES_VIEW_STATE, _mrofList, _getPrefsContext(), true);
} | [
"function",
"_purgeAllExceptWorkingSet",
"(",
")",
"{",
"_mrofList",
"=",
"_createMROFList",
"(",
")",
";",
"$mrofList",
".",
"empty",
"(",
")",
";",
"_createMROFDisplayList",
"(",
"true",
")",
";",
"$currentContext",
"=",
"null",
";",
"PreferencesManager",
".",
"setViewState",
"(",
"OPEN_FILES_VIEW_STATE",
",",
"_mrofList",
",",
"_getPrefsContext",
"(",
")",
",",
"true",
")",
";",
"}"
] | Clears the MROF list in memory and pop over but retains the working set entries
@private | [
"Clears",
"the",
"MROF",
"list",
"in",
"memory",
"and",
"pop",
"over",
"but",
"retains",
"the",
"working",
"set",
"entries"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NavigationAndHistory/main.js#L389-L395 |
2,145 | adobe/brackets | src/extensions/default/NavigationAndHistory/main.js | _onFocus | function _onFocus(event) {
var $scope = $(event.target).parent();
$("#mrof-container #mrof-list > li.highlight").removeClass("highlight");
$(event.target).parent().addClass("highlight");
$mrofContainer.find("#recent-file-path").text($scope.data("path"));
$mrofContainer.find("#recent-file-path").attr('title', ($scope.data("path")));
$currentContext = $scope;
} | javascript | function _onFocus(event) {
var $scope = $(event.target).parent();
$("#mrof-container #mrof-list > li.highlight").removeClass("highlight");
$(event.target).parent().addClass("highlight");
$mrofContainer.find("#recent-file-path").text($scope.data("path"));
$mrofContainer.find("#recent-file-path").attr('title', ($scope.data("path")));
$currentContext = $scope;
} | [
"function",
"_onFocus",
"(",
"event",
")",
"{",
"var",
"$scope",
"=",
"$",
"(",
"event",
".",
"target",
")",
".",
"parent",
"(",
")",
";",
"$",
"(",
"\"#mrof-container #mrof-list > li.highlight\"",
")",
".",
"removeClass",
"(",
"\"highlight\"",
")",
";",
"$",
"(",
"event",
".",
"target",
")",
".",
"parent",
"(",
")",
".",
"addClass",
"(",
"\"highlight\"",
")",
";",
"$mrofContainer",
".",
"find",
"(",
"\"#recent-file-path\"",
")",
".",
"text",
"(",
"$scope",
".",
"data",
"(",
"\"path\"",
")",
")",
";",
"$mrofContainer",
".",
"find",
"(",
"\"#recent-file-path\"",
")",
".",
"attr",
"(",
"'title'",
",",
"(",
"$scope",
".",
"data",
"(",
"\"path\"",
")",
")",
")",
";",
"$currentContext",
"=",
"$scope",
";",
"}"
] | Focus handler for the link in list item
@private | [
"Focus",
"handler",
"for",
"the",
"link",
"in",
"list",
"item"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NavigationAndHistory/main.js#L414-L421 |
2,146 | adobe/brackets | src/extensions/default/NavigationAndHistory/main.js | _onClick | function _onClick(event) {
var $scope = $(event.delegateTarget).parent();
_openEditorForContext({
path: $scope.data("path"),
paneId: $scope.data("paneId"),
cursor: $scope.data("cursor"),
hideOnOpenFile: true
});
} | javascript | function _onClick(event) {
var $scope = $(event.delegateTarget).parent();
_openEditorForContext({
path: $scope.data("path"),
paneId: $scope.data("paneId"),
cursor: $scope.data("cursor"),
hideOnOpenFile: true
});
} | [
"function",
"_onClick",
"(",
"event",
")",
"{",
"var",
"$scope",
"=",
"$",
"(",
"event",
".",
"delegateTarget",
")",
".",
"parent",
"(",
")",
";",
"_openEditorForContext",
"(",
"{",
"path",
":",
"$scope",
".",
"data",
"(",
"\"path\"",
")",
",",
"paneId",
":",
"$scope",
".",
"data",
"(",
"\"paneId\"",
")",
",",
"cursor",
":",
"$scope",
".",
"data",
"(",
"\"cursor\"",
")",
",",
"hideOnOpenFile",
":",
"true",
"}",
")",
";",
"}"
] | Click handler for the link in list item
@private | [
"Click",
"handler",
"for",
"the",
"link",
"in",
"list",
"item"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NavigationAndHistory/main.js#L427-L435 |
2,147 | adobe/brackets | src/extensions/default/NavigationAndHistory/main.js | _moveNext | function _moveNext() {
var $context, $next;
$context = $currentContext || $("#mrof-container #mrof-list > li.highlight");
if ($context.length > 0) {
$next = $context.next();
if ($next.length === 0) {
$next = $("#mrof-container #mrof-list > li").first();
}
if ($next.length > 0) {
$currentContext = $next;
$next.find("a.mroitem").trigger("focus");
}
} else {
//WTF! (Worse than failure). We should not get here.
$("#mrof-container #mrof-list > li > a.mroitem:visited").last().trigger("focus");
}
} | javascript | function _moveNext() {
var $context, $next;
$context = $currentContext || $("#mrof-container #mrof-list > li.highlight");
if ($context.length > 0) {
$next = $context.next();
if ($next.length === 0) {
$next = $("#mrof-container #mrof-list > li").first();
}
if ($next.length > 0) {
$currentContext = $next;
$next.find("a.mroitem").trigger("focus");
}
} else {
//WTF! (Worse than failure). We should not get here.
$("#mrof-container #mrof-list > li > a.mroitem:visited").last().trigger("focus");
}
} | [
"function",
"_moveNext",
"(",
")",
"{",
"var",
"$context",
",",
"$next",
";",
"$context",
"=",
"$currentContext",
"||",
"$",
"(",
"\"#mrof-container #mrof-list > li.highlight\"",
")",
";",
"if",
"(",
"$context",
".",
"length",
">",
"0",
")",
"{",
"$next",
"=",
"$context",
".",
"next",
"(",
")",
";",
"if",
"(",
"$next",
".",
"length",
"===",
"0",
")",
"{",
"$next",
"=",
"$",
"(",
"\"#mrof-container #mrof-list > li\"",
")",
".",
"first",
"(",
")",
";",
"}",
"if",
"(",
"$next",
".",
"length",
">",
"0",
")",
"{",
"$currentContext",
"=",
"$next",
";",
"$next",
".",
"find",
"(",
"\"a.mroitem\"",
")",
".",
"trigger",
"(",
"\"focus\"",
")",
";",
"}",
"}",
"else",
"{",
"//WTF! (Worse than failure). We should not get here.",
"$",
"(",
"\"#mrof-container #mrof-list > li > a.mroitem:visited\"",
")",
".",
"last",
"(",
")",
".",
"trigger",
"(",
"\"focus\"",
")",
";",
"}",
"}"
] | Opens the next item in MROF list if pop over is visible else displays the pop over
@private | [
"Opens",
"the",
"next",
"item",
"in",
"MROF",
"list",
"if",
"pop",
"over",
"is",
"visible",
"else",
"displays",
"the",
"pop",
"over"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NavigationAndHistory/main.js#L479-L496 |
2,148 | adobe/brackets | src/extensions/default/NavigationAndHistory/main.js | _movePrev | function _movePrev() {
var $context, $prev;
$context = $currentContext || $("#mrof-container #mrof-list > li.highlight");
if ($context.length > 0) {
$prev = $context.prev();
if ($prev.length === 0) {
$prev = $("#mrof-container #mrof-list > li").last();
}
if ($prev.length > 0) {
$currentContext = $prev;
$prev.find("a.mroitem").trigger("focus");
}
} else {
//WTF! (Worse than failure). We should not get here.
$("#mrof-container #mrof-list > li > a.mroitem:visited").last().trigger("focus");
}
} | javascript | function _movePrev() {
var $context, $prev;
$context = $currentContext || $("#mrof-container #mrof-list > li.highlight");
if ($context.length > 0) {
$prev = $context.prev();
if ($prev.length === 0) {
$prev = $("#mrof-container #mrof-list > li").last();
}
if ($prev.length > 0) {
$currentContext = $prev;
$prev.find("a.mroitem").trigger("focus");
}
} else {
//WTF! (Worse than failure). We should not get here.
$("#mrof-container #mrof-list > li > a.mroitem:visited").last().trigger("focus");
}
} | [
"function",
"_movePrev",
"(",
")",
"{",
"var",
"$context",
",",
"$prev",
";",
"$context",
"=",
"$currentContext",
"||",
"$",
"(",
"\"#mrof-container #mrof-list > li.highlight\"",
")",
";",
"if",
"(",
"$context",
".",
"length",
">",
"0",
")",
"{",
"$prev",
"=",
"$context",
".",
"prev",
"(",
")",
";",
"if",
"(",
"$prev",
".",
"length",
"===",
"0",
")",
"{",
"$prev",
"=",
"$",
"(",
"\"#mrof-container #mrof-list > li\"",
")",
".",
"last",
"(",
")",
";",
"}",
"if",
"(",
"$prev",
".",
"length",
">",
"0",
")",
"{",
"$currentContext",
"=",
"$prev",
";",
"$prev",
".",
"find",
"(",
"\"a.mroitem\"",
")",
".",
"trigger",
"(",
"\"focus\"",
")",
";",
"}",
"}",
"else",
"{",
"//WTF! (Worse than failure). We should not get here.",
"$",
"(",
"\"#mrof-container #mrof-list > li > a.mroitem:visited\"",
")",
".",
"last",
"(",
")",
".",
"trigger",
"(",
"\"focus\"",
")",
";",
"}",
"}"
] | Opens the previous item in MROF list if pop over is visible else displays the pop over
@private | [
"Opens",
"the",
"previous",
"item",
"in",
"MROF",
"list",
"if",
"pop",
"over",
"is",
"visible",
"else",
"displays",
"the",
"pop",
"over"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NavigationAndHistory/main.js#L519-L536 |
2,149 | adobe/brackets | src/extensions/default/NavigationAndHistory/main.js | _addToMROFList | function _addToMROFList(file, paneId, cursorPos) {
var filePath = file.fullPath;
if (!paneId) { // Don't handle this if not a full view/editor
return;
}
// Check existing list for this doc path and pane entry
var index = _.findIndex(_mrofList, function (record) {
return (record && record.file === filePath && record.paneId === paneId);
});
var entry;
if (index !== -1) {
entry = _mrofList[index];
if (entry.cursor && !cursorPos) {
cursorPos = entry.cursor;
}
}
entry = _makeMROFListEntry(filePath, paneId, cursorPos);
// Check if the file is an InMemoryFile
if (file.constructor.name === "InMemoryFile") {
// Mark the entry as inMem, so that we can knock it off from the list when removed from working set
entry.inMem = true;
}
if (index !== -1) {
_mrofList.splice(index, 1);
}
// add it to the front of the list
_mrofList.unshift(entry);
PreferencesManager.setViewState(OPEN_FILES_VIEW_STATE, _mrofList, _getPrefsContext(), true);
} | javascript | function _addToMROFList(file, paneId, cursorPos) {
var filePath = file.fullPath;
if (!paneId) { // Don't handle this if not a full view/editor
return;
}
// Check existing list for this doc path and pane entry
var index = _.findIndex(_mrofList, function (record) {
return (record && record.file === filePath && record.paneId === paneId);
});
var entry;
if (index !== -1) {
entry = _mrofList[index];
if (entry.cursor && !cursorPos) {
cursorPos = entry.cursor;
}
}
entry = _makeMROFListEntry(filePath, paneId, cursorPos);
// Check if the file is an InMemoryFile
if (file.constructor.name === "InMemoryFile") {
// Mark the entry as inMem, so that we can knock it off from the list when removed from working set
entry.inMem = true;
}
if (index !== -1) {
_mrofList.splice(index, 1);
}
// add it to the front of the list
_mrofList.unshift(entry);
PreferencesManager.setViewState(OPEN_FILES_VIEW_STATE, _mrofList, _getPrefsContext(), true);
} | [
"function",
"_addToMROFList",
"(",
"file",
",",
"paneId",
",",
"cursorPos",
")",
"{",
"var",
"filePath",
"=",
"file",
".",
"fullPath",
";",
"if",
"(",
"!",
"paneId",
")",
"{",
"// Don't handle this if not a full view/editor",
"return",
";",
"}",
"// Check existing list for this doc path and pane entry",
"var",
"index",
"=",
"_",
".",
"findIndex",
"(",
"_mrofList",
",",
"function",
"(",
"record",
")",
"{",
"return",
"(",
"record",
"&&",
"record",
".",
"file",
"===",
"filePath",
"&&",
"record",
".",
"paneId",
"===",
"paneId",
")",
";",
"}",
")",
";",
"var",
"entry",
";",
"if",
"(",
"index",
"!==",
"-",
"1",
")",
"{",
"entry",
"=",
"_mrofList",
"[",
"index",
"]",
";",
"if",
"(",
"entry",
".",
"cursor",
"&&",
"!",
"cursorPos",
")",
"{",
"cursorPos",
"=",
"entry",
".",
"cursor",
";",
"}",
"}",
"entry",
"=",
"_makeMROFListEntry",
"(",
"filePath",
",",
"paneId",
",",
"cursorPos",
")",
";",
"// Check if the file is an InMemoryFile",
"if",
"(",
"file",
".",
"constructor",
".",
"name",
"===",
"\"InMemoryFile\"",
")",
"{",
"// Mark the entry as inMem, so that we can knock it off from the list when removed from working set",
"entry",
".",
"inMem",
"=",
"true",
";",
"}",
"if",
"(",
"index",
"!==",
"-",
"1",
")",
"{",
"_mrofList",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"}",
"// add it to the front of the list",
"_mrofList",
".",
"unshift",
"(",
"entry",
")",
";",
"PreferencesManager",
".",
"setViewState",
"(",
"OPEN_FILES_VIEW_STATE",
",",
"_mrofList",
",",
"_getPrefsContext",
"(",
")",
",",
"true",
")",
";",
"}"
] | Adds an entry to MROF list
@private
@param {Editor} editor - editor to extract file information | [
"Adds",
"an",
"entry",
"to",
"MROF",
"list"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NavigationAndHistory/main.js#L579-L618 |
2,150 | adobe/brackets | src/extensions/default/NavigationAndHistory/main.js | _handleWorkingSetMove | function _handleWorkingSetMove(event, file, sourcePaneId, destinationPaneId) {
// Check existing list for this doc path and source pane entry
var index = _.findIndex(_mrofList, function (record) {
return (record && record.file === file.fullPath && record.paneId === sourcePaneId);
}), tIndex;
// If an entry is found update the pane info
if (index >= 0) {
// But an entry with the target pane Id should not exist
tIndex = _.findIndex(_mrofList, function (record) {
return (record && record.file === file.fullPath && record.paneId === destinationPaneId);
});
if (tIndex === -1) {
_mrofList[index].paneId = destinationPaneId;
} else {
// Remove this entry as it has been moved.
_mrofList.splice(index, 1);
}
}
} | javascript | function _handleWorkingSetMove(event, file, sourcePaneId, destinationPaneId) {
// Check existing list for this doc path and source pane entry
var index = _.findIndex(_mrofList, function (record) {
return (record && record.file === file.fullPath && record.paneId === sourcePaneId);
}), tIndex;
// If an entry is found update the pane info
if (index >= 0) {
// But an entry with the target pane Id should not exist
tIndex = _.findIndex(_mrofList, function (record) {
return (record && record.file === file.fullPath && record.paneId === destinationPaneId);
});
if (tIndex === -1) {
_mrofList[index].paneId = destinationPaneId;
} else {
// Remove this entry as it has been moved.
_mrofList.splice(index, 1);
}
}
} | [
"function",
"_handleWorkingSetMove",
"(",
"event",
",",
"file",
",",
"sourcePaneId",
",",
"destinationPaneId",
")",
"{",
"// Check existing list for this doc path and source pane entry",
"var",
"index",
"=",
"_",
".",
"findIndex",
"(",
"_mrofList",
",",
"function",
"(",
"record",
")",
"{",
"return",
"(",
"record",
"&&",
"record",
".",
"file",
"===",
"file",
".",
"fullPath",
"&&",
"record",
".",
"paneId",
"===",
"sourcePaneId",
")",
";",
"}",
")",
",",
"tIndex",
";",
"// If an entry is found update the pane info",
"if",
"(",
"index",
">=",
"0",
")",
"{",
"// But an entry with the target pane Id should not exist",
"tIndex",
"=",
"_",
".",
"findIndex",
"(",
"_mrofList",
",",
"function",
"(",
"record",
")",
"{",
"return",
"(",
"record",
"&&",
"record",
".",
"file",
"===",
"file",
".",
"fullPath",
"&&",
"record",
".",
"paneId",
"===",
"destinationPaneId",
")",
";",
"}",
")",
";",
"if",
"(",
"tIndex",
"===",
"-",
"1",
")",
"{",
"_mrofList",
"[",
"index",
"]",
".",
"paneId",
"=",
"destinationPaneId",
";",
"}",
"else",
"{",
"// Remove this entry as it has been moved.",
"_mrofList",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"}",
"}",
"}"
] | To update existing entry if a move has happened | [
"To",
"update",
"existing",
"entry",
"if",
"a",
"move",
"has",
"happened"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NavigationAndHistory/main.js#L621-L639 |
2,151 | adobe/brackets | src/extensions/default/NavigationAndHistory/main.js | _handlePaneMerge | function _handlePaneMerge(e, paneId) {
var index;
var targetPaneId = MainViewManager.FIRST_PANE;
$.each(_mrofList, function (itrIndex, value) {
if (value && value.paneId === paneId) { // We have got an entry which needs merge
// Before modifying the actual pane info check if an entry exists with same target pane
index = _.findIndex(_mrofList, function (record) {
return (record && record.file === value.file && record.paneId === targetPaneId);
});
if (index !== -1) { // A duplicate entry found, remove the current one instead of updating
_mrofList[index] = null;
} else { // Update with merged pane info
_mrofList[itrIndex].paneId = targetPaneId;
}
}
});
// Clean the null/undefined entries
_mrofList = _mrofList.filter(function (e) {return e; });
PreferencesManager.setViewState(OPEN_FILES_VIEW_STATE, _mrofList, _getPrefsContext(), true);
} | javascript | function _handlePaneMerge(e, paneId) {
var index;
var targetPaneId = MainViewManager.FIRST_PANE;
$.each(_mrofList, function (itrIndex, value) {
if (value && value.paneId === paneId) { // We have got an entry which needs merge
// Before modifying the actual pane info check if an entry exists with same target pane
index = _.findIndex(_mrofList, function (record) {
return (record && record.file === value.file && record.paneId === targetPaneId);
});
if (index !== -1) { // A duplicate entry found, remove the current one instead of updating
_mrofList[index] = null;
} else { // Update with merged pane info
_mrofList[itrIndex].paneId = targetPaneId;
}
}
});
// Clean the null/undefined entries
_mrofList = _mrofList.filter(function (e) {return e; });
PreferencesManager.setViewState(OPEN_FILES_VIEW_STATE, _mrofList, _getPrefsContext(), true);
} | [
"function",
"_handlePaneMerge",
"(",
"e",
",",
"paneId",
")",
"{",
"var",
"index",
";",
"var",
"targetPaneId",
"=",
"MainViewManager",
".",
"FIRST_PANE",
";",
"$",
".",
"each",
"(",
"_mrofList",
",",
"function",
"(",
"itrIndex",
",",
"value",
")",
"{",
"if",
"(",
"value",
"&&",
"value",
".",
"paneId",
"===",
"paneId",
")",
"{",
"// We have got an entry which needs merge",
"// Before modifying the actual pane info check if an entry exists with same target pane",
"index",
"=",
"_",
".",
"findIndex",
"(",
"_mrofList",
",",
"function",
"(",
"record",
")",
"{",
"return",
"(",
"record",
"&&",
"record",
".",
"file",
"===",
"value",
".",
"file",
"&&",
"record",
".",
"paneId",
"===",
"targetPaneId",
")",
";",
"}",
")",
";",
"if",
"(",
"index",
"!==",
"-",
"1",
")",
"{",
"// A duplicate entry found, remove the current one instead of updating",
"_mrofList",
"[",
"index",
"]",
"=",
"null",
";",
"}",
"else",
"{",
"// Update with merged pane info",
"_mrofList",
"[",
"itrIndex",
"]",
".",
"paneId",
"=",
"targetPaneId",
";",
"}",
"}",
"}",
")",
";",
"// Clean the null/undefined entries",
"_mrofList",
"=",
"_mrofList",
".",
"filter",
"(",
"function",
"(",
"e",
")",
"{",
"return",
"e",
";",
"}",
")",
";",
"PreferencesManager",
".",
"setViewState",
"(",
"OPEN_FILES_VIEW_STATE",
",",
"_mrofList",
",",
"_getPrefsContext",
"(",
")",
",",
"true",
")",
";",
"}"
] | Merges the entries to a single pane if split view have been merged Then purges duplicate entries in mrof list | [
"Merges",
"the",
"entries",
"to",
"a",
"single",
"pane",
"if",
"split",
"view",
"have",
"been",
"merged",
"Then",
"purges",
"duplicate",
"entries",
"in",
"mrof",
"list"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NavigationAndHistory/main.js#L701-L723 |
2,152 | adobe/brackets | src/extensions/default/NavigationAndHistory/main.js | handleCurrentFileChange | function handleCurrentFileChange(e, newFile, newPaneId, oldFile) {
if (newFile) {
if (_mrofList.length === 0) {
_initRecentFilesList();
}
_addToMROFList(newFile, newPaneId);
}
} | javascript | function handleCurrentFileChange(e, newFile, newPaneId, oldFile) {
if (newFile) {
if (_mrofList.length === 0) {
_initRecentFilesList();
}
_addToMROFList(newFile, newPaneId);
}
} | [
"function",
"handleCurrentFileChange",
"(",
"e",
",",
"newFile",
",",
"newPaneId",
",",
"oldFile",
")",
"{",
"if",
"(",
"newFile",
")",
"{",
"if",
"(",
"_mrofList",
".",
"length",
"===",
"0",
")",
"{",
"_initRecentFilesList",
"(",
")",
";",
"}",
"_addToMROFList",
"(",
"newFile",
",",
"newPaneId",
")",
";",
"}",
"}"
] | Handle current file change | [
"Handle",
"current",
"file",
"change"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NavigationAndHistory/main.js#L771-L779 |
2,153 | adobe/brackets | src/extensions/default/NavigationAndHistory/main.js | _handleActiveEditorChange | function _handleActiveEditorChange(event, current, previous) {
if (current) { // Handle only full editors
if (_mrofList.length === 0) {
_initRecentFilesList();
}
var file = current.document.file;
var paneId = current._paneId;
_addToMROFList(file, paneId, current.getCursorPos(true, "first"));
}
if (previous) { // Capture the last know cursor position
_updateCursorPosition(previous.document.file.fullPath, previous._paneId, previous.getCursorPos(true, "first"));
}
} | javascript | function _handleActiveEditorChange(event, current, previous) {
if (current) { // Handle only full editors
if (_mrofList.length === 0) {
_initRecentFilesList();
}
var file = current.document.file;
var paneId = current._paneId;
_addToMROFList(file, paneId, current.getCursorPos(true, "first"));
}
if (previous) { // Capture the last know cursor position
_updateCursorPosition(previous.document.file.fullPath, previous._paneId, previous.getCursorPos(true, "first"));
}
} | [
"function",
"_handleActiveEditorChange",
"(",
"event",
",",
"current",
",",
"previous",
")",
"{",
"if",
"(",
"current",
")",
"{",
"// Handle only full editors",
"if",
"(",
"_mrofList",
".",
"length",
"===",
"0",
")",
"{",
"_initRecentFilesList",
"(",
")",
";",
"}",
"var",
"file",
"=",
"current",
".",
"document",
".",
"file",
";",
"var",
"paneId",
"=",
"current",
".",
"_paneId",
";",
"_addToMROFList",
"(",
"file",
",",
"paneId",
",",
"current",
".",
"getCursorPos",
"(",
"true",
",",
"\"first\"",
")",
")",
";",
"}",
"if",
"(",
"previous",
")",
"{",
"// Capture the last know cursor position",
"_updateCursorPosition",
"(",
"previous",
".",
"document",
".",
"file",
".",
"fullPath",
",",
"previous",
".",
"_paneId",
",",
"previous",
".",
"getCursorPos",
"(",
"true",
",",
"\"first\"",
")",
")",
";",
"}",
"}"
] | Handle Active Editor change to update mrof information | [
"Handle",
"Active",
"Editor",
"change",
"to",
"update",
"mrof",
"information"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NavigationAndHistory/main.js#L782-L796 |
2,154 | adobe/brackets | src/extensions/default/JavaScriptRefactoring/ExtractToFunction.js | handleExtractToFunction | function handleExtractToFunction() {
var editor = EditorManager.getActiveEditor();
var result = new $.Deferred(); // used only for testing purpose
if (editor.getSelections().length > 1) {
editor.displayErrorMessageAtCursor(Strings.ERROR_EXTRACTTO_FUNCTION_MULTICURSORS);
result.resolve(Strings.ERROR_EXTRACTTO_FUNCTION_MULTICURSORS);
return;
}
initializeSession(editor);
var selection = editor.getSelection(),
doc = editor.document,
retObj = RefactoringUtils.normalizeText(editor.getSelectedText(), editor.indexFromPos(selection.start), editor.indexFromPos(selection.end)),
text = retObj.text,
start = retObj.start,
end = retObj.end,
ast,
scopes,
expns,
inlineMenu;
RefactoringUtils.getScopeData(session, editor.posFromIndex(start)).done(function(scope) {
ast = RefactoringUtils.getAST(doc.getText());
var isExpression = false;
if (!RefactoringUtils.checkStatement(ast, start, end, doc.getText())) {
isExpression = RefactoringUtils.getExpression(ast, start, end, doc.getText());
if (!isExpression) {
editor.displayErrorMessageAtCursor(Strings.ERROR_EXTRACTTO_FUNCTION_NOT_VALID);
result.resolve(Strings.ERROR_EXTRACTTO_FUNCTION_NOT_VALID);
return;
}
}
scopes = RefactoringUtils.getAllScopes(ast, scope, doc.getText());
// if only one scope, extract without menu
if (scopes.length === 1) {
extract(ast, text, scopes, scopes[0], scopes[0], start, end, isExpression);
result.resolve();
return;
}
inlineMenu = new InlineMenu(editor, Strings.EXTRACTTO_FUNCTION_SELECT_SCOPE);
inlineMenu.open(scopes.filter(RefactoringUtils.isFnScope));
result.resolve(inlineMenu);
inlineMenu.onSelect(function (scopeId) {
extract(ast, text, scopes, scopes[0], scopes[scopeId], start, end, isExpression);
inlineMenu.close();
});
inlineMenu.onClose(function(){
inlineMenu.close();
});
}).fail(function() {
editor.displayErrorMessageAtCursor(Strings.ERROR_TERN_FAILED);
result.resolve(Strings.ERROR_TERN_FAILED);
});
return result.promise();
} | javascript | function handleExtractToFunction() {
var editor = EditorManager.getActiveEditor();
var result = new $.Deferred(); // used only for testing purpose
if (editor.getSelections().length > 1) {
editor.displayErrorMessageAtCursor(Strings.ERROR_EXTRACTTO_FUNCTION_MULTICURSORS);
result.resolve(Strings.ERROR_EXTRACTTO_FUNCTION_MULTICURSORS);
return;
}
initializeSession(editor);
var selection = editor.getSelection(),
doc = editor.document,
retObj = RefactoringUtils.normalizeText(editor.getSelectedText(), editor.indexFromPos(selection.start), editor.indexFromPos(selection.end)),
text = retObj.text,
start = retObj.start,
end = retObj.end,
ast,
scopes,
expns,
inlineMenu;
RefactoringUtils.getScopeData(session, editor.posFromIndex(start)).done(function(scope) {
ast = RefactoringUtils.getAST(doc.getText());
var isExpression = false;
if (!RefactoringUtils.checkStatement(ast, start, end, doc.getText())) {
isExpression = RefactoringUtils.getExpression(ast, start, end, doc.getText());
if (!isExpression) {
editor.displayErrorMessageAtCursor(Strings.ERROR_EXTRACTTO_FUNCTION_NOT_VALID);
result.resolve(Strings.ERROR_EXTRACTTO_FUNCTION_NOT_VALID);
return;
}
}
scopes = RefactoringUtils.getAllScopes(ast, scope, doc.getText());
// if only one scope, extract without menu
if (scopes.length === 1) {
extract(ast, text, scopes, scopes[0], scopes[0], start, end, isExpression);
result.resolve();
return;
}
inlineMenu = new InlineMenu(editor, Strings.EXTRACTTO_FUNCTION_SELECT_SCOPE);
inlineMenu.open(scopes.filter(RefactoringUtils.isFnScope));
result.resolve(inlineMenu);
inlineMenu.onSelect(function (scopeId) {
extract(ast, text, scopes, scopes[0], scopes[scopeId], start, end, isExpression);
inlineMenu.close();
});
inlineMenu.onClose(function(){
inlineMenu.close();
});
}).fail(function() {
editor.displayErrorMessageAtCursor(Strings.ERROR_TERN_FAILED);
result.resolve(Strings.ERROR_TERN_FAILED);
});
return result.promise();
} | [
"function",
"handleExtractToFunction",
"(",
")",
"{",
"var",
"editor",
"=",
"EditorManager",
".",
"getActiveEditor",
"(",
")",
";",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"// used only for testing purpose",
"if",
"(",
"editor",
".",
"getSelections",
"(",
")",
".",
"length",
">",
"1",
")",
"{",
"editor",
".",
"displayErrorMessageAtCursor",
"(",
"Strings",
".",
"ERROR_EXTRACTTO_FUNCTION_MULTICURSORS",
")",
";",
"result",
".",
"resolve",
"(",
"Strings",
".",
"ERROR_EXTRACTTO_FUNCTION_MULTICURSORS",
")",
";",
"return",
";",
"}",
"initializeSession",
"(",
"editor",
")",
";",
"var",
"selection",
"=",
"editor",
".",
"getSelection",
"(",
")",
",",
"doc",
"=",
"editor",
".",
"document",
",",
"retObj",
"=",
"RefactoringUtils",
".",
"normalizeText",
"(",
"editor",
".",
"getSelectedText",
"(",
")",
",",
"editor",
".",
"indexFromPos",
"(",
"selection",
".",
"start",
")",
",",
"editor",
".",
"indexFromPos",
"(",
"selection",
".",
"end",
")",
")",
",",
"text",
"=",
"retObj",
".",
"text",
",",
"start",
"=",
"retObj",
".",
"start",
",",
"end",
"=",
"retObj",
".",
"end",
",",
"ast",
",",
"scopes",
",",
"expns",
",",
"inlineMenu",
";",
"RefactoringUtils",
".",
"getScopeData",
"(",
"session",
",",
"editor",
".",
"posFromIndex",
"(",
"start",
")",
")",
".",
"done",
"(",
"function",
"(",
"scope",
")",
"{",
"ast",
"=",
"RefactoringUtils",
".",
"getAST",
"(",
"doc",
".",
"getText",
"(",
")",
")",
";",
"var",
"isExpression",
"=",
"false",
";",
"if",
"(",
"!",
"RefactoringUtils",
".",
"checkStatement",
"(",
"ast",
",",
"start",
",",
"end",
",",
"doc",
".",
"getText",
"(",
")",
")",
")",
"{",
"isExpression",
"=",
"RefactoringUtils",
".",
"getExpression",
"(",
"ast",
",",
"start",
",",
"end",
",",
"doc",
".",
"getText",
"(",
")",
")",
";",
"if",
"(",
"!",
"isExpression",
")",
"{",
"editor",
".",
"displayErrorMessageAtCursor",
"(",
"Strings",
".",
"ERROR_EXTRACTTO_FUNCTION_NOT_VALID",
")",
";",
"result",
".",
"resolve",
"(",
"Strings",
".",
"ERROR_EXTRACTTO_FUNCTION_NOT_VALID",
")",
";",
"return",
";",
"}",
"}",
"scopes",
"=",
"RefactoringUtils",
".",
"getAllScopes",
"(",
"ast",
",",
"scope",
",",
"doc",
".",
"getText",
"(",
")",
")",
";",
"// if only one scope, extract without menu",
"if",
"(",
"scopes",
".",
"length",
"===",
"1",
")",
"{",
"extract",
"(",
"ast",
",",
"text",
",",
"scopes",
",",
"scopes",
"[",
"0",
"]",
",",
"scopes",
"[",
"0",
"]",
",",
"start",
",",
"end",
",",
"isExpression",
")",
";",
"result",
".",
"resolve",
"(",
")",
";",
"return",
";",
"}",
"inlineMenu",
"=",
"new",
"InlineMenu",
"(",
"editor",
",",
"Strings",
".",
"EXTRACTTO_FUNCTION_SELECT_SCOPE",
")",
";",
"inlineMenu",
".",
"open",
"(",
"scopes",
".",
"filter",
"(",
"RefactoringUtils",
".",
"isFnScope",
")",
")",
";",
"result",
".",
"resolve",
"(",
"inlineMenu",
")",
";",
"inlineMenu",
".",
"onSelect",
"(",
"function",
"(",
"scopeId",
")",
"{",
"extract",
"(",
"ast",
",",
"text",
",",
"scopes",
",",
"scopes",
"[",
"0",
"]",
",",
"scopes",
"[",
"scopeId",
"]",
",",
"start",
",",
"end",
",",
"isExpression",
")",
";",
"inlineMenu",
".",
"close",
"(",
")",
";",
"}",
")",
";",
"inlineMenu",
".",
"onClose",
"(",
"function",
"(",
")",
"{",
"inlineMenu",
".",
"close",
"(",
")",
";",
"}",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"editor",
".",
"displayErrorMessageAtCursor",
"(",
"Strings",
".",
"ERROR_TERN_FAILED",
")",
";",
"result",
".",
"resolve",
"(",
"Strings",
".",
"ERROR_TERN_FAILED",
")",
";",
"}",
")",
";",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] | Main function that handles extract to function | [
"Main",
"function",
"that",
"handles",
"extract",
"to",
"function"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptRefactoring/ExtractToFunction.js#L265-L328 |
2,155 | adobe/brackets | src/JSUtils/ScopeManager.js | initTernEnv | function initTernEnv() {
var path = [_absoluteModulePath, "node/node_modules/tern/defs/"].join("/"),
files = builtinFiles,
library;
files.forEach(function (i) {
FileSystem.resolve(path + i, function (err, file) {
if (!err) {
FileUtils.readAsText(file).done(function (text) {
library = JSON.parse(text);
builtinLibraryNames.push(library["!name"]);
ternEnvironment.push(library);
}).fail(function (error) {
console.log("failed to read tern config file " + i);
});
} else {
console.log("failed to read tern config file " + i);
}
});
});
} | javascript | function initTernEnv() {
var path = [_absoluteModulePath, "node/node_modules/tern/defs/"].join("/"),
files = builtinFiles,
library;
files.forEach(function (i) {
FileSystem.resolve(path + i, function (err, file) {
if (!err) {
FileUtils.readAsText(file).done(function (text) {
library = JSON.parse(text);
builtinLibraryNames.push(library["!name"]);
ternEnvironment.push(library);
}).fail(function (error) {
console.log("failed to read tern config file " + i);
});
} else {
console.log("failed to read tern config file " + i);
}
});
});
} | [
"function",
"initTernEnv",
"(",
")",
"{",
"var",
"path",
"=",
"[",
"_absoluteModulePath",
",",
"\"node/node_modules/tern/defs/\"",
"]",
".",
"join",
"(",
"\"/\"",
")",
",",
"files",
"=",
"builtinFiles",
",",
"library",
";",
"files",
".",
"forEach",
"(",
"function",
"(",
"i",
")",
"{",
"FileSystem",
".",
"resolve",
"(",
"path",
"+",
"i",
",",
"function",
"(",
"err",
",",
"file",
")",
"{",
"if",
"(",
"!",
"err",
")",
"{",
"FileUtils",
".",
"readAsText",
"(",
"file",
")",
".",
"done",
"(",
"function",
"(",
"text",
")",
"{",
"library",
"=",
"JSON",
".",
"parse",
"(",
"text",
")",
";",
"builtinLibraryNames",
".",
"push",
"(",
"library",
"[",
"\"!name\"",
"]",
")",
";",
"ternEnvironment",
".",
"push",
"(",
"library",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"error",
")",
"{",
"console",
".",
"log",
"(",
"\"failed to read tern config file \"",
"+",
"i",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"\"failed to read tern config file \"",
"+",
"i",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}"
] | Read in the json files that have type information for the builtins, dom,etc | [
"Read",
"in",
"the",
"json",
"files",
"that",
"have",
"type",
"information",
"for",
"the",
"builtins",
"dom",
"etc"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L93-L113 |
2,156 | adobe/brackets | src/JSUtils/ScopeManager.js | initPreferences | function initPreferences(projectRootPath) {
// Reject the old preferences if they have not completed.
if (deferredPreferences && deferredPreferences.state() === "pending") {
deferredPreferences.reject();
}
deferredPreferences = $.Deferred();
var pr = ProjectManager.getProjectRoot();
// Open preferences relative to the project root
// Normally there is a project root, but for unit tests we need to
// pass in a project root.
if (pr) {
projectRootPath = pr.fullPath;
} else if (!projectRootPath) {
console.log("initPreferences: projectRootPath has no value");
}
var path = projectRootPath + Preferences.FILE_NAME;
FileSystem.resolve(path, function (err, file) {
if (!err) {
FileUtils.readAsText(file).done(function (text) {
var configObj = null;
try {
configObj = JSON.parse(text);
} catch (e) {
// continue with null configObj which will result in
// default settings.
console.log("Error parsing preference file: " + path);
if (e instanceof SyntaxError) {
console.log(e.message);
}
}
preferences = new Preferences(configObj);
deferredPreferences.resolve();
}).fail(function (error) {
preferences = new Preferences();
deferredPreferences.resolve();
});
} else {
preferences = new Preferences();
deferredPreferences.resolve();
}
});
} | javascript | function initPreferences(projectRootPath) {
// Reject the old preferences if they have not completed.
if (deferredPreferences && deferredPreferences.state() === "pending") {
deferredPreferences.reject();
}
deferredPreferences = $.Deferred();
var pr = ProjectManager.getProjectRoot();
// Open preferences relative to the project root
// Normally there is a project root, but for unit tests we need to
// pass in a project root.
if (pr) {
projectRootPath = pr.fullPath;
} else if (!projectRootPath) {
console.log("initPreferences: projectRootPath has no value");
}
var path = projectRootPath + Preferences.FILE_NAME;
FileSystem.resolve(path, function (err, file) {
if (!err) {
FileUtils.readAsText(file).done(function (text) {
var configObj = null;
try {
configObj = JSON.parse(text);
} catch (e) {
// continue with null configObj which will result in
// default settings.
console.log("Error parsing preference file: " + path);
if (e instanceof SyntaxError) {
console.log(e.message);
}
}
preferences = new Preferences(configObj);
deferredPreferences.resolve();
}).fail(function (error) {
preferences = new Preferences();
deferredPreferences.resolve();
});
} else {
preferences = new Preferences();
deferredPreferences.resolve();
}
});
} | [
"function",
"initPreferences",
"(",
"projectRootPath",
")",
"{",
"// Reject the old preferences if they have not completed.",
"if",
"(",
"deferredPreferences",
"&&",
"deferredPreferences",
".",
"state",
"(",
")",
"===",
"\"pending\"",
")",
"{",
"deferredPreferences",
".",
"reject",
"(",
")",
";",
"}",
"deferredPreferences",
"=",
"$",
".",
"Deferred",
"(",
")",
";",
"var",
"pr",
"=",
"ProjectManager",
".",
"getProjectRoot",
"(",
")",
";",
"// Open preferences relative to the project root",
"// Normally there is a project root, but for unit tests we need to",
"// pass in a project root.",
"if",
"(",
"pr",
")",
"{",
"projectRootPath",
"=",
"pr",
".",
"fullPath",
";",
"}",
"else",
"if",
"(",
"!",
"projectRootPath",
")",
"{",
"console",
".",
"log",
"(",
"\"initPreferences: projectRootPath has no value\"",
")",
";",
"}",
"var",
"path",
"=",
"projectRootPath",
"+",
"Preferences",
".",
"FILE_NAME",
";",
"FileSystem",
".",
"resolve",
"(",
"path",
",",
"function",
"(",
"err",
",",
"file",
")",
"{",
"if",
"(",
"!",
"err",
")",
"{",
"FileUtils",
".",
"readAsText",
"(",
"file",
")",
".",
"done",
"(",
"function",
"(",
"text",
")",
"{",
"var",
"configObj",
"=",
"null",
";",
"try",
"{",
"configObj",
"=",
"JSON",
".",
"parse",
"(",
"text",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"// continue with null configObj which will result in",
"// default settings.",
"console",
".",
"log",
"(",
"\"Error parsing preference file: \"",
"+",
"path",
")",
";",
"if",
"(",
"e",
"instanceof",
"SyntaxError",
")",
"{",
"console",
".",
"log",
"(",
"e",
".",
"message",
")",
";",
"}",
"}",
"preferences",
"=",
"new",
"Preferences",
"(",
"configObj",
")",
";",
"deferredPreferences",
".",
"resolve",
"(",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"error",
")",
"{",
"preferences",
"=",
"new",
"Preferences",
"(",
")",
";",
"deferredPreferences",
".",
"resolve",
"(",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"preferences",
"=",
"new",
"Preferences",
"(",
")",
";",
"deferredPreferences",
".",
"resolve",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Init preferences from a file in the project root or builtin
defaults if no file is found;
@param {string=} projectRootPath - new project root path. Only needed
for unit tests. | [
"Init",
"preferences",
"from",
"a",
"file",
"in",
"the",
"project",
"root",
"or",
"builtin",
"defaults",
"if",
"no",
"file",
"is",
"found",
";"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L124-L170 |
2,157 | adobe/brackets | src/JSUtils/ScopeManager.js | isDirectoryExcluded | function isDirectoryExcluded(path) {
var excludes = preferences.getExcludedDirectories();
if (!excludes) {
return false;
}
var testPath = ProjectManager.makeProjectRelativeIfPossible(path);
testPath = FileUtils.stripTrailingSlash(testPath);
return excludes.test(testPath);
} | javascript | function isDirectoryExcluded(path) {
var excludes = preferences.getExcludedDirectories();
if (!excludes) {
return false;
}
var testPath = ProjectManager.makeProjectRelativeIfPossible(path);
testPath = FileUtils.stripTrailingSlash(testPath);
return excludes.test(testPath);
} | [
"function",
"isDirectoryExcluded",
"(",
"path",
")",
"{",
"var",
"excludes",
"=",
"preferences",
".",
"getExcludedDirectories",
"(",
")",
";",
"if",
"(",
"!",
"excludes",
")",
"{",
"return",
"false",
";",
"}",
"var",
"testPath",
"=",
"ProjectManager",
".",
"makeProjectRelativeIfPossible",
"(",
"path",
")",
";",
"testPath",
"=",
"FileUtils",
".",
"stripTrailingSlash",
"(",
"testPath",
")",
";",
"return",
"excludes",
".",
"test",
"(",
"testPath",
")",
";",
"}"
] | Test if the directory should be excluded from analysis.
@param {!string} path - full directory path.
@return {boolean} true if excluded, false otherwise. | [
"Test",
"if",
"the",
"directory",
"should",
"be",
"excluded",
"from",
"analysis",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L198-L209 |
2,158 | adobe/brackets | src/JSUtils/ScopeManager.js | isFileBeingEdited | function isFileBeingEdited(filePath) {
var currentEditor = EditorManager.getActiveEditor(),
currentDoc = currentEditor && currentEditor.document;
return (currentDoc && currentDoc.file.fullPath === filePath);
} | javascript | function isFileBeingEdited(filePath) {
var currentEditor = EditorManager.getActiveEditor(),
currentDoc = currentEditor && currentEditor.document;
return (currentDoc && currentDoc.file.fullPath === filePath);
} | [
"function",
"isFileBeingEdited",
"(",
"filePath",
")",
"{",
"var",
"currentEditor",
"=",
"EditorManager",
".",
"getActiveEditor",
"(",
")",
",",
"currentDoc",
"=",
"currentEditor",
"&&",
"currentEditor",
".",
"document",
";",
"return",
"(",
"currentDoc",
"&&",
"currentDoc",
".",
"file",
".",
"fullPath",
"===",
"filePath",
")",
";",
"}"
] | Test if the file path is in current editor
@param {string} filePath file path to test for exclusion.
@return {boolean} true if in editor, false otherwise. | [
"Test",
"if",
"the",
"file",
"path",
"is",
"in",
"current",
"editor"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L217-L222 |
2,159 | adobe/brackets | src/JSUtils/ScopeManager.js | isFileExcludedInternal | function isFileExcludedInternal(path) {
// The detectedExclusions are files detected to be troublesome with current versions of Tern.
// detectedExclusions is an array of full paths.
var detectedExclusions = PreferencesManager.get("jscodehints.detectedExclusions") || [];
if (detectedExclusions && detectedExclusions.indexOf(path) !== -1) {
return true;
}
return false;
} | javascript | function isFileExcludedInternal(path) {
// The detectedExclusions are files detected to be troublesome with current versions of Tern.
// detectedExclusions is an array of full paths.
var detectedExclusions = PreferencesManager.get("jscodehints.detectedExclusions") || [];
if (detectedExclusions && detectedExclusions.indexOf(path) !== -1) {
return true;
}
return false;
} | [
"function",
"isFileExcludedInternal",
"(",
"path",
")",
"{",
"// The detectedExclusions are files detected to be troublesome with current versions of Tern.",
"// detectedExclusions is an array of full paths.",
"var",
"detectedExclusions",
"=",
"PreferencesManager",
".",
"get",
"(",
"\"jscodehints.detectedExclusions\"",
")",
"||",
"[",
"]",
";",
"if",
"(",
"detectedExclusions",
"&&",
"detectedExclusions",
".",
"indexOf",
"(",
"path",
")",
"!==",
"-",
"1",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Test if the file path is an internal exclusion.
@param {string} path file path to test for exclusion.
@return {boolean} true if excluded, false otherwise. | [
"Test",
"if",
"the",
"file",
"path",
"is",
"an",
"internal",
"exclusion",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L230-L239 |
2,160 | adobe/brackets | src/JSUtils/ScopeManager.js | isFileExcluded | function isFileExcluded(file) {
if (file.name[0] === ".") {
return true;
}
var languageID = LanguageManager.getLanguageForPath(file.fullPath).getId();
if (languageID !== HintUtils.LANGUAGE_ID) {
return true;
}
var excludes = preferences.getExcludedFiles();
if (excludes && excludes.test(file.name)) {
return true;
}
if (isFileExcludedInternal(file.fullPath)) {
return true;
}
return false;
} | javascript | function isFileExcluded(file) {
if (file.name[0] === ".") {
return true;
}
var languageID = LanguageManager.getLanguageForPath(file.fullPath).getId();
if (languageID !== HintUtils.LANGUAGE_ID) {
return true;
}
var excludes = preferences.getExcludedFiles();
if (excludes && excludes.test(file.name)) {
return true;
}
if (isFileExcludedInternal(file.fullPath)) {
return true;
}
return false;
} | [
"function",
"isFileExcluded",
"(",
"file",
")",
"{",
"if",
"(",
"file",
".",
"name",
"[",
"0",
"]",
"===",
"\".\"",
")",
"{",
"return",
"true",
";",
"}",
"var",
"languageID",
"=",
"LanguageManager",
".",
"getLanguageForPath",
"(",
"file",
".",
"fullPath",
")",
".",
"getId",
"(",
")",
";",
"if",
"(",
"languageID",
"!==",
"HintUtils",
".",
"LANGUAGE_ID",
")",
"{",
"return",
"true",
";",
"}",
"var",
"excludes",
"=",
"preferences",
".",
"getExcludedFiles",
"(",
")",
";",
"if",
"(",
"excludes",
"&&",
"excludes",
".",
"test",
"(",
"file",
".",
"name",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"isFileExcludedInternal",
"(",
"file",
".",
"fullPath",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Test if the file should be excluded from analysis.
@param {!File} file - file to test for exclusion.
@return {boolean} true if excluded, false otherwise. | [
"Test",
"if",
"the",
"file",
"should",
"be",
"excluded",
"from",
"analysis",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L247-L267 |
2,161 | adobe/brackets | src/JSUtils/ScopeManager.js | addPendingRequest | function addPendingRequest(file, offset, type) {
var requests,
key = file + "@" + offset.line + "@" + offset.ch,
$deferredRequest;
// Reject detected exclusions
if (isFileExcludedInternal(file)) {
return (new $.Deferred()).reject().promise();
}
if (_.has(pendingTernRequests, key)) {
requests = pendingTernRequests[key];
} else {
requests = {};
pendingTernRequests[key] = requests;
}
if (_.has(requests, type)) {
$deferredRequest = requests[type];
} else {
requests[type] = $deferredRequest = new $.Deferred();
}
return $deferredRequest.promise();
} | javascript | function addPendingRequest(file, offset, type) {
var requests,
key = file + "@" + offset.line + "@" + offset.ch,
$deferredRequest;
// Reject detected exclusions
if (isFileExcludedInternal(file)) {
return (new $.Deferred()).reject().promise();
}
if (_.has(pendingTernRequests, key)) {
requests = pendingTernRequests[key];
} else {
requests = {};
pendingTernRequests[key] = requests;
}
if (_.has(requests, type)) {
$deferredRequest = requests[type];
} else {
requests[type] = $deferredRequest = new $.Deferred();
}
return $deferredRequest.promise();
} | [
"function",
"addPendingRequest",
"(",
"file",
",",
"offset",
",",
"type",
")",
"{",
"var",
"requests",
",",
"key",
"=",
"file",
"+",
"\"@\"",
"+",
"offset",
".",
"line",
"+",
"\"@\"",
"+",
"offset",
".",
"ch",
",",
"$deferredRequest",
";",
"// Reject detected exclusions",
"if",
"(",
"isFileExcludedInternal",
"(",
"file",
")",
")",
"{",
"return",
"(",
"new",
"$",
".",
"Deferred",
"(",
")",
")",
".",
"reject",
"(",
")",
".",
"promise",
"(",
")",
";",
"}",
"if",
"(",
"_",
".",
"has",
"(",
"pendingTernRequests",
",",
"key",
")",
")",
"{",
"requests",
"=",
"pendingTernRequests",
"[",
"key",
"]",
";",
"}",
"else",
"{",
"requests",
"=",
"{",
"}",
";",
"pendingTernRequests",
"[",
"key",
"]",
"=",
"requests",
";",
"}",
"if",
"(",
"_",
".",
"has",
"(",
"requests",
",",
"type",
")",
")",
"{",
"$deferredRequest",
"=",
"requests",
"[",
"type",
"]",
";",
"}",
"else",
"{",
"requests",
"[",
"type",
"]",
"=",
"$deferredRequest",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"}",
"return",
"$deferredRequest",
".",
"promise",
"(",
")",
";",
"}"
] | Add a pending request waiting for the tern-module to complete.
If file is a detected exclusion, then reject request.
@param {string} file - the name of the file
@param {{line: number, ch: number}} offset - the offset into the file the request is for
@param {string} type - the type of request
@return {jQuery.Promise} - the promise for the request | [
"Add",
"a",
"pending",
"request",
"waiting",
"for",
"the",
"tern",
"-",
"module",
"to",
"complete",
".",
"If",
"file",
"is",
"a",
"detected",
"exclusion",
"then",
"reject",
"request",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L278-L301 |
2,162 | adobe/brackets | src/JSUtils/ScopeManager.js | getJumptoDef | function getJumptoDef(fileInfo, offset) {
postMessage({
type: MessageIds.TERN_JUMPTODEF_MSG,
fileInfo: fileInfo,
offset: offset
});
return addPendingRequest(fileInfo.name, offset, MessageIds.TERN_JUMPTODEF_MSG);
} | javascript | function getJumptoDef(fileInfo, offset) {
postMessage({
type: MessageIds.TERN_JUMPTODEF_MSG,
fileInfo: fileInfo,
offset: offset
});
return addPendingRequest(fileInfo.name, offset, MessageIds.TERN_JUMPTODEF_MSG);
} | [
"function",
"getJumptoDef",
"(",
"fileInfo",
",",
"offset",
")",
"{",
"postMessage",
"(",
"{",
"type",
":",
"MessageIds",
".",
"TERN_JUMPTODEF_MSG",
",",
"fileInfo",
":",
"fileInfo",
",",
"offset",
":",
"offset",
"}",
")",
";",
"return",
"addPendingRequest",
"(",
"fileInfo",
".",
"name",
",",
"offset",
",",
"MessageIds",
".",
"TERN_JUMPTODEF_MSG",
")",
";",
"}"
] | Get a Promise for the definition from TernJS, for the file & offset passed in.
@param {{type: string, name: string, offsetLines: number, text: string}} fileInfo
- type of update, name of file, and the text of the update.
For "full" updates, the whole text of the file is present. For "part" updates,
the changed portion of the text. For "empty" updates, the file has not been modified
and the text is empty.
@param {{line: number, ch: number}} offset - the offset in the file the hints should be calculate at
@return {jQuery.Promise} - a promise that will resolve to definition when
it is done | [
"Get",
"a",
"Promise",
"for",
"the",
"definition",
"from",
"TernJS",
"for",
"the",
"file",
"&",
"offset",
"passed",
"in",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L345-L353 |
2,163 | adobe/brackets | src/JSUtils/ScopeManager.js | filterText | function filterText(text) {
var newText = text;
if (text.length > preferences.getMaxFileSize()) {
newText = "";
}
return newText;
} | javascript | function filterText(text) {
var newText = text;
if (text.length > preferences.getMaxFileSize()) {
newText = "";
}
return newText;
} | [
"function",
"filterText",
"(",
"text",
")",
"{",
"var",
"newText",
"=",
"text",
";",
"if",
"(",
"text",
".",
"length",
">",
"preferences",
".",
"getMaxFileSize",
"(",
")",
")",
"{",
"newText",
"=",
"\"\"",
";",
"}",
"return",
"newText",
";",
"}"
] | check to see if the text we are sending to Tern is too long.
@param {string} the text to check
@return {string} the text, or the empty text if the original was too long | [
"check",
"to",
"see",
"if",
"the",
"text",
"we",
"are",
"sending",
"to",
"Tern",
"is",
"too",
"long",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L360-L366 |
2,164 | adobe/brackets | src/JSUtils/ScopeManager.js | handleRename | function handleRename(response) {
if (response.error) {
EditorManager.getActiveEditor().displayErrorMessageAtCursor(response.error);
return;
}
var file = response.file,
offset = response.offset;
var $deferredFindRefs = getPendingRequest(file, offset, MessageIds.TERN_REFS);
if ($deferredFindRefs) {
$deferredFindRefs.resolveWith(null, [response]);
}
} | javascript | function handleRename(response) {
if (response.error) {
EditorManager.getActiveEditor().displayErrorMessageAtCursor(response.error);
return;
}
var file = response.file,
offset = response.offset;
var $deferredFindRefs = getPendingRequest(file, offset, MessageIds.TERN_REFS);
if ($deferredFindRefs) {
$deferredFindRefs.resolveWith(null, [response]);
}
} | [
"function",
"handleRename",
"(",
"response",
")",
"{",
"if",
"(",
"response",
".",
"error",
")",
"{",
"EditorManager",
".",
"getActiveEditor",
"(",
")",
".",
"displayErrorMessageAtCursor",
"(",
"response",
".",
"error",
")",
";",
"return",
";",
"}",
"var",
"file",
"=",
"response",
".",
"file",
",",
"offset",
"=",
"response",
".",
"offset",
";",
"var",
"$deferredFindRefs",
"=",
"getPendingRequest",
"(",
"file",
",",
"offset",
",",
"MessageIds",
".",
"TERN_REFS",
")",
";",
"if",
"(",
"$deferredFindRefs",
")",
"{",
"$deferredFindRefs",
".",
"resolveWith",
"(",
"null",
",",
"[",
"response",
"]",
")",
";",
"}",
"}"
] | Handle the response from the tern node domain when
it responds with the references
@param response - the response from the node domain | [
"Handle",
"the",
"response",
"from",
"the",
"tern",
"node",
"domain",
"when",
"it",
"responds",
"with",
"the",
"references"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L386-L401 |
2,165 | adobe/brackets | src/JSUtils/ScopeManager.js | requestJumptoDef | function requestJumptoDef(session, document, offset) {
var path = document.file.fullPath,
fileInfo = {
type: MessageIds.TERN_FILE_INFO_TYPE_FULL,
name: path,
offsetLines: 0,
text: filterText(session.getJavascriptText())
};
var ternPromise = getJumptoDef(fileInfo, offset);
return {promise: ternPromise};
} | javascript | function requestJumptoDef(session, document, offset) {
var path = document.file.fullPath,
fileInfo = {
type: MessageIds.TERN_FILE_INFO_TYPE_FULL,
name: path,
offsetLines: 0,
text: filterText(session.getJavascriptText())
};
var ternPromise = getJumptoDef(fileInfo, offset);
return {promise: ternPromise};
} | [
"function",
"requestJumptoDef",
"(",
"session",
",",
"document",
",",
"offset",
")",
"{",
"var",
"path",
"=",
"document",
".",
"file",
".",
"fullPath",
",",
"fileInfo",
"=",
"{",
"type",
":",
"MessageIds",
".",
"TERN_FILE_INFO_TYPE_FULL",
",",
"name",
":",
"path",
",",
"offsetLines",
":",
"0",
",",
"text",
":",
"filterText",
"(",
"session",
".",
"getJavascriptText",
"(",
")",
")",
"}",
";",
"var",
"ternPromise",
"=",
"getJumptoDef",
"(",
"fileInfo",
",",
"offset",
")",
";",
"return",
"{",
"promise",
":",
"ternPromise",
"}",
";",
"}"
] | Request Jump-To-Definition from Tern.
@param {session} session - the session
@param {Document} document - the document
@param {{line: number, ch: number}} offset - the offset into the document
@return {jQuery.Promise} - The promise will not complete until tern
has completed. | [
"Request",
"Jump",
"-",
"To",
"-",
"Definition",
"from",
"Tern",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L412-L424 |
2,166 | adobe/brackets | src/JSUtils/ScopeManager.js | handleJumptoDef | function handleJumptoDef(response) {
var file = response.file,
offset = response.offset;
var $deferredJump = getPendingRequest(file, offset, MessageIds.TERN_JUMPTODEF_MSG);
if ($deferredJump) {
response.fullPath = getResolvedPath(response.resultFile);
$deferredJump.resolveWith(null, [response]);
}
} | javascript | function handleJumptoDef(response) {
var file = response.file,
offset = response.offset;
var $deferredJump = getPendingRequest(file, offset, MessageIds.TERN_JUMPTODEF_MSG);
if ($deferredJump) {
response.fullPath = getResolvedPath(response.resultFile);
$deferredJump.resolveWith(null, [response]);
}
} | [
"function",
"handleJumptoDef",
"(",
"response",
")",
"{",
"var",
"file",
"=",
"response",
".",
"file",
",",
"offset",
"=",
"response",
".",
"offset",
";",
"var",
"$deferredJump",
"=",
"getPendingRequest",
"(",
"file",
",",
"offset",
",",
"MessageIds",
".",
"TERN_JUMPTODEF_MSG",
")",
";",
"if",
"(",
"$deferredJump",
")",
"{",
"response",
".",
"fullPath",
"=",
"getResolvedPath",
"(",
"response",
".",
"resultFile",
")",
";",
"$deferredJump",
".",
"resolveWith",
"(",
"null",
",",
"[",
"response",
"]",
")",
";",
"}",
"}"
] | Handle the response from the tern node domain when
it responds with the definition
@param response - the response from the node domain | [
"Handle",
"the",
"response",
"from",
"the",
"tern",
"node",
"domain",
"when",
"it",
"responds",
"with",
"the",
"definition"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L432-L443 |
2,167 | adobe/brackets | src/JSUtils/ScopeManager.js | handleScopeData | function handleScopeData(response) {
var file = response.file,
offset = response.offset;
var $deferredJump = getPendingRequest(file, offset, MessageIds.TERN_SCOPEDATA_MSG);
if ($deferredJump) {
$deferredJump.resolveWith(null, [response]);
}
} | javascript | function handleScopeData(response) {
var file = response.file,
offset = response.offset;
var $deferredJump = getPendingRequest(file, offset, MessageIds.TERN_SCOPEDATA_MSG);
if ($deferredJump) {
$deferredJump.resolveWith(null, [response]);
}
} | [
"function",
"handleScopeData",
"(",
"response",
")",
"{",
"var",
"file",
"=",
"response",
".",
"file",
",",
"offset",
"=",
"response",
".",
"offset",
";",
"var",
"$deferredJump",
"=",
"getPendingRequest",
"(",
"file",
",",
"offset",
",",
"MessageIds",
".",
"TERN_SCOPEDATA_MSG",
")",
";",
"if",
"(",
"$deferredJump",
")",
"{",
"$deferredJump",
".",
"resolveWith",
"(",
"null",
",",
"[",
"response",
"]",
")",
";",
"}",
"}"
] | Handle the response from the tern node domain when
it responds with the scope data
@param response - the response from the node domain | [
"Handle",
"the",
"response",
"from",
"the",
"tern",
"node",
"domain",
"when",
"it",
"responds",
"with",
"the",
"scope",
"data"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L451-L460 |
2,168 | adobe/brackets | src/JSUtils/ScopeManager.js | getTernHints | function getTernHints(fileInfo, offset, isProperty) {
/**
* If the document is large and we have modified a small portions of it that
* we are asking hints for, then send a partial document.
*/
postMessage({
type: MessageIds.TERN_COMPLETIONS_MSG,
fileInfo: fileInfo,
offset: offset,
isProperty: isProperty
});
return addPendingRequest(fileInfo.name, offset, MessageIds.TERN_COMPLETIONS_MSG);
} | javascript | function getTernHints(fileInfo, offset, isProperty) {
/**
* If the document is large and we have modified a small portions of it that
* we are asking hints for, then send a partial document.
*/
postMessage({
type: MessageIds.TERN_COMPLETIONS_MSG,
fileInfo: fileInfo,
offset: offset,
isProperty: isProperty
});
return addPendingRequest(fileInfo.name, offset, MessageIds.TERN_COMPLETIONS_MSG);
} | [
"function",
"getTernHints",
"(",
"fileInfo",
",",
"offset",
",",
"isProperty",
")",
"{",
"/**\n * If the document is large and we have modified a small portions of it that\n * we are asking hints for, then send a partial document.\n */",
"postMessage",
"(",
"{",
"type",
":",
"MessageIds",
".",
"TERN_COMPLETIONS_MSG",
",",
"fileInfo",
":",
"fileInfo",
",",
"offset",
":",
"offset",
",",
"isProperty",
":",
"isProperty",
"}",
")",
";",
"return",
"addPendingRequest",
"(",
"fileInfo",
".",
"name",
",",
"offset",
",",
"MessageIds",
".",
"TERN_COMPLETIONS_MSG",
")",
";",
"}"
] | Get a Promise for the completions from TernJS, for the file & offset passed in.
@param {{type: string, name: string, offsetLines: number, text: string}} fileInfo
- type of update, name of file, and the text of the update.
For "full" updates, the whole text of the file is present. For "part" updates,
the changed portion of the text. For "empty" updates, the file has not been modified
and the text is empty.
@param {{line: number, ch: number}} offset - the offset in the file the hints should be calculate at
@param {boolean} isProperty - true if getting a property hint,
otherwise getting an identifier hint.
@return {jQuery.Promise} - a promise that will resolve to an array of completions when
it is done | [
"Get",
"a",
"Promise",
"for",
"the",
"completions",
"from",
"TernJS",
"for",
"the",
"file",
"&",
"offset",
"passed",
"in",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L476-L490 |
2,169 | adobe/brackets | src/JSUtils/ScopeManager.js | getTernFunctionType | function getTernFunctionType(fileInfo, offset) {
postMessage({
type: MessageIds.TERN_CALLED_FUNC_TYPE_MSG,
fileInfo: fileInfo,
offset: offset
});
return addPendingRequest(fileInfo.name, offset, MessageIds.TERN_CALLED_FUNC_TYPE_MSG);
} | javascript | function getTernFunctionType(fileInfo, offset) {
postMessage({
type: MessageIds.TERN_CALLED_FUNC_TYPE_MSG,
fileInfo: fileInfo,
offset: offset
});
return addPendingRequest(fileInfo.name, offset, MessageIds.TERN_CALLED_FUNC_TYPE_MSG);
} | [
"function",
"getTernFunctionType",
"(",
"fileInfo",
",",
"offset",
")",
"{",
"postMessage",
"(",
"{",
"type",
":",
"MessageIds",
".",
"TERN_CALLED_FUNC_TYPE_MSG",
",",
"fileInfo",
":",
"fileInfo",
",",
"offset",
":",
"offset",
"}",
")",
";",
"return",
"addPendingRequest",
"(",
"fileInfo",
".",
"name",
",",
"offset",
",",
"MessageIds",
".",
"TERN_CALLED_FUNC_TYPE_MSG",
")",
";",
"}"
] | Get a Promise for the function type from TernJS.
@param {{type: string, name: string, offsetLines: number, text: string}} fileInfo
- type of update, name of file, and the text of the update.
For "full" updates, the whole text of the file is present. For "part" updates,
the changed portion of the text. For "empty" updates, the file has not been modified
and the text is empty.
@param {{line:number, ch:number}} offset - the line, column info for what we want the function type of.
@return {jQuery.Promise} - a promise that will resolve to the function type of the function being called. | [
"Get",
"a",
"Promise",
"for",
"the",
"function",
"type",
"from",
"TernJS",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L502-L510 |
2,170 | adobe/brackets | src/JSUtils/ScopeManager.js | getFragmentAround | function getFragmentAround(session, start) {
var minIndent = null,
minLine = null,
endLine,
cm = session.editor._codeMirror,
tabSize = cm.getOption("tabSize"),
document = session.editor.document,
p,
min,
indent,
line;
// expand range backwards
for (p = start.line - 1, min = Math.max(0, p - 100); p >= min; --p) {
line = session.getLine(p);
var fn = line.search(/\bfunction\b/);
if (fn >= 0) {
indent = CodeMirror.countColumn(line, null, tabSize);
if (minIndent === null || minIndent > indent) {
if (session.getToken({line: p, ch: fn + 1}).type === "keyword") {
minIndent = indent;
minLine = p;
}
}
}
}
if (minIndent === null) {
minIndent = 0;
}
if (minLine === null) {
minLine = min;
}
var max = Math.min(cm.lastLine(), start.line + 100),
endCh = 0;
for (endLine = start.line + 1; endLine < max; ++endLine) {
line = cm.getLine(endLine);
if (line.length > 0) {
indent = CodeMirror.countColumn(line, null, tabSize);
if (indent <= minIndent) {
endCh = line.length;
break;
}
}
}
var from = {line: minLine, ch: 0},
to = {line: endLine, ch: endCh};
return {type: MessageIds.TERN_FILE_INFO_TYPE_PART,
name: document.file.fullPath,
offsetLines: from.line,
text: document.getRange(from, to)};
} | javascript | function getFragmentAround(session, start) {
var minIndent = null,
minLine = null,
endLine,
cm = session.editor._codeMirror,
tabSize = cm.getOption("tabSize"),
document = session.editor.document,
p,
min,
indent,
line;
// expand range backwards
for (p = start.line - 1, min = Math.max(0, p - 100); p >= min; --p) {
line = session.getLine(p);
var fn = line.search(/\bfunction\b/);
if (fn >= 0) {
indent = CodeMirror.countColumn(line, null, tabSize);
if (minIndent === null || minIndent > indent) {
if (session.getToken({line: p, ch: fn + 1}).type === "keyword") {
minIndent = indent;
minLine = p;
}
}
}
}
if (minIndent === null) {
minIndent = 0;
}
if (minLine === null) {
minLine = min;
}
var max = Math.min(cm.lastLine(), start.line + 100),
endCh = 0;
for (endLine = start.line + 1; endLine < max; ++endLine) {
line = cm.getLine(endLine);
if (line.length > 0) {
indent = CodeMirror.countColumn(line, null, tabSize);
if (indent <= minIndent) {
endCh = line.length;
break;
}
}
}
var from = {line: minLine, ch: 0},
to = {line: endLine, ch: endCh};
return {type: MessageIds.TERN_FILE_INFO_TYPE_PART,
name: document.file.fullPath,
offsetLines: from.line,
text: document.getRange(from, to)};
} | [
"function",
"getFragmentAround",
"(",
"session",
",",
"start",
")",
"{",
"var",
"minIndent",
"=",
"null",
",",
"minLine",
"=",
"null",
",",
"endLine",
",",
"cm",
"=",
"session",
".",
"editor",
".",
"_codeMirror",
",",
"tabSize",
"=",
"cm",
".",
"getOption",
"(",
"\"tabSize\"",
")",
",",
"document",
"=",
"session",
".",
"editor",
".",
"document",
",",
"p",
",",
"min",
",",
"indent",
",",
"line",
";",
"// expand range backwards",
"for",
"(",
"p",
"=",
"start",
".",
"line",
"-",
"1",
",",
"min",
"=",
"Math",
".",
"max",
"(",
"0",
",",
"p",
"-",
"100",
")",
";",
"p",
">=",
"min",
";",
"--",
"p",
")",
"{",
"line",
"=",
"session",
".",
"getLine",
"(",
"p",
")",
";",
"var",
"fn",
"=",
"line",
".",
"search",
"(",
"/",
"\\bfunction\\b",
"/",
")",
";",
"if",
"(",
"fn",
">=",
"0",
")",
"{",
"indent",
"=",
"CodeMirror",
".",
"countColumn",
"(",
"line",
",",
"null",
",",
"tabSize",
")",
";",
"if",
"(",
"minIndent",
"===",
"null",
"||",
"minIndent",
">",
"indent",
")",
"{",
"if",
"(",
"session",
".",
"getToken",
"(",
"{",
"line",
":",
"p",
",",
"ch",
":",
"fn",
"+",
"1",
"}",
")",
".",
"type",
"===",
"\"keyword\"",
")",
"{",
"minIndent",
"=",
"indent",
";",
"minLine",
"=",
"p",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"minIndent",
"===",
"null",
")",
"{",
"minIndent",
"=",
"0",
";",
"}",
"if",
"(",
"minLine",
"===",
"null",
")",
"{",
"minLine",
"=",
"min",
";",
"}",
"var",
"max",
"=",
"Math",
".",
"min",
"(",
"cm",
".",
"lastLine",
"(",
")",
",",
"start",
".",
"line",
"+",
"100",
")",
",",
"endCh",
"=",
"0",
";",
"for",
"(",
"endLine",
"=",
"start",
".",
"line",
"+",
"1",
";",
"endLine",
"<",
"max",
";",
"++",
"endLine",
")",
"{",
"line",
"=",
"cm",
".",
"getLine",
"(",
"endLine",
")",
";",
"if",
"(",
"line",
".",
"length",
">",
"0",
")",
"{",
"indent",
"=",
"CodeMirror",
".",
"countColumn",
"(",
"line",
",",
"null",
",",
"tabSize",
")",
";",
"if",
"(",
"indent",
"<=",
"minIndent",
")",
"{",
"endCh",
"=",
"line",
".",
"length",
";",
"break",
";",
"}",
"}",
"}",
"var",
"from",
"=",
"{",
"line",
":",
"minLine",
",",
"ch",
":",
"0",
"}",
",",
"to",
"=",
"{",
"line",
":",
"endLine",
",",
"ch",
":",
"endCh",
"}",
";",
"return",
"{",
"type",
":",
"MessageIds",
".",
"TERN_FILE_INFO_TYPE_PART",
",",
"name",
":",
"document",
".",
"file",
".",
"fullPath",
",",
"offsetLines",
":",
"from",
".",
"line",
",",
"text",
":",
"document",
".",
"getRange",
"(",
"from",
",",
"to",
")",
"}",
";",
"}"
] | Given a starting and ending position, get a code fragment that is self contained
enough to be compiled.
@param {!Session} session - the current session
@param {{line: number, ch: number}} start - the starting position of the changes
@return {{type: string, name: string, offsetLines: number, text: string}} | [
"Given",
"a",
"starting",
"and",
"ending",
"position",
"get",
"a",
"code",
"fragment",
"that",
"is",
"self",
"contained",
"enough",
"to",
"be",
"compiled",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L521-L579 |
2,171 | adobe/brackets | src/JSUtils/ScopeManager.js | getFileInfo | function getFileInfo(session, preventPartialUpdates) {
var start = session.getCursor(),
end = start,
document = session.editor.document,
path = document.file.fullPath,
isHtmlFile = LanguageManager.getLanguageForPath(path).getId() === "html",
result;
if (isHtmlFile) {
result = {type: MessageIds.TERN_FILE_INFO_TYPE_FULL,
name: path,
text: session.getJavascriptText()};
} else if (!documentChanges) {
result = {type: MessageIds.TERN_FILE_INFO_TYPE_EMPTY,
name: path,
text: ""};
} else if (!preventPartialUpdates && session.editor.lineCount() > LARGE_LINE_COUNT &&
(documentChanges.to - documentChanges.from < LARGE_LINE_CHANGE) &&
documentChanges.from <= start.line &&
documentChanges.to > end.line) {
result = getFragmentAround(session, start);
} else {
result = {type: MessageIds.TERN_FILE_INFO_TYPE_FULL,
name: path,
text: getTextFromDocument(document)};
}
documentChanges = null;
return result;
} | javascript | function getFileInfo(session, preventPartialUpdates) {
var start = session.getCursor(),
end = start,
document = session.editor.document,
path = document.file.fullPath,
isHtmlFile = LanguageManager.getLanguageForPath(path).getId() === "html",
result;
if (isHtmlFile) {
result = {type: MessageIds.TERN_FILE_INFO_TYPE_FULL,
name: path,
text: session.getJavascriptText()};
} else if (!documentChanges) {
result = {type: MessageIds.TERN_FILE_INFO_TYPE_EMPTY,
name: path,
text: ""};
} else if (!preventPartialUpdates && session.editor.lineCount() > LARGE_LINE_COUNT &&
(documentChanges.to - documentChanges.from < LARGE_LINE_CHANGE) &&
documentChanges.from <= start.line &&
documentChanges.to > end.line) {
result = getFragmentAround(session, start);
} else {
result = {type: MessageIds.TERN_FILE_INFO_TYPE_FULL,
name: path,
text: getTextFromDocument(document)};
}
documentChanges = null;
return result;
} | [
"function",
"getFileInfo",
"(",
"session",
",",
"preventPartialUpdates",
")",
"{",
"var",
"start",
"=",
"session",
".",
"getCursor",
"(",
")",
",",
"end",
"=",
"start",
",",
"document",
"=",
"session",
".",
"editor",
".",
"document",
",",
"path",
"=",
"document",
".",
"file",
".",
"fullPath",
",",
"isHtmlFile",
"=",
"LanguageManager",
".",
"getLanguageForPath",
"(",
"path",
")",
".",
"getId",
"(",
")",
"===",
"\"html\"",
",",
"result",
";",
"if",
"(",
"isHtmlFile",
")",
"{",
"result",
"=",
"{",
"type",
":",
"MessageIds",
".",
"TERN_FILE_INFO_TYPE_FULL",
",",
"name",
":",
"path",
",",
"text",
":",
"session",
".",
"getJavascriptText",
"(",
")",
"}",
";",
"}",
"else",
"if",
"(",
"!",
"documentChanges",
")",
"{",
"result",
"=",
"{",
"type",
":",
"MessageIds",
".",
"TERN_FILE_INFO_TYPE_EMPTY",
",",
"name",
":",
"path",
",",
"text",
":",
"\"\"",
"}",
";",
"}",
"else",
"if",
"(",
"!",
"preventPartialUpdates",
"&&",
"session",
".",
"editor",
".",
"lineCount",
"(",
")",
">",
"LARGE_LINE_COUNT",
"&&",
"(",
"documentChanges",
".",
"to",
"-",
"documentChanges",
".",
"from",
"<",
"LARGE_LINE_CHANGE",
")",
"&&",
"documentChanges",
".",
"from",
"<=",
"start",
".",
"line",
"&&",
"documentChanges",
".",
"to",
">",
"end",
".",
"line",
")",
"{",
"result",
"=",
"getFragmentAround",
"(",
"session",
",",
"start",
")",
";",
"}",
"else",
"{",
"result",
"=",
"{",
"type",
":",
"MessageIds",
".",
"TERN_FILE_INFO_TYPE_FULL",
",",
"name",
":",
"path",
",",
"text",
":",
"getTextFromDocument",
"(",
"document",
")",
"}",
";",
"}",
"documentChanges",
"=",
"null",
";",
"return",
"result",
";",
"}"
] | Get an object that describes what tern needs to know about the updated
file to produce a hint. As a side-effect of this calls the document
changes are reset.
@param {!Session} session - the current session
@param {boolean=} preventPartialUpdates - if true, disallow partial updates.
Optional, defaults to false.
@return {{type: string, name: string, offsetLines: number, text: string}} | [
"Get",
"an",
"object",
"that",
"describes",
"what",
"tern",
"needs",
"to",
"know",
"about",
"the",
"updated",
"file",
"to",
"produce",
"a",
"hint",
".",
"As",
"a",
"side",
"-",
"effect",
"of",
"this",
"calls",
"the",
"document",
"changes",
"are",
"reset",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L592-L621 |
2,172 | adobe/brackets | src/JSUtils/ScopeManager.js | getOffset | function getOffset(session, fileInfo, offset) {
var newOffset;
if (offset) {
newOffset = {line: offset.line, ch: offset.ch};
} else {
newOffset = session.getCursor();
}
if (fileInfo.type === MessageIds.TERN_FILE_INFO_TYPE_PART) {
newOffset.line = Math.max(0, newOffset.line - fileInfo.offsetLines);
}
return newOffset;
} | javascript | function getOffset(session, fileInfo, offset) {
var newOffset;
if (offset) {
newOffset = {line: offset.line, ch: offset.ch};
} else {
newOffset = session.getCursor();
}
if (fileInfo.type === MessageIds.TERN_FILE_INFO_TYPE_PART) {
newOffset.line = Math.max(0, newOffset.line - fileInfo.offsetLines);
}
return newOffset;
} | [
"function",
"getOffset",
"(",
"session",
",",
"fileInfo",
",",
"offset",
")",
"{",
"var",
"newOffset",
";",
"if",
"(",
"offset",
")",
"{",
"newOffset",
"=",
"{",
"line",
":",
"offset",
".",
"line",
",",
"ch",
":",
"offset",
".",
"ch",
"}",
";",
"}",
"else",
"{",
"newOffset",
"=",
"session",
".",
"getCursor",
"(",
")",
";",
"}",
"if",
"(",
"fileInfo",
".",
"type",
"===",
"MessageIds",
".",
"TERN_FILE_INFO_TYPE_PART",
")",
"{",
"newOffset",
".",
"line",
"=",
"Math",
".",
"max",
"(",
"0",
",",
"newOffset",
".",
"line",
"-",
"fileInfo",
".",
"offsetLines",
")",
";",
"}",
"return",
"newOffset",
";",
"}"
] | Get the current offset. The offset is adjusted for "part" updates.
@param {!Session} session - the current session
@param {{type: string, name: string, offsetLines: number, text: string}} fileInfo
- type of update, name of file, and the text of the update.
For "full" updates, the whole text of the file is present. For "part" updates,
the changed portion of the text. For "empty" updates, the file has not been modified
and the text is empty.
@param {{line: number, ch: number}=} offset - the default offset (optional). Will
use the cursor if not provided.
@return {{line: number, ch: number}} | [
"Get",
"the",
"current",
"offset",
".",
"The",
"offset",
"is",
"adjusted",
"for",
"part",
"updates",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L636-L650 |
2,173 | adobe/brackets | src/JSUtils/ScopeManager.js | requestGuesses | function requestGuesses(session, document) {
var $deferred = $.Deferred(),
fileInfo = getFileInfo(session),
offset = getOffset(session, fileInfo);
postMessage({
type: MessageIds.TERN_GET_GUESSES_MSG,
fileInfo: fileInfo,
offset: offset
});
var promise = addPendingRequest(fileInfo.name, offset, MessageIds.TERN_GET_GUESSES_MSG);
promise.done(function (guesses) {
session.setGuesses(guesses);
$deferred.resolve();
}).fail(function () {
$deferred.reject();
});
return $deferred.promise();
} | javascript | function requestGuesses(session, document) {
var $deferred = $.Deferred(),
fileInfo = getFileInfo(session),
offset = getOffset(session, fileInfo);
postMessage({
type: MessageIds.TERN_GET_GUESSES_MSG,
fileInfo: fileInfo,
offset: offset
});
var promise = addPendingRequest(fileInfo.name, offset, MessageIds.TERN_GET_GUESSES_MSG);
promise.done(function (guesses) {
session.setGuesses(guesses);
$deferred.resolve();
}).fail(function () {
$deferred.reject();
});
return $deferred.promise();
} | [
"function",
"requestGuesses",
"(",
"session",
",",
"document",
")",
"{",
"var",
"$deferred",
"=",
"$",
".",
"Deferred",
"(",
")",
",",
"fileInfo",
"=",
"getFileInfo",
"(",
"session",
")",
",",
"offset",
"=",
"getOffset",
"(",
"session",
",",
"fileInfo",
")",
";",
"postMessage",
"(",
"{",
"type",
":",
"MessageIds",
".",
"TERN_GET_GUESSES_MSG",
",",
"fileInfo",
":",
"fileInfo",
",",
"offset",
":",
"offset",
"}",
")",
";",
"var",
"promise",
"=",
"addPendingRequest",
"(",
"fileInfo",
".",
"name",
",",
"offset",
",",
"MessageIds",
".",
"TERN_GET_GUESSES_MSG",
")",
";",
"promise",
".",
"done",
"(",
"function",
"(",
"guesses",
")",
"{",
"session",
".",
"setGuesses",
"(",
"guesses",
")",
";",
"$deferred",
".",
"resolve",
"(",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"$deferred",
".",
"reject",
"(",
")",
";",
"}",
")",
";",
"return",
"$deferred",
".",
"promise",
"(",
")",
";",
"}"
] | Get a Promise for all of the known properties from TernJS, for the directory and file.
The properties will be used as guesses in tern.
@param {Session} session - the active hinting session
@param {Document} document - the document for which scope info is
desired
@return {jQuery.Promise} - The promise will not complete until the tern
request has completed. | [
"Get",
"a",
"Promise",
"for",
"all",
"of",
"the",
"known",
"properties",
"from",
"TernJS",
"for",
"the",
"directory",
"and",
"file",
".",
"The",
"properties",
"will",
"be",
"used",
"as",
"guesses",
"in",
"tern",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L661-L681 |
2,174 | adobe/brackets | src/JSUtils/ScopeManager.js | handleTernCompletions | function handleTernCompletions(response) {
var file = response.file,
offset = response.offset,
completions = response.completions,
properties = response.properties,
fnType = response.fnType,
type = response.type,
error = response.error,
$deferredHints = getPendingRequest(file, offset, type);
if ($deferredHints) {
if (error) {
$deferredHints.reject();
} else if (completions) {
$deferredHints.resolveWith(null, [{completions: completions}]);
} else if (properties) {
$deferredHints.resolveWith(null, [{properties: properties}]);
} else if (fnType) {
$deferredHints.resolveWith(null, [fnType]);
}
}
} | javascript | function handleTernCompletions(response) {
var file = response.file,
offset = response.offset,
completions = response.completions,
properties = response.properties,
fnType = response.fnType,
type = response.type,
error = response.error,
$deferredHints = getPendingRequest(file, offset, type);
if ($deferredHints) {
if (error) {
$deferredHints.reject();
} else if (completions) {
$deferredHints.resolveWith(null, [{completions: completions}]);
} else if (properties) {
$deferredHints.resolveWith(null, [{properties: properties}]);
} else if (fnType) {
$deferredHints.resolveWith(null, [fnType]);
}
}
} | [
"function",
"handleTernCompletions",
"(",
"response",
")",
"{",
"var",
"file",
"=",
"response",
".",
"file",
",",
"offset",
"=",
"response",
".",
"offset",
",",
"completions",
"=",
"response",
".",
"completions",
",",
"properties",
"=",
"response",
".",
"properties",
",",
"fnType",
"=",
"response",
".",
"fnType",
",",
"type",
"=",
"response",
".",
"type",
",",
"error",
"=",
"response",
".",
"error",
",",
"$deferredHints",
"=",
"getPendingRequest",
"(",
"file",
",",
"offset",
",",
"type",
")",
";",
"if",
"(",
"$deferredHints",
")",
"{",
"if",
"(",
"error",
")",
"{",
"$deferredHints",
".",
"reject",
"(",
")",
";",
"}",
"else",
"if",
"(",
"completions",
")",
"{",
"$deferredHints",
".",
"resolveWith",
"(",
"null",
",",
"[",
"{",
"completions",
":",
"completions",
"}",
"]",
")",
";",
"}",
"else",
"if",
"(",
"properties",
")",
"{",
"$deferredHints",
".",
"resolveWith",
"(",
"null",
",",
"[",
"{",
"properties",
":",
"properties",
"}",
"]",
")",
";",
"}",
"else",
"if",
"(",
"fnType",
")",
"{",
"$deferredHints",
".",
"resolveWith",
"(",
"null",
",",
"[",
"fnType",
"]",
")",
";",
"}",
"}",
"}"
] | Handle the response from the tern node domain when
it responds with the list of completions
@param {{file: string, offset: {line: number, ch: number}, completions:Array.<string>,
properties:Array.<string>}} response - the response from node domain | [
"Handle",
"the",
"response",
"from",
"the",
"tern",
"node",
"domain",
"when",
"it",
"responds",
"with",
"the",
"list",
"of",
"completions"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L690-L712 |
2,175 | adobe/brackets | src/JSUtils/ScopeManager.js | handleGetGuesses | function handleGetGuesses(response) {
var path = response.file,
type = response.type,
offset = response.offset,
$deferredHints = getPendingRequest(path, offset, type);
if ($deferredHints) {
$deferredHints.resolveWith(null, [response.properties]);
}
} | javascript | function handleGetGuesses(response) {
var path = response.file,
type = response.type,
offset = response.offset,
$deferredHints = getPendingRequest(path, offset, type);
if ($deferredHints) {
$deferredHints.resolveWith(null, [response.properties]);
}
} | [
"function",
"handleGetGuesses",
"(",
"response",
")",
"{",
"var",
"path",
"=",
"response",
".",
"file",
",",
"type",
"=",
"response",
".",
"type",
",",
"offset",
"=",
"response",
".",
"offset",
",",
"$deferredHints",
"=",
"getPendingRequest",
"(",
"path",
",",
"offset",
",",
"type",
")",
";",
"if",
"(",
"$deferredHints",
")",
"{",
"$deferredHints",
".",
"resolveWith",
"(",
"null",
",",
"[",
"response",
".",
"properties",
"]",
")",
";",
"}",
"}"
] | Handle the response from the tern node domain when
it responds to the get guesses message.
@param {{file: string, type: string, offset: {line: number, ch: number},
properties: Array.<string>}} response -
the response from node domain contains the guesses for a
property lookup. | [
"Handle",
"the",
"response",
"from",
"the",
"tern",
"node",
"domain",
"when",
"it",
"responds",
"to",
"the",
"get",
"guesses",
"message",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L723-L732 |
2,176 | adobe/brackets | src/JSUtils/ScopeManager.js | handleUpdateFile | function handleUpdateFile(response) {
var path = response.path,
type = response.type,
$deferredHints = getPendingRequest(path, OFFSET_ZERO, type);
if ($deferredHints) {
$deferredHints.resolve();
}
} | javascript | function handleUpdateFile(response) {
var path = response.path,
type = response.type,
$deferredHints = getPendingRequest(path, OFFSET_ZERO, type);
if ($deferredHints) {
$deferredHints.resolve();
}
} | [
"function",
"handleUpdateFile",
"(",
"response",
")",
"{",
"var",
"path",
"=",
"response",
".",
"path",
",",
"type",
"=",
"response",
".",
"type",
",",
"$deferredHints",
"=",
"getPendingRequest",
"(",
"path",
",",
"OFFSET_ZERO",
",",
"type",
")",
";",
"if",
"(",
"$deferredHints",
")",
"{",
"$deferredHints",
".",
"resolve",
"(",
")",
";",
"}",
"}"
] | Handle the response from the tern node domain when
it responds to the update file message.
@param {{path: string, type: string}} response - the response from node domain | [
"Handle",
"the",
"response",
"from",
"the",
"tern",
"node",
"domain",
"when",
"it",
"responds",
"to",
"the",
"update",
"file",
"message",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L740-L749 |
2,177 | adobe/brackets | src/JSUtils/ScopeManager.js | handleTimedOut | function handleTimedOut(response) {
var detectedExclusions = PreferencesManager.get("jscodehints.detectedExclusions") || [],
filePath = response.file;
// Don't exclude the file currently being edited
if (isFileBeingEdited(filePath)) {
return;
}
// Handle file that is already excluded
if (detectedExclusions.indexOf(filePath) !== -1) {
console.log("JavaScriptCodeHints.handleTimedOut: file already in detectedExclusions array timed out: " + filePath);
return;
}
// Save detected exclusion in project prefs so no further time is wasted on it
detectedExclusions.push(filePath);
PreferencesManager.set("jscodehints.detectedExclusions", detectedExclusions, { location: { scope: "project" } });
// Show informational dialog
Dialogs.showModalDialog(
DefaultDialogs.DIALOG_ID_INFO,
Strings.DETECTED_EXCLUSION_TITLE,
StringUtils.format(
Strings.DETECTED_EXCLUSION_INFO,
StringUtils.breakableUrl(filePath)
),
[
{
className : Dialogs.DIALOG_BTN_CLASS_PRIMARY,
id : Dialogs.DIALOG_BTN_OK,
text : Strings.OK
}
]
);
} | javascript | function handleTimedOut(response) {
var detectedExclusions = PreferencesManager.get("jscodehints.detectedExclusions") || [],
filePath = response.file;
// Don't exclude the file currently being edited
if (isFileBeingEdited(filePath)) {
return;
}
// Handle file that is already excluded
if (detectedExclusions.indexOf(filePath) !== -1) {
console.log("JavaScriptCodeHints.handleTimedOut: file already in detectedExclusions array timed out: " + filePath);
return;
}
// Save detected exclusion in project prefs so no further time is wasted on it
detectedExclusions.push(filePath);
PreferencesManager.set("jscodehints.detectedExclusions", detectedExclusions, { location: { scope: "project" } });
// Show informational dialog
Dialogs.showModalDialog(
DefaultDialogs.DIALOG_ID_INFO,
Strings.DETECTED_EXCLUSION_TITLE,
StringUtils.format(
Strings.DETECTED_EXCLUSION_INFO,
StringUtils.breakableUrl(filePath)
),
[
{
className : Dialogs.DIALOG_BTN_CLASS_PRIMARY,
id : Dialogs.DIALOG_BTN_OK,
text : Strings.OK
}
]
);
} | [
"function",
"handleTimedOut",
"(",
"response",
")",
"{",
"var",
"detectedExclusions",
"=",
"PreferencesManager",
".",
"get",
"(",
"\"jscodehints.detectedExclusions\"",
")",
"||",
"[",
"]",
",",
"filePath",
"=",
"response",
".",
"file",
";",
"// Don't exclude the file currently being edited",
"if",
"(",
"isFileBeingEdited",
"(",
"filePath",
")",
")",
"{",
"return",
";",
"}",
"// Handle file that is already excluded",
"if",
"(",
"detectedExclusions",
".",
"indexOf",
"(",
"filePath",
")",
"!==",
"-",
"1",
")",
"{",
"console",
".",
"log",
"(",
"\"JavaScriptCodeHints.handleTimedOut: file already in detectedExclusions array timed out: \"",
"+",
"filePath",
")",
";",
"return",
";",
"}",
"// Save detected exclusion in project prefs so no further time is wasted on it",
"detectedExclusions",
".",
"push",
"(",
"filePath",
")",
";",
"PreferencesManager",
".",
"set",
"(",
"\"jscodehints.detectedExclusions\"",
",",
"detectedExclusions",
",",
"{",
"location",
":",
"{",
"scope",
":",
"\"project\"",
"}",
"}",
")",
";",
"// Show informational dialog",
"Dialogs",
".",
"showModalDialog",
"(",
"DefaultDialogs",
".",
"DIALOG_ID_INFO",
",",
"Strings",
".",
"DETECTED_EXCLUSION_TITLE",
",",
"StringUtils",
".",
"format",
"(",
"Strings",
".",
"DETECTED_EXCLUSION_INFO",
",",
"StringUtils",
".",
"breakableUrl",
"(",
"filePath",
")",
")",
",",
"[",
"{",
"className",
":",
"Dialogs",
".",
"DIALOG_BTN_CLASS_PRIMARY",
",",
"id",
":",
"Dialogs",
".",
"DIALOG_BTN_OK",
",",
"text",
":",
"Strings",
".",
"OK",
"}",
"]",
")",
";",
"}"
] | Handle timed out inference
@param {{path: string, type: string}} response - the response from node domain | [
"Handle",
"timed",
"out",
"inference"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L756-L792 |
2,178 | adobe/brackets | src/JSUtils/ScopeManager.js | postMessage | function postMessage(msg) {
addFilesPromise.done(function (ternModule) {
// If an error came up during file handling, bail out now
if (!_ternNodeDomain) {
return;
}
if (config.debug) {
console.debug("Sending message", msg);
}
_ternNodeDomain.exec("invokeTernCommand", msg);
});
} | javascript | function postMessage(msg) {
addFilesPromise.done(function (ternModule) {
// If an error came up during file handling, bail out now
if (!_ternNodeDomain) {
return;
}
if (config.debug) {
console.debug("Sending message", msg);
}
_ternNodeDomain.exec("invokeTernCommand", msg);
});
} | [
"function",
"postMessage",
"(",
"msg",
")",
"{",
"addFilesPromise",
".",
"done",
"(",
"function",
"(",
"ternModule",
")",
"{",
"// If an error came up during file handling, bail out now",
"if",
"(",
"!",
"_ternNodeDomain",
")",
"{",
"return",
";",
"}",
"if",
"(",
"config",
".",
"debug",
")",
"{",
"console",
".",
"debug",
"(",
"\"Sending message\"",
",",
"msg",
")",
";",
"}",
"_ternNodeDomain",
".",
"exec",
"(",
"\"invokeTernCommand\"",
",",
"msg",
")",
";",
"}",
")",
";",
"}"
] | Send a message to the tern node domain - if the module is being initialized,
the message will not be posted until initialization is complete | [
"Send",
"a",
"message",
"to",
"the",
"tern",
"node",
"domain",
"-",
"if",
"the",
"module",
"is",
"being",
"initialized",
"the",
"message",
"will",
"not",
"be",
"posted",
"until",
"initialization",
"is",
"complete"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L852-L864 |
2,179 | adobe/brackets | src/JSUtils/ScopeManager.js | _postMessageByPass | function _postMessageByPass(msg) {
ternPromise.done(function (ternModule) {
if (config.debug) {
console.debug("Sending message", msg);
}
_ternNodeDomain.exec("invokeTernCommand", msg);
});
} | javascript | function _postMessageByPass(msg) {
ternPromise.done(function (ternModule) {
if (config.debug) {
console.debug("Sending message", msg);
}
_ternNodeDomain.exec("invokeTernCommand", msg);
});
} | [
"function",
"_postMessageByPass",
"(",
"msg",
")",
"{",
"ternPromise",
".",
"done",
"(",
"function",
"(",
"ternModule",
")",
"{",
"if",
"(",
"config",
".",
"debug",
")",
"{",
"console",
".",
"debug",
"(",
"\"Sending message\"",
",",
"msg",
")",
";",
"}",
"_ternNodeDomain",
".",
"exec",
"(",
"\"invokeTernCommand\"",
",",
"msg",
")",
";",
"}",
")",
";",
"}"
] | Send a message to the tern node domain - this is only for messages that
need to be sent before and while the addFilesPromise is being resolved. | [
"Send",
"a",
"message",
"to",
"the",
"tern",
"node",
"domain",
"-",
"this",
"is",
"only",
"for",
"messages",
"that",
"need",
"to",
"be",
"sent",
"before",
"and",
"while",
"the",
"addFilesPromise",
"is",
"being",
"resolved",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L870-L877 |
2,180 | adobe/brackets | src/JSUtils/ScopeManager.js | updateTernFile | function updateTernFile(document) {
var path = document.file.fullPath;
_postMessageByPass({
type : MessageIds.TERN_UPDATE_FILE_MSG,
path : path,
text : getTextFromDocument(document)
});
return addPendingRequest(path, OFFSET_ZERO, MessageIds.TERN_UPDATE_FILE_MSG);
} | javascript | function updateTernFile(document) {
var path = document.file.fullPath;
_postMessageByPass({
type : MessageIds.TERN_UPDATE_FILE_MSG,
path : path,
text : getTextFromDocument(document)
});
return addPendingRequest(path, OFFSET_ZERO, MessageIds.TERN_UPDATE_FILE_MSG);
} | [
"function",
"updateTernFile",
"(",
"document",
")",
"{",
"var",
"path",
"=",
"document",
".",
"file",
".",
"fullPath",
";",
"_postMessageByPass",
"(",
"{",
"type",
":",
"MessageIds",
".",
"TERN_UPDATE_FILE_MSG",
",",
"path",
":",
"path",
",",
"text",
":",
"getTextFromDocument",
"(",
"document",
")",
"}",
")",
";",
"return",
"addPendingRequest",
"(",
"path",
",",
"OFFSET_ZERO",
",",
"MessageIds",
".",
"TERN_UPDATE_FILE_MSG",
")",
";",
"}"
] | Update tern with the new contents of a given file.
@param {Document} document - the document to update
@return {jQuery.Promise} - the promise for the request | [
"Update",
"tern",
"with",
"the",
"new",
"contents",
"of",
"a",
"given",
"file",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L885-L895 |
2,181 | adobe/brackets | src/JSUtils/ScopeManager.js | handleTernGetFile | function handleTernGetFile(request) {
function replyWith(name, txt) {
_postMessageByPass({
type: MessageIds.TERN_GET_FILE_MSG,
file: name,
text: txt
});
}
var name = request.file;
/**
* Helper function to get the text of a given document and send it to tern.
* If DocumentManager successfully gets the file's text then we'll send it to the tern node domain.
* The Promise for getDocumentText() is returned so that custom fail functions can be used.
*
* @param {string} filePath - the path of the file to get the text of
* @return {jQuery.Promise} - the Promise returned from DocumentMangaer.getDocumentText()
*/
function getDocText(filePath) {
if (!FileSystem.isAbsolutePath(filePath) || // don't handle URLs
filePath.slice(0, 2) === "//") { // don't handle protocol-relative URLs like //example.com/main.js (see #10566)
return (new $.Deferred()).reject().promise();
}
var file = FileSystem.getFileForPath(filePath),
promise = DocumentManager.getDocumentText(file);
promise.done(function (docText) {
resolvedFiles[name] = filePath;
numResolvedFiles++;
replyWith(name, filterText(docText));
});
return promise;
}
/**
* Helper function to find any files in the project that end with the
* name we are looking for. This is so we can find requirejs modules
* when the baseUrl is unknown, or when the project root is not the same
* as the script root (e.g. if you open the 'brackets' dir instead of 'brackets/src' dir).
*/
function findNameInProject() {
// check for any files in project that end with the right path.
var fileName = name.substring(name.lastIndexOf("/") + 1);
function _fileFilter(entry) {
return entry.name === fileName;
}
ProjectManager.getAllFiles(_fileFilter).done(function (files) {
var file;
files = files.filter(function (file) {
var pos = file.fullPath.length - name.length;
return pos === file.fullPath.lastIndexOf(name);
});
if (files.length === 1) {
file = files[0];
}
if (file) {
getDocText(file.fullPath).fail(function () {
replyWith(name, "");
});
} else {
replyWith(name, "");
}
});
}
if (!isFileExcludedInternal(name)) {
getDocText(name).fail(function () {
getDocText(rootTernDir + name).fail(function () {
// check relative to project root
getDocText(projectRoot + name)
// last look for any files that end with the right path
// in the project
.fail(findNameInProject);
});
});
}
} | javascript | function handleTernGetFile(request) {
function replyWith(name, txt) {
_postMessageByPass({
type: MessageIds.TERN_GET_FILE_MSG,
file: name,
text: txt
});
}
var name = request.file;
/**
* Helper function to get the text of a given document and send it to tern.
* If DocumentManager successfully gets the file's text then we'll send it to the tern node domain.
* The Promise for getDocumentText() is returned so that custom fail functions can be used.
*
* @param {string} filePath - the path of the file to get the text of
* @return {jQuery.Promise} - the Promise returned from DocumentMangaer.getDocumentText()
*/
function getDocText(filePath) {
if (!FileSystem.isAbsolutePath(filePath) || // don't handle URLs
filePath.slice(0, 2) === "//") { // don't handle protocol-relative URLs like //example.com/main.js (see #10566)
return (new $.Deferred()).reject().promise();
}
var file = FileSystem.getFileForPath(filePath),
promise = DocumentManager.getDocumentText(file);
promise.done(function (docText) {
resolvedFiles[name] = filePath;
numResolvedFiles++;
replyWith(name, filterText(docText));
});
return promise;
}
/**
* Helper function to find any files in the project that end with the
* name we are looking for. This is so we can find requirejs modules
* when the baseUrl is unknown, or when the project root is not the same
* as the script root (e.g. if you open the 'brackets' dir instead of 'brackets/src' dir).
*/
function findNameInProject() {
// check for any files in project that end with the right path.
var fileName = name.substring(name.lastIndexOf("/") + 1);
function _fileFilter(entry) {
return entry.name === fileName;
}
ProjectManager.getAllFiles(_fileFilter).done(function (files) {
var file;
files = files.filter(function (file) {
var pos = file.fullPath.length - name.length;
return pos === file.fullPath.lastIndexOf(name);
});
if (files.length === 1) {
file = files[0];
}
if (file) {
getDocText(file.fullPath).fail(function () {
replyWith(name, "");
});
} else {
replyWith(name, "");
}
});
}
if (!isFileExcludedInternal(name)) {
getDocText(name).fail(function () {
getDocText(rootTernDir + name).fail(function () {
// check relative to project root
getDocText(projectRoot + name)
// last look for any files that end with the right path
// in the project
.fail(findNameInProject);
});
});
}
} | [
"function",
"handleTernGetFile",
"(",
"request",
")",
"{",
"function",
"replyWith",
"(",
"name",
",",
"txt",
")",
"{",
"_postMessageByPass",
"(",
"{",
"type",
":",
"MessageIds",
".",
"TERN_GET_FILE_MSG",
",",
"file",
":",
"name",
",",
"text",
":",
"txt",
"}",
")",
";",
"}",
"var",
"name",
"=",
"request",
".",
"file",
";",
"/**\n * Helper function to get the text of a given document and send it to tern.\n * If DocumentManager successfully gets the file's text then we'll send it to the tern node domain.\n * The Promise for getDocumentText() is returned so that custom fail functions can be used.\n *\n * @param {string} filePath - the path of the file to get the text of\n * @return {jQuery.Promise} - the Promise returned from DocumentMangaer.getDocumentText()\n */",
"function",
"getDocText",
"(",
"filePath",
")",
"{",
"if",
"(",
"!",
"FileSystem",
".",
"isAbsolutePath",
"(",
"filePath",
")",
"||",
"// don't handle URLs",
"filePath",
".",
"slice",
"(",
"0",
",",
"2",
")",
"===",
"\"//\"",
")",
"{",
"// don't handle protocol-relative URLs like //example.com/main.js (see #10566)",
"return",
"(",
"new",
"$",
".",
"Deferred",
"(",
")",
")",
".",
"reject",
"(",
")",
".",
"promise",
"(",
")",
";",
"}",
"var",
"file",
"=",
"FileSystem",
".",
"getFileForPath",
"(",
"filePath",
")",
",",
"promise",
"=",
"DocumentManager",
".",
"getDocumentText",
"(",
"file",
")",
";",
"promise",
".",
"done",
"(",
"function",
"(",
"docText",
")",
"{",
"resolvedFiles",
"[",
"name",
"]",
"=",
"filePath",
";",
"numResolvedFiles",
"++",
";",
"replyWith",
"(",
"name",
",",
"filterText",
"(",
"docText",
")",
")",
";",
"}",
")",
";",
"return",
"promise",
";",
"}",
"/**\n * Helper function to find any files in the project that end with the\n * name we are looking for. This is so we can find requirejs modules\n * when the baseUrl is unknown, or when the project root is not the same\n * as the script root (e.g. if you open the 'brackets' dir instead of 'brackets/src' dir).\n */",
"function",
"findNameInProject",
"(",
")",
"{",
"// check for any files in project that end with the right path.",
"var",
"fileName",
"=",
"name",
".",
"substring",
"(",
"name",
".",
"lastIndexOf",
"(",
"\"/\"",
")",
"+",
"1",
")",
";",
"function",
"_fileFilter",
"(",
"entry",
")",
"{",
"return",
"entry",
".",
"name",
"===",
"fileName",
";",
"}",
"ProjectManager",
".",
"getAllFiles",
"(",
"_fileFilter",
")",
".",
"done",
"(",
"function",
"(",
"files",
")",
"{",
"var",
"file",
";",
"files",
"=",
"files",
".",
"filter",
"(",
"function",
"(",
"file",
")",
"{",
"var",
"pos",
"=",
"file",
".",
"fullPath",
".",
"length",
"-",
"name",
".",
"length",
";",
"return",
"pos",
"===",
"file",
".",
"fullPath",
".",
"lastIndexOf",
"(",
"name",
")",
";",
"}",
")",
";",
"if",
"(",
"files",
".",
"length",
"===",
"1",
")",
"{",
"file",
"=",
"files",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"file",
")",
"{",
"getDocText",
"(",
"file",
".",
"fullPath",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"replyWith",
"(",
"name",
",",
"\"\"",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"replyWith",
"(",
"name",
",",
"\"\"",
")",
";",
"}",
"}",
")",
";",
"}",
"if",
"(",
"!",
"isFileExcludedInternal",
"(",
"name",
")",
")",
"{",
"getDocText",
"(",
"name",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"getDocText",
"(",
"rootTernDir",
"+",
"name",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"// check relative to project root",
"getDocText",
"(",
"projectRoot",
"+",
"name",
")",
"// last look for any files that end with the right path",
"// in the project",
".",
"fail",
"(",
"findNameInProject",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}",
"}"
] | Handle a request from the tern node domain for text of a file
@param {{file:string}} request - the request from the tern node domain. Should be an Object containing the name
of the file tern wants the contents of | [
"Handle",
"a",
"request",
"from",
"the",
"tern",
"node",
"domain",
"for",
"text",
"of",
"a",
"file"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L903-L985 |
2,182 | adobe/brackets | src/JSUtils/ScopeManager.js | primePump | function primePump(path, isUntitledDoc) {
_postMessageByPass({
type : MessageIds.TERN_PRIME_PUMP_MSG,
path : path,
isUntitledDoc : isUntitledDoc
});
return addPendingRequest(path, OFFSET_ZERO, MessageIds.TERN_PRIME_PUMP_MSG);
} | javascript | function primePump(path, isUntitledDoc) {
_postMessageByPass({
type : MessageIds.TERN_PRIME_PUMP_MSG,
path : path,
isUntitledDoc : isUntitledDoc
});
return addPendingRequest(path, OFFSET_ZERO, MessageIds.TERN_PRIME_PUMP_MSG);
} | [
"function",
"primePump",
"(",
"path",
",",
"isUntitledDoc",
")",
"{",
"_postMessageByPass",
"(",
"{",
"type",
":",
"MessageIds",
".",
"TERN_PRIME_PUMP_MSG",
",",
"path",
":",
"path",
",",
"isUntitledDoc",
":",
"isUntitledDoc",
"}",
")",
";",
"return",
"addPendingRequest",
"(",
"path",
",",
"OFFSET_ZERO",
",",
"MessageIds",
".",
"TERN_PRIME_PUMP_MSG",
")",
";",
"}"
] | Prime the pump for a fast first lookup.
@param {string} path - full path of file
@return {jQuery.Promise} - the promise for the request | [
"Prime",
"the",
"pump",
"for",
"a",
"fast",
"first",
"lookup",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L993-L1001 |
2,183 | adobe/brackets | src/JSUtils/ScopeManager.js | handlePrimePumpCompletion | function handlePrimePumpCompletion(response) {
var path = response.path,
type = response.type,
$deferredHints = getPendingRequest(path, OFFSET_ZERO, type);
if ($deferredHints) {
$deferredHints.resolve();
}
} | javascript | function handlePrimePumpCompletion(response) {
var path = response.path,
type = response.type,
$deferredHints = getPendingRequest(path, OFFSET_ZERO, type);
if ($deferredHints) {
$deferredHints.resolve();
}
} | [
"function",
"handlePrimePumpCompletion",
"(",
"response",
")",
"{",
"var",
"path",
"=",
"response",
".",
"path",
",",
"type",
"=",
"response",
".",
"type",
",",
"$deferredHints",
"=",
"getPendingRequest",
"(",
"path",
",",
"OFFSET_ZERO",
",",
"type",
")",
";",
"if",
"(",
"$deferredHints",
")",
"{",
"$deferredHints",
".",
"resolve",
"(",
")",
";",
"}",
"}"
] | Handle the response from the tern node domain when
it responds to the prime pump message.
@param {{path: string, type: string}} response - the response from node domain | [
"Handle",
"the",
"response",
"from",
"the",
"tern",
"node",
"domain",
"when",
"it",
"responds",
"to",
"the",
"prime",
"pump",
"message",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L1009-L1018 |
2,184 | adobe/brackets | src/JSUtils/ScopeManager.js | addFilesToTern | function addFilesToTern(files) {
// limit the number of files added to tern.
var maxFileCount = preferences.getMaxFileCount();
if (numResolvedFiles + numAddedFiles < maxFileCount) {
var available = maxFileCount - numResolvedFiles - numAddedFiles;
if (available < files.length) {
files = files.slice(0, available);
}
numAddedFiles += files.length;
ternPromise.done(function (ternModule) {
var msg = {
type : MessageIds.TERN_ADD_FILES_MSG,
files : files
};
if (config.debug) {
console.debug("Sending message", msg);
}
_ternNodeDomain.exec("invokeTernCommand", msg);
});
} else {
stopAddingFiles = true;
}
return stopAddingFiles;
} | javascript | function addFilesToTern(files) {
// limit the number of files added to tern.
var maxFileCount = preferences.getMaxFileCount();
if (numResolvedFiles + numAddedFiles < maxFileCount) {
var available = maxFileCount - numResolvedFiles - numAddedFiles;
if (available < files.length) {
files = files.slice(0, available);
}
numAddedFiles += files.length;
ternPromise.done(function (ternModule) {
var msg = {
type : MessageIds.TERN_ADD_FILES_MSG,
files : files
};
if (config.debug) {
console.debug("Sending message", msg);
}
_ternNodeDomain.exec("invokeTernCommand", msg);
});
} else {
stopAddingFiles = true;
}
return stopAddingFiles;
} | [
"function",
"addFilesToTern",
"(",
"files",
")",
"{",
"// limit the number of files added to tern.",
"var",
"maxFileCount",
"=",
"preferences",
".",
"getMaxFileCount",
"(",
")",
";",
"if",
"(",
"numResolvedFiles",
"+",
"numAddedFiles",
"<",
"maxFileCount",
")",
"{",
"var",
"available",
"=",
"maxFileCount",
"-",
"numResolvedFiles",
"-",
"numAddedFiles",
";",
"if",
"(",
"available",
"<",
"files",
".",
"length",
")",
"{",
"files",
"=",
"files",
".",
"slice",
"(",
"0",
",",
"available",
")",
";",
"}",
"numAddedFiles",
"+=",
"files",
".",
"length",
";",
"ternPromise",
".",
"done",
"(",
"function",
"(",
"ternModule",
")",
"{",
"var",
"msg",
"=",
"{",
"type",
":",
"MessageIds",
".",
"TERN_ADD_FILES_MSG",
",",
"files",
":",
"files",
"}",
";",
"if",
"(",
"config",
".",
"debug",
")",
"{",
"console",
".",
"debug",
"(",
"\"Sending message\"",
",",
"msg",
")",
";",
"}",
"_ternNodeDomain",
".",
"exec",
"(",
"\"invokeTernCommand\"",
",",
"msg",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"stopAddingFiles",
"=",
"true",
";",
"}",
"return",
"stopAddingFiles",
";",
"}"
] | Add new files to tern, keeping any previous files.
The tern server must be initialized before making
this call.
@param {Array.<string>} files - array of file to add to tern.
@return {boolean} - true if more files may be added, false if maximum has been reached. | [
"Add",
"new",
"files",
"to",
"tern",
"keeping",
"any",
"previous",
"files",
".",
"The",
"tern",
"server",
"must",
"be",
"initialized",
"before",
"making",
"this",
"call",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L1028-L1056 |
2,185 | adobe/brackets | src/JSUtils/ScopeManager.js | addAllFilesAndSubdirectories | function addAllFilesAndSubdirectories(dir, doneCallback) {
FileSystem.resolve(dir, function (err, directory) {
function visitor(entry) {
if (entry.isFile) {
if (!isFileExcluded(entry)) { // ignore .dotfiles and non-.js files
addFilesToTern([entry.fullPath]);
}
} else {
return !isDirectoryExcluded(entry.fullPath) &&
entry.name.indexOf(".") !== 0 &&
!stopAddingFiles;
}
}
if (err) {
return;
}
if (dir === FileSystem.getDirectoryForPath(rootTernDir)) {
doneCallback();
return;
}
directory.visit(visitor, doneCallback);
});
} | javascript | function addAllFilesAndSubdirectories(dir, doneCallback) {
FileSystem.resolve(dir, function (err, directory) {
function visitor(entry) {
if (entry.isFile) {
if (!isFileExcluded(entry)) { // ignore .dotfiles and non-.js files
addFilesToTern([entry.fullPath]);
}
} else {
return !isDirectoryExcluded(entry.fullPath) &&
entry.name.indexOf(".") !== 0 &&
!stopAddingFiles;
}
}
if (err) {
return;
}
if (dir === FileSystem.getDirectoryForPath(rootTernDir)) {
doneCallback();
return;
}
directory.visit(visitor, doneCallback);
});
} | [
"function",
"addAllFilesAndSubdirectories",
"(",
"dir",
",",
"doneCallback",
")",
"{",
"FileSystem",
".",
"resolve",
"(",
"dir",
",",
"function",
"(",
"err",
",",
"directory",
")",
"{",
"function",
"visitor",
"(",
"entry",
")",
"{",
"if",
"(",
"entry",
".",
"isFile",
")",
"{",
"if",
"(",
"!",
"isFileExcluded",
"(",
"entry",
")",
")",
"{",
"// ignore .dotfiles and non-.js files",
"addFilesToTern",
"(",
"[",
"entry",
".",
"fullPath",
"]",
")",
";",
"}",
"}",
"else",
"{",
"return",
"!",
"isDirectoryExcluded",
"(",
"entry",
".",
"fullPath",
")",
"&&",
"entry",
".",
"name",
".",
"indexOf",
"(",
"\".\"",
")",
"!==",
"0",
"&&",
"!",
"stopAddingFiles",
";",
"}",
"}",
"if",
"(",
"err",
")",
"{",
"return",
";",
"}",
"if",
"(",
"dir",
"===",
"FileSystem",
".",
"getDirectoryForPath",
"(",
"rootTernDir",
")",
")",
"{",
"doneCallback",
"(",
")",
";",
"return",
";",
"}",
"directory",
".",
"visit",
"(",
"visitor",
",",
"doneCallback",
")",
";",
"}",
")",
";",
"}"
] | Add the files in the directory and subdirectories of a given directory
to tern.
@param {string} dir - the root directory to add.
@param {function ()} doneCallback - called when all files have been
added to tern. | [
"Add",
"the",
"files",
"in",
"the",
"directory",
"and",
"subdirectories",
"of",
"a",
"given",
"directory",
"to",
"tern",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L1066-L1091 |
2,186 | adobe/brackets | src/JSUtils/ScopeManager.js | initTernModule | function initTernModule() {
var moduleDeferred = $.Deferred();
ternPromise = moduleDeferred.promise();
function prepareTern() {
_ternNodeDomain.exec("setInterface", {
messageIds : MessageIds
});
_ternNodeDomain.exec("invokeTernCommand", {
type: MessageIds.SET_CONFIG,
config: config
});
moduleDeferred.resolveWith(null, [_ternNodeDomain]);
}
if (_ternNodeDomain) {
_ternNodeDomain.exec("resetTernServer");
moduleDeferred.resolveWith(null, [_ternNodeDomain]);
} else {
_ternNodeDomain = new NodeDomain("TernNodeDomain", _domainPath);
_ternNodeDomain.on("data", function (evt, data) {
if (config.debug) {
console.log("Message received", data.type);
}
var response = data,
type = response.type;
if (type === MessageIds.TERN_COMPLETIONS_MSG ||
type === MessageIds.TERN_CALLED_FUNC_TYPE_MSG) {
// handle any completions the tern server calculated
handleTernCompletions(response);
} else if (type === MessageIds.TERN_GET_FILE_MSG) {
// handle a request for the contents of a file
handleTernGetFile(response);
} else if (type === MessageIds.TERN_JUMPTODEF_MSG) {
handleJumptoDef(response);
} else if (type === MessageIds.TERN_SCOPEDATA_MSG) {
handleScopeData(response);
} else if (type === MessageIds.TERN_REFS) {
handleRename(response);
} else if (type === MessageIds.TERN_PRIME_PUMP_MSG) {
handlePrimePumpCompletion(response);
} else if (type === MessageIds.TERN_GET_GUESSES_MSG) {
handleGetGuesses(response);
} else if (type === MessageIds.TERN_UPDATE_FILE_MSG) {
handleUpdateFile(response);
} else if (type === MessageIds.TERN_INFERENCE_TIMEDOUT) {
handleTimedOut(response);
} else if (type === MessageIds.TERN_WORKER_READY) {
moduleDeferred.resolveWith(null, [_ternNodeDomain]);
} else if (type === "RE_INIT_TERN") {
// Ensure the request is because of a node restart
if (currentModule) {
prepareTern();
// Mark the module with resetForced, then creation of TernModule will
// happen again as part of '_maybeReset' call
currentModule.resetForced = true;
}
} else {
console.log("Tern Module: " + (response.log || response));
}
});
_ternNodeDomain.promise().done(prepareTern);
}
} | javascript | function initTernModule() {
var moduleDeferred = $.Deferred();
ternPromise = moduleDeferred.promise();
function prepareTern() {
_ternNodeDomain.exec("setInterface", {
messageIds : MessageIds
});
_ternNodeDomain.exec("invokeTernCommand", {
type: MessageIds.SET_CONFIG,
config: config
});
moduleDeferred.resolveWith(null, [_ternNodeDomain]);
}
if (_ternNodeDomain) {
_ternNodeDomain.exec("resetTernServer");
moduleDeferred.resolveWith(null, [_ternNodeDomain]);
} else {
_ternNodeDomain = new NodeDomain("TernNodeDomain", _domainPath);
_ternNodeDomain.on("data", function (evt, data) {
if (config.debug) {
console.log("Message received", data.type);
}
var response = data,
type = response.type;
if (type === MessageIds.TERN_COMPLETIONS_MSG ||
type === MessageIds.TERN_CALLED_FUNC_TYPE_MSG) {
// handle any completions the tern server calculated
handleTernCompletions(response);
} else if (type === MessageIds.TERN_GET_FILE_MSG) {
// handle a request for the contents of a file
handleTernGetFile(response);
} else if (type === MessageIds.TERN_JUMPTODEF_MSG) {
handleJumptoDef(response);
} else if (type === MessageIds.TERN_SCOPEDATA_MSG) {
handleScopeData(response);
} else if (type === MessageIds.TERN_REFS) {
handleRename(response);
} else if (type === MessageIds.TERN_PRIME_PUMP_MSG) {
handlePrimePumpCompletion(response);
} else if (type === MessageIds.TERN_GET_GUESSES_MSG) {
handleGetGuesses(response);
} else if (type === MessageIds.TERN_UPDATE_FILE_MSG) {
handleUpdateFile(response);
} else if (type === MessageIds.TERN_INFERENCE_TIMEDOUT) {
handleTimedOut(response);
} else if (type === MessageIds.TERN_WORKER_READY) {
moduleDeferred.resolveWith(null, [_ternNodeDomain]);
} else if (type === "RE_INIT_TERN") {
// Ensure the request is because of a node restart
if (currentModule) {
prepareTern();
// Mark the module with resetForced, then creation of TernModule will
// happen again as part of '_maybeReset' call
currentModule.resetForced = true;
}
} else {
console.log("Tern Module: " + (response.log || response));
}
});
_ternNodeDomain.promise().done(prepareTern);
}
} | [
"function",
"initTernModule",
"(",
")",
"{",
"var",
"moduleDeferred",
"=",
"$",
".",
"Deferred",
"(",
")",
";",
"ternPromise",
"=",
"moduleDeferred",
".",
"promise",
"(",
")",
";",
"function",
"prepareTern",
"(",
")",
"{",
"_ternNodeDomain",
".",
"exec",
"(",
"\"setInterface\"",
",",
"{",
"messageIds",
":",
"MessageIds",
"}",
")",
";",
"_ternNodeDomain",
".",
"exec",
"(",
"\"invokeTernCommand\"",
",",
"{",
"type",
":",
"MessageIds",
".",
"SET_CONFIG",
",",
"config",
":",
"config",
"}",
")",
";",
"moduleDeferred",
".",
"resolveWith",
"(",
"null",
",",
"[",
"_ternNodeDomain",
"]",
")",
";",
"}",
"if",
"(",
"_ternNodeDomain",
")",
"{",
"_ternNodeDomain",
".",
"exec",
"(",
"\"resetTernServer\"",
")",
";",
"moduleDeferred",
".",
"resolveWith",
"(",
"null",
",",
"[",
"_ternNodeDomain",
"]",
")",
";",
"}",
"else",
"{",
"_ternNodeDomain",
"=",
"new",
"NodeDomain",
"(",
"\"TernNodeDomain\"",
",",
"_domainPath",
")",
";",
"_ternNodeDomain",
".",
"on",
"(",
"\"data\"",
",",
"function",
"(",
"evt",
",",
"data",
")",
"{",
"if",
"(",
"config",
".",
"debug",
")",
"{",
"console",
".",
"log",
"(",
"\"Message received\"",
",",
"data",
".",
"type",
")",
";",
"}",
"var",
"response",
"=",
"data",
",",
"type",
"=",
"response",
".",
"type",
";",
"if",
"(",
"type",
"===",
"MessageIds",
".",
"TERN_COMPLETIONS_MSG",
"||",
"type",
"===",
"MessageIds",
".",
"TERN_CALLED_FUNC_TYPE_MSG",
")",
"{",
"// handle any completions the tern server calculated",
"handleTernCompletions",
"(",
"response",
")",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"MessageIds",
".",
"TERN_GET_FILE_MSG",
")",
"{",
"// handle a request for the contents of a file",
"handleTernGetFile",
"(",
"response",
")",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"MessageIds",
".",
"TERN_JUMPTODEF_MSG",
")",
"{",
"handleJumptoDef",
"(",
"response",
")",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"MessageIds",
".",
"TERN_SCOPEDATA_MSG",
")",
"{",
"handleScopeData",
"(",
"response",
")",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"MessageIds",
".",
"TERN_REFS",
")",
"{",
"handleRename",
"(",
"response",
")",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"MessageIds",
".",
"TERN_PRIME_PUMP_MSG",
")",
"{",
"handlePrimePumpCompletion",
"(",
"response",
")",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"MessageIds",
".",
"TERN_GET_GUESSES_MSG",
")",
"{",
"handleGetGuesses",
"(",
"response",
")",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"MessageIds",
".",
"TERN_UPDATE_FILE_MSG",
")",
"{",
"handleUpdateFile",
"(",
"response",
")",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"MessageIds",
".",
"TERN_INFERENCE_TIMEDOUT",
")",
"{",
"handleTimedOut",
"(",
"response",
")",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"MessageIds",
".",
"TERN_WORKER_READY",
")",
"{",
"moduleDeferred",
".",
"resolveWith",
"(",
"null",
",",
"[",
"_ternNodeDomain",
"]",
")",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"\"RE_INIT_TERN\"",
")",
"{",
"// Ensure the request is because of a node restart",
"if",
"(",
"currentModule",
")",
"{",
"prepareTern",
"(",
")",
";",
"// Mark the module with resetForced, then creation of TernModule will ",
"// happen again as part of '_maybeReset' call",
"currentModule",
".",
"resetForced",
"=",
"true",
";",
"}",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"\"Tern Module: \"",
"+",
"(",
"response",
".",
"log",
"||",
"response",
")",
")",
";",
"}",
"}",
")",
";",
"_ternNodeDomain",
".",
"promise",
"(",
")",
".",
"done",
"(",
"prepareTern",
")",
";",
"}",
"}"
] | Init the Tern module that does all the code hinting work. | [
"Init",
"the",
"Tern",
"module",
"that",
"does",
"all",
"the",
"code",
"hinting",
"work",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L1096-L1163 |
2,187 | adobe/brackets | src/JSUtils/ScopeManager.js | doEditorChange | function doEditorChange(session, document, previousDocument) {
var file = document.file,
path = file.fullPath,
dir = file.parentPath,
pr;
var addFilesDeferred = $.Deferred();
documentChanges = null;
addFilesPromise = addFilesDeferred.promise();
pr = ProjectManager.getProjectRoot() ? ProjectManager.getProjectRoot().fullPath : null;
// avoid re-initializing tern if possible.
if (canSkipTernInitialization(path)) {
// update the previous document in tern to prevent stale files.
if (isDocumentDirty && previousDocument) {
var updateFilePromise = updateTernFile(previousDocument);
updateFilePromise.done(function () {
primePump(path, document.isUntitled());
addFilesDeferred.resolveWith(null, [_ternNodeDomain]);
});
} else {
addFilesDeferred.resolveWith(null, [_ternNodeDomain]);
}
isDocumentDirty = false;
return;
}
if (previousDocument && previousDocument.isDirty) {
updateTernFile(previousDocument);
}
isDocumentDirty = false;
resolvedFiles = {};
projectRoot = pr;
ensurePreferences();
deferredPreferences.done(function () {
if (file instanceof InMemoryFile) {
initTernServer(pr, []);
var hintsPromise = primePump(path, true);
hintsPromise.done(function () {
addFilesDeferred.resolveWith(null, [_ternNodeDomain]);
});
return;
}
FileSystem.resolve(dir, function (err, directory) {
if (err) {
console.error("Error resolving", dir);
addFilesDeferred.resolveWith(null);
return;
}
directory.getContents(function (err, contents) {
if (err) {
console.error("Error getting contents for", directory);
addFilesDeferred.resolveWith(null);
return;
}
var files = contents
.filter(function (entry) {
return entry.isFile && !isFileExcluded(entry);
})
.map(function (entry) {
return entry.fullPath;
});
initTernServer(dir, files);
var hintsPromise = primePump(path, false);
hintsPromise.done(function () {
if (!usingModules()) {
// Read the subdirectories of the new file's directory.
// Read them first in case there are too many files to
// read in the project.
addAllFilesAndSubdirectories(dir, function () {
// If the file is in the project root, then read
// all the files under the project root.
var currentDir = (dir + "/");
if (projectRoot && currentDir !== projectRoot &&
currentDir.indexOf(projectRoot) === 0) {
addAllFilesAndSubdirectories(projectRoot, function () {
// prime the pump again but this time don't wait
// for completion.
primePump(path, false);
addFilesDeferred.resolveWith(null, [_ternNodeDomain]);
});
} else {
addFilesDeferred.resolveWith(null, [_ternNodeDomain]);
}
});
} else {
addFilesDeferred.resolveWith(null, [_ternNodeDomain]);
}
});
});
});
});
} | javascript | function doEditorChange(session, document, previousDocument) {
var file = document.file,
path = file.fullPath,
dir = file.parentPath,
pr;
var addFilesDeferred = $.Deferred();
documentChanges = null;
addFilesPromise = addFilesDeferred.promise();
pr = ProjectManager.getProjectRoot() ? ProjectManager.getProjectRoot().fullPath : null;
// avoid re-initializing tern if possible.
if (canSkipTernInitialization(path)) {
// update the previous document in tern to prevent stale files.
if (isDocumentDirty && previousDocument) {
var updateFilePromise = updateTernFile(previousDocument);
updateFilePromise.done(function () {
primePump(path, document.isUntitled());
addFilesDeferred.resolveWith(null, [_ternNodeDomain]);
});
} else {
addFilesDeferred.resolveWith(null, [_ternNodeDomain]);
}
isDocumentDirty = false;
return;
}
if (previousDocument && previousDocument.isDirty) {
updateTernFile(previousDocument);
}
isDocumentDirty = false;
resolvedFiles = {};
projectRoot = pr;
ensurePreferences();
deferredPreferences.done(function () {
if (file instanceof InMemoryFile) {
initTernServer(pr, []);
var hintsPromise = primePump(path, true);
hintsPromise.done(function () {
addFilesDeferred.resolveWith(null, [_ternNodeDomain]);
});
return;
}
FileSystem.resolve(dir, function (err, directory) {
if (err) {
console.error("Error resolving", dir);
addFilesDeferred.resolveWith(null);
return;
}
directory.getContents(function (err, contents) {
if (err) {
console.error("Error getting contents for", directory);
addFilesDeferred.resolveWith(null);
return;
}
var files = contents
.filter(function (entry) {
return entry.isFile && !isFileExcluded(entry);
})
.map(function (entry) {
return entry.fullPath;
});
initTernServer(dir, files);
var hintsPromise = primePump(path, false);
hintsPromise.done(function () {
if (!usingModules()) {
// Read the subdirectories of the new file's directory.
// Read them first in case there are too many files to
// read in the project.
addAllFilesAndSubdirectories(dir, function () {
// If the file is in the project root, then read
// all the files under the project root.
var currentDir = (dir + "/");
if (projectRoot && currentDir !== projectRoot &&
currentDir.indexOf(projectRoot) === 0) {
addAllFilesAndSubdirectories(projectRoot, function () {
// prime the pump again but this time don't wait
// for completion.
primePump(path, false);
addFilesDeferred.resolveWith(null, [_ternNodeDomain]);
});
} else {
addFilesDeferred.resolveWith(null, [_ternNodeDomain]);
}
});
} else {
addFilesDeferred.resolveWith(null, [_ternNodeDomain]);
}
});
});
});
});
} | [
"function",
"doEditorChange",
"(",
"session",
",",
"document",
",",
"previousDocument",
")",
"{",
"var",
"file",
"=",
"document",
".",
"file",
",",
"path",
"=",
"file",
".",
"fullPath",
",",
"dir",
"=",
"file",
".",
"parentPath",
",",
"pr",
";",
"var",
"addFilesDeferred",
"=",
"$",
".",
"Deferred",
"(",
")",
";",
"documentChanges",
"=",
"null",
";",
"addFilesPromise",
"=",
"addFilesDeferred",
".",
"promise",
"(",
")",
";",
"pr",
"=",
"ProjectManager",
".",
"getProjectRoot",
"(",
")",
"?",
"ProjectManager",
".",
"getProjectRoot",
"(",
")",
".",
"fullPath",
":",
"null",
";",
"// avoid re-initializing tern if possible.",
"if",
"(",
"canSkipTernInitialization",
"(",
"path",
")",
")",
"{",
"// update the previous document in tern to prevent stale files.",
"if",
"(",
"isDocumentDirty",
"&&",
"previousDocument",
")",
"{",
"var",
"updateFilePromise",
"=",
"updateTernFile",
"(",
"previousDocument",
")",
";",
"updateFilePromise",
".",
"done",
"(",
"function",
"(",
")",
"{",
"primePump",
"(",
"path",
",",
"document",
".",
"isUntitled",
"(",
")",
")",
";",
"addFilesDeferred",
".",
"resolveWith",
"(",
"null",
",",
"[",
"_ternNodeDomain",
"]",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"addFilesDeferred",
".",
"resolveWith",
"(",
"null",
",",
"[",
"_ternNodeDomain",
"]",
")",
";",
"}",
"isDocumentDirty",
"=",
"false",
";",
"return",
";",
"}",
"if",
"(",
"previousDocument",
"&&",
"previousDocument",
".",
"isDirty",
")",
"{",
"updateTernFile",
"(",
"previousDocument",
")",
";",
"}",
"isDocumentDirty",
"=",
"false",
";",
"resolvedFiles",
"=",
"{",
"}",
";",
"projectRoot",
"=",
"pr",
";",
"ensurePreferences",
"(",
")",
";",
"deferredPreferences",
".",
"done",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"file",
"instanceof",
"InMemoryFile",
")",
"{",
"initTernServer",
"(",
"pr",
",",
"[",
"]",
")",
";",
"var",
"hintsPromise",
"=",
"primePump",
"(",
"path",
",",
"true",
")",
";",
"hintsPromise",
".",
"done",
"(",
"function",
"(",
")",
"{",
"addFilesDeferred",
".",
"resolveWith",
"(",
"null",
",",
"[",
"_ternNodeDomain",
"]",
")",
";",
"}",
")",
";",
"return",
";",
"}",
"FileSystem",
".",
"resolve",
"(",
"dir",
",",
"function",
"(",
"err",
",",
"directory",
")",
"{",
"if",
"(",
"err",
")",
"{",
"console",
".",
"error",
"(",
"\"Error resolving\"",
",",
"dir",
")",
";",
"addFilesDeferred",
".",
"resolveWith",
"(",
"null",
")",
";",
"return",
";",
"}",
"directory",
".",
"getContents",
"(",
"function",
"(",
"err",
",",
"contents",
")",
"{",
"if",
"(",
"err",
")",
"{",
"console",
".",
"error",
"(",
"\"Error getting contents for\"",
",",
"directory",
")",
";",
"addFilesDeferred",
".",
"resolveWith",
"(",
"null",
")",
";",
"return",
";",
"}",
"var",
"files",
"=",
"contents",
".",
"filter",
"(",
"function",
"(",
"entry",
")",
"{",
"return",
"entry",
".",
"isFile",
"&&",
"!",
"isFileExcluded",
"(",
"entry",
")",
";",
"}",
")",
".",
"map",
"(",
"function",
"(",
"entry",
")",
"{",
"return",
"entry",
".",
"fullPath",
";",
"}",
")",
";",
"initTernServer",
"(",
"dir",
",",
"files",
")",
";",
"var",
"hintsPromise",
"=",
"primePump",
"(",
"path",
",",
"false",
")",
";",
"hintsPromise",
".",
"done",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"usingModules",
"(",
")",
")",
"{",
"// Read the subdirectories of the new file's directory.",
"// Read them first in case there are too many files to",
"// read in the project.",
"addAllFilesAndSubdirectories",
"(",
"dir",
",",
"function",
"(",
")",
"{",
"// If the file is in the project root, then read",
"// all the files under the project root.",
"var",
"currentDir",
"=",
"(",
"dir",
"+",
"\"/\"",
")",
";",
"if",
"(",
"projectRoot",
"&&",
"currentDir",
"!==",
"projectRoot",
"&&",
"currentDir",
".",
"indexOf",
"(",
"projectRoot",
")",
"===",
"0",
")",
"{",
"addAllFilesAndSubdirectories",
"(",
"projectRoot",
",",
"function",
"(",
")",
"{",
"// prime the pump again but this time don't wait",
"// for completion.",
"primePump",
"(",
"path",
",",
"false",
")",
";",
"addFilesDeferred",
".",
"resolveWith",
"(",
"null",
",",
"[",
"_ternNodeDomain",
"]",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"addFilesDeferred",
".",
"resolveWith",
"(",
"null",
",",
"[",
"_ternNodeDomain",
"]",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"addFilesDeferred",
".",
"resolveWith",
"(",
"null",
",",
"[",
"_ternNodeDomain",
"]",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Do the work to initialize a code hinting session.
@param {Session} session - the active hinting session (TODO: currently unused)
@param {!Document} document - the document the editor has changed to
@param {?Document} previousDocument - the document the editor has changed from | [
"Do",
"the",
"work",
"to",
"initialize",
"a",
"code",
"hinting",
"session",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L1208-L1310 |
2,188 | adobe/brackets | src/JSUtils/ScopeManager.js | resetModule | function resetModule() {
function resetTernServer() {
if (_ternNodeDomain.ready()) {
_ternNodeDomain.exec('resetTernServer');
}
}
if (_ternNodeDomain) {
if (addFilesPromise) {
// If we're in the middle of added files, don't reset
// until we're done
addFilesPromise.done(resetTernServer).fail(resetTernServer);
} else {
resetTernServer();
}
}
} | javascript | function resetModule() {
function resetTernServer() {
if (_ternNodeDomain.ready()) {
_ternNodeDomain.exec('resetTernServer');
}
}
if (_ternNodeDomain) {
if (addFilesPromise) {
// If we're in the middle of added files, don't reset
// until we're done
addFilesPromise.done(resetTernServer).fail(resetTernServer);
} else {
resetTernServer();
}
}
} | [
"function",
"resetModule",
"(",
")",
"{",
"function",
"resetTernServer",
"(",
")",
"{",
"if",
"(",
"_ternNodeDomain",
".",
"ready",
"(",
")",
")",
"{",
"_ternNodeDomain",
".",
"exec",
"(",
"'resetTernServer'",
")",
";",
"}",
"}",
"if",
"(",
"_ternNodeDomain",
")",
"{",
"if",
"(",
"addFilesPromise",
")",
"{",
"// If we're in the middle of added files, don't reset ",
"// until we're done",
"addFilesPromise",
".",
"done",
"(",
"resetTernServer",
")",
".",
"fail",
"(",
"resetTernServer",
")",
";",
"}",
"else",
"{",
"resetTernServer",
"(",
")",
";",
"}",
"}",
"}"
] | Do some cleanup when a project is closed.
We can clean up the node tern server we use to calculate hints now, since
we know we will need to re-init it in any new project that is opened. | [
"Do",
"some",
"cleanup",
"when",
"a",
"project",
"is",
"closed",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L1335-L1351 |
2,189 | adobe/brackets | src/JSUtils/ScopeManager.js | _maybeReset | function _maybeReset(session, document, force) {
var newTernModule;
// if we're in the middle of a reset, don't have to check
// the new module will be online soon
if (!resettingDeferred) {
// We don't reset if the debugging flag is set
// because it's easier to debug if the module isn't
// getting reset all the time.
if (currentModule.resetForced || force || (!config.noReset && ++_hintCount > MAX_HINTS)) {
if (config.debug) {
console.debug("Resetting tern module");
}
resettingDeferred = new $.Deferred();
newTernModule = new TernModule();
newTernModule.handleEditorChange(session, document, null);
newTernModule.whenReady(function () {
// reset the old module
currentModule.resetModule();
currentModule = newTernModule;
resettingDeferred.resolve(currentModule);
// all done reseting
resettingDeferred = null;
});
_hintCount = 0;
} else {
var d = new $.Deferred();
d.resolve(currentModule);
return d.promise();
}
}
return resettingDeferred.promise();
} | javascript | function _maybeReset(session, document, force) {
var newTernModule;
// if we're in the middle of a reset, don't have to check
// the new module will be online soon
if (!resettingDeferred) {
// We don't reset if the debugging flag is set
// because it's easier to debug if the module isn't
// getting reset all the time.
if (currentModule.resetForced || force || (!config.noReset && ++_hintCount > MAX_HINTS)) {
if (config.debug) {
console.debug("Resetting tern module");
}
resettingDeferred = new $.Deferred();
newTernModule = new TernModule();
newTernModule.handleEditorChange(session, document, null);
newTernModule.whenReady(function () {
// reset the old module
currentModule.resetModule();
currentModule = newTernModule;
resettingDeferred.resolve(currentModule);
// all done reseting
resettingDeferred = null;
});
_hintCount = 0;
} else {
var d = new $.Deferred();
d.resolve(currentModule);
return d.promise();
}
}
return resettingDeferred.promise();
} | [
"function",
"_maybeReset",
"(",
"session",
",",
"document",
",",
"force",
")",
"{",
"var",
"newTernModule",
";",
"// if we're in the middle of a reset, don't have to check",
"// the new module will be online soon",
"if",
"(",
"!",
"resettingDeferred",
")",
"{",
"// We don't reset if the debugging flag is set",
"// because it's easier to debug if the module isn't",
"// getting reset all the time.",
"if",
"(",
"currentModule",
".",
"resetForced",
"||",
"force",
"||",
"(",
"!",
"config",
".",
"noReset",
"&&",
"++",
"_hintCount",
">",
"MAX_HINTS",
")",
")",
"{",
"if",
"(",
"config",
".",
"debug",
")",
"{",
"console",
".",
"debug",
"(",
"\"Resetting tern module\"",
")",
";",
"}",
"resettingDeferred",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"newTernModule",
"=",
"new",
"TernModule",
"(",
")",
";",
"newTernModule",
".",
"handleEditorChange",
"(",
"session",
",",
"document",
",",
"null",
")",
";",
"newTernModule",
".",
"whenReady",
"(",
"function",
"(",
")",
"{",
"// reset the old module",
"currentModule",
".",
"resetModule",
"(",
")",
";",
"currentModule",
"=",
"newTernModule",
";",
"resettingDeferred",
".",
"resolve",
"(",
"currentModule",
")",
";",
"// all done reseting",
"resettingDeferred",
"=",
"null",
";",
"}",
")",
";",
"_hintCount",
"=",
"0",
";",
"}",
"else",
"{",
"var",
"d",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"d",
".",
"resolve",
"(",
"currentModule",
")",
";",
"return",
"d",
".",
"promise",
"(",
")",
";",
"}",
"}",
"return",
"resettingDeferred",
".",
"promise",
"(",
")",
";",
"}"
] | reset the tern module, if necessary.
During debugging, you can turn this automatic resetting behavior off
by running this in the console:
brackets._configureJSCodeHints({ noReset: true })
This function is also used in unit testing with the "force" flag to
reset the module for each test to start with a clean environment.
@param {Session} session
@param {Document} document
@param {boolean} force true to force a reset regardless of how long since the last one
@return {Promise} Promise resolved when the module is ready.
The new (or current, if there was no reset) module is passed to the callback. | [
"reset",
"the",
"tern",
"module",
"if",
"necessary",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L1384-L1418 |
2,190 | adobe/brackets | src/JSUtils/ScopeManager.js | requestParameterHint | function requestParameterHint(session, functionOffset) {
var $deferredHints = $.Deferred(),
fileInfo = getFileInfo(session, true),
offset = getOffset(session, fileInfo, functionOffset),
fnTypePromise = getTernFunctionType(fileInfo, offset);
$.when(fnTypePromise).done(
function (fnType) {
session.setFnType(fnType);
session.setFunctionCallPos(functionOffset);
$deferredHints.resolveWith(null, [fnType]);
}
).fail(function () {
$deferredHints.reject();
});
return $deferredHints.promise();
} | javascript | function requestParameterHint(session, functionOffset) {
var $deferredHints = $.Deferred(),
fileInfo = getFileInfo(session, true),
offset = getOffset(session, fileInfo, functionOffset),
fnTypePromise = getTernFunctionType(fileInfo, offset);
$.when(fnTypePromise).done(
function (fnType) {
session.setFnType(fnType);
session.setFunctionCallPos(functionOffset);
$deferredHints.resolveWith(null, [fnType]);
}
).fail(function () {
$deferredHints.reject();
});
return $deferredHints.promise();
} | [
"function",
"requestParameterHint",
"(",
"session",
",",
"functionOffset",
")",
"{",
"var",
"$deferredHints",
"=",
"$",
".",
"Deferred",
"(",
")",
",",
"fileInfo",
"=",
"getFileInfo",
"(",
"session",
",",
"true",
")",
",",
"offset",
"=",
"getOffset",
"(",
"session",
",",
"fileInfo",
",",
"functionOffset",
")",
",",
"fnTypePromise",
"=",
"getTernFunctionType",
"(",
"fileInfo",
",",
"offset",
")",
";",
"$",
".",
"when",
"(",
"fnTypePromise",
")",
".",
"done",
"(",
"function",
"(",
"fnType",
")",
"{",
"session",
".",
"setFnType",
"(",
"fnType",
")",
";",
"session",
".",
"setFunctionCallPos",
"(",
"functionOffset",
")",
";",
"$deferredHints",
".",
"resolveWith",
"(",
"null",
",",
"[",
"fnType",
"]",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"$deferredHints",
".",
"reject",
"(",
")",
";",
"}",
")",
";",
"return",
"$deferredHints",
".",
"promise",
"(",
")",
";",
"}"
] | Request a parameter hint from Tern.
@param {Session} session - the active hinting session
@param {{line: number, ch: number}} functionOffset - the offset of the function call.
@return {jQuery.Promise} - The promise will not complete until the
hint has completed. | [
"Request",
"a",
"parameter",
"hint",
"from",
"Tern",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L1428-L1445 |
2,191 | adobe/brackets | src/JSUtils/ScopeManager.js | requestHints | function requestHints(session, document) {
var $deferredHints = $.Deferred(),
hintPromise,
sessionType = session.getType(),
fileInfo = getFileInfo(session),
offset = getOffset(session, fileInfo, null);
_maybeReset(session, document);
hintPromise = getTernHints(fileInfo, offset, sessionType.property);
$.when(hintPromise).done(
function (completions, fnType) {
if (completions.completions) {
session.setTernHints(completions.completions);
session.setGuesses(null);
} else {
session.setTernHints([]);
session.setGuesses(completions.properties);
}
$deferredHints.resolveWith(null);
}
).fail(function () {
$deferredHints.reject();
});
return $deferredHints.promise();
} | javascript | function requestHints(session, document) {
var $deferredHints = $.Deferred(),
hintPromise,
sessionType = session.getType(),
fileInfo = getFileInfo(session),
offset = getOffset(session, fileInfo, null);
_maybeReset(session, document);
hintPromise = getTernHints(fileInfo, offset, sessionType.property);
$.when(hintPromise).done(
function (completions, fnType) {
if (completions.completions) {
session.setTernHints(completions.completions);
session.setGuesses(null);
} else {
session.setTernHints([]);
session.setGuesses(completions.properties);
}
$deferredHints.resolveWith(null);
}
).fail(function () {
$deferredHints.reject();
});
return $deferredHints.promise();
} | [
"function",
"requestHints",
"(",
"session",
",",
"document",
")",
"{",
"var",
"$deferredHints",
"=",
"$",
".",
"Deferred",
"(",
")",
",",
"hintPromise",
",",
"sessionType",
"=",
"session",
".",
"getType",
"(",
")",
",",
"fileInfo",
"=",
"getFileInfo",
"(",
"session",
")",
",",
"offset",
"=",
"getOffset",
"(",
"session",
",",
"fileInfo",
",",
"null",
")",
";",
"_maybeReset",
"(",
"session",
",",
"document",
")",
";",
"hintPromise",
"=",
"getTernHints",
"(",
"fileInfo",
",",
"offset",
",",
"sessionType",
".",
"property",
")",
";",
"$",
".",
"when",
"(",
"hintPromise",
")",
".",
"done",
"(",
"function",
"(",
"completions",
",",
"fnType",
")",
"{",
"if",
"(",
"completions",
".",
"completions",
")",
"{",
"session",
".",
"setTernHints",
"(",
"completions",
".",
"completions",
")",
";",
"session",
".",
"setGuesses",
"(",
"null",
")",
";",
"}",
"else",
"{",
"session",
".",
"setTernHints",
"(",
"[",
"]",
")",
";",
"session",
".",
"setGuesses",
"(",
"completions",
".",
"properties",
")",
";",
"}",
"$deferredHints",
".",
"resolveWith",
"(",
"null",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"$deferredHints",
".",
"reject",
"(",
")",
";",
"}",
")",
";",
"return",
"$deferredHints",
".",
"promise",
"(",
")",
";",
"}"
] | Request hints from Tern.
Note that successive calls to getScope may return the same objects, so
clients that wish to modify those objects (e.g., by annotating them based
on some temporary context) should copy them first. See, e.g.,
Session.getHints().
@param {Session} session - the active hinting session
@param {Document} document - the document for which scope info is
desired
@return {jQuery.Promise} - The promise will not complete until the tern
hints have completed. | [
"Request",
"hints",
"from",
"Tern",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L1461-L1489 |
2,192 | adobe/brackets | src/JSUtils/ScopeManager.js | trackChange | function trackChange(changeList) {
var changed = documentChanges, i;
if (changed === null) {
documentChanges = changed = {from: changeList[0].from.line, to: changeList[0].from.line};
if (config.debug) {
console.debug("ScopeManager: document has changed");
}
}
for (i = 0; i < changeList.length; i++) {
var thisChange = changeList[i],
end = thisChange.from.line + (thisChange.text.length - 1);
if (thisChange.from.line < changed.to) {
changed.to = changed.to - (thisChange.to.line - end);
}
if (end >= changed.to) {
changed.to = end + 1;
}
if (changed.from > thisChange.from.line) {
changed.from = thisChange.from.line;
}
}
} | javascript | function trackChange(changeList) {
var changed = documentChanges, i;
if (changed === null) {
documentChanges = changed = {from: changeList[0].from.line, to: changeList[0].from.line};
if (config.debug) {
console.debug("ScopeManager: document has changed");
}
}
for (i = 0; i < changeList.length; i++) {
var thisChange = changeList[i],
end = thisChange.from.line + (thisChange.text.length - 1);
if (thisChange.from.line < changed.to) {
changed.to = changed.to - (thisChange.to.line - end);
}
if (end >= changed.to) {
changed.to = end + 1;
}
if (changed.from > thisChange.from.line) {
changed.from = thisChange.from.line;
}
}
} | [
"function",
"trackChange",
"(",
"changeList",
")",
"{",
"var",
"changed",
"=",
"documentChanges",
",",
"i",
";",
"if",
"(",
"changed",
"===",
"null",
")",
"{",
"documentChanges",
"=",
"changed",
"=",
"{",
"from",
":",
"changeList",
"[",
"0",
"]",
".",
"from",
".",
"line",
",",
"to",
":",
"changeList",
"[",
"0",
"]",
".",
"from",
".",
"line",
"}",
";",
"if",
"(",
"config",
".",
"debug",
")",
"{",
"console",
".",
"debug",
"(",
"\"ScopeManager: document has changed\"",
")",
";",
"}",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"changeList",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"thisChange",
"=",
"changeList",
"[",
"i",
"]",
",",
"end",
"=",
"thisChange",
".",
"from",
".",
"line",
"+",
"(",
"thisChange",
".",
"text",
".",
"length",
"-",
"1",
")",
";",
"if",
"(",
"thisChange",
".",
"from",
".",
"line",
"<",
"changed",
".",
"to",
")",
"{",
"changed",
".",
"to",
"=",
"changed",
".",
"to",
"-",
"(",
"thisChange",
".",
"to",
".",
"line",
"-",
"end",
")",
";",
"}",
"if",
"(",
"end",
">=",
"changed",
".",
"to",
")",
"{",
"changed",
".",
"to",
"=",
"end",
"+",
"1",
";",
"}",
"if",
"(",
"changed",
".",
"from",
">",
"thisChange",
".",
"from",
".",
"line",
")",
"{",
"changed",
".",
"from",
"=",
"thisChange",
".",
"from",
".",
"line",
";",
"}",
"}",
"}"
] | Track the update area of the current document so we can tell if we can send
partial updates to tern or not.
@param {Array.<{from: {line:number, ch: number}, to: {line:number, ch: number},
text: Array<string>}>} changeList - the document changes from the current change event | [
"Track",
"the",
"update",
"area",
"of",
"the",
"current",
"document",
"so",
"we",
"can",
"tell",
"if",
"we",
"can",
"send",
"partial",
"updates",
"to",
"tern",
"or",
"not",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L1498-L1522 |
2,193 | adobe/brackets | src/extensibility/node/ExtensionManagerDomain.js | _removeFailedInstallation | function _removeFailedInstallation(installDirectory) {
fs.remove(installDirectory, function (err) {
if (err) {
console.error("Error while removing directory after failed installation", installDirectory, err);
}
});
} | javascript | function _removeFailedInstallation(installDirectory) {
fs.remove(installDirectory, function (err) {
if (err) {
console.error("Error while removing directory after failed installation", installDirectory, err);
}
});
} | [
"function",
"_removeFailedInstallation",
"(",
"installDirectory",
")",
"{",
"fs",
".",
"remove",
"(",
"installDirectory",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"console",
".",
"error",
"(",
"\"Error while removing directory after failed installation\"",
",",
"installDirectory",
",",
"err",
")",
";",
"}",
"}",
")",
";",
"}"
] | Private function to remove the installation directory if the installation fails.
This does not call any callbacks. It's assumed that the callback has already been called
and this cleanup routine will do its best to complete in the background. If there's
a problem here, it is simply logged with console.error.
@param {string} installDirectory Directory to remove | [
"Private",
"function",
"to",
"remove",
"the",
"installation",
"directory",
"if",
"the",
"installation",
"fails",
".",
"This",
"does",
"not",
"call",
"any",
"callbacks",
".",
"It",
"s",
"assumed",
"that",
"the",
"callback",
"has",
"already",
"been",
"called",
"and",
"this",
"cleanup",
"routine",
"will",
"do",
"its",
"best",
"to",
"complete",
"in",
"the",
"background",
".",
"If",
"there",
"s",
"a",
"problem",
"here",
"it",
"is",
"simply",
"logged",
"with",
"console",
".",
"error",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/node/ExtensionManagerDomain.js#L74-L80 |
2,194 | adobe/brackets | src/extensibility/node/ExtensionManagerDomain.js | _performInstall | function _performInstall(packagePath, installDirectory, validationResult, callback) {
validationResult.installedTo = installDirectory;
function fail(err) {
_removeFailedInstallation(installDirectory);
callback(err, null);
}
function finish() {
// The status may have already been set previously (as in the
// DISABLED case.
if (!validationResult.installationStatus) {
validationResult.installationStatus = Statuses.INSTALLED;
}
callback(null, validationResult);
}
fs.mkdirs(installDirectory, function (err) {
if (err) {
callback(err);
return;
}
var sourceDir = path.join(validationResult.extractDir, validationResult.commonPrefix);
fs.copy(sourceDir, installDirectory, function (err) {
if (err) {
return fail(err);
}
finish();
});
});
} | javascript | function _performInstall(packagePath, installDirectory, validationResult, callback) {
validationResult.installedTo = installDirectory;
function fail(err) {
_removeFailedInstallation(installDirectory);
callback(err, null);
}
function finish() {
// The status may have already been set previously (as in the
// DISABLED case.
if (!validationResult.installationStatus) {
validationResult.installationStatus = Statuses.INSTALLED;
}
callback(null, validationResult);
}
fs.mkdirs(installDirectory, function (err) {
if (err) {
callback(err);
return;
}
var sourceDir = path.join(validationResult.extractDir, validationResult.commonPrefix);
fs.copy(sourceDir, installDirectory, function (err) {
if (err) {
return fail(err);
}
finish();
});
});
} | [
"function",
"_performInstall",
"(",
"packagePath",
",",
"installDirectory",
",",
"validationResult",
",",
"callback",
")",
"{",
"validationResult",
".",
"installedTo",
"=",
"installDirectory",
";",
"function",
"fail",
"(",
"err",
")",
"{",
"_removeFailedInstallation",
"(",
"installDirectory",
")",
";",
"callback",
"(",
"err",
",",
"null",
")",
";",
"}",
"function",
"finish",
"(",
")",
"{",
"// The status may have already been set previously (as in the",
"// DISABLED case.",
"if",
"(",
"!",
"validationResult",
".",
"installationStatus",
")",
"{",
"validationResult",
".",
"installationStatus",
"=",
"Statuses",
".",
"INSTALLED",
";",
"}",
"callback",
"(",
"null",
",",
"validationResult",
")",
";",
"}",
"fs",
".",
"mkdirs",
"(",
"installDirectory",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"return",
";",
"}",
"var",
"sourceDir",
"=",
"path",
".",
"join",
"(",
"validationResult",
".",
"extractDir",
",",
"validationResult",
".",
"commonPrefix",
")",
";",
"fs",
".",
"copy",
"(",
"sourceDir",
",",
"installDirectory",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"fail",
"(",
"err",
")",
";",
"}",
"finish",
"(",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Private function to unzip to the correct directory.
@param {string} Absolute path to the package zip file
@param {string} Absolute path to the destination directory for unzipping
@param {Object} the return value with the useful information for the client
@param {Function} callback function that is called at the end of the unzipping | [
"Private",
"function",
"to",
"unzip",
"to",
"the",
"correct",
"directory",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/node/ExtensionManagerDomain.js#L90-L121 |
2,195 | adobe/brackets | src/extensibility/node/ExtensionManagerDomain.js | _removeAndInstall | function _removeAndInstall(packagePath, installDirectory, validationResult, callback) {
// If this extension was previously installed but disabled, we will overwrite the
// previous installation in that directory.
fs.remove(installDirectory, function (err) {
if (err) {
callback(err);
return;
}
_performInstall(packagePath, installDirectory, validationResult, callback);
});
} | javascript | function _removeAndInstall(packagePath, installDirectory, validationResult, callback) {
// If this extension was previously installed but disabled, we will overwrite the
// previous installation in that directory.
fs.remove(installDirectory, function (err) {
if (err) {
callback(err);
return;
}
_performInstall(packagePath, installDirectory, validationResult, callback);
});
} | [
"function",
"_removeAndInstall",
"(",
"packagePath",
",",
"installDirectory",
",",
"validationResult",
",",
"callback",
")",
"{",
"// If this extension was previously installed but disabled, we will overwrite the",
"// previous installation in that directory.",
"fs",
".",
"remove",
"(",
"installDirectory",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"return",
";",
"}",
"_performInstall",
"(",
"packagePath",
",",
"installDirectory",
",",
"validationResult",
",",
"callback",
")",
";",
"}",
")",
";",
"}"
] | Private function to remove the target directory and then install.
@param {string} Absolute path to the package zip file
@param {string} Absolute path to the destination directory for unzipping
@param {Object} the return value with the useful information for the client
@param {Function} callback function that is called at the end of the unzipping | [
"Private",
"function",
"to",
"remove",
"the",
"target",
"directory",
"and",
"then",
"install",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/node/ExtensionManagerDomain.js#L131-L141 |
2,196 | adobe/brackets | src/extensibility/node/ExtensionManagerDomain.js | legacyPackageCheck | function legacyPackageCheck(legacyDirectory) {
return fs.existsSync(legacyDirectory) && !fs.existsSync(path.join(legacyDirectory, "package.json"));
} | javascript | function legacyPackageCheck(legacyDirectory) {
return fs.existsSync(legacyDirectory) && !fs.existsSync(path.join(legacyDirectory, "package.json"));
} | [
"function",
"legacyPackageCheck",
"(",
"legacyDirectory",
")",
"{",
"return",
"fs",
".",
"existsSync",
"(",
"legacyDirectory",
")",
"&&",
"!",
"fs",
".",
"existsSync",
"(",
"path",
".",
"join",
"(",
"legacyDirectory",
",",
"\"package.json\"",
")",
")",
";",
"}"
] | A "legacy package" is an extension that was installed based on the GitHub name without
a package.json file. Checking for the presence of these legacy extensions will help
users upgrade if the extension developer puts a different name in package.json than
the name of the GitHub project.
@param {string} legacyDirectory directory to check for old-style extension. | [
"A",
"legacy",
"package",
"is",
"an",
"extension",
"that",
"was",
"installed",
"based",
"on",
"the",
"GitHub",
"name",
"without",
"a",
"package",
".",
"json",
"file",
".",
"Checking",
"for",
"the",
"presence",
"of",
"these",
"legacy",
"extensions",
"will",
"help",
"users",
"upgrade",
"if",
"the",
"extension",
"developer",
"puts",
"a",
"different",
"name",
"in",
"package",
".",
"json",
"than",
"the",
"name",
"of",
"the",
"GitHub",
"project",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/node/ExtensionManagerDomain.js#L185-L187 |
2,197 | adobe/brackets | src/extensibility/node/ExtensionManagerDomain.js | _cmdInstall | function _cmdInstall(packagePath, destinationDirectory, options, callback, pCallback, _doUpdate) {
if (!options || !options.disabledDirectory || !options.apiVersion || !options.systemExtensionDirectory) {
callback(new Error(Errors.MISSING_REQUIRED_OPTIONS), null);
return;
}
function validateCallback(err, validationResult) {
validationResult.localPath = packagePath;
// This is a wrapper for the callback that will delete the temporary
// directory to which the package was unzipped.
function deleteTempAndCallback(err) {
if (validationResult.extractDir) {
fs.remove(validationResult.extractDir);
delete validationResult.extractDir;
}
callback(err, validationResult);
}
// If there was trouble at the validation stage, we stop right away.
if (err || validationResult.errors.length > 0) {
validationResult.installationStatus = Statuses.FAILED;
deleteTempAndCallback(err);
return;
}
// Prefers the package.json name field, but will take the zip
// file's name if that's all that's available.
var extensionName, guessedName;
if (options.nameHint) {
guessedName = path.basename(options.nameHint, ".zip");
} else {
guessedName = path.basename(packagePath, ".zip");
}
if (validationResult.metadata) {
extensionName = validationResult.metadata.name;
} else {
extensionName = guessedName;
}
validationResult.name = extensionName;
var installDirectory = path.join(destinationDirectory, extensionName),
legacyDirectory = path.join(destinationDirectory, guessedName),
systemInstallDirectory = path.join(options.systemExtensionDirectory, extensionName);
if (validationResult.metadata && validationResult.metadata.engines &&
validationResult.metadata.engines.brackets) {
var compatible = semver.satisfies(options.apiVersion,
validationResult.metadata.engines.brackets);
if (!compatible) {
installDirectory = path.join(options.disabledDirectory, extensionName);
validationResult.installationStatus = Statuses.DISABLED;
validationResult.disabledReason = Errors.API_NOT_COMPATIBLE;
_removeAndInstall(packagePath, installDirectory, validationResult, deleteTempAndCallback);
return;
}
}
// The "legacy" stuff should go away after all of the commonly used extensions
// have been upgraded with package.json files.
var hasLegacyPackage = validationResult.metadata && legacyPackageCheck(legacyDirectory);
// If the extension is already there, we signal to the front end that it's already installed
// unless the front end has signaled an intent to update.
if (hasLegacyPackage || fs.existsSync(installDirectory) || fs.existsSync(systemInstallDirectory)) {
if (_doUpdate === true) {
if (hasLegacyPackage) {
// When there's a legacy installed extension, remove it first,
// then also remove any new-style directory the user may have.
// This helps clean up if the user is in a state where they have
// both legacy and new extensions installed.
fs.remove(legacyDirectory, function (err) {
if (err) {
deleteTempAndCallback(err);
return;
}
_removeAndInstall(packagePath, installDirectory, validationResult, deleteTempAndCallback);
});
} else {
_removeAndInstall(packagePath, installDirectory, validationResult, deleteTempAndCallback);
}
} else if (hasLegacyPackage) {
validationResult.installationStatus = Statuses.NEEDS_UPDATE;
validationResult.name = guessedName;
deleteTempAndCallback(null);
} else {
_checkExistingInstallation(validationResult, installDirectory, systemInstallDirectory, deleteTempAndCallback);
}
} else {
// Regular installation with no conflicts.
validationResult.disabledReason = null;
_performInstall(packagePath, installDirectory, validationResult, deleteTempAndCallback);
}
}
validate(packagePath, options, validateCallback);
} | javascript | function _cmdInstall(packagePath, destinationDirectory, options, callback, pCallback, _doUpdate) {
if (!options || !options.disabledDirectory || !options.apiVersion || !options.systemExtensionDirectory) {
callback(new Error(Errors.MISSING_REQUIRED_OPTIONS), null);
return;
}
function validateCallback(err, validationResult) {
validationResult.localPath = packagePath;
// This is a wrapper for the callback that will delete the temporary
// directory to which the package was unzipped.
function deleteTempAndCallback(err) {
if (validationResult.extractDir) {
fs.remove(validationResult.extractDir);
delete validationResult.extractDir;
}
callback(err, validationResult);
}
// If there was trouble at the validation stage, we stop right away.
if (err || validationResult.errors.length > 0) {
validationResult.installationStatus = Statuses.FAILED;
deleteTempAndCallback(err);
return;
}
// Prefers the package.json name field, but will take the zip
// file's name if that's all that's available.
var extensionName, guessedName;
if (options.nameHint) {
guessedName = path.basename(options.nameHint, ".zip");
} else {
guessedName = path.basename(packagePath, ".zip");
}
if (validationResult.metadata) {
extensionName = validationResult.metadata.name;
} else {
extensionName = guessedName;
}
validationResult.name = extensionName;
var installDirectory = path.join(destinationDirectory, extensionName),
legacyDirectory = path.join(destinationDirectory, guessedName),
systemInstallDirectory = path.join(options.systemExtensionDirectory, extensionName);
if (validationResult.metadata && validationResult.metadata.engines &&
validationResult.metadata.engines.brackets) {
var compatible = semver.satisfies(options.apiVersion,
validationResult.metadata.engines.brackets);
if (!compatible) {
installDirectory = path.join(options.disabledDirectory, extensionName);
validationResult.installationStatus = Statuses.DISABLED;
validationResult.disabledReason = Errors.API_NOT_COMPATIBLE;
_removeAndInstall(packagePath, installDirectory, validationResult, deleteTempAndCallback);
return;
}
}
// The "legacy" stuff should go away after all of the commonly used extensions
// have been upgraded with package.json files.
var hasLegacyPackage = validationResult.metadata && legacyPackageCheck(legacyDirectory);
// If the extension is already there, we signal to the front end that it's already installed
// unless the front end has signaled an intent to update.
if (hasLegacyPackage || fs.existsSync(installDirectory) || fs.existsSync(systemInstallDirectory)) {
if (_doUpdate === true) {
if (hasLegacyPackage) {
// When there's a legacy installed extension, remove it first,
// then also remove any new-style directory the user may have.
// This helps clean up if the user is in a state where they have
// both legacy and new extensions installed.
fs.remove(legacyDirectory, function (err) {
if (err) {
deleteTempAndCallback(err);
return;
}
_removeAndInstall(packagePath, installDirectory, validationResult, deleteTempAndCallback);
});
} else {
_removeAndInstall(packagePath, installDirectory, validationResult, deleteTempAndCallback);
}
} else if (hasLegacyPackage) {
validationResult.installationStatus = Statuses.NEEDS_UPDATE;
validationResult.name = guessedName;
deleteTempAndCallback(null);
} else {
_checkExistingInstallation(validationResult, installDirectory, systemInstallDirectory, deleteTempAndCallback);
}
} else {
// Regular installation with no conflicts.
validationResult.disabledReason = null;
_performInstall(packagePath, installDirectory, validationResult, deleteTempAndCallback);
}
}
validate(packagePath, options, validateCallback);
} | [
"function",
"_cmdInstall",
"(",
"packagePath",
",",
"destinationDirectory",
",",
"options",
",",
"callback",
",",
"pCallback",
",",
"_doUpdate",
")",
"{",
"if",
"(",
"!",
"options",
"||",
"!",
"options",
".",
"disabledDirectory",
"||",
"!",
"options",
".",
"apiVersion",
"||",
"!",
"options",
".",
"systemExtensionDirectory",
")",
"{",
"callback",
"(",
"new",
"Error",
"(",
"Errors",
".",
"MISSING_REQUIRED_OPTIONS",
")",
",",
"null",
")",
";",
"return",
";",
"}",
"function",
"validateCallback",
"(",
"err",
",",
"validationResult",
")",
"{",
"validationResult",
".",
"localPath",
"=",
"packagePath",
";",
"// This is a wrapper for the callback that will delete the temporary",
"// directory to which the package was unzipped.",
"function",
"deleteTempAndCallback",
"(",
"err",
")",
"{",
"if",
"(",
"validationResult",
".",
"extractDir",
")",
"{",
"fs",
".",
"remove",
"(",
"validationResult",
".",
"extractDir",
")",
";",
"delete",
"validationResult",
".",
"extractDir",
";",
"}",
"callback",
"(",
"err",
",",
"validationResult",
")",
";",
"}",
"// If there was trouble at the validation stage, we stop right away.",
"if",
"(",
"err",
"||",
"validationResult",
".",
"errors",
".",
"length",
">",
"0",
")",
"{",
"validationResult",
".",
"installationStatus",
"=",
"Statuses",
".",
"FAILED",
";",
"deleteTempAndCallback",
"(",
"err",
")",
";",
"return",
";",
"}",
"// Prefers the package.json name field, but will take the zip",
"// file's name if that's all that's available.",
"var",
"extensionName",
",",
"guessedName",
";",
"if",
"(",
"options",
".",
"nameHint",
")",
"{",
"guessedName",
"=",
"path",
".",
"basename",
"(",
"options",
".",
"nameHint",
",",
"\".zip\"",
")",
";",
"}",
"else",
"{",
"guessedName",
"=",
"path",
".",
"basename",
"(",
"packagePath",
",",
"\".zip\"",
")",
";",
"}",
"if",
"(",
"validationResult",
".",
"metadata",
")",
"{",
"extensionName",
"=",
"validationResult",
".",
"metadata",
".",
"name",
";",
"}",
"else",
"{",
"extensionName",
"=",
"guessedName",
";",
"}",
"validationResult",
".",
"name",
"=",
"extensionName",
";",
"var",
"installDirectory",
"=",
"path",
".",
"join",
"(",
"destinationDirectory",
",",
"extensionName",
")",
",",
"legacyDirectory",
"=",
"path",
".",
"join",
"(",
"destinationDirectory",
",",
"guessedName",
")",
",",
"systemInstallDirectory",
"=",
"path",
".",
"join",
"(",
"options",
".",
"systemExtensionDirectory",
",",
"extensionName",
")",
";",
"if",
"(",
"validationResult",
".",
"metadata",
"&&",
"validationResult",
".",
"metadata",
".",
"engines",
"&&",
"validationResult",
".",
"metadata",
".",
"engines",
".",
"brackets",
")",
"{",
"var",
"compatible",
"=",
"semver",
".",
"satisfies",
"(",
"options",
".",
"apiVersion",
",",
"validationResult",
".",
"metadata",
".",
"engines",
".",
"brackets",
")",
";",
"if",
"(",
"!",
"compatible",
")",
"{",
"installDirectory",
"=",
"path",
".",
"join",
"(",
"options",
".",
"disabledDirectory",
",",
"extensionName",
")",
";",
"validationResult",
".",
"installationStatus",
"=",
"Statuses",
".",
"DISABLED",
";",
"validationResult",
".",
"disabledReason",
"=",
"Errors",
".",
"API_NOT_COMPATIBLE",
";",
"_removeAndInstall",
"(",
"packagePath",
",",
"installDirectory",
",",
"validationResult",
",",
"deleteTempAndCallback",
")",
";",
"return",
";",
"}",
"}",
"// The \"legacy\" stuff should go away after all of the commonly used extensions",
"// have been upgraded with package.json files.",
"var",
"hasLegacyPackage",
"=",
"validationResult",
".",
"metadata",
"&&",
"legacyPackageCheck",
"(",
"legacyDirectory",
")",
";",
"// If the extension is already there, we signal to the front end that it's already installed",
"// unless the front end has signaled an intent to update.",
"if",
"(",
"hasLegacyPackage",
"||",
"fs",
".",
"existsSync",
"(",
"installDirectory",
")",
"||",
"fs",
".",
"existsSync",
"(",
"systemInstallDirectory",
")",
")",
"{",
"if",
"(",
"_doUpdate",
"===",
"true",
")",
"{",
"if",
"(",
"hasLegacyPackage",
")",
"{",
"// When there's a legacy installed extension, remove it first,",
"// then also remove any new-style directory the user may have.",
"// This helps clean up if the user is in a state where they have",
"// both legacy and new extensions installed.",
"fs",
".",
"remove",
"(",
"legacyDirectory",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"deleteTempAndCallback",
"(",
"err",
")",
";",
"return",
";",
"}",
"_removeAndInstall",
"(",
"packagePath",
",",
"installDirectory",
",",
"validationResult",
",",
"deleteTempAndCallback",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"_removeAndInstall",
"(",
"packagePath",
",",
"installDirectory",
",",
"validationResult",
",",
"deleteTempAndCallback",
")",
";",
"}",
"}",
"else",
"if",
"(",
"hasLegacyPackage",
")",
"{",
"validationResult",
".",
"installationStatus",
"=",
"Statuses",
".",
"NEEDS_UPDATE",
";",
"validationResult",
".",
"name",
"=",
"guessedName",
";",
"deleteTempAndCallback",
"(",
"null",
")",
";",
"}",
"else",
"{",
"_checkExistingInstallation",
"(",
"validationResult",
",",
"installDirectory",
",",
"systemInstallDirectory",
",",
"deleteTempAndCallback",
")",
";",
"}",
"}",
"else",
"{",
"// Regular installation with no conflicts.",
"validationResult",
".",
"disabledReason",
"=",
"null",
";",
"_performInstall",
"(",
"packagePath",
",",
"installDirectory",
",",
"validationResult",
",",
"deleteTempAndCallback",
")",
";",
"}",
"}",
"validate",
"(",
"packagePath",
",",
"options",
",",
"validateCallback",
")",
";",
"}"
] | Implements the "install" command in the "extensions" domain.
There is no need to call validate independently. Validation is the first
thing that is done here.
After the extension is validated, it is installed in destinationDirectory
unless the extension is already present there. If it is already present,
a determination is made about whether the package being installed is
an update. If it does appear to be an update, then result.installationStatus
is set to NEEDS_UPDATE. If not, then it's set to ALREADY_INSTALLED.
If the installation succeeds, then result.installationStatus is set to INSTALLED.
The extension is unzipped into a directory in destinationDirectory with
the name of the extension (the name is derived either from package.json
or the name of the zip file).
The destinationDirectory will be created if it does not exist.
@param {string} Absolute path to the package zip file
@param {string} the destination directory
@param {{disabledDirectory: !string, apiVersion: !string, nameHint: ?string,
systemExtensionDirectory: !string}} additional settings to control the installation
@param {function} callback (err, result)
@param {function} pCallback (msg) callback for notifications about operation progress
@param {boolean} _doUpdate private argument to signal that an update should be performed | [
"Implements",
"the",
"install",
"command",
"in",
"the",
"extensions",
"domain",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/node/ExtensionManagerDomain.js#L217-L313 |
2,198 | adobe/brackets | src/extensibility/node/ExtensionManagerDomain.js | deleteTempAndCallback | function deleteTempAndCallback(err) {
if (validationResult.extractDir) {
fs.remove(validationResult.extractDir);
delete validationResult.extractDir;
}
callback(err, validationResult);
} | javascript | function deleteTempAndCallback(err) {
if (validationResult.extractDir) {
fs.remove(validationResult.extractDir);
delete validationResult.extractDir;
}
callback(err, validationResult);
} | [
"function",
"deleteTempAndCallback",
"(",
"err",
")",
"{",
"if",
"(",
"validationResult",
".",
"extractDir",
")",
"{",
"fs",
".",
"remove",
"(",
"validationResult",
".",
"extractDir",
")",
";",
"delete",
"validationResult",
".",
"extractDir",
";",
"}",
"callback",
"(",
"err",
",",
"validationResult",
")",
";",
"}"
] | This is a wrapper for the callback that will delete the temporary directory to which the package was unzipped. | [
"This",
"is",
"a",
"wrapper",
"for",
"the",
"callback",
"that",
"will",
"delete",
"the",
"temporary",
"directory",
"to",
"which",
"the",
"package",
"was",
"unzipped",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/node/ExtensionManagerDomain.js#L228-L234 |
2,199 | adobe/brackets | src/extensibility/node/ExtensionManagerDomain.js | _cmdUpdate | function _cmdUpdate(packagePath, destinationDirectory, options, callback, pCallback) {
_cmdInstall(packagePath, destinationDirectory, options, callback, pCallback, true);
} | javascript | function _cmdUpdate(packagePath, destinationDirectory, options, callback, pCallback) {
_cmdInstall(packagePath, destinationDirectory, options, callback, pCallback, true);
} | [
"function",
"_cmdUpdate",
"(",
"packagePath",
",",
"destinationDirectory",
",",
"options",
",",
"callback",
",",
"pCallback",
")",
"{",
"_cmdInstall",
"(",
"packagePath",
",",
"destinationDirectory",
",",
"options",
",",
"callback",
",",
"pCallback",
",",
"true",
")",
";",
"}"
] | Implements the "update" command in the "extensions" domain.
Currently, this just wraps _cmdInstall, but will remove the existing directory
first.
There is no need to call validate independently. Validation is the first
thing that is done here.
After the extension is validated, it is installed in destinationDirectory
unless the extension is already present there. If it is already present,
a determination is made about whether the package being installed is
an update. If it does appear to be an update, then result.installationStatus
is set to NEEDS_UPDATE. If not, then it's set to ALREADY_INSTALLED.
If the installation succeeds, then result.installationStatus is set to INSTALLED.
The extension is unzipped into a directory in destinationDirectory with
the name of the extension (the name is derived either from package.json
or the name of the zip file).
The destinationDirectory will be created if it does not exist.
@param {string} Absolute path to the package zip file
@param {string} the destination directory
@param {{disabledDirectory: !string, apiVersion: !string, nameHint: ?string,
systemExtensionDirectory: !string}} additional settings to control the installation
@param {function} callback (err, result)
@param {function} pCallback (msg) callback for notifications about operation progress | [
"Implements",
"the",
"update",
"command",
"in",
"the",
"extensions",
"domain",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/node/ExtensionManagerDomain.js#L345-L347 |
Subsets and Splits