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
|
---|---|---|---|---|---|---|---|---|---|---|---|
1,900 | adobe/brackets | src/extensions/default/AutoUpdate/main.js | initState | function initState() {
var result = $.Deferred();
updateJsonHandler.parse()
.done(function() {
result.resolve();
})
.fail(function (code) {
var logMsg;
switch (code) {
case StateHandlerMessages.FILE_NOT_FOUND:
logMsg = "AutoUpdate : updateHelper.json cannot be parsed, does not exist";
break;
case StateHandlerMessages.FILE_NOT_READ:
logMsg = "AutoUpdate : updateHelper.json could not be read";
break;
case StateHandlerMessages.FILE_PARSE_EXCEPTION:
logMsg = "AutoUpdate : updateHelper.json could not be parsed, exception encountered";
break;
case StateHandlerMessages.FILE_READ_FAIL:
logMsg = "AutoUpdate : updateHelper.json could not be parsed";
break;
}
console.log(logMsg);
result.reject();
});
return result.promise();
} | javascript | function initState() {
var result = $.Deferred();
updateJsonHandler.parse()
.done(function() {
result.resolve();
})
.fail(function (code) {
var logMsg;
switch (code) {
case StateHandlerMessages.FILE_NOT_FOUND:
logMsg = "AutoUpdate : updateHelper.json cannot be parsed, does not exist";
break;
case StateHandlerMessages.FILE_NOT_READ:
logMsg = "AutoUpdate : updateHelper.json could not be read";
break;
case StateHandlerMessages.FILE_PARSE_EXCEPTION:
logMsg = "AutoUpdate : updateHelper.json could not be parsed, exception encountered";
break;
case StateHandlerMessages.FILE_READ_FAIL:
logMsg = "AutoUpdate : updateHelper.json could not be parsed";
break;
}
console.log(logMsg);
result.reject();
});
return result.promise();
} | [
"function",
"initState",
"(",
")",
"{",
"var",
"result",
"=",
"$",
".",
"Deferred",
"(",
")",
";",
"updateJsonHandler",
".",
"parse",
"(",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"result",
".",
"resolve",
"(",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"code",
")",
"{",
"var",
"logMsg",
";",
"switch",
"(",
"code",
")",
"{",
"case",
"StateHandlerMessages",
".",
"FILE_NOT_FOUND",
":",
"logMsg",
"=",
"\"AutoUpdate : updateHelper.json cannot be parsed, does not exist\"",
";",
"break",
";",
"case",
"StateHandlerMessages",
".",
"FILE_NOT_READ",
":",
"logMsg",
"=",
"\"AutoUpdate : updateHelper.json could not be read\"",
";",
"break",
";",
"case",
"StateHandlerMessages",
".",
"FILE_PARSE_EXCEPTION",
":",
"logMsg",
"=",
"\"AutoUpdate : updateHelper.json could not be parsed, exception encountered\"",
";",
"break",
";",
"case",
"StateHandlerMessages",
".",
"FILE_READ_FAIL",
":",
"logMsg",
"=",
"\"AutoUpdate : updateHelper.json could not be parsed\"",
";",
"break",
";",
"}",
"console",
".",
"log",
"(",
"logMsg",
")",
";",
"result",
".",
"reject",
"(",
")",
";",
"}",
")",
";",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] | Initializes the state of parsed content from updateHelper.json
returns Promise Object Which is resolved when parsing is success
and rejected if parsing is failed. | [
"Initializes",
"the",
"state",
"of",
"parsed",
"content",
"from",
"updateHelper",
".",
"json",
"returns",
"Promise",
"Object",
"Which",
"is",
"resolved",
"when",
"parsing",
"is",
"success",
"and",
"rejected",
"if",
"parsing",
"is",
"failed",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L287-L313 |
1,901 | adobe/brackets | src/extensions/default/AutoUpdate/main.js | setupAutoUpdate | function setupAutoUpdate() {
updateJsonHandler = new StateHandler(updateJsonPath);
updateDomain.on('data', receiveMessageFromNode);
updateDomain.exec('initNode', {
messageIds: MessageIds,
updateDir: updateDir,
requester: domainID
});
} | javascript | function setupAutoUpdate() {
updateJsonHandler = new StateHandler(updateJsonPath);
updateDomain.on('data', receiveMessageFromNode);
updateDomain.exec('initNode', {
messageIds: MessageIds,
updateDir: updateDir,
requester: domainID
});
} | [
"function",
"setupAutoUpdate",
"(",
")",
"{",
"updateJsonHandler",
"=",
"new",
"StateHandler",
"(",
"updateJsonPath",
")",
";",
"updateDomain",
".",
"on",
"(",
"'data'",
",",
"receiveMessageFromNode",
")",
";",
"updateDomain",
".",
"exec",
"(",
"'initNode'",
",",
"{",
"messageIds",
":",
"MessageIds",
",",
"updateDir",
":",
"updateDir",
",",
"requester",
":",
"domainID",
"}",
")",
";",
"}"
] | Sets up the Auto Update environment | [
"Sets",
"up",
"the",
"Auto",
"Update",
"environment"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L320-L329 |
1,902 | adobe/brackets | src/extensions/default/AutoUpdate/main.js | initializeState | function initializeState() {
var result = $.Deferred();
FileSystem.resolve(updateDir, function (err) {
if (!err) {
result.resolve();
} else {
var directory = FileSystem.getDirectoryForPath(updateDir);
directory.create(function (error) {
if (error) {
console.error('AutoUpdate : Error in creating update directory in Appdata');
result.reject();
} else {
result.resolve();
}
});
}
});
return result.promise();
} | javascript | function initializeState() {
var result = $.Deferred();
FileSystem.resolve(updateDir, function (err) {
if (!err) {
result.resolve();
} else {
var directory = FileSystem.getDirectoryForPath(updateDir);
directory.create(function (error) {
if (error) {
console.error('AutoUpdate : Error in creating update directory in Appdata');
result.reject();
} else {
result.resolve();
}
});
}
});
return result.promise();
} | [
"function",
"initializeState",
"(",
")",
"{",
"var",
"result",
"=",
"$",
".",
"Deferred",
"(",
")",
";",
"FileSystem",
".",
"resolve",
"(",
"updateDir",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"!",
"err",
")",
"{",
"result",
".",
"resolve",
"(",
")",
";",
"}",
"else",
"{",
"var",
"directory",
"=",
"FileSystem",
".",
"getDirectoryForPath",
"(",
"updateDir",
")",
";",
"directory",
".",
"create",
"(",
"function",
"(",
"error",
")",
"{",
"if",
"(",
"error",
")",
"{",
"console",
".",
"error",
"(",
"'AutoUpdate : Error in creating update directory in Appdata'",
")",
";",
"result",
".",
"reject",
"(",
")",
";",
"}",
"else",
"{",
"result",
".",
"resolve",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
"}",
")",
";",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] | Initializes the state for AutoUpdate process
@returns {$.Deferred} - a jquery promise,
that is resolved with success or failure
of state initialization | [
"Initializes",
"the",
"state",
"for",
"AutoUpdate",
"process"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L338-L358 |
1,903 | adobe/brackets | src/extensions/default/AutoUpdate/main.js | initiateAutoUpdate | function initiateAutoUpdate(updateParams) {
_updateParams = updateParams;
downloadAttemptsRemaining = MAX_DOWNLOAD_ATTEMPTS;
initializeState()
.done(function () {
var setUpdateInProgress = function() {
var initNodeFn = function () {
isAutoUpdateInitiated = true;
postMessageToNode(MessageIds.INITIALIZE_STATE, _updateParams);
};
if (updateJsonHandler.get('latestBuildNumber') !== _updateParams.latestBuildNumber) {
setUpdateStateInJSON('latestBuildNumber', _updateParams.latestBuildNumber)
.done(initNodeFn);
} else {
initNodeFn();
}
};
checkIfAnotherSessionInProgress()
.done(function(inProgress) {
if(inProgress) {
UpdateInfoBar.showUpdateBar({
type: "error",
title: Strings.AUTOUPDATE_ERROR,
description: Strings.AUTOUPDATE_IN_PROGRESS
});
} else {
setUpdateStateInJSON("autoUpdateInProgress", true)
.done(setUpdateInProgress);
}
})
.fail(function() {
setUpdateStateInJSON("autoUpdateInProgress", true)
.done(setUpdateInProgress);
});
})
.fail(function () {
UpdateInfoBar.showUpdateBar({
type: "error",
title: Strings.INITIALISATION_FAILED,
description: ""
});
});
} | javascript | function initiateAutoUpdate(updateParams) {
_updateParams = updateParams;
downloadAttemptsRemaining = MAX_DOWNLOAD_ATTEMPTS;
initializeState()
.done(function () {
var setUpdateInProgress = function() {
var initNodeFn = function () {
isAutoUpdateInitiated = true;
postMessageToNode(MessageIds.INITIALIZE_STATE, _updateParams);
};
if (updateJsonHandler.get('latestBuildNumber') !== _updateParams.latestBuildNumber) {
setUpdateStateInJSON('latestBuildNumber', _updateParams.latestBuildNumber)
.done(initNodeFn);
} else {
initNodeFn();
}
};
checkIfAnotherSessionInProgress()
.done(function(inProgress) {
if(inProgress) {
UpdateInfoBar.showUpdateBar({
type: "error",
title: Strings.AUTOUPDATE_ERROR,
description: Strings.AUTOUPDATE_IN_PROGRESS
});
} else {
setUpdateStateInJSON("autoUpdateInProgress", true)
.done(setUpdateInProgress);
}
})
.fail(function() {
setUpdateStateInJSON("autoUpdateInProgress", true)
.done(setUpdateInProgress);
});
})
.fail(function () {
UpdateInfoBar.showUpdateBar({
type: "error",
title: Strings.INITIALISATION_FAILED,
description: ""
});
});
} | [
"function",
"initiateAutoUpdate",
"(",
"updateParams",
")",
"{",
"_updateParams",
"=",
"updateParams",
";",
"downloadAttemptsRemaining",
"=",
"MAX_DOWNLOAD_ATTEMPTS",
";",
"initializeState",
"(",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"var",
"setUpdateInProgress",
"=",
"function",
"(",
")",
"{",
"var",
"initNodeFn",
"=",
"function",
"(",
")",
"{",
"isAutoUpdateInitiated",
"=",
"true",
";",
"postMessageToNode",
"(",
"MessageIds",
".",
"INITIALIZE_STATE",
",",
"_updateParams",
")",
";",
"}",
";",
"if",
"(",
"updateJsonHandler",
".",
"get",
"(",
"'latestBuildNumber'",
")",
"!==",
"_updateParams",
".",
"latestBuildNumber",
")",
"{",
"setUpdateStateInJSON",
"(",
"'latestBuildNumber'",
",",
"_updateParams",
".",
"latestBuildNumber",
")",
".",
"done",
"(",
"initNodeFn",
")",
";",
"}",
"else",
"{",
"initNodeFn",
"(",
")",
";",
"}",
"}",
";",
"checkIfAnotherSessionInProgress",
"(",
")",
".",
"done",
"(",
"function",
"(",
"inProgress",
")",
"{",
"if",
"(",
"inProgress",
")",
"{",
"UpdateInfoBar",
".",
"showUpdateBar",
"(",
"{",
"type",
":",
"\"error\"",
",",
"title",
":",
"Strings",
".",
"AUTOUPDATE_ERROR",
",",
"description",
":",
"Strings",
".",
"AUTOUPDATE_IN_PROGRESS",
"}",
")",
";",
"}",
"else",
"{",
"setUpdateStateInJSON",
"(",
"\"autoUpdateInProgress\"",
",",
"true",
")",
".",
"done",
"(",
"setUpdateInProgress",
")",
";",
"}",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"setUpdateStateInJSON",
"(",
"\"autoUpdateInProgress\"",
",",
"true",
")",
".",
"done",
"(",
"setUpdateInProgress",
")",
";",
"}",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"UpdateInfoBar",
".",
"showUpdateBar",
"(",
"{",
"type",
":",
"\"error\"",
",",
"title",
":",
"Strings",
".",
"INITIALISATION_FAILED",
",",
"description",
":",
"\"\"",
"}",
")",
";",
"}",
")",
";",
"}"
] | Handles the auto update event, which is triggered when user clicks GetItNow in UpdateNotification dialog
@param {object} updateParams - json object containing update information {
installerName - name of the installer
downloadURL - download URL
latestBuildNumber - build number
checksum - checksum } | [
"Handles",
"the",
"auto",
"update",
"event",
"which",
"is",
"triggered",
"when",
"user",
"clicks",
"GetItNow",
"in",
"UpdateNotification",
"dialog"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L370-L419 |
1,904 | adobe/brackets | src/extensions/default/AutoUpdate/main.js | resetStateInFailure | function resetStateInFailure(message) {
updateJsonHandler.reset();
UpdateInfoBar.showUpdateBar({
type: "error",
title: Strings.UPDATE_FAILED,
description: ""
});
enableCheckForUpdateEntry(true);
console.error(message);
} | javascript | function resetStateInFailure(message) {
updateJsonHandler.reset();
UpdateInfoBar.showUpdateBar({
type: "error",
title: Strings.UPDATE_FAILED,
description: ""
});
enableCheckForUpdateEntry(true);
console.error(message);
} | [
"function",
"resetStateInFailure",
"(",
"message",
")",
"{",
"updateJsonHandler",
".",
"reset",
"(",
")",
";",
"UpdateInfoBar",
".",
"showUpdateBar",
"(",
"{",
"type",
":",
"\"error\"",
",",
"title",
":",
"Strings",
".",
"UPDATE_FAILED",
",",
"description",
":",
"\"\"",
"}",
")",
";",
"enableCheckForUpdateEntry",
"(",
"true",
")",
";",
"console",
".",
"error",
"(",
"message",
")",
";",
"}"
] | Resets the update state in updatehelper.json in case of failure,
and logs an error with the message
@param {string} message - the message to be logged onto console | [
"Resets",
"the",
"update",
"state",
"in",
"updatehelper",
".",
"json",
"in",
"case",
"of",
"failure",
"and",
"logs",
"an",
"error",
"with",
"the",
"message"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L611-L623 |
1,905 | adobe/brackets | src/extensions/default/AutoUpdate/main.js | setUpdateStateInJSON | function setUpdateStateInJSON(key, value) {
var result = $.Deferred();
updateJsonHandler.set(key, value)
.done(function () {
result.resolve();
})
.fail(function () {
resetStateInFailure("AutoUpdate : Could not modify updatehelper.json");
result.reject();
});
return result.promise();
} | javascript | function setUpdateStateInJSON(key, value) {
var result = $.Deferred();
updateJsonHandler.set(key, value)
.done(function () {
result.resolve();
})
.fail(function () {
resetStateInFailure("AutoUpdate : Could not modify updatehelper.json");
result.reject();
});
return result.promise();
} | [
"function",
"setUpdateStateInJSON",
"(",
"key",
",",
"value",
")",
"{",
"var",
"result",
"=",
"$",
".",
"Deferred",
"(",
")",
";",
"updateJsonHandler",
".",
"set",
"(",
"key",
",",
"value",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"result",
".",
"resolve",
"(",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"resetStateInFailure",
"(",
"\"AutoUpdate : Could not modify updatehelper.json\"",
")",
";",
"result",
".",
"reject",
"(",
")",
";",
"}",
")",
";",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] | Sets the update state in updateHelper.json in Appdata
@param {string} key - key to be set
@param {string} value - value to be set
@returns {$.Deferred} - a jquery promise, that is resolved with
success or failure of state update in json file | [
"Sets",
"the",
"update",
"state",
"in",
"updateHelper",
".",
"json",
"in",
"Appdata"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L632-L644 |
1,906 | adobe/brackets | src/extensions/default/AutoUpdate/main.js | handleSafeToDownload | function handleSafeToDownload() {
var downloadFn = function () {
if (isFirstIterationDownload()) {
// For the first iteration of download, show download
//status info in Status bar, and pass download to node
UpdateStatus.showUpdateStatus("initial-download");
postMessageToNode(MessageIds.DOWNLOAD_INSTALLER, true);
} else {
/* For the retry iterations of download, modify the
download status info in Status bar, and pass download to node */
var attempt = (MAX_DOWNLOAD_ATTEMPTS - downloadAttemptsRemaining);
if (attempt > 1) {
var info = attempt.toString() + "/5";
var status = {
target: "retry-download",
spans: [{
id: "attempt",
val: info
}]
};
UpdateStatus.modifyUpdateStatus(status);
} else {
UpdateStatus.showUpdateStatus("retry-download");
}
postMessageToNode(MessageIds.DOWNLOAD_INSTALLER, false);
}
--downloadAttemptsRemaining;
};
if(!isAutoUpdateInitiated) {
isAutoUpdateInitiated = true;
updateJsonHandler.refresh()
.done(function() {
setUpdateStateInJSON('downloadCompleted', false)
.done(downloadFn);
});
} else {
setUpdateStateInJSON('downloadCompleted', false)
.done(downloadFn);
}
} | javascript | function handleSafeToDownload() {
var downloadFn = function () {
if (isFirstIterationDownload()) {
// For the first iteration of download, show download
//status info in Status bar, and pass download to node
UpdateStatus.showUpdateStatus("initial-download");
postMessageToNode(MessageIds.DOWNLOAD_INSTALLER, true);
} else {
/* For the retry iterations of download, modify the
download status info in Status bar, and pass download to node */
var attempt = (MAX_DOWNLOAD_ATTEMPTS - downloadAttemptsRemaining);
if (attempt > 1) {
var info = attempt.toString() + "/5";
var status = {
target: "retry-download",
spans: [{
id: "attempt",
val: info
}]
};
UpdateStatus.modifyUpdateStatus(status);
} else {
UpdateStatus.showUpdateStatus("retry-download");
}
postMessageToNode(MessageIds.DOWNLOAD_INSTALLER, false);
}
--downloadAttemptsRemaining;
};
if(!isAutoUpdateInitiated) {
isAutoUpdateInitiated = true;
updateJsonHandler.refresh()
.done(function() {
setUpdateStateInJSON('downloadCompleted', false)
.done(downloadFn);
});
} else {
setUpdateStateInJSON('downloadCompleted', false)
.done(downloadFn);
}
} | [
"function",
"handleSafeToDownload",
"(",
")",
"{",
"var",
"downloadFn",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"isFirstIterationDownload",
"(",
")",
")",
"{",
"// For the first iteration of download, show download",
"//status info in Status bar, and pass download to node",
"UpdateStatus",
".",
"showUpdateStatus",
"(",
"\"initial-download\"",
")",
";",
"postMessageToNode",
"(",
"MessageIds",
".",
"DOWNLOAD_INSTALLER",
",",
"true",
")",
";",
"}",
"else",
"{",
"/* For the retry iterations of download, modify the\n download status info in Status bar, and pass download to node */",
"var",
"attempt",
"=",
"(",
"MAX_DOWNLOAD_ATTEMPTS",
"-",
"downloadAttemptsRemaining",
")",
";",
"if",
"(",
"attempt",
">",
"1",
")",
"{",
"var",
"info",
"=",
"attempt",
".",
"toString",
"(",
")",
"+",
"\"/5\"",
";",
"var",
"status",
"=",
"{",
"target",
":",
"\"retry-download\"",
",",
"spans",
":",
"[",
"{",
"id",
":",
"\"attempt\"",
",",
"val",
":",
"info",
"}",
"]",
"}",
";",
"UpdateStatus",
".",
"modifyUpdateStatus",
"(",
"status",
")",
";",
"}",
"else",
"{",
"UpdateStatus",
".",
"showUpdateStatus",
"(",
"\"retry-download\"",
")",
";",
"}",
"postMessageToNode",
"(",
"MessageIds",
".",
"DOWNLOAD_INSTALLER",
",",
"false",
")",
";",
"}",
"--",
"downloadAttemptsRemaining",
";",
"}",
";",
"if",
"(",
"!",
"isAutoUpdateInitiated",
")",
"{",
"isAutoUpdateInitiated",
"=",
"true",
";",
"updateJsonHandler",
".",
"refresh",
"(",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"setUpdateStateInJSON",
"(",
"'downloadCompleted'",
",",
"false",
")",
".",
"done",
"(",
"downloadFn",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"setUpdateStateInJSON",
"(",
"'downloadCompleted'",
",",
"false",
")",
".",
"done",
"(",
"downloadFn",
")",
";",
"}",
"}"
] | Handles a safe download of the latest installer,
safety is ensured by cleaning up any pre-existing installers
from update directory before beginning a fresh download | [
"Handles",
"a",
"safe",
"download",
"of",
"the",
"latest",
"installer",
"safety",
"is",
"ensured",
"by",
"cleaning",
"up",
"any",
"pre",
"-",
"existing",
"installers",
"from",
"update",
"directory",
"before",
"beginning",
"a",
"fresh",
"download"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L651-L692 |
1,907 | adobe/brackets | src/extensions/default/AutoUpdate/main.js | attemptToDownload | function attemptToDownload() {
if (checkIfOnline()) {
postMessageToNode(MessageIds.PERFORM_CLEANUP, ['.json'], true);
} else {
enableCheckForUpdateEntry(true);
UpdateStatus.cleanUpdateStatus();
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_FAILED,
"autoUpdate",
"download",
"fail",
"No Internet connection available."
);
UpdateInfoBar.showUpdateBar({
type: "warning",
title: Strings.DOWNLOAD_FAILED,
description: Strings.INTERNET_UNAVAILABLE
});
setUpdateStateInJSON("autoUpdateInProgress", false);
}
} | javascript | function attemptToDownload() {
if (checkIfOnline()) {
postMessageToNode(MessageIds.PERFORM_CLEANUP, ['.json'], true);
} else {
enableCheckForUpdateEntry(true);
UpdateStatus.cleanUpdateStatus();
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_FAILED,
"autoUpdate",
"download",
"fail",
"No Internet connection available."
);
UpdateInfoBar.showUpdateBar({
type: "warning",
title: Strings.DOWNLOAD_FAILED,
description: Strings.INTERNET_UNAVAILABLE
});
setUpdateStateInJSON("autoUpdateInProgress", false);
}
} | [
"function",
"attemptToDownload",
"(",
")",
"{",
"if",
"(",
"checkIfOnline",
"(",
")",
")",
"{",
"postMessageToNode",
"(",
"MessageIds",
".",
"PERFORM_CLEANUP",
",",
"[",
"'.json'",
"]",
",",
"true",
")",
";",
"}",
"else",
"{",
"enableCheckForUpdateEntry",
"(",
"true",
")",
";",
"UpdateStatus",
".",
"cleanUpdateStatus",
"(",
")",
";",
"HealthLogger",
".",
"sendAnalyticsData",
"(",
"autoUpdateEventNames",
".",
"AUTOUPDATE_DOWNLOAD_FAILED",
",",
"\"autoUpdate\"",
",",
"\"download\"",
",",
"\"fail\"",
",",
"\"No Internet connection available.\"",
")",
";",
"UpdateInfoBar",
".",
"showUpdateBar",
"(",
"{",
"type",
":",
"\"warning\"",
",",
"title",
":",
"Strings",
".",
"DOWNLOAD_FAILED",
",",
"description",
":",
"Strings",
".",
"INTERNET_UNAVAILABLE",
"}",
")",
";",
"setUpdateStateInJSON",
"(",
"\"autoUpdateInProgress\"",
",",
"false",
")",
";",
"}",
"}"
] | Attempts a download of the latest installer, while cleaning up any existing downloaded installers | [
"Attempts",
"a",
"download",
"of",
"the",
"latest",
"installer",
"while",
"cleaning",
"up",
"any",
"existing",
"downloaded",
"installers"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L705-L726 |
1,908 | adobe/brackets | src/extensions/default/AutoUpdate/main.js | showStatusInfo | function showStatusInfo(statusObj) {
if (statusObj.target === "initial-download") {
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_START,
"autoUpdate",
"download",
"started",
""
);
UpdateStatus.modifyUpdateStatus(statusObj);
}
UpdateStatus.displayProgress(statusObj);
} | javascript | function showStatusInfo(statusObj) {
if (statusObj.target === "initial-download") {
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_START,
"autoUpdate",
"download",
"started",
""
);
UpdateStatus.modifyUpdateStatus(statusObj);
}
UpdateStatus.displayProgress(statusObj);
} | [
"function",
"showStatusInfo",
"(",
"statusObj",
")",
"{",
"if",
"(",
"statusObj",
".",
"target",
"===",
"\"initial-download\"",
")",
"{",
"HealthLogger",
".",
"sendAnalyticsData",
"(",
"autoUpdateEventNames",
".",
"AUTOUPDATE_DOWNLOAD_START",
",",
"\"autoUpdate\"",
",",
"\"download\"",
",",
"\"started\"",
",",
"\"\"",
")",
";",
"UpdateStatus",
".",
"modifyUpdateStatus",
"(",
"statusObj",
")",
";",
"}",
"UpdateStatus",
".",
"displayProgress",
"(",
"statusObj",
")",
";",
"}"
] | Handles the show status information callback from Node.
It modifies the info displayed on Status bar.
@param {object} statusObj - json containing status info {
target - id of string to display,
spans - Array containing json objects of type - {
id - span id,
val - string to fill the span element with }
} | [
"Handles",
"the",
"show",
"status",
"information",
"callback",
"from",
"Node",
".",
"It",
"modifies",
"the",
"info",
"displayed",
"on",
"Status",
"bar",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L760-L772 |
1,909 | adobe/brackets | src/extensions/default/AutoUpdate/main.js | showErrorMessage | function showErrorMessage(message) {
var analyticsDescriptionMessage = "";
switch (message) {
case _nodeErrorMessages.UPDATEDIR_READ_FAILED:
analyticsDescriptionMessage = "Update directory could not be read.";
break;
case _nodeErrorMessages.UPDATEDIR_CLEAN_FAILED:
analyticsDescriptionMessage = "Update directory could not be cleaned.";
break;
}
console.log("AutoUpdate : Clean-up failed! Reason : " + analyticsDescriptionMessage + ".\n");
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_CLEANUP_FAILED,
"autoUpdate",
"cleanUp",
"fail",
analyticsDescriptionMessage
);
} | javascript | function showErrorMessage(message) {
var analyticsDescriptionMessage = "";
switch (message) {
case _nodeErrorMessages.UPDATEDIR_READ_FAILED:
analyticsDescriptionMessage = "Update directory could not be read.";
break;
case _nodeErrorMessages.UPDATEDIR_CLEAN_FAILED:
analyticsDescriptionMessage = "Update directory could not be cleaned.";
break;
}
console.log("AutoUpdate : Clean-up failed! Reason : " + analyticsDescriptionMessage + ".\n");
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_CLEANUP_FAILED,
"autoUpdate",
"cleanUp",
"fail",
analyticsDescriptionMessage
);
} | [
"function",
"showErrorMessage",
"(",
"message",
")",
"{",
"var",
"analyticsDescriptionMessage",
"=",
"\"\"",
";",
"switch",
"(",
"message",
")",
"{",
"case",
"_nodeErrorMessages",
".",
"UPDATEDIR_READ_FAILED",
":",
"analyticsDescriptionMessage",
"=",
"\"Update directory could not be read.\"",
";",
"break",
";",
"case",
"_nodeErrorMessages",
".",
"UPDATEDIR_CLEAN_FAILED",
":",
"analyticsDescriptionMessage",
"=",
"\"Update directory could not be cleaned.\"",
";",
"break",
";",
"}",
"console",
".",
"log",
"(",
"\"AutoUpdate : Clean-up failed! Reason : \"",
"+",
"analyticsDescriptionMessage",
"+",
"\".\\n\"",
")",
";",
"HealthLogger",
".",
"sendAnalyticsData",
"(",
"autoUpdateEventNames",
".",
"AUTOUPDATE_CLEANUP_FAILED",
",",
"\"autoUpdate\"",
",",
"\"cleanUp\"",
",",
"\"fail\"",
",",
"analyticsDescriptionMessage",
")",
";",
"}"
] | Handles the error messages from Node, in a popup displayed to the user.
@param {string} message - error string | [
"Handles",
"the",
"error",
"messages",
"from",
"Node",
"in",
"a",
"popup",
"displayed",
"to",
"the",
"user",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L778-L797 |
1,910 | adobe/brackets | src/extensions/default/AutoUpdate/main.js | initiateUpdateProcess | function initiateUpdateProcess(formattedInstallerPath, formattedLogFilePath, installStatusFilePath) {
// Get additional update parameters on Mac : installDir, appName, and updateDir
function getAdditionalParams() {
var retval = {};
var installDir = FileUtils.getNativeBracketsDirectoryPath();
if (installDir) {
var appPath = installDir.split("/Contents/www")[0];
installDir = appPath.substr(0, appPath.lastIndexOf('/'));
var appName = appPath.substr(appPath.lastIndexOf('/') + 1);
retval = {
installDir: installDir,
appName: appName,
updateDir: updateDir
};
}
return retval;
}
// Update function, to carry out app update
var updateFn = function () {
var infoObj = {
installerPath: formattedInstallerPath,
logFilePath: formattedLogFilePath,
installStatusFilePath: installStatusFilePath
};
if (brackets.platform === "mac") {
var additionalParams = getAdditionalParams(),
key;
for (key in additionalParams) {
if (additionalParams.hasOwnProperty(key)) {
infoObj[key] = additionalParams[key];
}
}
}
// Set update parameters for app update
if (brackets.app.setUpdateParams) {
brackets.app.setUpdateParams(JSON.stringify(infoObj), function (err) {
if (err) {
resetStateInFailure("AutoUpdate : Update parameters could not be set for the installer. Error encountered: " + err);
} else {
setAppQuitHandler();
CommandManager.execute(Commands.FILE_QUIT);
}
});
} else {
resetStateInFailure("AutoUpdate : setUpdateParams could not be found in shell");
}
};
setUpdateStateInJSON('updateInitiatedInPrevSession', true)
.done(updateFn);
} | javascript | function initiateUpdateProcess(formattedInstallerPath, formattedLogFilePath, installStatusFilePath) {
// Get additional update parameters on Mac : installDir, appName, and updateDir
function getAdditionalParams() {
var retval = {};
var installDir = FileUtils.getNativeBracketsDirectoryPath();
if (installDir) {
var appPath = installDir.split("/Contents/www")[0];
installDir = appPath.substr(0, appPath.lastIndexOf('/'));
var appName = appPath.substr(appPath.lastIndexOf('/') + 1);
retval = {
installDir: installDir,
appName: appName,
updateDir: updateDir
};
}
return retval;
}
// Update function, to carry out app update
var updateFn = function () {
var infoObj = {
installerPath: formattedInstallerPath,
logFilePath: formattedLogFilePath,
installStatusFilePath: installStatusFilePath
};
if (brackets.platform === "mac") {
var additionalParams = getAdditionalParams(),
key;
for (key in additionalParams) {
if (additionalParams.hasOwnProperty(key)) {
infoObj[key] = additionalParams[key];
}
}
}
// Set update parameters for app update
if (brackets.app.setUpdateParams) {
brackets.app.setUpdateParams(JSON.stringify(infoObj), function (err) {
if (err) {
resetStateInFailure("AutoUpdate : Update parameters could not be set for the installer. Error encountered: " + err);
} else {
setAppQuitHandler();
CommandManager.execute(Commands.FILE_QUIT);
}
});
} else {
resetStateInFailure("AutoUpdate : setUpdateParams could not be found in shell");
}
};
setUpdateStateInJSON('updateInitiatedInPrevSession', true)
.done(updateFn);
} | [
"function",
"initiateUpdateProcess",
"(",
"formattedInstallerPath",
",",
"formattedLogFilePath",
",",
"installStatusFilePath",
")",
"{",
"// Get additional update parameters on Mac : installDir, appName, and updateDir",
"function",
"getAdditionalParams",
"(",
")",
"{",
"var",
"retval",
"=",
"{",
"}",
";",
"var",
"installDir",
"=",
"FileUtils",
".",
"getNativeBracketsDirectoryPath",
"(",
")",
";",
"if",
"(",
"installDir",
")",
"{",
"var",
"appPath",
"=",
"installDir",
".",
"split",
"(",
"\"/Contents/www\"",
")",
"[",
"0",
"]",
";",
"installDir",
"=",
"appPath",
".",
"substr",
"(",
"0",
",",
"appPath",
".",
"lastIndexOf",
"(",
"'/'",
")",
")",
";",
"var",
"appName",
"=",
"appPath",
".",
"substr",
"(",
"appPath",
".",
"lastIndexOf",
"(",
"'/'",
")",
"+",
"1",
")",
";",
"retval",
"=",
"{",
"installDir",
":",
"installDir",
",",
"appName",
":",
"appName",
",",
"updateDir",
":",
"updateDir",
"}",
";",
"}",
"return",
"retval",
";",
"}",
"// Update function, to carry out app update",
"var",
"updateFn",
"=",
"function",
"(",
")",
"{",
"var",
"infoObj",
"=",
"{",
"installerPath",
":",
"formattedInstallerPath",
",",
"logFilePath",
":",
"formattedLogFilePath",
",",
"installStatusFilePath",
":",
"installStatusFilePath",
"}",
";",
"if",
"(",
"brackets",
".",
"platform",
"===",
"\"mac\"",
")",
"{",
"var",
"additionalParams",
"=",
"getAdditionalParams",
"(",
")",
",",
"key",
";",
"for",
"(",
"key",
"in",
"additionalParams",
")",
"{",
"if",
"(",
"additionalParams",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"infoObj",
"[",
"key",
"]",
"=",
"additionalParams",
"[",
"key",
"]",
";",
"}",
"}",
"}",
"// Set update parameters for app update",
"if",
"(",
"brackets",
".",
"app",
".",
"setUpdateParams",
")",
"{",
"brackets",
".",
"app",
".",
"setUpdateParams",
"(",
"JSON",
".",
"stringify",
"(",
"infoObj",
")",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"resetStateInFailure",
"(",
"\"AutoUpdate : Update parameters could not be set for the installer. Error encountered: \"",
"+",
"err",
")",
";",
"}",
"else",
"{",
"setAppQuitHandler",
"(",
")",
";",
"CommandManager",
".",
"execute",
"(",
"Commands",
".",
"FILE_QUIT",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"resetStateInFailure",
"(",
"\"AutoUpdate : setUpdateParams could not be found in shell\"",
")",
";",
"}",
"}",
";",
"setUpdateStateInJSON",
"(",
"'updateInitiatedInPrevSession'",
",",
"true",
")",
".",
"done",
"(",
"updateFn",
")",
";",
"}"
] | Initiates the update process, when user clicks UpdateNow in the update popup
@param {string} formattedInstallerPath - formatted path to the latest installer
@param {string} formattedLogFilePath - formatted path to the installer log file
@param {string} installStatusFilePath - path to the install status log file | [
"Initiates",
"the",
"update",
"process",
"when",
"user",
"clicks",
"UpdateNow",
"in",
"the",
"update",
"popup"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L829-L885 |
1,911 | adobe/brackets | src/extensions/default/AutoUpdate/main.js | function () {
var infoObj = {
installerPath: formattedInstallerPath,
logFilePath: formattedLogFilePath,
installStatusFilePath: installStatusFilePath
};
if (brackets.platform === "mac") {
var additionalParams = getAdditionalParams(),
key;
for (key in additionalParams) {
if (additionalParams.hasOwnProperty(key)) {
infoObj[key] = additionalParams[key];
}
}
}
// Set update parameters for app update
if (brackets.app.setUpdateParams) {
brackets.app.setUpdateParams(JSON.stringify(infoObj), function (err) {
if (err) {
resetStateInFailure("AutoUpdate : Update parameters could not be set for the installer. Error encountered: " + err);
} else {
setAppQuitHandler();
CommandManager.execute(Commands.FILE_QUIT);
}
});
} else {
resetStateInFailure("AutoUpdate : setUpdateParams could not be found in shell");
}
} | javascript | function () {
var infoObj = {
installerPath: formattedInstallerPath,
logFilePath: formattedLogFilePath,
installStatusFilePath: installStatusFilePath
};
if (brackets.platform === "mac") {
var additionalParams = getAdditionalParams(),
key;
for (key in additionalParams) {
if (additionalParams.hasOwnProperty(key)) {
infoObj[key] = additionalParams[key];
}
}
}
// Set update parameters for app update
if (brackets.app.setUpdateParams) {
brackets.app.setUpdateParams(JSON.stringify(infoObj), function (err) {
if (err) {
resetStateInFailure("AutoUpdate : Update parameters could not be set for the installer. Error encountered: " + err);
} else {
setAppQuitHandler();
CommandManager.execute(Commands.FILE_QUIT);
}
});
} else {
resetStateInFailure("AutoUpdate : setUpdateParams could not be found in shell");
}
} | [
"function",
"(",
")",
"{",
"var",
"infoObj",
"=",
"{",
"installerPath",
":",
"formattedInstallerPath",
",",
"logFilePath",
":",
"formattedLogFilePath",
",",
"installStatusFilePath",
":",
"installStatusFilePath",
"}",
";",
"if",
"(",
"brackets",
".",
"platform",
"===",
"\"mac\"",
")",
"{",
"var",
"additionalParams",
"=",
"getAdditionalParams",
"(",
")",
",",
"key",
";",
"for",
"(",
"key",
"in",
"additionalParams",
")",
"{",
"if",
"(",
"additionalParams",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"infoObj",
"[",
"key",
"]",
"=",
"additionalParams",
"[",
"key",
"]",
";",
"}",
"}",
"}",
"// Set update parameters for app update",
"if",
"(",
"brackets",
".",
"app",
".",
"setUpdateParams",
")",
"{",
"brackets",
".",
"app",
".",
"setUpdateParams",
"(",
"JSON",
".",
"stringify",
"(",
"infoObj",
")",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"resetStateInFailure",
"(",
"\"AutoUpdate : Update parameters could not be set for the installer. Error encountered: \"",
"+",
"err",
")",
";",
"}",
"else",
"{",
"setAppQuitHandler",
"(",
")",
";",
"CommandManager",
".",
"execute",
"(",
"Commands",
".",
"FILE_QUIT",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"resetStateInFailure",
"(",
"\"AutoUpdate : setUpdateParams could not be found in shell\"",
")",
";",
"}",
"}"
] | Update function, to carry out app update | [
"Update",
"function",
"to",
"carry",
"out",
"app",
"update"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L851-L882 |
|
1,912 | adobe/brackets | src/extensions/default/AutoUpdate/main.js | handleValidationStatus | function handleValidationStatus(statusObj) {
enableCheckForUpdateEntry(true);
UpdateStatus.cleanUpdateStatus();
if (statusObj.valid) {
// Installer is validated successfully
var statusValidFn = function () {
// Restart button click handler
var restartBtnClicked = function () {
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_COMPLETE_USER_CLICK_RESTART,
"autoUpdate",
"installNotification",
"installNow ",
"click"
);
detachUpdateBarBtnHandlers();
initiateUpdateProcess(statusObj.installerPath, statusObj.logFilePath, statusObj.installStatusFilePath);
};
// Later button click handler
var laterBtnClicked = function () {
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_COMPLETE_USER_CLICK_LATER,
"autoUpdate",
"installNotification",
"cancel",
"click"
);
detachUpdateBarBtnHandlers();
setUpdateStateInJSON('updateInitiatedInPrevSession', false);
};
//attaching UpdateBar handlers
UpdateInfoBar.on(UpdateInfoBar.RESTART_BTN_CLICKED, restartBtnClicked);
UpdateInfoBar.on(UpdateInfoBar.LATER_BTN_CLICKED, laterBtnClicked);
UpdateInfoBar.showUpdateBar({
title: Strings.DOWNLOAD_COMPLETE,
description: Strings.CLICK_RESTART_TO_UPDATE,
needButtons: true
});
setUpdateStateInJSON("autoUpdateInProgress", false);
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOADCOMPLETE_UPDATE_BAR_RENDERED,
"autoUpdate",
"installNotification",
"render",
""
);
};
if(!isAutoUpdateInitiated) {
isAutoUpdateInitiated = true;
updateJsonHandler.refresh()
.done(function() {
setUpdateStateInJSON('downloadCompleted', true)
.done(statusValidFn);
});
} else {
setUpdateStateInJSON('downloadCompleted', true)
.done(statusValidFn);
}
} else {
// Installer validation failed
if (updateJsonHandler.get("downloadCompleted")) {
// If this was a cached download, retry downloading
updateJsonHandler.reset();
var statusInvalidFn = function () {
downloadAttemptsRemaining = MAX_DOWNLOAD_ATTEMPTS;
getLatestInstaller();
};
setUpdateStateInJSON('downloadCompleted', false)
.done(statusInvalidFn);
} else {
// If this is a new download, prompt the message on update bar
var descriptionMessage = "",
analyticsDescriptionMessage = "";
switch (statusObj.err) {
case _nodeErrorMessages.CHECKSUM_DID_NOT_MATCH:
descriptionMessage = Strings.CHECKSUM_DID_NOT_MATCH;
analyticsDescriptionMessage = "Checksum didn't match.";
break;
case _nodeErrorMessages.INSTALLER_NOT_FOUND:
descriptionMessage = Strings.INSTALLER_NOT_FOUND;
analyticsDescriptionMessage = "Installer not found.";
break;
}
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_FAILED,
"autoUpdate",
"download",
"fail",
analyticsDescriptionMessage
);
UpdateInfoBar.showUpdateBar({
type: "error",
title: Strings.VALIDATION_FAILED,
description: descriptionMessage
});
setUpdateStateInJSON("autoUpdateInProgress", false);
}
}
} | javascript | function handleValidationStatus(statusObj) {
enableCheckForUpdateEntry(true);
UpdateStatus.cleanUpdateStatus();
if (statusObj.valid) {
// Installer is validated successfully
var statusValidFn = function () {
// Restart button click handler
var restartBtnClicked = function () {
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_COMPLETE_USER_CLICK_RESTART,
"autoUpdate",
"installNotification",
"installNow ",
"click"
);
detachUpdateBarBtnHandlers();
initiateUpdateProcess(statusObj.installerPath, statusObj.logFilePath, statusObj.installStatusFilePath);
};
// Later button click handler
var laterBtnClicked = function () {
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_COMPLETE_USER_CLICK_LATER,
"autoUpdate",
"installNotification",
"cancel",
"click"
);
detachUpdateBarBtnHandlers();
setUpdateStateInJSON('updateInitiatedInPrevSession', false);
};
//attaching UpdateBar handlers
UpdateInfoBar.on(UpdateInfoBar.RESTART_BTN_CLICKED, restartBtnClicked);
UpdateInfoBar.on(UpdateInfoBar.LATER_BTN_CLICKED, laterBtnClicked);
UpdateInfoBar.showUpdateBar({
title: Strings.DOWNLOAD_COMPLETE,
description: Strings.CLICK_RESTART_TO_UPDATE,
needButtons: true
});
setUpdateStateInJSON("autoUpdateInProgress", false);
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOADCOMPLETE_UPDATE_BAR_RENDERED,
"autoUpdate",
"installNotification",
"render",
""
);
};
if(!isAutoUpdateInitiated) {
isAutoUpdateInitiated = true;
updateJsonHandler.refresh()
.done(function() {
setUpdateStateInJSON('downloadCompleted', true)
.done(statusValidFn);
});
} else {
setUpdateStateInJSON('downloadCompleted', true)
.done(statusValidFn);
}
} else {
// Installer validation failed
if (updateJsonHandler.get("downloadCompleted")) {
// If this was a cached download, retry downloading
updateJsonHandler.reset();
var statusInvalidFn = function () {
downloadAttemptsRemaining = MAX_DOWNLOAD_ATTEMPTS;
getLatestInstaller();
};
setUpdateStateInJSON('downloadCompleted', false)
.done(statusInvalidFn);
} else {
// If this is a new download, prompt the message on update bar
var descriptionMessage = "",
analyticsDescriptionMessage = "";
switch (statusObj.err) {
case _nodeErrorMessages.CHECKSUM_DID_NOT_MATCH:
descriptionMessage = Strings.CHECKSUM_DID_NOT_MATCH;
analyticsDescriptionMessage = "Checksum didn't match.";
break;
case _nodeErrorMessages.INSTALLER_NOT_FOUND:
descriptionMessage = Strings.INSTALLER_NOT_FOUND;
analyticsDescriptionMessage = "Installer not found.";
break;
}
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_FAILED,
"autoUpdate",
"download",
"fail",
analyticsDescriptionMessage
);
UpdateInfoBar.showUpdateBar({
type: "error",
title: Strings.VALIDATION_FAILED,
description: descriptionMessage
});
setUpdateStateInJSON("autoUpdateInProgress", false);
}
}
} | [
"function",
"handleValidationStatus",
"(",
"statusObj",
")",
"{",
"enableCheckForUpdateEntry",
"(",
"true",
")",
";",
"UpdateStatus",
".",
"cleanUpdateStatus",
"(",
")",
";",
"if",
"(",
"statusObj",
".",
"valid",
")",
"{",
"// Installer is validated successfully",
"var",
"statusValidFn",
"=",
"function",
"(",
")",
"{",
"// Restart button click handler",
"var",
"restartBtnClicked",
"=",
"function",
"(",
")",
"{",
"HealthLogger",
".",
"sendAnalyticsData",
"(",
"autoUpdateEventNames",
".",
"AUTOUPDATE_DOWNLOAD_COMPLETE_USER_CLICK_RESTART",
",",
"\"autoUpdate\"",
",",
"\"installNotification\"",
",",
"\"installNow \"",
",",
"\"click\"",
")",
";",
"detachUpdateBarBtnHandlers",
"(",
")",
";",
"initiateUpdateProcess",
"(",
"statusObj",
".",
"installerPath",
",",
"statusObj",
".",
"logFilePath",
",",
"statusObj",
".",
"installStatusFilePath",
")",
";",
"}",
";",
"// Later button click handler",
"var",
"laterBtnClicked",
"=",
"function",
"(",
")",
"{",
"HealthLogger",
".",
"sendAnalyticsData",
"(",
"autoUpdateEventNames",
".",
"AUTOUPDATE_DOWNLOAD_COMPLETE_USER_CLICK_LATER",
",",
"\"autoUpdate\"",
",",
"\"installNotification\"",
",",
"\"cancel\"",
",",
"\"click\"",
")",
";",
"detachUpdateBarBtnHandlers",
"(",
")",
";",
"setUpdateStateInJSON",
"(",
"'updateInitiatedInPrevSession'",
",",
"false",
")",
";",
"}",
";",
"//attaching UpdateBar handlers",
"UpdateInfoBar",
".",
"on",
"(",
"UpdateInfoBar",
".",
"RESTART_BTN_CLICKED",
",",
"restartBtnClicked",
")",
";",
"UpdateInfoBar",
".",
"on",
"(",
"UpdateInfoBar",
".",
"LATER_BTN_CLICKED",
",",
"laterBtnClicked",
")",
";",
"UpdateInfoBar",
".",
"showUpdateBar",
"(",
"{",
"title",
":",
"Strings",
".",
"DOWNLOAD_COMPLETE",
",",
"description",
":",
"Strings",
".",
"CLICK_RESTART_TO_UPDATE",
",",
"needButtons",
":",
"true",
"}",
")",
";",
"setUpdateStateInJSON",
"(",
"\"autoUpdateInProgress\"",
",",
"false",
")",
";",
"HealthLogger",
".",
"sendAnalyticsData",
"(",
"autoUpdateEventNames",
".",
"AUTOUPDATE_DOWNLOADCOMPLETE_UPDATE_BAR_RENDERED",
",",
"\"autoUpdate\"",
",",
"\"installNotification\"",
",",
"\"render\"",
",",
"\"\"",
")",
";",
"}",
";",
"if",
"(",
"!",
"isAutoUpdateInitiated",
")",
"{",
"isAutoUpdateInitiated",
"=",
"true",
";",
"updateJsonHandler",
".",
"refresh",
"(",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"setUpdateStateInJSON",
"(",
"'downloadCompleted'",
",",
"true",
")",
".",
"done",
"(",
"statusValidFn",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"setUpdateStateInJSON",
"(",
"'downloadCompleted'",
",",
"true",
")",
".",
"done",
"(",
"statusValidFn",
")",
";",
"}",
"}",
"else",
"{",
"// Installer validation failed",
"if",
"(",
"updateJsonHandler",
".",
"get",
"(",
"\"downloadCompleted\"",
")",
")",
"{",
"// If this was a cached download, retry downloading",
"updateJsonHandler",
".",
"reset",
"(",
")",
";",
"var",
"statusInvalidFn",
"=",
"function",
"(",
")",
"{",
"downloadAttemptsRemaining",
"=",
"MAX_DOWNLOAD_ATTEMPTS",
";",
"getLatestInstaller",
"(",
")",
";",
"}",
";",
"setUpdateStateInJSON",
"(",
"'downloadCompleted'",
",",
"false",
")",
".",
"done",
"(",
"statusInvalidFn",
")",
";",
"}",
"else",
"{",
"// If this is a new download, prompt the message on update bar",
"var",
"descriptionMessage",
"=",
"\"\"",
",",
"analyticsDescriptionMessage",
"=",
"\"\"",
";",
"switch",
"(",
"statusObj",
".",
"err",
")",
"{",
"case",
"_nodeErrorMessages",
".",
"CHECKSUM_DID_NOT_MATCH",
":",
"descriptionMessage",
"=",
"Strings",
".",
"CHECKSUM_DID_NOT_MATCH",
";",
"analyticsDescriptionMessage",
"=",
"\"Checksum didn't match.\"",
";",
"break",
";",
"case",
"_nodeErrorMessages",
".",
"INSTALLER_NOT_FOUND",
":",
"descriptionMessage",
"=",
"Strings",
".",
"INSTALLER_NOT_FOUND",
";",
"analyticsDescriptionMessage",
"=",
"\"Installer not found.\"",
";",
"break",
";",
"}",
"HealthLogger",
".",
"sendAnalyticsData",
"(",
"autoUpdateEventNames",
".",
"AUTOUPDATE_DOWNLOAD_FAILED",
",",
"\"autoUpdate\"",
",",
"\"download\"",
",",
"\"fail\"",
",",
"analyticsDescriptionMessage",
")",
";",
"UpdateInfoBar",
".",
"showUpdateBar",
"(",
"{",
"type",
":",
"\"error\"",
",",
"title",
":",
"Strings",
".",
"VALIDATION_FAILED",
",",
"description",
":",
"descriptionMessage",
"}",
")",
";",
"setUpdateStateInJSON",
"(",
"\"autoUpdateInProgress\"",
",",
"false",
")",
";",
"}",
"}",
"}"
] | Handles the installer validation callback from Node
@param {object} statusObj - json containing - {
valid - (boolean)true for a valid installer, false otherwise,
installerPath, logFilePath,
installStatusFilePath - for a valid installer,
err - for an invalid installer } | [
"Handles",
"the",
"installer",
"validation",
"callback",
"from",
"Node"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L904-L1018 |
1,913 | adobe/brackets | src/extensions/default/AutoUpdate/main.js | function () {
// Restart button click handler
var restartBtnClicked = function () {
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_COMPLETE_USER_CLICK_RESTART,
"autoUpdate",
"installNotification",
"installNow ",
"click"
);
detachUpdateBarBtnHandlers();
initiateUpdateProcess(statusObj.installerPath, statusObj.logFilePath, statusObj.installStatusFilePath);
};
// Later button click handler
var laterBtnClicked = function () {
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_COMPLETE_USER_CLICK_LATER,
"autoUpdate",
"installNotification",
"cancel",
"click"
);
detachUpdateBarBtnHandlers();
setUpdateStateInJSON('updateInitiatedInPrevSession', false);
};
//attaching UpdateBar handlers
UpdateInfoBar.on(UpdateInfoBar.RESTART_BTN_CLICKED, restartBtnClicked);
UpdateInfoBar.on(UpdateInfoBar.LATER_BTN_CLICKED, laterBtnClicked);
UpdateInfoBar.showUpdateBar({
title: Strings.DOWNLOAD_COMPLETE,
description: Strings.CLICK_RESTART_TO_UPDATE,
needButtons: true
});
setUpdateStateInJSON("autoUpdateInProgress", false);
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOADCOMPLETE_UPDATE_BAR_RENDERED,
"autoUpdate",
"installNotification",
"render",
""
);
} | javascript | function () {
// Restart button click handler
var restartBtnClicked = function () {
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_COMPLETE_USER_CLICK_RESTART,
"autoUpdate",
"installNotification",
"installNow ",
"click"
);
detachUpdateBarBtnHandlers();
initiateUpdateProcess(statusObj.installerPath, statusObj.logFilePath, statusObj.installStatusFilePath);
};
// Later button click handler
var laterBtnClicked = function () {
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_COMPLETE_USER_CLICK_LATER,
"autoUpdate",
"installNotification",
"cancel",
"click"
);
detachUpdateBarBtnHandlers();
setUpdateStateInJSON('updateInitiatedInPrevSession', false);
};
//attaching UpdateBar handlers
UpdateInfoBar.on(UpdateInfoBar.RESTART_BTN_CLICKED, restartBtnClicked);
UpdateInfoBar.on(UpdateInfoBar.LATER_BTN_CLICKED, laterBtnClicked);
UpdateInfoBar.showUpdateBar({
title: Strings.DOWNLOAD_COMPLETE,
description: Strings.CLICK_RESTART_TO_UPDATE,
needButtons: true
});
setUpdateStateInJSON("autoUpdateInProgress", false);
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOADCOMPLETE_UPDATE_BAR_RENDERED,
"autoUpdate",
"installNotification",
"render",
""
);
} | [
"function",
"(",
")",
"{",
"// Restart button click handler",
"var",
"restartBtnClicked",
"=",
"function",
"(",
")",
"{",
"HealthLogger",
".",
"sendAnalyticsData",
"(",
"autoUpdateEventNames",
".",
"AUTOUPDATE_DOWNLOAD_COMPLETE_USER_CLICK_RESTART",
",",
"\"autoUpdate\"",
",",
"\"installNotification\"",
",",
"\"installNow \"",
",",
"\"click\"",
")",
";",
"detachUpdateBarBtnHandlers",
"(",
")",
";",
"initiateUpdateProcess",
"(",
"statusObj",
".",
"installerPath",
",",
"statusObj",
".",
"logFilePath",
",",
"statusObj",
".",
"installStatusFilePath",
")",
";",
"}",
";",
"// Later button click handler",
"var",
"laterBtnClicked",
"=",
"function",
"(",
")",
"{",
"HealthLogger",
".",
"sendAnalyticsData",
"(",
"autoUpdateEventNames",
".",
"AUTOUPDATE_DOWNLOAD_COMPLETE_USER_CLICK_LATER",
",",
"\"autoUpdate\"",
",",
"\"installNotification\"",
",",
"\"cancel\"",
",",
"\"click\"",
")",
";",
"detachUpdateBarBtnHandlers",
"(",
")",
";",
"setUpdateStateInJSON",
"(",
"'updateInitiatedInPrevSession'",
",",
"false",
")",
";",
"}",
";",
"//attaching UpdateBar handlers",
"UpdateInfoBar",
".",
"on",
"(",
"UpdateInfoBar",
".",
"RESTART_BTN_CLICKED",
",",
"restartBtnClicked",
")",
";",
"UpdateInfoBar",
".",
"on",
"(",
"UpdateInfoBar",
".",
"LATER_BTN_CLICKED",
",",
"laterBtnClicked",
")",
";",
"UpdateInfoBar",
".",
"showUpdateBar",
"(",
"{",
"title",
":",
"Strings",
".",
"DOWNLOAD_COMPLETE",
",",
"description",
":",
"Strings",
".",
"CLICK_RESTART_TO_UPDATE",
",",
"needButtons",
":",
"true",
"}",
")",
";",
"setUpdateStateInJSON",
"(",
"\"autoUpdateInProgress\"",
",",
"false",
")",
";",
"HealthLogger",
".",
"sendAnalyticsData",
"(",
"autoUpdateEventNames",
".",
"AUTOUPDATE_DOWNLOADCOMPLETE_UPDATE_BAR_RENDERED",
",",
"\"autoUpdate\"",
",",
"\"installNotification\"",
",",
"\"render\"",
",",
"\"\"",
")",
";",
"}"
] | Installer is validated successfully | [
"Installer",
"is",
"validated",
"successfully"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L911-L957 |
|
1,914 | adobe/brackets | src/extensions/default/AutoUpdate/main.js | function () {
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_COMPLETE_USER_CLICK_RESTART,
"autoUpdate",
"installNotification",
"installNow ",
"click"
);
detachUpdateBarBtnHandlers();
initiateUpdateProcess(statusObj.installerPath, statusObj.logFilePath, statusObj.installStatusFilePath);
} | javascript | function () {
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_COMPLETE_USER_CLICK_RESTART,
"autoUpdate",
"installNotification",
"installNow ",
"click"
);
detachUpdateBarBtnHandlers();
initiateUpdateProcess(statusObj.installerPath, statusObj.logFilePath, statusObj.installStatusFilePath);
} | [
"function",
"(",
")",
"{",
"HealthLogger",
".",
"sendAnalyticsData",
"(",
"autoUpdateEventNames",
".",
"AUTOUPDATE_DOWNLOAD_COMPLETE_USER_CLICK_RESTART",
",",
"\"autoUpdate\"",
",",
"\"installNotification\"",
",",
"\"installNow \"",
",",
"\"click\"",
")",
";",
"detachUpdateBarBtnHandlers",
"(",
")",
";",
"initiateUpdateProcess",
"(",
"statusObj",
".",
"installerPath",
",",
"statusObj",
".",
"logFilePath",
",",
"statusObj",
".",
"installStatusFilePath",
")",
";",
"}"
] | Restart button click handler | [
"Restart",
"button",
"click",
"handler"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L914-L924 |
|
1,915 | adobe/brackets | src/extensions/default/AutoUpdate/main.js | handleDownloadFailure | function handleDownloadFailure(message) {
console.log("AutoUpdate : Download of latest installer failed in Attempt " +
(MAX_DOWNLOAD_ATTEMPTS - downloadAttemptsRemaining) + ".\n Reason : " + message);
if (downloadAttemptsRemaining) {
// Retry the downloading
attemptToDownload();
} else {
// Download could not completed, all attempts exhausted
enableCheckForUpdateEntry(true);
UpdateStatus.cleanUpdateStatus();
var descriptionMessage = "",
analyticsDescriptionMessage = "";
if (message === _nodeErrorMessages.DOWNLOAD_ERROR) {
descriptionMessage = Strings.DOWNLOAD_ERROR;
analyticsDescriptionMessage = "Error occurred while downloading.";
} else if (message === _nodeErrorMessages.NETWORK_SLOW_OR_DISCONNECTED) {
descriptionMessage = Strings.NETWORK_SLOW_OR_DISCONNECTED;
analyticsDescriptionMessage = "Network is Disconnected or too slow.";
}
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_FAILED,
"autoUpdate",
"download",
"fail",
analyticsDescriptionMessage
);
UpdateInfoBar.showUpdateBar({
type: "error",
title: Strings.DOWNLOAD_FAILED,
description: descriptionMessage
});
setUpdateStateInJSON("autoUpdateInProgress", false);
}
} | javascript | function handleDownloadFailure(message) {
console.log("AutoUpdate : Download of latest installer failed in Attempt " +
(MAX_DOWNLOAD_ATTEMPTS - downloadAttemptsRemaining) + ".\n Reason : " + message);
if (downloadAttemptsRemaining) {
// Retry the downloading
attemptToDownload();
} else {
// Download could not completed, all attempts exhausted
enableCheckForUpdateEntry(true);
UpdateStatus.cleanUpdateStatus();
var descriptionMessage = "",
analyticsDescriptionMessage = "";
if (message === _nodeErrorMessages.DOWNLOAD_ERROR) {
descriptionMessage = Strings.DOWNLOAD_ERROR;
analyticsDescriptionMessage = "Error occurred while downloading.";
} else if (message === _nodeErrorMessages.NETWORK_SLOW_OR_DISCONNECTED) {
descriptionMessage = Strings.NETWORK_SLOW_OR_DISCONNECTED;
analyticsDescriptionMessage = "Network is Disconnected or too slow.";
}
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_FAILED,
"autoUpdate",
"download",
"fail",
analyticsDescriptionMessage
);
UpdateInfoBar.showUpdateBar({
type: "error",
title: Strings.DOWNLOAD_FAILED,
description: descriptionMessage
});
setUpdateStateInJSON("autoUpdateInProgress", false);
}
} | [
"function",
"handleDownloadFailure",
"(",
"message",
")",
"{",
"console",
".",
"log",
"(",
"\"AutoUpdate : Download of latest installer failed in Attempt \"",
"+",
"(",
"MAX_DOWNLOAD_ATTEMPTS",
"-",
"downloadAttemptsRemaining",
")",
"+",
"\".\\n Reason : \"",
"+",
"message",
")",
";",
"if",
"(",
"downloadAttemptsRemaining",
")",
"{",
"// Retry the downloading",
"attemptToDownload",
"(",
")",
";",
"}",
"else",
"{",
"// Download could not completed, all attempts exhausted",
"enableCheckForUpdateEntry",
"(",
"true",
")",
";",
"UpdateStatus",
".",
"cleanUpdateStatus",
"(",
")",
";",
"var",
"descriptionMessage",
"=",
"\"\"",
",",
"analyticsDescriptionMessage",
"=",
"\"\"",
";",
"if",
"(",
"message",
"===",
"_nodeErrorMessages",
".",
"DOWNLOAD_ERROR",
")",
"{",
"descriptionMessage",
"=",
"Strings",
".",
"DOWNLOAD_ERROR",
";",
"analyticsDescriptionMessage",
"=",
"\"Error occurred while downloading.\"",
";",
"}",
"else",
"if",
"(",
"message",
"===",
"_nodeErrorMessages",
".",
"NETWORK_SLOW_OR_DISCONNECTED",
")",
"{",
"descriptionMessage",
"=",
"Strings",
".",
"NETWORK_SLOW_OR_DISCONNECTED",
";",
"analyticsDescriptionMessage",
"=",
"\"Network is Disconnected or too slow.\"",
";",
"}",
"HealthLogger",
".",
"sendAnalyticsData",
"(",
"autoUpdateEventNames",
".",
"AUTOUPDATE_DOWNLOAD_FAILED",
",",
"\"autoUpdate\"",
",",
"\"download\"",
",",
"\"fail\"",
",",
"analyticsDescriptionMessage",
")",
";",
"UpdateInfoBar",
".",
"showUpdateBar",
"(",
"{",
"type",
":",
"\"error\"",
",",
"title",
":",
"Strings",
".",
"DOWNLOAD_FAILED",
",",
"description",
":",
"descriptionMessage",
"}",
")",
";",
"setUpdateStateInJSON",
"(",
"\"autoUpdateInProgress\"",
",",
"false",
")",
";",
"}",
"}"
] | Handles the download failure callback from Node
@param {string} message - reason of download failure | [
"Handles",
"the",
"download",
"failure",
"callback",
"from",
"Node"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L1024-L1063 |
1,916 | adobe/brackets | src/extensions/default/AutoUpdate/main.js | registerBracketsFunctions | function registerBracketsFunctions() {
functionMap["brackets.notifyinitializationComplete"] = handleInitializationComplete;
functionMap["brackets.showStatusInfo"] = showStatusInfo;
functionMap["brackets.notifyDownloadSuccess"] = handleDownloadSuccess;
functionMap["brackets.showErrorMessage"] = showErrorMessage;
functionMap["brackets.notifyDownloadFailure"] = handleDownloadFailure;
functionMap["brackets.notifySafeToDownload"] = handleSafeToDownload;
functionMap["brackets.notifyvalidationStatus"] = handleValidationStatus;
functionMap["brackets.notifyInstallationStatus"] = handleInstallationStatus;
ProjectManager.on("beforeProjectClose beforeAppClose", _handleAppClose);
} | javascript | function registerBracketsFunctions() {
functionMap["brackets.notifyinitializationComplete"] = handleInitializationComplete;
functionMap["brackets.showStatusInfo"] = showStatusInfo;
functionMap["brackets.notifyDownloadSuccess"] = handleDownloadSuccess;
functionMap["brackets.showErrorMessage"] = showErrorMessage;
functionMap["brackets.notifyDownloadFailure"] = handleDownloadFailure;
functionMap["brackets.notifySafeToDownload"] = handleSafeToDownload;
functionMap["brackets.notifyvalidationStatus"] = handleValidationStatus;
functionMap["brackets.notifyInstallationStatus"] = handleInstallationStatus;
ProjectManager.on("beforeProjectClose beforeAppClose", _handleAppClose);
} | [
"function",
"registerBracketsFunctions",
"(",
")",
"{",
"functionMap",
"[",
"\"brackets.notifyinitializationComplete\"",
"]",
"=",
"handleInitializationComplete",
";",
"functionMap",
"[",
"\"brackets.showStatusInfo\"",
"]",
"=",
"showStatusInfo",
";",
"functionMap",
"[",
"\"brackets.notifyDownloadSuccess\"",
"]",
"=",
"handleDownloadSuccess",
";",
"functionMap",
"[",
"\"brackets.showErrorMessage\"",
"]",
"=",
"showErrorMessage",
";",
"functionMap",
"[",
"\"brackets.notifyDownloadFailure\"",
"]",
"=",
"handleDownloadFailure",
";",
"functionMap",
"[",
"\"brackets.notifySafeToDownload\"",
"]",
"=",
"handleSafeToDownload",
";",
"functionMap",
"[",
"\"brackets.notifyvalidationStatus\"",
"]",
"=",
"handleValidationStatus",
";",
"functionMap",
"[",
"\"brackets.notifyInstallationStatus\"",
"]",
"=",
"handleInstallationStatus",
";",
"ProjectManager",
".",
"on",
"(",
"\"beforeProjectClose beforeAppClose\"",
",",
"_handleAppClose",
")",
";",
"}"
] | Generates a map for brackets side functions | [
"Generates",
"a",
"map",
"for",
"brackets",
"side",
"functions"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L1098-L1109 |
1,917 | adobe/brackets | src/extensions/default/MDNDocs/main.js | inlineProvider | function inlineProvider(hostEditor, pos) {
var jsonFile, propInfo,
propQueue = [], // priority queue of propNames to try
langId = hostEditor.getLanguageForSelection().getId(),
supportedLangs = {
"css": true,
"scss": true,
"less": true,
"html": true
},
isQuickDocAvailable = langId ? supportedLangs[langId] : -1; // fail if langId is falsy
// Only provide docs when cursor is in supported language
if (!isQuickDocAvailable) {
return null;
}
// Send analytics data for Quick Doc open
HealthLogger.sendAnalyticsData(
"cssQuickDoc",
"usage",
"quickDoc",
"open"
);
// Only provide docs if the selection is within a single line
var sel = hostEditor.getSelection();
if (sel.start.line !== sel.end.line) {
return null;
}
if (langId === "html") { // HTML
jsonFile = "html.json";
propInfo = HTMLUtils.getTagInfo(hostEditor, sel.start);
if (propInfo.position.tokenType === HTMLUtils.ATTR_NAME && propInfo.attr && propInfo.attr.name) {
// we're on an HTML attribute (and not on its value)
propQueue.push(propInfo.attr.name.toLowerCase());
}
if (propInfo.tagName) { // we're somehow on an HTML tag (no matter where exactly)
propInfo = propInfo.tagName.toLowerCase();
propQueue.push("<" + propInfo + ">");
}
} else { // CSS-like language
jsonFile = "css.json";
propInfo = CSSUtils.getInfoAtPos(hostEditor, sel.start);
if (propInfo.name) {
propQueue.push(propInfo.name);
// remove possible vendor prefixes
propQueue.push(propInfo.name.replace(/^-(?:webkit|moz|ms|o)-/, ""));
}
}
// Are we on a supported property? (no matter if info is available for the property)
if (propQueue.length) {
var result = new $.Deferred();
// Load JSON file if not done yet
getDocs(jsonFile)
.done(function (docs) {
// Construct inline widget (if we have docs for this property)
var displayName, propDetails,
propName = _.find(propQueue, function (propName) { // find the first property where info is available
return docs.hasOwnProperty(propName);
});
if (propName) {
propDetails = docs[propName];
displayName = propName.substr(propName.lastIndexOf("/") + 1);
}
if (propDetails) {
var inlineWidget = new InlineDocsViewer(displayName, propDetails);
inlineWidget.load(hostEditor);
result.resolve(inlineWidget);
} else {
result.reject();
}
})
.fail(function () {
result.reject();
});
return result.promise();
} else {
return null;
}
} | javascript | function inlineProvider(hostEditor, pos) {
var jsonFile, propInfo,
propQueue = [], // priority queue of propNames to try
langId = hostEditor.getLanguageForSelection().getId(),
supportedLangs = {
"css": true,
"scss": true,
"less": true,
"html": true
},
isQuickDocAvailable = langId ? supportedLangs[langId] : -1; // fail if langId is falsy
// Only provide docs when cursor is in supported language
if (!isQuickDocAvailable) {
return null;
}
// Send analytics data for Quick Doc open
HealthLogger.sendAnalyticsData(
"cssQuickDoc",
"usage",
"quickDoc",
"open"
);
// Only provide docs if the selection is within a single line
var sel = hostEditor.getSelection();
if (sel.start.line !== sel.end.line) {
return null;
}
if (langId === "html") { // HTML
jsonFile = "html.json";
propInfo = HTMLUtils.getTagInfo(hostEditor, sel.start);
if (propInfo.position.tokenType === HTMLUtils.ATTR_NAME && propInfo.attr && propInfo.attr.name) {
// we're on an HTML attribute (and not on its value)
propQueue.push(propInfo.attr.name.toLowerCase());
}
if (propInfo.tagName) { // we're somehow on an HTML tag (no matter where exactly)
propInfo = propInfo.tagName.toLowerCase();
propQueue.push("<" + propInfo + ">");
}
} else { // CSS-like language
jsonFile = "css.json";
propInfo = CSSUtils.getInfoAtPos(hostEditor, sel.start);
if (propInfo.name) {
propQueue.push(propInfo.name);
// remove possible vendor prefixes
propQueue.push(propInfo.name.replace(/^-(?:webkit|moz|ms|o)-/, ""));
}
}
// Are we on a supported property? (no matter if info is available for the property)
if (propQueue.length) {
var result = new $.Deferred();
// Load JSON file if not done yet
getDocs(jsonFile)
.done(function (docs) {
// Construct inline widget (if we have docs for this property)
var displayName, propDetails,
propName = _.find(propQueue, function (propName) { // find the first property where info is available
return docs.hasOwnProperty(propName);
});
if (propName) {
propDetails = docs[propName];
displayName = propName.substr(propName.lastIndexOf("/") + 1);
}
if (propDetails) {
var inlineWidget = new InlineDocsViewer(displayName, propDetails);
inlineWidget.load(hostEditor);
result.resolve(inlineWidget);
} else {
result.reject();
}
})
.fail(function () {
result.reject();
});
return result.promise();
} else {
return null;
}
} | [
"function",
"inlineProvider",
"(",
"hostEditor",
",",
"pos",
")",
"{",
"var",
"jsonFile",
",",
"propInfo",
",",
"propQueue",
"=",
"[",
"]",
",",
"// priority queue of propNames to try",
"langId",
"=",
"hostEditor",
".",
"getLanguageForSelection",
"(",
")",
".",
"getId",
"(",
")",
",",
"supportedLangs",
"=",
"{",
"\"css\"",
":",
"true",
",",
"\"scss\"",
":",
"true",
",",
"\"less\"",
":",
"true",
",",
"\"html\"",
":",
"true",
"}",
",",
"isQuickDocAvailable",
"=",
"langId",
"?",
"supportedLangs",
"[",
"langId",
"]",
":",
"-",
"1",
";",
"// fail if langId is falsy",
"// Only provide docs when cursor is in supported language",
"if",
"(",
"!",
"isQuickDocAvailable",
")",
"{",
"return",
"null",
";",
"}",
"// Send analytics data for Quick Doc open",
"HealthLogger",
".",
"sendAnalyticsData",
"(",
"\"cssQuickDoc\"",
",",
"\"usage\"",
",",
"\"quickDoc\"",
",",
"\"open\"",
")",
";",
"// Only provide docs if the selection is within a single line",
"var",
"sel",
"=",
"hostEditor",
".",
"getSelection",
"(",
")",
";",
"if",
"(",
"sel",
".",
"start",
".",
"line",
"!==",
"sel",
".",
"end",
".",
"line",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"langId",
"===",
"\"html\"",
")",
"{",
"// HTML",
"jsonFile",
"=",
"\"html.json\"",
";",
"propInfo",
"=",
"HTMLUtils",
".",
"getTagInfo",
"(",
"hostEditor",
",",
"sel",
".",
"start",
")",
";",
"if",
"(",
"propInfo",
".",
"position",
".",
"tokenType",
"===",
"HTMLUtils",
".",
"ATTR_NAME",
"&&",
"propInfo",
".",
"attr",
"&&",
"propInfo",
".",
"attr",
".",
"name",
")",
"{",
"// we're on an HTML attribute (and not on its value)",
"propQueue",
".",
"push",
"(",
"propInfo",
".",
"attr",
".",
"name",
".",
"toLowerCase",
"(",
")",
")",
";",
"}",
"if",
"(",
"propInfo",
".",
"tagName",
")",
"{",
"// we're somehow on an HTML tag (no matter where exactly)",
"propInfo",
"=",
"propInfo",
".",
"tagName",
".",
"toLowerCase",
"(",
")",
";",
"propQueue",
".",
"push",
"(",
"\"<\"",
"+",
"propInfo",
"+",
"\">\"",
")",
";",
"}",
"}",
"else",
"{",
"// CSS-like language",
"jsonFile",
"=",
"\"css.json\"",
";",
"propInfo",
"=",
"CSSUtils",
".",
"getInfoAtPos",
"(",
"hostEditor",
",",
"sel",
".",
"start",
")",
";",
"if",
"(",
"propInfo",
".",
"name",
")",
"{",
"propQueue",
".",
"push",
"(",
"propInfo",
".",
"name",
")",
";",
"// remove possible vendor prefixes",
"propQueue",
".",
"push",
"(",
"propInfo",
".",
"name",
".",
"replace",
"(",
"/",
"^-(?:webkit|moz|ms|o)-",
"/",
",",
"\"\"",
")",
")",
";",
"}",
"}",
"// Are we on a supported property? (no matter if info is available for the property)",
"if",
"(",
"propQueue",
".",
"length",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"// Load JSON file if not done yet",
"getDocs",
"(",
"jsonFile",
")",
".",
"done",
"(",
"function",
"(",
"docs",
")",
"{",
"// Construct inline widget (if we have docs for this property)",
"var",
"displayName",
",",
"propDetails",
",",
"propName",
"=",
"_",
".",
"find",
"(",
"propQueue",
",",
"function",
"(",
"propName",
")",
"{",
"// find the first property where info is available",
"return",
"docs",
".",
"hasOwnProperty",
"(",
"propName",
")",
";",
"}",
")",
";",
"if",
"(",
"propName",
")",
"{",
"propDetails",
"=",
"docs",
"[",
"propName",
"]",
";",
"displayName",
"=",
"propName",
".",
"substr",
"(",
"propName",
".",
"lastIndexOf",
"(",
"\"/\"",
")",
"+",
"1",
")",
";",
"}",
"if",
"(",
"propDetails",
")",
"{",
"var",
"inlineWidget",
"=",
"new",
"InlineDocsViewer",
"(",
"displayName",
",",
"propDetails",
")",
";",
"inlineWidget",
".",
"load",
"(",
"hostEditor",
")",
";",
"result",
".",
"resolve",
"(",
"inlineWidget",
")",
";",
"}",
"else",
"{",
"result",
".",
"reject",
"(",
")",
";",
"}",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"result",
".",
"reject",
"(",
")",
";",
"}",
")",
";",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Inline docs provider.
@param {!Editor} editor
@param {!{line:Number, ch:Number}} pos
@return {?$.Promise} resolved with an InlineWidget; null if we're not going to provide anything | [
"Inline",
"docs",
"provider",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/MDNDocs/main.js#L89-L176 |
1,918 | adobe/brackets | src/extensions/default/HealthData/HealthDataManager.js | getHealthData | function getHealthData() {
var result = new $.Deferred(),
oneTimeHealthData = {};
oneTimeHealthData.snapshotTime = Date.now();
oneTimeHealthData.os = brackets.platform;
oneTimeHealthData.userAgent = window.navigator.userAgent;
oneTimeHealthData.osLanguage = brackets.app.language;
oneTimeHealthData.bracketsLanguage = brackets.getLocale();
oneTimeHealthData.bracketsVersion = brackets.metadata.version;
$.extend(oneTimeHealthData, HealthLogger.getAggregatedHealthData());
HealthDataUtils.getUserInstalledExtensions()
.done(function (userInstalledExtensions) {
oneTimeHealthData.installedExtensions = userInstalledExtensions;
})
.always(function () {
HealthDataUtils.getUserInstalledTheme()
.done(function (bracketsTheme) {
oneTimeHealthData.bracketsTheme = bracketsTheme;
})
.always(function () {
var userUuid = PreferencesManager.getViewState("UUID");
var olderUuid = PreferencesManager.getViewState("OlderUUID");
if (userUuid && olderUuid) {
oneTimeHealthData.uuid = userUuid;
oneTimeHealthData.olderuuid = olderUuid;
return result.resolve(oneTimeHealthData);
} else {
// So we are going to get the Machine hash in either of the cases.
if (appshell.app.getMachineHash) {
appshell.app.getMachineHash(function (err, macHash) {
var generatedUuid;
if (err) {
generatedUuid = uuid.v4();
} else {
generatedUuid = macHash;
}
if (!userUuid) {
// Could be a new user. In this case
// both will remain the same.
userUuid = olderUuid = generatedUuid;
} else {
// For existing user, we will still cache
// the older uuid, so that we can improve
// our reporting in terms of figuring out
// the new users accurately.
olderUuid = userUuid;
userUuid = generatedUuid;
}
PreferencesManager.setViewState("UUID", userUuid);
PreferencesManager.setViewState("OlderUUID", olderUuid);
oneTimeHealthData.uuid = userUuid;
oneTimeHealthData.olderuuid = olderUuid;
return result.resolve(oneTimeHealthData);
});
} else {
// Probably running on older shell, in which case we will
// assign the same uuid to olderuuid.
if (!userUuid) {
oneTimeHealthData.uuid = oneTimeHealthData.olderuuid = uuid.v4();
} else {
oneTimeHealthData.olderuuid = userUuid;
}
PreferencesManager.setViewState("UUID", oneTimeHealthData.uuid);
PreferencesManager.setViewState("OlderUUID", oneTimeHealthData.olderuuid);
return result.resolve(oneTimeHealthData);
}
}
});
});
return result.promise();
} | javascript | function getHealthData() {
var result = new $.Deferred(),
oneTimeHealthData = {};
oneTimeHealthData.snapshotTime = Date.now();
oneTimeHealthData.os = brackets.platform;
oneTimeHealthData.userAgent = window.navigator.userAgent;
oneTimeHealthData.osLanguage = brackets.app.language;
oneTimeHealthData.bracketsLanguage = brackets.getLocale();
oneTimeHealthData.bracketsVersion = brackets.metadata.version;
$.extend(oneTimeHealthData, HealthLogger.getAggregatedHealthData());
HealthDataUtils.getUserInstalledExtensions()
.done(function (userInstalledExtensions) {
oneTimeHealthData.installedExtensions = userInstalledExtensions;
})
.always(function () {
HealthDataUtils.getUserInstalledTheme()
.done(function (bracketsTheme) {
oneTimeHealthData.bracketsTheme = bracketsTheme;
})
.always(function () {
var userUuid = PreferencesManager.getViewState("UUID");
var olderUuid = PreferencesManager.getViewState("OlderUUID");
if (userUuid && olderUuid) {
oneTimeHealthData.uuid = userUuid;
oneTimeHealthData.olderuuid = olderUuid;
return result.resolve(oneTimeHealthData);
} else {
// So we are going to get the Machine hash in either of the cases.
if (appshell.app.getMachineHash) {
appshell.app.getMachineHash(function (err, macHash) {
var generatedUuid;
if (err) {
generatedUuid = uuid.v4();
} else {
generatedUuid = macHash;
}
if (!userUuid) {
// Could be a new user. In this case
// both will remain the same.
userUuid = olderUuid = generatedUuid;
} else {
// For existing user, we will still cache
// the older uuid, so that we can improve
// our reporting in terms of figuring out
// the new users accurately.
olderUuid = userUuid;
userUuid = generatedUuid;
}
PreferencesManager.setViewState("UUID", userUuid);
PreferencesManager.setViewState("OlderUUID", olderUuid);
oneTimeHealthData.uuid = userUuid;
oneTimeHealthData.olderuuid = olderUuid;
return result.resolve(oneTimeHealthData);
});
} else {
// Probably running on older shell, in which case we will
// assign the same uuid to olderuuid.
if (!userUuid) {
oneTimeHealthData.uuid = oneTimeHealthData.olderuuid = uuid.v4();
} else {
oneTimeHealthData.olderuuid = userUuid;
}
PreferencesManager.setViewState("UUID", oneTimeHealthData.uuid);
PreferencesManager.setViewState("OlderUUID", oneTimeHealthData.olderuuid);
return result.resolve(oneTimeHealthData);
}
}
});
});
return result.promise();
} | [
"function",
"getHealthData",
"(",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"oneTimeHealthData",
"=",
"{",
"}",
";",
"oneTimeHealthData",
".",
"snapshotTime",
"=",
"Date",
".",
"now",
"(",
")",
";",
"oneTimeHealthData",
".",
"os",
"=",
"brackets",
".",
"platform",
";",
"oneTimeHealthData",
".",
"userAgent",
"=",
"window",
".",
"navigator",
".",
"userAgent",
";",
"oneTimeHealthData",
".",
"osLanguage",
"=",
"brackets",
".",
"app",
".",
"language",
";",
"oneTimeHealthData",
".",
"bracketsLanguage",
"=",
"brackets",
".",
"getLocale",
"(",
")",
";",
"oneTimeHealthData",
".",
"bracketsVersion",
"=",
"brackets",
".",
"metadata",
".",
"version",
";",
"$",
".",
"extend",
"(",
"oneTimeHealthData",
",",
"HealthLogger",
".",
"getAggregatedHealthData",
"(",
")",
")",
";",
"HealthDataUtils",
".",
"getUserInstalledExtensions",
"(",
")",
".",
"done",
"(",
"function",
"(",
"userInstalledExtensions",
")",
"{",
"oneTimeHealthData",
".",
"installedExtensions",
"=",
"userInstalledExtensions",
";",
"}",
")",
".",
"always",
"(",
"function",
"(",
")",
"{",
"HealthDataUtils",
".",
"getUserInstalledTheme",
"(",
")",
".",
"done",
"(",
"function",
"(",
"bracketsTheme",
")",
"{",
"oneTimeHealthData",
".",
"bracketsTheme",
"=",
"bracketsTheme",
";",
"}",
")",
".",
"always",
"(",
"function",
"(",
")",
"{",
"var",
"userUuid",
"=",
"PreferencesManager",
".",
"getViewState",
"(",
"\"UUID\"",
")",
";",
"var",
"olderUuid",
"=",
"PreferencesManager",
".",
"getViewState",
"(",
"\"OlderUUID\"",
")",
";",
"if",
"(",
"userUuid",
"&&",
"olderUuid",
")",
"{",
"oneTimeHealthData",
".",
"uuid",
"=",
"userUuid",
";",
"oneTimeHealthData",
".",
"olderuuid",
"=",
"olderUuid",
";",
"return",
"result",
".",
"resolve",
"(",
"oneTimeHealthData",
")",
";",
"}",
"else",
"{",
"// So we are going to get the Machine hash in either of the cases.",
"if",
"(",
"appshell",
".",
"app",
".",
"getMachineHash",
")",
"{",
"appshell",
".",
"app",
".",
"getMachineHash",
"(",
"function",
"(",
"err",
",",
"macHash",
")",
"{",
"var",
"generatedUuid",
";",
"if",
"(",
"err",
")",
"{",
"generatedUuid",
"=",
"uuid",
".",
"v4",
"(",
")",
";",
"}",
"else",
"{",
"generatedUuid",
"=",
"macHash",
";",
"}",
"if",
"(",
"!",
"userUuid",
")",
"{",
"// Could be a new user. In this case",
"// both will remain the same.",
"userUuid",
"=",
"olderUuid",
"=",
"generatedUuid",
";",
"}",
"else",
"{",
"// For existing user, we will still cache",
"// the older uuid, so that we can improve",
"// our reporting in terms of figuring out",
"// the new users accurately.",
"olderUuid",
"=",
"userUuid",
";",
"userUuid",
"=",
"generatedUuid",
";",
"}",
"PreferencesManager",
".",
"setViewState",
"(",
"\"UUID\"",
",",
"userUuid",
")",
";",
"PreferencesManager",
".",
"setViewState",
"(",
"\"OlderUUID\"",
",",
"olderUuid",
")",
";",
"oneTimeHealthData",
".",
"uuid",
"=",
"userUuid",
";",
"oneTimeHealthData",
".",
"olderuuid",
"=",
"olderUuid",
";",
"return",
"result",
".",
"resolve",
"(",
"oneTimeHealthData",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"// Probably running on older shell, in which case we will",
"// assign the same uuid to olderuuid.",
"if",
"(",
"!",
"userUuid",
")",
"{",
"oneTimeHealthData",
".",
"uuid",
"=",
"oneTimeHealthData",
".",
"olderuuid",
"=",
"uuid",
".",
"v4",
"(",
")",
";",
"}",
"else",
"{",
"oneTimeHealthData",
".",
"olderuuid",
"=",
"userUuid",
";",
"}",
"PreferencesManager",
".",
"setViewState",
"(",
"\"UUID\"",
",",
"oneTimeHealthData",
".",
"uuid",
")",
";",
"PreferencesManager",
".",
"setViewState",
"(",
"\"OlderUUID\"",
",",
"oneTimeHealthData",
".",
"olderuuid",
")",
";",
"return",
"result",
".",
"resolve",
"(",
"oneTimeHealthData",
")",
";",
"}",
"}",
"}",
")",
";",
"}",
")",
";",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] | Get the Health Data which will be sent to the server. Initially it is only one time data. | [
"Get",
"the",
"Health",
"Data",
"which",
"will",
"be",
"sent",
"to",
"the",
"server",
".",
"Initially",
"it",
"is",
"only",
"one",
"time",
"data",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/HealthData/HealthDataManager.js#L51-L130 |
1,919 | adobe/brackets | src/extensions/default/HealthData/HealthDataManager.js | sendHealthDataToServer | function sendHealthDataToServer() {
var result = new $.Deferred();
getHealthData().done(function (healthData) {
var url = brackets.config.healthDataServerURL,
data = JSON.stringify(healthData);
$.ajax({
url: url,
type: "POST",
data: data,
dataType: "text",
contentType: "text/plain"
})
.done(function () {
result.resolve();
})
.fail(function (jqXHR, status, errorThrown) {
console.error("Error in sending Health Data. Response : " + jqXHR.responseText + ". Status : " + status + ". Error : " + errorThrown);
result.reject();
});
})
.fail(function () {
result.reject();
});
return result.promise();
} | javascript | function sendHealthDataToServer() {
var result = new $.Deferred();
getHealthData().done(function (healthData) {
var url = brackets.config.healthDataServerURL,
data = JSON.stringify(healthData);
$.ajax({
url: url,
type: "POST",
data: data,
dataType: "text",
contentType: "text/plain"
})
.done(function () {
result.resolve();
})
.fail(function (jqXHR, status, errorThrown) {
console.error("Error in sending Health Data. Response : " + jqXHR.responseText + ". Status : " + status + ". Error : " + errorThrown);
result.reject();
});
})
.fail(function () {
result.reject();
});
return result.promise();
} | [
"function",
"sendHealthDataToServer",
"(",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"getHealthData",
"(",
")",
".",
"done",
"(",
"function",
"(",
"healthData",
")",
"{",
"var",
"url",
"=",
"brackets",
".",
"config",
".",
"healthDataServerURL",
",",
"data",
"=",
"JSON",
".",
"stringify",
"(",
"healthData",
")",
";",
"$",
".",
"ajax",
"(",
"{",
"url",
":",
"url",
",",
"type",
":",
"\"POST\"",
",",
"data",
":",
"data",
",",
"dataType",
":",
"\"text\"",
",",
"contentType",
":",
"\"text/plain\"",
"}",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"result",
".",
"resolve",
"(",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"jqXHR",
",",
"status",
",",
"errorThrown",
")",
"{",
"console",
".",
"error",
"(",
"\"Error in sending Health Data. Response : \"",
"+",
"jqXHR",
".",
"responseText",
"+",
"\". Status : \"",
"+",
"status",
"+",
"\". Error : \"",
"+",
"errorThrown",
")",
";",
"result",
".",
"reject",
"(",
")",
";",
"}",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"result",
".",
"reject",
"(",
")",
";",
"}",
")",
";",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] | Send data to the server | [
"Send",
"data",
"to",
"the",
"server"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/HealthData/HealthDataManager.js#L184-L212 |
1,920 | adobe/brackets | src/extensions/default/HealthData/HealthDataManager.js | sendAnalyticsDataToServer | function sendAnalyticsDataToServer(eventParams) {
var result = new $.Deferred();
var analyticsData = getAnalyticsData(eventParams);
$.ajax({
url: brackets.config.analyticsDataServerURL,
type: "POST",
data: JSON.stringify({events: [analyticsData]}),
headers: {
"Content-Type": "application/json",
"x-api-key": brackets.config.serviceKey
}
})
.done(function () {
result.resolve();
})
.fail(function (jqXHR, status, errorThrown) {
console.error("Error in sending Adobe Analytics Data. Response : " + jqXHR.responseText + ". Status : " + status + ". Error : " + errorThrown);
result.reject();
});
return result.promise();
} | javascript | function sendAnalyticsDataToServer(eventParams) {
var result = new $.Deferred();
var analyticsData = getAnalyticsData(eventParams);
$.ajax({
url: brackets.config.analyticsDataServerURL,
type: "POST",
data: JSON.stringify({events: [analyticsData]}),
headers: {
"Content-Type": "application/json",
"x-api-key": brackets.config.serviceKey
}
})
.done(function () {
result.resolve();
})
.fail(function (jqXHR, status, errorThrown) {
console.error("Error in sending Adobe Analytics Data. Response : " + jqXHR.responseText + ". Status : " + status + ". Error : " + errorThrown);
result.reject();
});
return result.promise();
} | [
"function",
"sendAnalyticsDataToServer",
"(",
"eventParams",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"var",
"analyticsData",
"=",
"getAnalyticsData",
"(",
"eventParams",
")",
";",
"$",
".",
"ajax",
"(",
"{",
"url",
":",
"brackets",
".",
"config",
".",
"analyticsDataServerURL",
",",
"type",
":",
"\"POST\"",
",",
"data",
":",
"JSON",
".",
"stringify",
"(",
"{",
"events",
":",
"[",
"analyticsData",
"]",
"}",
")",
",",
"headers",
":",
"{",
"\"Content-Type\"",
":",
"\"application/json\"",
",",
"\"x-api-key\"",
":",
"brackets",
".",
"config",
".",
"serviceKey",
"}",
"}",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"result",
".",
"resolve",
"(",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"jqXHR",
",",
"status",
",",
"errorThrown",
")",
"{",
"console",
".",
"error",
"(",
"\"Error in sending Adobe Analytics Data. Response : \"",
"+",
"jqXHR",
".",
"responseText",
"+",
"\". Status : \"",
"+",
"status",
"+",
"\". Error : \"",
"+",
"errorThrown",
")",
";",
"result",
".",
"reject",
"(",
")",
";",
"}",
")",
";",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] | Send Analytics data to Server | [
"Send",
"Analytics",
"data",
"to",
"Server"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/HealthData/HealthDataManager.js#L215-L237 |
1,921 | adobe/brackets | src/LiveDevelopment/LiveDevMultiBrowser.js | _setStatus | function _setStatus(status, closeReason) {
// Don't send a notification when the status didn't actually change
if (status === exports.status) {
return;
}
exports.status = status;
var reason = status === STATUS_INACTIVE ? closeReason : null;
exports.trigger("statusChange", status, reason);
} | javascript | function _setStatus(status, closeReason) {
// Don't send a notification when the status didn't actually change
if (status === exports.status) {
return;
}
exports.status = status;
var reason = status === STATUS_INACTIVE ? closeReason : null;
exports.trigger("statusChange", status, reason);
} | [
"function",
"_setStatus",
"(",
"status",
",",
"closeReason",
")",
"{",
"// Don't send a notification when the status didn't actually change",
"if",
"(",
"status",
"===",
"exports",
".",
"status",
")",
"{",
"return",
";",
"}",
"exports",
".",
"status",
"=",
"status",
";",
"var",
"reason",
"=",
"status",
"===",
"STATUS_INACTIVE",
"?",
"closeReason",
":",
"null",
";",
"exports",
".",
"trigger",
"(",
"\"statusChange\"",
",",
"status",
",",
"reason",
")",
";",
"}"
] | Update the status. Triggers a statusChange event.
@param {number} status new status
@param {?string} closeReason Optional string key suffix to display to
user when closing the live development connection (see LIVE_DEV_* keys) | [
"Update",
"the",
"status",
".",
"Triggers",
"a",
"statusChange",
"event",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevMultiBrowser.js#L201-L211 |
1,922 | adobe/brackets | src/LiveDevelopment/LiveDevMultiBrowser.js | _docIsOutOfSync | function _docIsOutOfSync(doc) {
var liveDoc = _server && _server.get(doc.file.fullPath),
isLiveEditingEnabled = liveDoc && liveDoc.isLiveEditingEnabled();
return doc.isDirty && !isLiveEditingEnabled;
} | javascript | function _docIsOutOfSync(doc) {
var liveDoc = _server && _server.get(doc.file.fullPath),
isLiveEditingEnabled = liveDoc && liveDoc.isLiveEditingEnabled();
return doc.isDirty && !isLiveEditingEnabled;
} | [
"function",
"_docIsOutOfSync",
"(",
"doc",
")",
"{",
"var",
"liveDoc",
"=",
"_server",
"&&",
"_server",
".",
"get",
"(",
"doc",
".",
"file",
".",
"fullPath",
")",
",",
"isLiveEditingEnabled",
"=",
"liveDoc",
"&&",
"liveDoc",
".",
"isLiveEditingEnabled",
"(",
")",
";",
"return",
"doc",
".",
"isDirty",
"&&",
"!",
"isLiveEditingEnabled",
";",
"}"
] | Documents are considered to be out-of-sync if they are dirty and
do not have "update while editing" support
@param {Document} doc
@return {boolean} | [
"Documents",
"are",
"considered",
"to",
"be",
"out",
"-",
"of",
"-",
"sync",
"if",
"they",
"are",
"dirty",
"and",
"do",
"not",
"have",
"update",
"while",
"editing",
"support"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevMultiBrowser.js#L278-L283 |
1,923 | adobe/brackets | src/LiveDevelopment/LiveDevMultiBrowser.js | _styleSheetAdded | function _styleSheetAdded(event, url, roots) {
var path = _server && _server.urlToPath(url),
alreadyAdded = !!_relatedDocuments[url];
// path may be null if loading an external stylesheet.
// Also, the stylesheet may already exist and be reported as added twice
// due to Chrome reporting added/removed events after incremental changes
// are pushed to the browser
if (!path || alreadyAdded) {
return;
}
var docPromise = DocumentManager.getDocumentForPath(path);
docPromise.done(function (doc) {
if ((_classForDocument(doc) === LiveCSSDocument) &&
(!_liveDocument || (doc !== _liveDocument.doc))) {
var liveDoc = _createLiveDocument(doc, doc._masterEditor, roots);
if (liveDoc) {
_server.add(liveDoc);
_relatedDocuments[doc.url] = liveDoc;
liveDoc.on("updateDoc", function (event, url) {
var path = _server.urlToPath(url),
doc = getLiveDocForPath(path);
doc._updateBrowser();
});
}
}
});
} | javascript | function _styleSheetAdded(event, url, roots) {
var path = _server && _server.urlToPath(url),
alreadyAdded = !!_relatedDocuments[url];
// path may be null if loading an external stylesheet.
// Also, the stylesheet may already exist and be reported as added twice
// due to Chrome reporting added/removed events after incremental changes
// are pushed to the browser
if (!path || alreadyAdded) {
return;
}
var docPromise = DocumentManager.getDocumentForPath(path);
docPromise.done(function (doc) {
if ((_classForDocument(doc) === LiveCSSDocument) &&
(!_liveDocument || (doc !== _liveDocument.doc))) {
var liveDoc = _createLiveDocument(doc, doc._masterEditor, roots);
if (liveDoc) {
_server.add(liveDoc);
_relatedDocuments[doc.url] = liveDoc;
liveDoc.on("updateDoc", function (event, url) {
var path = _server.urlToPath(url),
doc = getLiveDocForPath(path);
doc._updateBrowser();
});
}
}
});
} | [
"function",
"_styleSheetAdded",
"(",
"event",
",",
"url",
",",
"roots",
")",
"{",
"var",
"path",
"=",
"_server",
"&&",
"_server",
".",
"urlToPath",
"(",
"url",
")",
",",
"alreadyAdded",
"=",
"!",
"!",
"_relatedDocuments",
"[",
"url",
"]",
";",
"// path may be null if loading an external stylesheet.",
"// Also, the stylesheet may already exist and be reported as added twice",
"// due to Chrome reporting added/removed events after incremental changes",
"// are pushed to the browser",
"if",
"(",
"!",
"path",
"||",
"alreadyAdded",
")",
"{",
"return",
";",
"}",
"var",
"docPromise",
"=",
"DocumentManager",
".",
"getDocumentForPath",
"(",
"path",
")",
";",
"docPromise",
".",
"done",
"(",
"function",
"(",
"doc",
")",
"{",
"if",
"(",
"(",
"_classForDocument",
"(",
"doc",
")",
"===",
"LiveCSSDocument",
")",
"&&",
"(",
"!",
"_liveDocument",
"||",
"(",
"doc",
"!==",
"_liveDocument",
".",
"doc",
")",
")",
")",
"{",
"var",
"liveDoc",
"=",
"_createLiveDocument",
"(",
"doc",
",",
"doc",
".",
"_masterEditor",
",",
"roots",
")",
";",
"if",
"(",
"liveDoc",
")",
"{",
"_server",
".",
"add",
"(",
"liveDoc",
")",
";",
"_relatedDocuments",
"[",
"doc",
".",
"url",
"]",
"=",
"liveDoc",
";",
"liveDoc",
".",
"on",
"(",
"\"updateDoc\"",
",",
"function",
"(",
"event",
",",
"url",
")",
"{",
"var",
"path",
"=",
"_server",
".",
"urlToPath",
"(",
"url",
")",
",",
"doc",
"=",
"getLiveDocForPath",
"(",
"path",
")",
";",
"doc",
".",
"_updateBrowser",
"(",
")",
";",
"}",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Handles a notification from the browser that a stylesheet was loaded into
the live HTML document. If the stylesheet maps to a file in the project, then
creates a live document for the stylesheet and adds it to _relatedDocuments.
@param {$.Event} event
@param {string} url The URL of the stylesheet that was added.
@param {array} roots The URLs of the roots of the stylesheet (the css files loaded through <link>) | [
"Handles",
"a",
"notification",
"from",
"the",
"browser",
"that",
"a",
"stylesheet",
"was",
"loaded",
"into",
"the",
"live",
"HTML",
"document",
".",
"If",
"the",
"stylesheet",
"maps",
"to",
"a",
"file",
"in",
"the",
"project",
"then",
"creates",
"a",
"live",
"document",
"for",
"the",
"stylesheet",
"and",
"adds",
"it",
"to",
"_relatedDocuments",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevMultiBrowser.js#L293-L322 |
1,924 | adobe/brackets | src/LiveDevelopment/LiveDevMultiBrowser.js | open | function open() {
// TODO: need to run _onDocumentChange() after load if doc != currentDocument here? Maybe not, since activeEditorChange
// doesn't trigger it, while inline editors can still cause edits in doc other than currentDoc...
_getInitialDocFromCurrent().done(function (doc) {
var prepareServerPromise = (doc && _prepareServer(doc)) || new $.Deferred().reject(),
otherDocumentsInWorkingFiles;
if (doc && !doc._masterEditor) {
otherDocumentsInWorkingFiles = MainViewManager.getWorkingSetSize(MainViewManager.ALL_PANES);
MainViewManager.addToWorkingSet(MainViewManager.ACTIVE_PANE, doc.file);
if (!otherDocumentsInWorkingFiles) {
CommandManager.execute(Commands.CMD_OPEN, { fullPath: doc.file.fullPath });
}
}
// wait for server (StaticServer, Base URL or file:)
prepareServerPromise
.done(function () {
_setStatus(STATUS_CONNECTING);
_doLaunchAfterServerReady(doc);
})
.fail(function () {
_showWrongDocError();
});
});
} | javascript | function open() {
// TODO: need to run _onDocumentChange() after load if doc != currentDocument here? Maybe not, since activeEditorChange
// doesn't trigger it, while inline editors can still cause edits in doc other than currentDoc...
_getInitialDocFromCurrent().done(function (doc) {
var prepareServerPromise = (doc && _prepareServer(doc)) || new $.Deferred().reject(),
otherDocumentsInWorkingFiles;
if (doc && !doc._masterEditor) {
otherDocumentsInWorkingFiles = MainViewManager.getWorkingSetSize(MainViewManager.ALL_PANES);
MainViewManager.addToWorkingSet(MainViewManager.ACTIVE_PANE, doc.file);
if (!otherDocumentsInWorkingFiles) {
CommandManager.execute(Commands.CMD_OPEN, { fullPath: doc.file.fullPath });
}
}
// wait for server (StaticServer, Base URL or file:)
prepareServerPromise
.done(function () {
_setStatus(STATUS_CONNECTING);
_doLaunchAfterServerReady(doc);
})
.fail(function () {
_showWrongDocError();
});
});
} | [
"function",
"open",
"(",
")",
"{",
"// TODO: need to run _onDocumentChange() after load if doc != currentDocument here? Maybe not, since activeEditorChange",
"// doesn't trigger it, while inline editors can still cause edits in doc other than currentDoc...",
"_getInitialDocFromCurrent",
"(",
")",
".",
"done",
"(",
"function",
"(",
"doc",
")",
"{",
"var",
"prepareServerPromise",
"=",
"(",
"doc",
"&&",
"_prepareServer",
"(",
"doc",
")",
")",
"||",
"new",
"$",
".",
"Deferred",
"(",
")",
".",
"reject",
"(",
")",
",",
"otherDocumentsInWorkingFiles",
";",
"if",
"(",
"doc",
"&&",
"!",
"doc",
".",
"_masterEditor",
")",
"{",
"otherDocumentsInWorkingFiles",
"=",
"MainViewManager",
".",
"getWorkingSetSize",
"(",
"MainViewManager",
".",
"ALL_PANES",
")",
";",
"MainViewManager",
".",
"addToWorkingSet",
"(",
"MainViewManager",
".",
"ACTIVE_PANE",
",",
"doc",
".",
"file",
")",
";",
"if",
"(",
"!",
"otherDocumentsInWorkingFiles",
")",
"{",
"CommandManager",
".",
"execute",
"(",
"Commands",
".",
"CMD_OPEN",
",",
"{",
"fullPath",
":",
"doc",
".",
"file",
".",
"fullPath",
"}",
")",
";",
"}",
"}",
"// wait for server (StaticServer, Base URL or file:)",
"prepareServerPromise",
".",
"done",
"(",
"function",
"(",
")",
"{",
"_setStatus",
"(",
"STATUS_CONNECTING",
")",
";",
"_doLaunchAfterServerReady",
"(",
"doc",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"_showWrongDocError",
"(",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Open a live preview on the current docuemnt. | [
"Open",
"a",
"live",
"preview",
"on",
"the",
"current",
"docuemnt",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevMultiBrowser.js#L691-L717 |
1,925 | adobe/brackets | src/LiveDevelopment/LiveDevMultiBrowser.js | init | function init(config) {
exports.config = config;
MainViewManager
.on("currentFileChange", _onFileChange);
DocumentManager
.on("documentSaved", _onDocumentSaved)
.on("dirtyFlagChange", _onDirtyFlagChange);
ProjectManager
.on("beforeProjectClose beforeAppClose", close);
// Default transport for live connection messages - can be changed
setTransport(NodeSocketTransport);
// Default launcher for preview browser - can be changed
setLauncher(DefaultLauncher);
// Initialize exports.status
_setStatus(STATUS_INACTIVE);
} | javascript | function init(config) {
exports.config = config;
MainViewManager
.on("currentFileChange", _onFileChange);
DocumentManager
.on("documentSaved", _onDocumentSaved)
.on("dirtyFlagChange", _onDirtyFlagChange);
ProjectManager
.on("beforeProjectClose beforeAppClose", close);
// Default transport for live connection messages - can be changed
setTransport(NodeSocketTransport);
// Default launcher for preview browser - can be changed
setLauncher(DefaultLauncher);
// Initialize exports.status
_setStatus(STATUS_INACTIVE);
} | [
"function",
"init",
"(",
"config",
")",
"{",
"exports",
".",
"config",
"=",
"config",
";",
"MainViewManager",
".",
"on",
"(",
"\"currentFileChange\"",
",",
"_onFileChange",
")",
";",
"DocumentManager",
".",
"on",
"(",
"\"documentSaved\"",
",",
"_onDocumentSaved",
")",
".",
"on",
"(",
"\"dirtyFlagChange\"",
",",
"_onDirtyFlagChange",
")",
";",
"ProjectManager",
".",
"on",
"(",
"\"beforeProjectClose beforeAppClose\"",
",",
"close",
")",
";",
"// Default transport for live connection messages - can be changed",
"setTransport",
"(",
"NodeSocketTransport",
")",
";",
"// Default launcher for preview browser - can be changed",
"setLauncher",
"(",
"DefaultLauncher",
")",
";",
"// Initialize exports.status",
"_setStatus",
"(",
"STATUS_INACTIVE",
")",
";",
"}"
] | Initialize the LiveDevelopment module. | [
"Initialize",
"the",
"LiveDevelopment",
"module",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevMultiBrowser.js#L818-L836 |
1,926 | adobe/brackets | src/LiveDevelopment/LiveDevMultiBrowser.js | getCurrentProjectServerConfig | function getCurrentProjectServerConfig() {
return {
baseUrl: ProjectManager.getBaseUrl(),
pathResolver: ProjectManager.makeProjectRelativeIfPossible,
root: ProjectManager.getProjectRoot().fullPath
};
} | javascript | function getCurrentProjectServerConfig() {
return {
baseUrl: ProjectManager.getBaseUrl(),
pathResolver: ProjectManager.makeProjectRelativeIfPossible,
root: ProjectManager.getProjectRoot().fullPath
};
} | [
"function",
"getCurrentProjectServerConfig",
"(",
")",
"{",
"return",
"{",
"baseUrl",
":",
"ProjectManager",
".",
"getBaseUrl",
"(",
")",
",",
"pathResolver",
":",
"ProjectManager",
".",
"makeProjectRelativeIfPossible",
",",
"root",
":",
"ProjectManager",
".",
"getProjectRoot",
"(",
")",
".",
"fullPath",
"}",
";",
"}"
] | Returns current project server config. Copied from original LiveDevelopment. | [
"Returns",
"current",
"project",
"server",
"config",
".",
"Copied",
"from",
"original",
"LiveDevelopment",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevMultiBrowser.js#L894-L900 |
1,927 | adobe/brackets | src/extensions/default/DebugCommands/NodeDebugUtils.js | logNodeState | function logNodeState() {
if (brackets.app && brackets.app.getNodeState) {
brackets.app.getNodeState(function (err, port) {
if (err) {
console.log("[NodeDebugUtils] Node is in error state " + err);
} else {
console.log("[NodeDebugUtils] Node is listening on port " + port);
}
});
} else {
console.error("[NodeDebugUtils] No brackets.app.getNodeState function. Maybe you're running the wrong shell?");
}
} | javascript | function logNodeState() {
if (brackets.app && brackets.app.getNodeState) {
brackets.app.getNodeState(function (err, port) {
if (err) {
console.log("[NodeDebugUtils] Node is in error state " + err);
} else {
console.log("[NodeDebugUtils] Node is listening on port " + port);
}
});
} else {
console.error("[NodeDebugUtils] No brackets.app.getNodeState function. Maybe you're running the wrong shell?");
}
} | [
"function",
"logNodeState",
"(",
")",
"{",
"if",
"(",
"brackets",
".",
"app",
"&&",
"brackets",
".",
"app",
".",
"getNodeState",
")",
"{",
"brackets",
".",
"app",
".",
"getNodeState",
"(",
"function",
"(",
"err",
",",
"port",
")",
"{",
"if",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"\"[NodeDebugUtils] Node is in error state \"",
"+",
"err",
")",
";",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"\"[NodeDebugUtils] Node is listening on port \"",
"+",
"port",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"console",
".",
"error",
"(",
"\"[NodeDebugUtils] No brackets.app.getNodeState function. Maybe you're running the wrong shell?\"",
")",
";",
"}",
"}"
] | Logs the state of the current node server to the console. | [
"Logs",
"the",
"state",
"of",
"the",
"current",
"node",
"server",
"to",
"the",
"console",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/DebugCommands/NodeDebugUtils.js#L47-L59 |
1,928 | adobe/brackets | src/extensions/default/DebugCommands/NodeDebugUtils.js | restartNode | function restartNode() {
try {
_nodeConnection.domains.base.restartNode();
} catch (e) {
window.alert("Failed trying to restart Node: " + e.message);
}
} | javascript | function restartNode() {
try {
_nodeConnection.domains.base.restartNode();
} catch (e) {
window.alert("Failed trying to restart Node: " + e.message);
}
} | [
"function",
"restartNode",
"(",
")",
"{",
"try",
"{",
"_nodeConnection",
".",
"domains",
".",
"base",
".",
"restartNode",
"(",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"window",
".",
"alert",
"(",
"\"Failed trying to restart Node: \"",
"+",
"e",
".",
"message",
")",
";",
"}",
"}"
] | Sends a command to node to cause a restart. | [
"Sends",
"a",
"command",
"to",
"node",
"to",
"cause",
"a",
"restart",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/DebugCommands/NodeDebugUtils.js#L64-L70 |
1,929 | adobe/brackets | src/extensions/default/DebugCommands/NodeDebugUtils.js | enableDebugger | function enableDebugger() {
try {
_nodeConnection.domains.base.enableDebugger();
} catch (e) {
window.alert("Failed trying to enable Node debugger: " + e.message);
}
} | javascript | function enableDebugger() {
try {
_nodeConnection.domains.base.enableDebugger();
} catch (e) {
window.alert("Failed trying to enable Node debugger: " + e.message);
}
} | [
"function",
"enableDebugger",
"(",
")",
"{",
"try",
"{",
"_nodeConnection",
".",
"domains",
".",
"base",
".",
"enableDebugger",
"(",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"window",
".",
"alert",
"(",
"\"Failed trying to enable Node debugger: \"",
"+",
"e",
".",
"message",
")",
";",
"}",
"}"
] | Sends a command to node to enable the debugger. | [
"Sends",
"a",
"command",
"to",
"node",
"to",
"enable",
"the",
"debugger",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/DebugCommands/NodeDebugUtils.js#L75-L81 |
1,930 | adobe/brackets | src/extensions/default/CSSCodeHints/main.js | formatHints | function formatHints(hints, query) {
var hasColorSwatch = hints.some(function (token) {
return token.color;
});
StringMatch.basicMatchSort(hints);
return hints.map(function (token) {
var $hintObj = $("<span>").addClass("brackets-css-hints");
// highlight the matched portion of each hint
if (token.stringRanges) {
token.stringRanges.forEach(function (item) {
if (item.matched) {
$hintObj.append($("<span>")
.text(item.text)
.addClass("matched-hint"));
} else {
$hintObj.append(item.text);
}
});
} else {
$hintObj.text(token.value);
}
if (hasColorSwatch) {
$hintObj = ColorUtils.formatColorHint($hintObj, token.color);
}
return $hintObj;
});
} | javascript | function formatHints(hints, query) {
var hasColorSwatch = hints.some(function (token) {
return token.color;
});
StringMatch.basicMatchSort(hints);
return hints.map(function (token) {
var $hintObj = $("<span>").addClass("brackets-css-hints");
// highlight the matched portion of each hint
if (token.stringRanges) {
token.stringRanges.forEach(function (item) {
if (item.matched) {
$hintObj.append($("<span>")
.text(item.text)
.addClass("matched-hint"));
} else {
$hintObj.append(item.text);
}
});
} else {
$hintObj.text(token.value);
}
if (hasColorSwatch) {
$hintObj = ColorUtils.formatColorHint($hintObj, token.color);
}
return $hintObj;
});
} | [
"function",
"formatHints",
"(",
"hints",
",",
"query",
")",
"{",
"var",
"hasColorSwatch",
"=",
"hints",
".",
"some",
"(",
"function",
"(",
"token",
")",
"{",
"return",
"token",
".",
"color",
";",
"}",
")",
";",
"StringMatch",
".",
"basicMatchSort",
"(",
"hints",
")",
";",
"return",
"hints",
".",
"map",
"(",
"function",
"(",
"token",
")",
"{",
"var",
"$hintObj",
"=",
"$",
"(",
"\"<span>\"",
")",
".",
"addClass",
"(",
"\"brackets-css-hints\"",
")",
";",
"// highlight the matched portion of each hint",
"if",
"(",
"token",
".",
"stringRanges",
")",
"{",
"token",
".",
"stringRanges",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"if",
"(",
"item",
".",
"matched",
")",
"{",
"$hintObj",
".",
"append",
"(",
"$",
"(",
"\"<span>\"",
")",
".",
"text",
"(",
"item",
".",
"text",
")",
".",
"addClass",
"(",
"\"matched-hint\"",
")",
")",
";",
"}",
"else",
"{",
"$hintObj",
".",
"append",
"(",
"item",
".",
"text",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"$hintObj",
".",
"text",
"(",
"token",
".",
"value",
")",
";",
"}",
"if",
"(",
"hasColorSwatch",
")",
"{",
"$hintObj",
"=",
"ColorUtils",
".",
"formatColorHint",
"(",
"$hintObj",
",",
"token",
".",
"color",
")",
";",
"}",
"return",
"$hintObj",
";",
"}",
")",
";",
"}"
] | Returns a sorted and formatted list of hints with the query substring
highlighted.
@param {Array.<Object>} hints - the list of hints to format
@param {string} query - querystring used for highlighting matched
portions of each hint
@return {Array.jQuery} sorted Array of jQuery DOM elements to insert | [
"Returns",
"a",
"sorted",
"and",
"formatted",
"list",
"of",
"hints",
"with",
"the",
"query",
"substring",
"highlighted",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CSSCodeHints/main.js#L193-L223 |
1,931 | adobe/brackets | src/filesystem/FileSystemEntry.js | compareFilesWithIndices | function compareFilesWithIndices(index1, index2) {
return entries[index1]._name.toLocaleLowerCase().localeCompare(entries[index2]._name.toLocaleLowerCase());
} | javascript | function compareFilesWithIndices(index1, index2) {
return entries[index1]._name.toLocaleLowerCase().localeCompare(entries[index2]._name.toLocaleLowerCase());
} | [
"function",
"compareFilesWithIndices",
"(",
"index1",
",",
"index2",
")",
"{",
"return",
"entries",
"[",
"index1",
"]",
".",
"_name",
".",
"toLocaleLowerCase",
"(",
")",
".",
"localeCompare",
"(",
"entries",
"[",
"index2",
"]",
".",
"_name",
".",
"toLocaleLowerCase",
"(",
")",
")",
";",
"}"
] | sort entries if required | [
"sort",
"entries",
"if",
"required"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/filesystem/FileSystemEntry.js#L510-L512 |
1,932 | adobe/brackets | src/search/node/FindInFilesDomain.js | offsetToLineNum | function offsetToLineNum(textOrLines, offset) {
if (Array.isArray(textOrLines)) {
var lines = textOrLines,
total = 0,
line;
for (line = 0; line < lines.length; line++) {
if (total < offset) {
// add 1 per line since /n were removed by splitting, but they needed to
// contribute to the total offset count
total += lines[line].length + 1;
} else if (total === offset) {
return line;
} else {
return line - 1;
}
}
// if offset is NOT over the total then offset is in the last line
if (offset <= total) {
return line - 1;
} else {
return undefined;
}
} else {
return textOrLines.substr(0, offset).split("\n").length - 1;
}
} | javascript | function offsetToLineNum(textOrLines, offset) {
if (Array.isArray(textOrLines)) {
var lines = textOrLines,
total = 0,
line;
for (line = 0; line < lines.length; line++) {
if (total < offset) {
// add 1 per line since /n were removed by splitting, but they needed to
// contribute to the total offset count
total += lines[line].length + 1;
} else if (total === offset) {
return line;
} else {
return line - 1;
}
}
// if offset is NOT over the total then offset is in the last line
if (offset <= total) {
return line - 1;
} else {
return undefined;
}
} else {
return textOrLines.substr(0, offset).split("\n").length - 1;
}
} | [
"function",
"offsetToLineNum",
"(",
"textOrLines",
",",
"offset",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"textOrLines",
")",
")",
"{",
"var",
"lines",
"=",
"textOrLines",
",",
"total",
"=",
"0",
",",
"line",
";",
"for",
"(",
"line",
"=",
"0",
";",
"line",
"<",
"lines",
".",
"length",
";",
"line",
"++",
")",
"{",
"if",
"(",
"total",
"<",
"offset",
")",
"{",
"// add 1 per line since /n were removed by splitting, but they needed to",
"// contribute to the total offset count",
"total",
"+=",
"lines",
"[",
"line",
"]",
".",
"length",
"+",
"1",
";",
"}",
"else",
"if",
"(",
"total",
"===",
"offset",
")",
"{",
"return",
"line",
";",
"}",
"else",
"{",
"return",
"line",
"-",
"1",
";",
"}",
"}",
"// if offset is NOT over the total then offset is in the last line",
"if",
"(",
"offset",
"<=",
"total",
")",
"{",
"return",
"line",
"-",
"1",
";",
"}",
"else",
"{",
"return",
"undefined",
";",
"}",
"}",
"else",
"{",
"return",
"textOrLines",
".",
"substr",
"(",
"0",
",",
"offset",
")",
".",
"split",
"(",
"\"\\n\"",
")",
".",
"length",
"-",
"1",
";",
"}",
"}"
] | Copied from StringUtils.js
Returns a line number corresponding to an offset in some text. The text can
be specified as a single string or as an array of strings that correspond to
the lines of the string.
Specify the text in lines when repeatedly calling the function on the same
text in a loop. Use getLines() to divide the text into lines, then repeatedly call
this function to compute a line number from the offset.
@param {string | Array.<string>} textOrLines - string or array of lines from which
to compute the line number from the offset
@param {number} offset
@return {number} line number | [
"Copied",
"from",
"StringUtils",
".",
"js",
"Returns",
"a",
"line",
"number",
"corresponding",
"to",
"an",
"offset",
"in",
"some",
"text",
".",
"The",
"text",
"can",
"be",
"specified",
"as",
"a",
"single",
"string",
"or",
"as",
"an",
"array",
"of",
"strings",
"that",
"correspond",
"to",
"the",
"lines",
"of",
"the",
"string",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/node/FindInFilesDomain.js#L68-L94 |
1,933 | adobe/brackets | src/search/node/FindInFilesDomain.js | getSearchMatches | function getSearchMatches(contents, queryExpr) {
if (!contents) {
return;
}
// Quick exit if not found or if we hit the limit
if (foundMaximum || contents.search(queryExpr) === -1) {
return [];
}
var match, lineNum, line, ch, totalMatchLength, matchedLines, numMatchedLines, lastLineLength, endCh,
padding, leftPadding, rightPadding, highlightOffset, highlightEndCh,
lines = contents.split("\n"),
matches = [];
while ((match = queryExpr.exec(contents)) !== null) {
lineNum = offsetToLineNum(lines, match.index);
line = lines[lineNum];
ch = match.index - contents.lastIndexOf("\n", match.index) - 1; // 0-based index
matchedLines = match[0].split("\n");
numMatchedLines = matchedLines.length;
totalMatchLength = match[0].length;
lastLineLength = matchedLines[matchedLines.length - 1].length;
endCh = (numMatchedLines === 1 ? ch + totalMatchLength : lastLineLength);
highlightEndCh = (numMatchedLines === 1 ? endCh : line.length);
highlightOffset = 0;
if (highlightEndCh <= MAX_DISPLAY_LENGTH) {
// Don't store more than 200 chars per line
line = line.substr(0, Math.min(MAX_DISPLAY_LENGTH, line.length));
} else if (totalMatchLength > MAX_DISPLAY_LENGTH) {
// impossible to display the whole match
line = line.substr(ch, ch + MAX_DISPLAY_LENGTH);
highlightOffset = ch;
} else {
// Try to have both beginning and end of match displayed
padding = MAX_DISPLAY_LENGTH - totalMatchLength;
rightPadding = Math.floor(Math.min(padding / 2, line.length - highlightEndCh));
leftPadding = Math.ceil(padding - rightPadding);
highlightOffset = ch - leftPadding;
line = line.substring(highlightOffset, highlightEndCh + rightPadding);
}
matches.push({
start: {line: lineNum, ch: ch},
end: {line: lineNum + numMatchedLines - 1, ch: endCh},
highlightOffset: highlightOffset,
// Note that the following offsets from the beginning of the file are *not* updated if the search
// results change. These are currently only used for multi-file replacement, and we always
// abort the replace (by shutting the results panel) if we detect any result changes, so we don't
// need to keep them up to date. Eventually, we should either get rid of the need for these (by
// doing everything in terms of line/ch offsets, though that will require re-splitting files when
// doing a replace) or properly update them.
startOffset: match.index,
endOffset: match.index + totalMatchLength,
line: line,
result: match,
isChecked: true
});
// We have the max hits in just this 1 file. Stop searching this file.
// This fixed issue #1829 where code hangs on too many hits.
// Adds one over MAX_RESULTS_IN_A_FILE in order to know if the search has exceeded
// or is equal to MAX_RESULTS_IN_A_FILE. Additional result removed in SearchModel
if (matches.length > MAX_RESULTS_IN_A_FILE) {
queryExpr.lastIndex = 0;
break;
}
// Pathological regexps like /^/ return 0-length matches. Ensure we make progress anyway
if (totalMatchLength === 0) {
queryExpr.lastIndex++;
}
}
return matches;
} | javascript | function getSearchMatches(contents, queryExpr) {
if (!contents) {
return;
}
// Quick exit if not found or if we hit the limit
if (foundMaximum || contents.search(queryExpr) === -1) {
return [];
}
var match, lineNum, line, ch, totalMatchLength, matchedLines, numMatchedLines, lastLineLength, endCh,
padding, leftPadding, rightPadding, highlightOffset, highlightEndCh,
lines = contents.split("\n"),
matches = [];
while ((match = queryExpr.exec(contents)) !== null) {
lineNum = offsetToLineNum(lines, match.index);
line = lines[lineNum];
ch = match.index - contents.lastIndexOf("\n", match.index) - 1; // 0-based index
matchedLines = match[0].split("\n");
numMatchedLines = matchedLines.length;
totalMatchLength = match[0].length;
lastLineLength = matchedLines[matchedLines.length - 1].length;
endCh = (numMatchedLines === 1 ? ch + totalMatchLength : lastLineLength);
highlightEndCh = (numMatchedLines === 1 ? endCh : line.length);
highlightOffset = 0;
if (highlightEndCh <= MAX_DISPLAY_LENGTH) {
// Don't store more than 200 chars per line
line = line.substr(0, Math.min(MAX_DISPLAY_LENGTH, line.length));
} else if (totalMatchLength > MAX_DISPLAY_LENGTH) {
// impossible to display the whole match
line = line.substr(ch, ch + MAX_DISPLAY_LENGTH);
highlightOffset = ch;
} else {
// Try to have both beginning and end of match displayed
padding = MAX_DISPLAY_LENGTH - totalMatchLength;
rightPadding = Math.floor(Math.min(padding / 2, line.length - highlightEndCh));
leftPadding = Math.ceil(padding - rightPadding);
highlightOffset = ch - leftPadding;
line = line.substring(highlightOffset, highlightEndCh + rightPadding);
}
matches.push({
start: {line: lineNum, ch: ch},
end: {line: lineNum + numMatchedLines - 1, ch: endCh},
highlightOffset: highlightOffset,
// Note that the following offsets from the beginning of the file are *not* updated if the search
// results change. These are currently only used for multi-file replacement, and we always
// abort the replace (by shutting the results panel) if we detect any result changes, so we don't
// need to keep them up to date. Eventually, we should either get rid of the need for these (by
// doing everything in terms of line/ch offsets, though that will require re-splitting files when
// doing a replace) or properly update them.
startOffset: match.index,
endOffset: match.index + totalMatchLength,
line: line,
result: match,
isChecked: true
});
// We have the max hits in just this 1 file. Stop searching this file.
// This fixed issue #1829 where code hangs on too many hits.
// Adds one over MAX_RESULTS_IN_A_FILE in order to know if the search has exceeded
// or is equal to MAX_RESULTS_IN_A_FILE. Additional result removed in SearchModel
if (matches.length > MAX_RESULTS_IN_A_FILE) {
queryExpr.lastIndex = 0;
break;
}
// Pathological regexps like /^/ return 0-length matches. Ensure we make progress anyway
if (totalMatchLength === 0) {
queryExpr.lastIndex++;
}
}
return matches;
} | [
"function",
"getSearchMatches",
"(",
"contents",
",",
"queryExpr",
")",
"{",
"if",
"(",
"!",
"contents",
")",
"{",
"return",
";",
"}",
"// Quick exit if not found or if we hit the limit",
"if",
"(",
"foundMaximum",
"||",
"contents",
".",
"search",
"(",
"queryExpr",
")",
"===",
"-",
"1",
")",
"{",
"return",
"[",
"]",
";",
"}",
"var",
"match",
",",
"lineNum",
",",
"line",
",",
"ch",
",",
"totalMatchLength",
",",
"matchedLines",
",",
"numMatchedLines",
",",
"lastLineLength",
",",
"endCh",
",",
"padding",
",",
"leftPadding",
",",
"rightPadding",
",",
"highlightOffset",
",",
"highlightEndCh",
",",
"lines",
"=",
"contents",
".",
"split",
"(",
"\"\\n\"",
")",
",",
"matches",
"=",
"[",
"]",
";",
"while",
"(",
"(",
"match",
"=",
"queryExpr",
".",
"exec",
"(",
"contents",
")",
")",
"!==",
"null",
")",
"{",
"lineNum",
"=",
"offsetToLineNum",
"(",
"lines",
",",
"match",
".",
"index",
")",
";",
"line",
"=",
"lines",
"[",
"lineNum",
"]",
";",
"ch",
"=",
"match",
".",
"index",
"-",
"contents",
".",
"lastIndexOf",
"(",
"\"\\n\"",
",",
"match",
".",
"index",
")",
"-",
"1",
";",
"// 0-based index",
"matchedLines",
"=",
"match",
"[",
"0",
"]",
".",
"split",
"(",
"\"\\n\"",
")",
";",
"numMatchedLines",
"=",
"matchedLines",
".",
"length",
";",
"totalMatchLength",
"=",
"match",
"[",
"0",
"]",
".",
"length",
";",
"lastLineLength",
"=",
"matchedLines",
"[",
"matchedLines",
".",
"length",
"-",
"1",
"]",
".",
"length",
";",
"endCh",
"=",
"(",
"numMatchedLines",
"===",
"1",
"?",
"ch",
"+",
"totalMatchLength",
":",
"lastLineLength",
")",
";",
"highlightEndCh",
"=",
"(",
"numMatchedLines",
"===",
"1",
"?",
"endCh",
":",
"line",
".",
"length",
")",
";",
"highlightOffset",
"=",
"0",
";",
"if",
"(",
"highlightEndCh",
"<=",
"MAX_DISPLAY_LENGTH",
")",
"{",
"// Don't store more than 200 chars per line",
"line",
"=",
"line",
".",
"substr",
"(",
"0",
",",
"Math",
".",
"min",
"(",
"MAX_DISPLAY_LENGTH",
",",
"line",
".",
"length",
")",
")",
";",
"}",
"else",
"if",
"(",
"totalMatchLength",
">",
"MAX_DISPLAY_LENGTH",
")",
"{",
"// impossible to display the whole match",
"line",
"=",
"line",
".",
"substr",
"(",
"ch",
",",
"ch",
"+",
"MAX_DISPLAY_LENGTH",
")",
";",
"highlightOffset",
"=",
"ch",
";",
"}",
"else",
"{",
"// Try to have both beginning and end of match displayed",
"padding",
"=",
"MAX_DISPLAY_LENGTH",
"-",
"totalMatchLength",
";",
"rightPadding",
"=",
"Math",
".",
"floor",
"(",
"Math",
".",
"min",
"(",
"padding",
"/",
"2",
",",
"line",
".",
"length",
"-",
"highlightEndCh",
")",
")",
";",
"leftPadding",
"=",
"Math",
".",
"ceil",
"(",
"padding",
"-",
"rightPadding",
")",
";",
"highlightOffset",
"=",
"ch",
"-",
"leftPadding",
";",
"line",
"=",
"line",
".",
"substring",
"(",
"highlightOffset",
",",
"highlightEndCh",
"+",
"rightPadding",
")",
";",
"}",
"matches",
".",
"push",
"(",
"{",
"start",
":",
"{",
"line",
":",
"lineNum",
",",
"ch",
":",
"ch",
"}",
",",
"end",
":",
"{",
"line",
":",
"lineNum",
"+",
"numMatchedLines",
"-",
"1",
",",
"ch",
":",
"endCh",
"}",
",",
"highlightOffset",
":",
"highlightOffset",
",",
"// Note that the following offsets from the beginning of the file are *not* updated if the search",
"// results change. These are currently only used for multi-file replacement, and we always",
"// abort the replace (by shutting the results panel) if we detect any result changes, so we don't",
"// need to keep them up to date. Eventually, we should either get rid of the need for these (by",
"// doing everything in terms of line/ch offsets, though that will require re-splitting files when",
"// doing a replace) or properly update them.",
"startOffset",
":",
"match",
".",
"index",
",",
"endOffset",
":",
"match",
".",
"index",
"+",
"totalMatchLength",
",",
"line",
":",
"line",
",",
"result",
":",
"match",
",",
"isChecked",
":",
"true",
"}",
")",
";",
"// We have the max hits in just this 1 file. Stop searching this file.",
"// This fixed issue #1829 where code hangs on too many hits.",
"// Adds one over MAX_RESULTS_IN_A_FILE in order to know if the search has exceeded",
"// or is equal to MAX_RESULTS_IN_A_FILE. Additional result removed in SearchModel",
"if",
"(",
"matches",
".",
"length",
">",
"MAX_RESULTS_IN_A_FILE",
")",
"{",
"queryExpr",
".",
"lastIndex",
"=",
"0",
";",
"break",
";",
"}",
"// Pathological regexps like /^/ return 0-length matches. Ensure we make progress anyway",
"if",
"(",
"totalMatchLength",
"===",
"0",
")",
"{",
"queryExpr",
".",
"lastIndex",
"++",
";",
"}",
"}",
"return",
"matches",
";",
"}"
] | Searches through the contents and returns an array of matches
@param {string} contents
@param {RegExp} queryExpr
@return {!Array.<{start: {line:number,ch:number}, end: {line:number,ch:number}, line: string}>} | [
"Searches",
"through",
"the",
"contents",
"and",
"returns",
"an",
"array",
"of",
"matches"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/node/FindInFilesDomain.js#L102-L180 |
1,934 | adobe/brackets | src/search/node/FindInFilesDomain.js | getFilesizeInBytes | function getFilesizeInBytes(fileName) {
try {
var stats = fs.statSync(fileName);
return stats.size || 0;
} catch (ex) {
console.log(ex);
return 0;
}
} | javascript | function getFilesizeInBytes(fileName) {
try {
var stats = fs.statSync(fileName);
return stats.size || 0;
} catch (ex) {
console.log(ex);
return 0;
}
} | [
"function",
"getFilesizeInBytes",
"(",
"fileName",
")",
"{",
"try",
"{",
"var",
"stats",
"=",
"fs",
".",
"statSync",
"(",
"fileName",
")",
";",
"return",
"stats",
".",
"size",
"||",
"0",
";",
"}",
"catch",
"(",
"ex",
")",
"{",
"console",
".",
"log",
"(",
"ex",
")",
";",
"return",
"0",
";",
"}",
"}"
] | Gets the file size in bytes.
@param {string} fileName The name of the file to get the size
@returns {Number} the file size in bytes | [
"Gets",
"the",
"file",
"size",
"in",
"bytes",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/node/FindInFilesDomain.js#L195-L203 |
1,935 | adobe/brackets | src/search/node/FindInFilesDomain.js | setResults | function setResults(fullpath, resultInfo, maxResultsToReturn) {
if (results[fullpath]) {
numMatches -= results[fullpath].matches.length;
delete results[fullpath];
}
if (foundMaximum || !resultInfo || !resultInfo.matches || !resultInfo.matches.length) {
return;
}
// Make sure that the optional `collapsed` property is explicitly set to either true or false,
// to avoid logic issues later with comparing values.
resultInfo.collapsed = collapseResults;
results[fullpath] = resultInfo;
numMatches += resultInfo.matches.length;
evaluatedMatches += resultInfo.matches.length;
maxResultsToReturn = maxResultsToReturn || MAX_RESULTS_TO_RETURN;
if (numMatches >= maxResultsToReturn || evaluatedMatches > MAX_TOTAL_RESULTS) {
foundMaximum = true;
}
} | javascript | function setResults(fullpath, resultInfo, maxResultsToReturn) {
if (results[fullpath]) {
numMatches -= results[fullpath].matches.length;
delete results[fullpath];
}
if (foundMaximum || !resultInfo || !resultInfo.matches || !resultInfo.matches.length) {
return;
}
// Make sure that the optional `collapsed` property is explicitly set to either true or false,
// to avoid logic issues later with comparing values.
resultInfo.collapsed = collapseResults;
results[fullpath] = resultInfo;
numMatches += resultInfo.matches.length;
evaluatedMatches += resultInfo.matches.length;
maxResultsToReturn = maxResultsToReturn || MAX_RESULTS_TO_RETURN;
if (numMatches >= maxResultsToReturn || evaluatedMatches > MAX_TOTAL_RESULTS) {
foundMaximum = true;
}
} | [
"function",
"setResults",
"(",
"fullpath",
",",
"resultInfo",
",",
"maxResultsToReturn",
")",
"{",
"if",
"(",
"results",
"[",
"fullpath",
"]",
")",
"{",
"numMatches",
"-=",
"results",
"[",
"fullpath",
"]",
".",
"matches",
".",
"length",
";",
"delete",
"results",
"[",
"fullpath",
"]",
";",
"}",
"if",
"(",
"foundMaximum",
"||",
"!",
"resultInfo",
"||",
"!",
"resultInfo",
".",
"matches",
"||",
"!",
"resultInfo",
".",
"matches",
".",
"length",
")",
"{",
"return",
";",
"}",
"// Make sure that the optional `collapsed` property is explicitly set to either true or false,",
"// to avoid logic issues later with comparing values.",
"resultInfo",
".",
"collapsed",
"=",
"collapseResults",
";",
"results",
"[",
"fullpath",
"]",
"=",
"resultInfo",
";",
"numMatches",
"+=",
"resultInfo",
".",
"matches",
".",
"length",
";",
"evaluatedMatches",
"+=",
"resultInfo",
".",
"matches",
".",
"length",
";",
"maxResultsToReturn",
"=",
"maxResultsToReturn",
"||",
"MAX_RESULTS_TO_RETURN",
";",
"if",
"(",
"numMatches",
">=",
"maxResultsToReturn",
"||",
"evaluatedMatches",
">",
"MAX_TOTAL_RESULTS",
")",
"{",
"foundMaximum",
"=",
"true",
";",
"}",
"}"
] | Sets the list of matches for the given path, removing the previous match info, if any, and updating
the total match count. Note that for the count to remain accurate, the previous match info must not have
been mutated since it was set.
@param {string} fullpath Full path to the file containing the matches.
@param {!{matches: Object, collapsed: boolean=}} resultInfo Info for the matches to set:
matches - Array of matches, in the format returned by FindInFiles.getSearchMatches()
collapsed - Optional: whether the results should be collapsed in the UI (default false). | [
"Sets",
"the",
"list",
"of",
"matches",
"for",
"the",
"given",
"path",
"removing",
"the",
"previous",
"match",
"info",
"if",
"any",
"and",
"updating",
"the",
"total",
"match",
"count",
".",
"Note",
"that",
"for",
"the",
"count",
"to",
"remain",
"accurate",
"the",
"previous",
"match",
"info",
"must",
"not",
"have",
"been",
"mutated",
"since",
"it",
"was",
"set",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/node/FindInFilesDomain.js#L237-L258 |
1,936 | adobe/brackets | src/search/node/FindInFilesDomain.js | doSearchInOneFile | function doSearchInOneFile(filepath, text, queryExpr, maxResultsToReturn) {
var matches = getSearchMatches(text, queryExpr);
setResults(filepath, {matches: matches}, maxResultsToReturn);
} | javascript | function doSearchInOneFile(filepath, text, queryExpr, maxResultsToReturn) {
var matches = getSearchMatches(text, queryExpr);
setResults(filepath, {matches: matches}, maxResultsToReturn);
} | [
"function",
"doSearchInOneFile",
"(",
"filepath",
",",
"text",
",",
"queryExpr",
",",
"maxResultsToReturn",
")",
"{",
"var",
"matches",
"=",
"getSearchMatches",
"(",
"text",
",",
"queryExpr",
")",
";",
"setResults",
"(",
"filepath",
",",
"{",
"matches",
":",
"matches",
"}",
",",
"maxResultsToReturn",
")",
";",
"}"
] | Finds search results in the given file and adds them to 'results'
@param {string} filepath
@param {string} text contents of the file
@param {Object} queryExpr
@param {number} maxResultsToReturn the maximum of results that should be returned in the current search. | [
"Finds",
"search",
"results",
"in",
"the",
"given",
"file",
"and",
"adds",
"them",
"to",
"results"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/node/FindInFilesDomain.js#L267-L270 |
1,937 | adobe/brackets | src/search/node/FindInFilesDomain.js | doSearchInFiles | function doSearchInFiles(fileList, queryExpr, startFileIndex, maxResultsToReturn) {
var i;
if (fileList.length === 0) {
console.log('no files found');
return;
} else {
startFileIndex = startFileIndex || 0;
for (i = startFileIndex; i < fileList.length && !foundMaximum; i++) {
doSearchInOneFile(fileList[i], getFileContentsForFile(fileList[i]), queryExpr, maxResultsToReturn);
}
lastSearchedIndex = i;
}
} | javascript | function doSearchInFiles(fileList, queryExpr, startFileIndex, maxResultsToReturn) {
var i;
if (fileList.length === 0) {
console.log('no files found');
return;
} else {
startFileIndex = startFileIndex || 0;
for (i = startFileIndex; i < fileList.length && !foundMaximum; i++) {
doSearchInOneFile(fileList[i], getFileContentsForFile(fileList[i]), queryExpr, maxResultsToReturn);
}
lastSearchedIndex = i;
}
} | [
"function",
"doSearchInFiles",
"(",
"fileList",
",",
"queryExpr",
",",
"startFileIndex",
",",
"maxResultsToReturn",
")",
"{",
"var",
"i",
";",
"if",
"(",
"fileList",
".",
"length",
"===",
"0",
")",
"{",
"console",
".",
"log",
"(",
"'no files found'",
")",
";",
"return",
";",
"}",
"else",
"{",
"startFileIndex",
"=",
"startFileIndex",
"||",
"0",
";",
"for",
"(",
"i",
"=",
"startFileIndex",
";",
"i",
"<",
"fileList",
".",
"length",
"&&",
"!",
"foundMaximum",
";",
"i",
"++",
")",
"{",
"doSearchInOneFile",
"(",
"fileList",
"[",
"i",
"]",
",",
"getFileContentsForFile",
"(",
"fileList",
"[",
"i",
"]",
")",
",",
"queryExpr",
",",
"maxResultsToReturn",
")",
";",
"}",
"lastSearchedIndex",
"=",
"i",
";",
"}",
"}"
] | Search in the list of files given and populate the results
@param {array} fileList array of file paths
@param {Object} queryExpr
@param {number} startFileIndex the start index of the array from which the search has to be done
@param {number} maxResultsToReturn the maximum number of results to return in this search | [
"Search",
"in",
"the",
"list",
"of",
"files",
"given",
"and",
"populate",
"the",
"results"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/node/FindInFilesDomain.js#L279-L292 |
1,938 | adobe/brackets | src/search/node/FindInFilesDomain.js | fileCrawler | function fileCrawler() {
if (!files || (files && files.length === 0)) {
setTimeout(fileCrawler, 1000);
return;
}
var contents = "";
if (currentCrawlIndex < files.length) {
contents = getFileContentsForFile(files[currentCrawlIndex]);
if (contents) {
cacheSize += contents.length;
}
currentCrawlIndex++;
}
if (currentCrawlIndex < files.length) {
crawlComplete = false;
setImmediate(fileCrawler);
} else {
crawlComplete = true;
if (!crawlEventSent) {
crawlEventSent = true;
_domainManager.emitEvent("FindInFiles", "crawlComplete", [files.length, cacheSize]);
}
setTimeout(fileCrawler, 1000);
}
} | javascript | function fileCrawler() {
if (!files || (files && files.length === 0)) {
setTimeout(fileCrawler, 1000);
return;
}
var contents = "";
if (currentCrawlIndex < files.length) {
contents = getFileContentsForFile(files[currentCrawlIndex]);
if (contents) {
cacheSize += contents.length;
}
currentCrawlIndex++;
}
if (currentCrawlIndex < files.length) {
crawlComplete = false;
setImmediate(fileCrawler);
} else {
crawlComplete = true;
if (!crawlEventSent) {
crawlEventSent = true;
_domainManager.emitEvent("FindInFiles", "crawlComplete", [files.length, cacheSize]);
}
setTimeout(fileCrawler, 1000);
}
} | [
"function",
"fileCrawler",
"(",
")",
"{",
"if",
"(",
"!",
"files",
"||",
"(",
"files",
"&&",
"files",
".",
"length",
"===",
"0",
")",
")",
"{",
"setTimeout",
"(",
"fileCrawler",
",",
"1000",
")",
";",
"return",
";",
"}",
"var",
"contents",
"=",
"\"\"",
";",
"if",
"(",
"currentCrawlIndex",
"<",
"files",
".",
"length",
")",
"{",
"contents",
"=",
"getFileContentsForFile",
"(",
"files",
"[",
"currentCrawlIndex",
"]",
")",
";",
"if",
"(",
"contents",
")",
"{",
"cacheSize",
"+=",
"contents",
".",
"length",
";",
"}",
"currentCrawlIndex",
"++",
";",
"}",
"if",
"(",
"currentCrawlIndex",
"<",
"files",
".",
"length",
")",
"{",
"crawlComplete",
"=",
"false",
";",
"setImmediate",
"(",
"fileCrawler",
")",
";",
"}",
"else",
"{",
"crawlComplete",
"=",
"true",
";",
"if",
"(",
"!",
"crawlEventSent",
")",
"{",
"crawlEventSent",
"=",
"true",
";",
"_domainManager",
".",
"emitEvent",
"(",
"\"FindInFiles\"",
",",
"\"crawlComplete\"",
",",
"[",
"files",
".",
"length",
",",
"cacheSize",
"]",
")",
";",
"}",
"setTimeout",
"(",
"fileCrawler",
",",
"1000",
")",
";",
"}",
"}"
] | Crawls through the files in the project ans stores them in cache. Since that could take a while
we do it in batches so that node wont be blocked. | [
"Crawls",
"through",
"the",
"files",
"in",
"the",
"project",
"ans",
"stores",
"them",
"in",
"cache",
".",
"Since",
"that",
"could",
"take",
"a",
"while",
"we",
"do",
"it",
"in",
"batches",
"so",
"that",
"node",
"wont",
"be",
"blocked",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/node/FindInFilesDomain.js#L343-L367 |
1,939 | adobe/brackets | src/search/node/FindInFilesDomain.js | countNumMatches | function countNumMatches(contents, queryExpr) {
if (!contents) {
return 0;
}
var matches = contents.match(queryExpr);
return matches ? matches.length : 0;
} | javascript | function countNumMatches(contents, queryExpr) {
if (!contents) {
return 0;
}
var matches = contents.match(queryExpr);
return matches ? matches.length : 0;
} | [
"function",
"countNumMatches",
"(",
"contents",
",",
"queryExpr",
")",
"{",
"if",
"(",
"!",
"contents",
")",
"{",
"return",
"0",
";",
"}",
"var",
"matches",
"=",
"contents",
".",
"match",
"(",
"queryExpr",
")",
";",
"return",
"matches",
"?",
"matches",
".",
"length",
":",
"0",
";",
"}"
] | Counts the number of matches matching the queryExpr in the given contents
@param {String} contents The contents to search on
@param {Object} queryExpr
@return {number} number of matches | [
"Counts",
"the",
"number",
"of",
"matches",
"matching",
"the",
"queryExpr",
"in",
"the",
"given",
"contents"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/node/FindInFilesDomain.js#L388-L394 |
1,940 | adobe/brackets | src/search/node/FindInFilesDomain.js | getNumMatches | function getNumMatches(fileList, queryExpr) {
var i,
matches = 0;
for (i = 0; i < fileList.length; i++) {
var temp = countNumMatches(getFileContentsForFile(fileList[i]), queryExpr);
if (temp) {
numFiles++;
matches += temp;
}
if (matches > MAX_TOTAL_RESULTS) {
exceedsMaximum = true;
break;
}
}
return matches;
} | javascript | function getNumMatches(fileList, queryExpr) {
var i,
matches = 0;
for (i = 0; i < fileList.length; i++) {
var temp = countNumMatches(getFileContentsForFile(fileList[i]), queryExpr);
if (temp) {
numFiles++;
matches += temp;
}
if (matches > MAX_TOTAL_RESULTS) {
exceedsMaximum = true;
break;
}
}
return matches;
} | [
"function",
"getNumMatches",
"(",
"fileList",
",",
"queryExpr",
")",
"{",
"var",
"i",
",",
"matches",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"fileList",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"temp",
"=",
"countNumMatches",
"(",
"getFileContentsForFile",
"(",
"fileList",
"[",
"i",
"]",
")",
",",
"queryExpr",
")",
";",
"if",
"(",
"temp",
")",
"{",
"numFiles",
"++",
";",
"matches",
"+=",
"temp",
";",
"}",
"if",
"(",
"matches",
">",
"MAX_TOTAL_RESULTS",
")",
"{",
"exceedsMaximum",
"=",
"true",
";",
"break",
";",
"}",
"}",
"return",
"matches",
";",
"}"
] | Get the total number of matches from all the files in fileList
@param {array} fileList file path array
@param {Object} queryExpr
@return {Number} total number of matches | [
"Get",
"the",
"total",
"number",
"of",
"matches",
"from",
"all",
"the",
"files",
"in",
"fileList"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/node/FindInFilesDomain.js#L402-L417 |
1,941 | adobe/brackets | src/search/node/FindInFilesDomain.js | doSearch | function doSearch(searchObject, nextPages) {
savedSearchObject = searchObject;
if (!files) {
console.log("no file object found");
return {};
}
results = {};
numMatches = 0;
numFiles = 0;
foundMaximum = false;
if (!nextPages) {
exceedsMaximum = false;
evaluatedMatches = 0;
}
var queryObject = parseQueryInfo(searchObject.queryInfo);
if (searchObject.files) {
files = searchObject.files;
}
if (searchObject.getAllResults) {
searchObject.maxResultsToReturn = MAX_TOTAL_RESULTS;
}
doSearchInFiles(files, queryObject.queryExpr, searchObject.startFileIndex, searchObject.maxResultsToReturn);
if (crawlComplete && !nextPages) {
numMatches = getNumMatches(files, queryObject.queryExpr);
}
var send_object = {
"results": results,
"foundMaximum": foundMaximum,
"exceedsMaximum": exceedsMaximum
};
if (!nextPages) {
send_object.numMatches = numMatches;
send_object.numFiles = numFiles;
}
if (searchObject.getAllResults) {
send_object.allResultsAvailable = true;
}
return send_object;
} | javascript | function doSearch(searchObject, nextPages) {
savedSearchObject = searchObject;
if (!files) {
console.log("no file object found");
return {};
}
results = {};
numMatches = 0;
numFiles = 0;
foundMaximum = false;
if (!nextPages) {
exceedsMaximum = false;
evaluatedMatches = 0;
}
var queryObject = parseQueryInfo(searchObject.queryInfo);
if (searchObject.files) {
files = searchObject.files;
}
if (searchObject.getAllResults) {
searchObject.maxResultsToReturn = MAX_TOTAL_RESULTS;
}
doSearchInFiles(files, queryObject.queryExpr, searchObject.startFileIndex, searchObject.maxResultsToReturn);
if (crawlComplete && !nextPages) {
numMatches = getNumMatches(files, queryObject.queryExpr);
}
var send_object = {
"results": results,
"foundMaximum": foundMaximum,
"exceedsMaximum": exceedsMaximum
};
if (!nextPages) {
send_object.numMatches = numMatches;
send_object.numFiles = numFiles;
}
if (searchObject.getAllResults) {
send_object.allResultsAvailable = true;
}
return send_object;
} | [
"function",
"doSearch",
"(",
"searchObject",
",",
"nextPages",
")",
"{",
"savedSearchObject",
"=",
"searchObject",
";",
"if",
"(",
"!",
"files",
")",
"{",
"console",
".",
"log",
"(",
"\"no file object found\"",
")",
";",
"return",
"{",
"}",
";",
"}",
"results",
"=",
"{",
"}",
";",
"numMatches",
"=",
"0",
";",
"numFiles",
"=",
"0",
";",
"foundMaximum",
"=",
"false",
";",
"if",
"(",
"!",
"nextPages",
")",
"{",
"exceedsMaximum",
"=",
"false",
";",
"evaluatedMatches",
"=",
"0",
";",
"}",
"var",
"queryObject",
"=",
"parseQueryInfo",
"(",
"searchObject",
".",
"queryInfo",
")",
";",
"if",
"(",
"searchObject",
".",
"files",
")",
"{",
"files",
"=",
"searchObject",
".",
"files",
";",
"}",
"if",
"(",
"searchObject",
".",
"getAllResults",
")",
"{",
"searchObject",
".",
"maxResultsToReturn",
"=",
"MAX_TOTAL_RESULTS",
";",
"}",
"doSearchInFiles",
"(",
"files",
",",
"queryObject",
".",
"queryExpr",
",",
"searchObject",
".",
"startFileIndex",
",",
"searchObject",
".",
"maxResultsToReturn",
")",
";",
"if",
"(",
"crawlComplete",
"&&",
"!",
"nextPages",
")",
"{",
"numMatches",
"=",
"getNumMatches",
"(",
"files",
",",
"queryObject",
".",
"queryExpr",
")",
";",
"}",
"var",
"send_object",
"=",
"{",
"\"results\"",
":",
"results",
",",
"\"foundMaximum\"",
":",
"foundMaximum",
",",
"\"exceedsMaximum\"",
":",
"exceedsMaximum",
"}",
";",
"if",
"(",
"!",
"nextPages",
")",
"{",
"send_object",
".",
"numMatches",
"=",
"numMatches",
";",
"send_object",
".",
"numFiles",
"=",
"numFiles",
";",
"}",
"if",
"(",
"searchObject",
".",
"getAllResults",
")",
"{",
"send_object",
".",
"allResultsAvailable",
"=",
"true",
";",
"}",
"return",
"send_object",
";",
"}"
] | Do a search with the searchObject context and return the results
@param {Object} searchObject
@param {boolean} nextPages set to true if to indicate that next page of an existing page is being fetched
@return {Object} search results | [
"Do",
"a",
"search",
"with",
"the",
"searchObject",
"context",
"and",
"return",
"the",
"results"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/node/FindInFilesDomain.js#L425-L466 |
1,942 | adobe/brackets | src/search/node/FindInFilesDomain.js | removeFilesFromCache | function removeFilesFromCache(updateObject) {
var fileList = updateObject.fileList || [],
filesInSearchScope = updateObject.filesInSearchScope || [],
i = 0;
for (i = 0; i < fileList.length; i++) {
delete projectCache[fileList[i]];
}
function isNotInRemovedFilesList(path) {
return (filesInSearchScope.indexOf(path) === -1) ? true : false;
}
files = files ? files.filter(isNotInRemovedFilesList) : files;
} | javascript | function removeFilesFromCache(updateObject) {
var fileList = updateObject.fileList || [],
filesInSearchScope = updateObject.filesInSearchScope || [],
i = 0;
for (i = 0; i < fileList.length; i++) {
delete projectCache[fileList[i]];
}
function isNotInRemovedFilesList(path) {
return (filesInSearchScope.indexOf(path) === -1) ? true : false;
}
files = files ? files.filter(isNotInRemovedFilesList) : files;
} | [
"function",
"removeFilesFromCache",
"(",
"updateObject",
")",
"{",
"var",
"fileList",
"=",
"updateObject",
".",
"fileList",
"||",
"[",
"]",
",",
"filesInSearchScope",
"=",
"updateObject",
".",
"filesInSearchScope",
"||",
"[",
"]",
",",
"i",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"fileList",
".",
"length",
";",
"i",
"++",
")",
"{",
"delete",
"projectCache",
"[",
"fileList",
"[",
"i",
"]",
"]",
";",
"}",
"function",
"isNotInRemovedFilesList",
"(",
"path",
")",
"{",
"return",
"(",
"filesInSearchScope",
".",
"indexOf",
"(",
"path",
")",
"===",
"-",
"1",
")",
"?",
"true",
":",
"false",
";",
"}",
"files",
"=",
"files",
"?",
"files",
".",
"filter",
"(",
"isNotInRemovedFilesList",
")",
":",
"files",
";",
"}"
] | Remove the list of given files from the project cache
@param {Object} updateObject | [
"Remove",
"the",
"list",
"of",
"given",
"files",
"from",
"the",
"project",
"cache"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/node/FindInFilesDomain.js#L472-L483 |
1,943 | adobe/brackets | src/search/node/FindInFilesDomain.js | addFilesToCache | function addFilesToCache(updateObject) {
var fileList = updateObject.fileList || [],
filesInSearchScope = updateObject.filesInSearchScope || [],
i = 0,
changedFilesAlreadyInList = [],
newFiles = [];
for (i = 0; i < fileList.length; i++) {
// We just add a null entry indicating the precense of the file in the project list.
// The file will be later read when required.
projectCache[fileList[i]] = null;
}
//Now update the search scope
function isInChangedFileList(path) {
return (filesInSearchScope.indexOf(path) !== -1) ? true : false;
}
changedFilesAlreadyInList = files ? files.filter(isInChangedFileList) : [];
function isNotAlreadyInList(path) {
return (changedFilesAlreadyInList.indexOf(path) === -1) ? true : false;
}
newFiles = changedFilesAlreadyInList.filter(isNotAlreadyInList);
files.push.apply(files, newFiles);
} | javascript | function addFilesToCache(updateObject) {
var fileList = updateObject.fileList || [],
filesInSearchScope = updateObject.filesInSearchScope || [],
i = 0,
changedFilesAlreadyInList = [],
newFiles = [];
for (i = 0; i < fileList.length; i++) {
// We just add a null entry indicating the precense of the file in the project list.
// The file will be later read when required.
projectCache[fileList[i]] = null;
}
//Now update the search scope
function isInChangedFileList(path) {
return (filesInSearchScope.indexOf(path) !== -1) ? true : false;
}
changedFilesAlreadyInList = files ? files.filter(isInChangedFileList) : [];
function isNotAlreadyInList(path) {
return (changedFilesAlreadyInList.indexOf(path) === -1) ? true : false;
}
newFiles = changedFilesAlreadyInList.filter(isNotAlreadyInList);
files.push.apply(files, newFiles);
} | [
"function",
"addFilesToCache",
"(",
"updateObject",
")",
"{",
"var",
"fileList",
"=",
"updateObject",
".",
"fileList",
"||",
"[",
"]",
",",
"filesInSearchScope",
"=",
"updateObject",
".",
"filesInSearchScope",
"||",
"[",
"]",
",",
"i",
"=",
"0",
",",
"changedFilesAlreadyInList",
"=",
"[",
"]",
",",
"newFiles",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"fileList",
".",
"length",
";",
"i",
"++",
")",
"{",
"// We just add a null entry indicating the precense of the file in the project list.",
"// The file will be later read when required.",
"projectCache",
"[",
"fileList",
"[",
"i",
"]",
"]",
"=",
"null",
";",
"}",
"//Now update the search scope",
"function",
"isInChangedFileList",
"(",
"path",
")",
"{",
"return",
"(",
"filesInSearchScope",
".",
"indexOf",
"(",
"path",
")",
"!==",
"-",
"1",
")",
"?",
"true",
":",
"false",
";",
"}",
"changedFilesAlreadyInList",
"=",
"files",
"?",
"files",
".",
"filter",
"(",
"isInChangedFileList",
")",
":",
"[",
"]",
";",
"function",
"isNotAlreadyInList",
"(",
"path",
")",
"{",
"return",
"(",
"changedFilesAlreadyInList",
".",
"indexOf",
"(",
"path",
")",
"===",
"-",
"1",
")",
"?",
"true",
":",
"false",
";",
"}",
"newFiles",
"=",
"changedFilesAlreadyInList",
".",
"filter",
"(",
"isNotAlreadyInList",
")",
";",
"files",
".",
"push",
".",
"apply",
"(",
"files",
",",
"newFiles",
")",
";",
"}"
] | Adds the list of given files to the project cache. However the files will not be
read at this time. We just delete the project cache entry which will trigger a fetch on search.
@param {Object} updateObject | [
"Adds",
"the",
"list",
"of",
"given",
"files",
"to",
"the",
"project",
"cache",
".",
"However",
"the",
"files",
"will",
"not",
"be",
"read",
"at",
"this",
"time",
".",
"We",
"just",
"delete",
"the",
"project",
"cache",
"entry",
"which",
"will",
"trigger",
"a",
"fetch",
"on",
"search",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/node/FindInFilesDomain.js#L490-L512 |
1,944 | adobe/brackets | src/search/node/FindInFilesDomain.js | getNextPage | function getNextPage() {
var send_object = {
"results": {},
"numMatches": 0,
"foundMaximum": foundMaximum,
"exceedsMaximum": exceedsMaximum
};
if (!savedSearchObject) {
return send_object;
}
savedSearchObject.startFileIndex = lastSearchedIndex;
return doSearch(savedSearchObject, true);
} | javascript | function getNextPage() {
var send_object = {
"results": {},
"numMatches": 0,
"foundMaximum": foundMaximum,
"exceedsMaximum": exceedsMaximum
};
if (!savedSearchObject) {
return send_object;
}
savedSearchObject.startFileIndex = lastSearchedIndex;
return doSearch(savedSearchObject, true);
} | [
"function",
"getNextPage",
"(",
")",
"{",
"var",
"send_object",
"=",
"{",
"\"results\"",
":",
"{",
"}",
",",
"\"numMatches\"",
":",
"0",
",",
"\"foundMaximum\"",
":",
"foundMaximum",
",",
"\"exceedsMaximum\"",
":",
"exceedsMaximum",
"}",
";",
"if",
"(",
"!",
"savedSearchObject",
")",
"{",
"return",
"send_object",
";",
"}",
"savedSearchObject",
".",
"startFileIndex",
"=",
"lastSearchedIndex",
";",
"return",
"doSearch",
"(",
"savedSearchObject",
",",
"true",
")",
";",
"}"
] | Gets the next page of results of the ongoing search
@return {Object} search results | [
"Gets",
"the",
"next",
"page",
"of",
"results",
"of",
"the",
"ongoing",
"search"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/node/FindInFilesDomain.js#L526-L538 |
1,945 | adobe/brackets | src/search/node/FindInFilesDomain.js | getAllResults | function getAllResults() {
var send_object = {
"results": {},
"numMatches": 0,
"foundMaximum": foundMaximum,
"exceedsMaximum": exceedsMaximum
};
if (!savedSearchObject) {
return send_object;
}
savedSearchObject.startFileIndex = 0;
savedSearchObject.getAllResults = true;
return doSearch(savedSearchObject);
} | javascript | function getAllResults() {
var send_object = {
"results": {},
"numMatches": 0,
"foundMaximum": foundMaximum,
"exceedsMaximum": exceedsMaximum
};
if (!savedSearchObject) {
return send_object;
}
savedSearchObject.startFileIndex = 0;
savedSearchObject.getAllResults = true;
return doSearch(savedSearchObject);
} | [
"function",
"getAllResults",
"(",
")",
"{",
"var",
"send_object",
"=",
"{",
"\"results\"",
":",
"{",
"}",
",",
"\"numMatches\"",
":",
"0",
",",
"\"foundMaximum\"",
":",
"foundMaximum",
",",
"\"exceedsMaximum\"",
":",
"exceedsMaximum",
"}",
";",
"if",
"(",
"!",
"savedSearchObject",
")",
"{",
"return",
"send_object",
";",
"}",
"savedSearchObject",
".",
"startFileIndex",
"=",
"0",
";",
"savedSearchObject",
".",
"getAllResults",
"=",
"true",
";",
"return",
"doSearch",
"(",
"savedSearchObject",
")",
";",
"}"
] | Gets all the results for the saved search query if present or empty search results
@return {Object} The results object | [
"Gets",
"all",
"the",
"results",
"for",
"the",
"saved",
"search",
"query",
"if",
"present",
"or",
"empty",
"search",
"results"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/node/FindInFilesDomain.js#L544-L557 |
1,946 | adobe/brackets | src/widgets/Dialogs.js | function (e, autoDismiss) {
var $primaryBtn = this.find(".primary"),
buttonId = null,
which = String.fromCharCode(e.which),
$focusedElement = this.find(".dialog-button:focus, a:focus");
function stopEvent() {
e.preventDefault();
e.stopPropagation();
}
// There might be a textfield in the dialog's UI; don't want to mistake normal typing for dialog dismissal
var inTextArea = (e.target.tagName === "TEXTAREA"),
inTypingField = inTextArea || ($(e.target).filter(":text, :password").length > 0);
if (e.which === KeyEvent.DOM_VK_TAB) {
// We don't want to stopEvent() in this case since we might want the default behavior.
// _handleTab takes care of stopping/preventing default as necessary.
_handleTab(e, this);
} else if (e.which === KeyEvent.DOM_VK_ESCAPE) {
buttonId = DIALOG_BTN_CANCEL;
} else if (e.which === KeyEvent.DOM_VK_RETURN && (!inTextArea || e.ctrlKey)) {
// Enter key in single-line text input always dismisses; in text area, only Ctrl+Enter dismisses
// Click primary
stopEvent();
if (e.target.tagName === "BUTTON") {
this.find(e.target).click();
} else if (e.target.tagName !== "INPUT") {
// If the target element is not BUTTON or INPUT, click the primary button
// We're making an exception for INPUT element because of this issue: GH-11416
$primaryBtn.click();
}
} else if (e.which === KeyEvent.DOM_VK_SPACE) {
if ($focusedElement.length) {
// Space bar on focused button or link
stopEvent();
$focusedElement.click();
}
} else if (brackets.platform === "mac") {
// CMD+Backspace Don't Save
if (e.metaKey && (e.which === KeyEvent.DOM_VK_BACK_SPACE)) {
if (_hasButton(this, DIALOG_BTN_DONTSAVE)) {
buttonId = DIALOG_BTN_DONTSAVE;
}
// FIXME (issue #418) CMD+. Cancel swallowed by native shell
} else if (e.metaKey && (e.which === KeyEvent.DOM_VK_PERIOD)) {
buttonId = DIALOG_BTN_CANCEL;
}
} else { // if (brackets.platform === "win") {
// 'N' Don't Save
if (which === "N" && !inTypingField) {
if (_hasButton(this, DIALOG_BTN_DONTSAVE)) {
buttonId = DIALOG_BTN_DONTSAVE;
}
}
}
if (buttonId) {
stopEvent();
_processButton(this, buttonId, autoDismiss);
}
// Stop any other global hooks from processing the event (but
// allow it to continue bubbling if we haven't otherwise stopped it).
return true;
} | javascript | function (e, autoDismiss) {
var $primaryBtn = this.find(".primary"),
buttonId = null,
which = String.fromCharCode(e.which),
$focusedElement = this.find(".dialog-button:focus, a:focus");
function stopEvent() {
e.preventDefault();
e.stopPropagation();
}
// There might be a textfield in the dialog's UI; don't want to mistake normal typing for dialog dismissal
var inTextArea = (e.target.tagName === "TEXTAREA"),
inTypingField = inTextArea || ($(e.target).filter(":text, :password").length > 0);
if (e.which === KeyEvent.DOM_VK_TAB) {
// We don't want to stopEvent() in this case since we might want the default behavior.
// _handleTab takes care of stopping/preventing default as necessary.
_handleTab(e, this);
} else if (e.which === KeyEvent.DOM_VK_ESCAPE) {
buttonId = DIALOG_BTN_CANCEL;
} else if (e.which === KeyEvent.DOM_VK_RETURN && (!inTextArea || e.ctrlKey)) {
// Enter key in single-line text input always dismisses; in text area, only Ctrl+Enter dismisses
// Click primary
stopEvent();
if (e.target.tagName === "BUTTON") {
this.find(e.target).click();
} else if (e.target.tagName !== "INPUT") {
// If the target element is not BUTTON or INPUT, click the primary button
// We're making an exception for INPUT element because of this issue: GH-11416
$primaryBtn.click();
}
} else if (e.which === KeyEvent.DOM_VK_SPACE) {
if ($focusedElement.length) {
// Space bar on focused button or link
stopEvent();
$focusedElement.click();
}
} else if (brackets.platform === "mac") {
// CMD+Backspace Don't Save
if (e.metaKey && (e.which === KeyEvent.DOM_VK_BACK_SPACE)) {
if (_hasButton(this, DIALOG_BTN_DONTSAVE)) {
buttonId = DIALOG_BTN_DONTSAVE;
}
// FIXME (issue #418) CMD+. Cancel swallowed by native shell
} else if (e.metaKey && (e.which === KeyEvent.DOM_VK_PERIOD)) {
buttonId = DIALOG_BTN_CANCEL;
}
} else { // if (brackets.platform === "win") {
// 'N' Don't Save
if (which === "N" && !inTypingField) {
if (_hasButton(this, DIALOG_BTN_DONTSAVE)) {
buttonId = DIALOG_BTN_DONTSAVE;
}
}
}
if (buttonId) {
stopEvent();
_processButton(this, buttonId, autoDismiss);
}
// Stop any other global hooks from processing the event (but
// allow it to continue bubbling if we haven't otherwise stopped it).
return true;
} | [
"function",
"(",
"e",
",",
"autoDismiss",
")",
"{",
"var",
"$primaryBtn",
"=",
"this",
".",
"find",
"(",
"\".primary\"",
")",
",",
"buttonId",
"=",
"null",
",",
"which",
"=",
"String",
".",
"fromCharCode",
"(",
"e",
".",
"which",
")",
",",
"$focusedElement",
"=",
"this",
".",
"find",
"(",
"\".dialog-button:focus, a:focus\"",
")",
";",
"function",
"stopEvent",
"(",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"e",
".",
"stopPropagation",
"(",
")",
";",
"}",
"// There might be a textfield in the dialog's UI; don't want to mistake normal typing for dialog dismissal",
"var",
"inTextArea",
"=",
"(",
"e",
".",
"target",
".",
"tagName",
"===",
"\"TEXTAREA\"",
")",
",",
"inTypingField",
"=",
"inTextArea",
"||",
"(",
"$",
"(",
"e",
".",
"target",
")",
".",
"filter",
"(",
"\":text, :password\"",
")",
".",
"length",
">",
"0",
")",
";",
"if",
"(",
"e",
".",
"which",
"===",
"KeyEvent",
".",
"DOM_VK_TAB",
")",
"{",
"// We don't want to stopEvent() in this case since we might want the default behavior.",
"// _handleTab takes care of stopping/preventing default as necessary.",
"_handleTab",
"(",
"e",
",",
"this",
")",
";",
"}",
"else",
"if",
"(",
"e",
".",
"which",
"===",
"KeyEvent",
".",
"DOM_VK_ESCAPE",
")",
"{",
"buttonId",
"=",
"DIALOG_BTN_CANCEL",
";",
"}",
"else",
"if",
"(",
"e",
".",
"which",
"===",
"KeyEvent",
".",
"DOM_VK_RETURN",
"&&",
"(",
"!",
"inTextArea",
"||",
"e",
".",
"ctrlKey",
")",
")",
"{",
"// Enter key in single-line text input always dismisses; in text area, only Ctrl+Enter dismisses",
"// Click primary",
"stopEvent",
"(",
")",
";",
"if",
"(",
"e",
".",
"target",
".",
"tagName",
"===",
"\"BUTTON\"",
")",
"{",
"this",
".",
"find",
"(",
"e",
".",
"target",
")",
".",
"click",
"(",
")",
";",
"}",
"else",
"if",
"(",
"e",
".",
"target",
".",
"tagName",
"!==",
"\"INPUT\"",
")",
"{",
"// If the target element is not BUTTON or INPUT, click the primary button",
"// We're making an exception for INPUT element because of this issue: GH-11416",
"$primaryBtn",
".",
"click",
"(",
")",
";",
"}",
"}",
"else",
"if",
"(",
"e",
".",
"which",
"===",
"KeyEvent",
".",
"DOM_VK_SPACE",
")",
"{",
"if",
"(",
"$focusedElement",
".",
"length",
")",
"{",
"// Space bar on focused button or link",
"stopEvent",
"(",
")",
";",
"$focusedElement",
".",
"click",
"(",
")",
";",
"}",
"}",
"else",
"if",
"(",
"brackets",
".",
"platform",
"===",
"\"mac\"",
")",
"{",
"// CMD+Backspace Don't Save",
"if",
"(",
"e",
".",
"metaKey",
"&&",
"(",
"e",
".",
"which",
"===",
"KeyEvent",
".",
"DOM_VK_BACK_SPACE",
")",
")",
"{",
"if",
"(",
"_hasButton",
"(",
"this",
",",
"DIALOG_BTN_DONTSAVE",
")",
")",
"{",
"buttonId",
"=",
"DIALOG_BTN_DONTSAVE",
";",
"}",
"// FIXME (issue #418) CMD+. Cancel swallowed by native shell",
"}",
"else",
"if",
"(",
"e",
".",
"metaKey",
"&&",
"(",
"e",
".",
"which",
"===",
"KeyEvent",
".",
"DOM_VK_PERIOD",
")",
")",
"{",
"buttonId",
"=",
"DIALOG_BTN_CANCEL",
";",
"}",
"}",
"else",
"{",
"// if (brackets.platform === \"win\") {",
"// 'N' Don't Save",
"if",
"(",
"which",
"===",
"\"N\"",
"&&",
"!",
"inTypingField",
")",
"{",
"if",
"(",
"_hasButton",
"(",
"this",
",",
"DIALOG_BTN_DONTSAVE",
")",
")",
"{",
"buttonId",
"=",
"DIALOG_BTN_DONTSAVE",
";",
"}",
"}",
"}",
"if",
"(",
"buttonId",
")",
"{",
"stopEvent",
"(",
")",
";",
"_processButton",
"(",
"this",
",",
"buttonId",
",",
"autoDismiss",
")",
";",
"}",
"// Stop any other global hooks from processing the event (but",
"// allow it to continue bubbling if we haven't otherwise stopped it).",
"return",
"true",
";",
"}"
] | Handles the keyDown event for the dialogs
@param {$.Event} e
@param {boolean} autoDismiss
@return {boolean} | [
"Handles",
"the",
"keyDown",
"event",
"for",
"the",
"dialogs"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/widgets/Dialogs.js#L142-L207 |
|
1,947 | adobe/brackets | src/widgets/Dialogs.js | setDialogMaxSize | function setDialogMaxSize() {
var maxWidth, maxHeight,
$dlgs = $(".modal-inner-wrapper > .instance");
// Verify 1 or more modal dialogs are showing
if ($dlgs.length > 0) {
maxWidth = $("body").width();
maxHeight = $("body").height();
$dlgs.css({
"max-width": maxWidth,
"max-height": maxHeight,
"overflow": "auto"
});
}
} | javascript | function setDialogMaxSize() {
var maxWidth, maxHeight,
$dlgs = $(".modal-inner-wrapper > .instance");
// Verify 1 or more modal dialogs are showing
if ($dlgs.length > 0) {
maxWidth = $("body").width();
maxHeight = $("body").height();
$dlgs.css({
"max-width": maxWidth,
"max-height": maxHeight,
"overflow": "auto"
});
}
} | [
"function",
"setDialogMaxSize",
"(",
")",
"{",
"var",
"maxWidth",
",",
"maxHeight",
",",
"$dlgs",
"=",
"$",
"(",
"\".modal-inner-wrapper > .instance\"",
")",
";",
"// Verify 1 or more modal dialogs are showing",
"if",
"(",
"$dlgs",
".",
"length",
">",
"0",
")",
"{",
"maxWidth",
"=",
"$",
"(",
"\"body\"",
")",
".",
"width",
"(",
")",
";",
"maxHeight",
"=",
"$",
"(",
"\"body\"",
")",
".",
"height",
"(",
")",
";",
"$dlgs",
".",
"css",
"(",
"{",
"\"max-width\"",
":",
"maxWidth",
",",
"\"max-height\"",
":",
"maxHeight",
",",
"\"overflow\"",
":",
"\"auto\"",
"}",
")",
";",
"}",
"}"
] | Don't allow dialog to exceed viewport size | [
"Don",
"t",
"allow",
"dialog",
"to",
"exceed",
"viewport",
"size"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/widgets/Dialogs.js#L260-L275 |
1,948 | adobe/brackets | src/widgets/Dialogs.js | showModalDialog | function showModalDialog(dlgClass, title, message, buttons, autoDismiss) {
var templateVars = {
dlgClass: dlgClass,
title: title || "",
message: message || "",
buttons: buttons || [{ className: DIALOG_BTN_CLASS_PRIMARY, id: DIALOG_BTN_OK, text: Strings.OK }]
};
var template = Mustache.render(DialogTemplate, templateVars);
return showModalDialogUsingTemplate(template, autoDismiss);
} | javascript | function showModalDialog(dlgClass, title, message, buttons, autoDismiss) {
var templateVars = {
dlgClass: dlgClass,
title: title || "",
message: message || "",
buttons: buttons || [{ className: DIALOG_BTN_CLASS_PRIMARY, id: DIALOG_BTN_OK, text: Strings.OK }]
};
var template = Mustache.render(DialogTemplate, templateVars);
return showModalDialogUsingTemplate(template, autoDismiss);
} | [
"function",
"showModalDialog",
"(",
"dlgClass",
",",
"title",
",",
"message",
",",
"buttons",
",",
"autoDismiss",
")",
"{",
"var",
"templateVars",
"=",
"{",
"dlgClass",
":",
"dlgClass",
",",
"title",
":",
"title",
"||",
"\"\"",
",",
"message",
":",
"message",
"||",
"\"\"",
",",
"buttons",
":",
"buttons",
"||",
"[",
"{",
"className",
":",
"DIALOG_BTN_CLASS_PRIMARY",
",",
"id",
":",
"DIALOG_BTN_OK",
",",
"text",
":",
"Strings",
".",
"OK",
"}",
"]",
"}",
";",
"var",
"template",
"=",
"Mustache",
".",
"render",
"(",
"DialogTemplate",
",",
"templateVars",
")",
";",
"return",
"showModalDialogUsingTemplate",
"(",
"template",
",",
"autoDismiss",
")",
";",
"}"
] | Creates a new general purpose modal dialog using the default template and the template variables given
as parameters as described.
@param {string} dlgClass A class name identifier for the dialog. Typically one of DefaultDialogs.*
@param {string=} title The title of the dialog. Can contain HTML markup. Defaults to "".
@param {string=} message The message to display in the dialog. Can contain HTML markup. Defaults to "".
@param {Array.<{className: string, id: string, text: string}>=} buttons An array of buttons where each button
has a class, id and text property. The id is used in "data-button-id". Defaults to a single Ok button.
Typically className is one of DIALOG_BTN_CLASS_*, id is one of DIALOG_BTN_*
@param {boolean=} autoDismiss Whether to automatically dismiss the dialog when one of the buttons
is clicked. Default true. If false, you'll need to manually handle button clicks and the Esc
key, and dismiss the dialog yourself when ready by calling `close()` on the returned dialog.
@return {Dialog} | [
"Creates",
"a",
"new",
"general",
"purpose",
"modal",
"dialog",
"using",
"the",
"default",
"template",
"and",
"the",
"template",
"variables",
"given",
"as",
"parameters",
"as",
"described",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/widgets/Dialogs.js#L397-L407 |
1,949 | adobe/brackets | src/utils/BuildInfoUtils.js | _loadSHA | function _loadSHA(path, callback) {
var result = new $.Deferred();
if (brackets.inBrowser) {
result.reject();
} else {
// HEAD contains a SHA in detached-head mode; otherwise it contains a relative path
// to a file in /refs which in turn contains the SHA
var file = FileSystem.getFileForPath(path);
FileUtils.readAsText(file).done(function (text) {
if (text.indexOf("ref: ") === 0) {
// e.g. "ref: refs/heads/branchname"
var basePath = path.substr(0, path.lastIndexOf("/")),
refRelPath = text.substr(5).trim(),
branch = text.substr(16).trim();
_loadSHA(basePath + "/" + refRelPath, callback).done(function (data) {
result.resolve({ branch: branch, sha: data.sha.trim() });
}).fail(function () {
result.resolve({ branch: branch });
});
} else {
result.resolve({ sha: text });
}
}).fail(function () {
result.reject();
});
}
return result.promise();
} | javascript | function _loadSHA(path, callback) {
var result = new $.Deferred();
if (brackets.inBrowser) {
result.reject();
} else {
// HEAD contains a SHA in detached-head mode; otherwise it contains a relative path
// to a file in /refs which in turn contains the SHA
var file = FileSystem.getFileForPath(path);
FileUtils.readAsText(file).done(function (text) {
if (text.indexOf("ref: ") === 0) {
// e.g. "ref: refs/heads/branchname"
var basePath = path.substr(0, path.lastIndexOf("/")),
refRelPath = text.substr(5).trim(),
branch = text.substr(16).trim();
_loadSHA(basePath + "/" + refRelPath, callback).done(function (data) {
result.resolve({ branch: branch, sha: data.sha.trim() });
}).fail(function () {
result.resolve({ branch: branch });
});
} else {
result.resolve({ sha: text });
}
}).fail(function () {
result.reject();
});
}
return result.promise();
} | [
"function",
"_loadSHA",
"(",
"path",
",",
"callback",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"if",
"(",
"brackets",
".",
"inBrowser",
")",
"{",
"result",
".",
"reject",
"(",
")",
";",
"}",
"else",
"{",
"// HEAD contains a SHA in detached-head mode; otherwise it contains a relative path",
"// to a file in /refs which in turn contains the SHA",
"var",
"file",
"=",
"FileSystem",
".",
"getFileForPath",
"(",
"path",
")",
";",
"FileUtils",
".",
"readAsText",
"(",
"file",
")",
".",
"done",
"(",
"function",
"(",
"text",
")",
"{",
"if",
"(",
"text",
".",
"indexOf",
"(",
"\"ref: \"",
")",
"===",
"0",
")",
"{",
"// e.g. \"ref: refs/heads/branchname\"",
"var",
"basePath",
"=",
"path",
".",
"substr",
"(",
"0",
",",
"path",
".",
"lastIndexOf",
"(",
"\"/\"",
")",
")",
",",
"refRelPath",
"=",
"text",
".",
"substr",
"(",
"5",
")",
".",
"trim",
"(",
")",
",",
"branch",
"=",
"text",
".",
"substr",
"(",
"16",
")",
".",
"trim",
"(",
")",
";",
"_loadSHA",
"(",
"basePath",
"+",
"\"/\"",
"+",
"refRelPath",
",",
"callback",
")",
".",
"done",
"(",
"function",
"(",
"data",
")",
"{",
"result",
".",
"resolve",
"(",
"{",
"branch",
":",
"branch",
",",
"sha",
":",
"data",
".",
"sha",
".",
"trim",
"(",
")",
"}",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"result",
".",
"resolve",
"(",
"{",
"branch",
":",
"branch",
"}",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"result",
".",
"resolve",
"(",
"{",
"sha",
":",
"text",
"}",
")",
";",
"}",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"result",
".",
"reject",
"(",
")",
";",
"}",
")",
";",
"}",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] | Loads a SHA from Git metadata file. If the file contains a symbolic ref name, follows the ref
and loads the SHA from that file in turn. | [
"Loads",
"a",
"SHA",
"from",
"Git",
"metadata",
"file",
".",
"If",
"the",
"file",
"contains",
"a",
"symbolic",
"ref",
"name",
"follows",
"the",
"ref",
"and",
"loads",
"the",
"SHA",
"from",
"that",
"file",
"in",
"turn",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/BuildInfoUtils.js#L41-L71 |
1,950 | adobe/brackets | src/utils/UpdateNotification.js | _getVersionInfoUrl | function _getVersionInfoUrl(locale, removeCountryPartOfLocale) {
locale = locale || brackets.getLocale();
if (removeCountryPartOfLocale) {
locale = locale.substring(0, 2);
}
//AUTOUPDATE_PRERELEASE_BEGIN
// The following code is needed for supporting Auto Update in prerelease,
//and will be removed eventually for stable releases
{
if (locale) {
if(locale.length > 2) {
locale = locale.substring(0, 2);
}
switch(locale) {
case "de":
break;
case "es":
break;
case "fr":
break;
case "ja":
break;
case "en":
default:
locale = "en";
}
return brackets.config.update_info_url.replace("<locale>", locale);
}
}
//AUTOUPDATE_PRERELEASE_END
return brackets.config.update_info_url + '?locale=' + locale;
} | javascript | function _getVersionInfoUrl(locale, removeCountryPartOfLocale) {
locale = locale || brackets.getLocale();
if (removeCountryPartOfLocale) {
locale = locale.substring(0, 2);
}
//AUTOUPDATE_PRERELEASE_BEGIN
// The following code is needed for supporting Auto Update in prerelease,
//and will be removed eventually for stable releases
{
if (locale) {
if(locale.length > 2) {
locale = locale.substring(0, 2);
}
switch(locale) {
case "de":
break;
case "es":
break;
case "fr":
break;
case "ja":
break;
case "en":
default:
locale = "en";
}
return brackets.config.update_info_url.replace("<locale>", locale);
}
}
//AUTOUPDATE_PRERELEASE_END
return brackets.config.update_info_url + '?locale=' + locale;
} | [
"function",
"_getVersionInfoUrl",
"(",
"locale",
",",
"removeCountryPartOfLocale",
")",
"{",
"locale",
"=",
"locale",
"||",
"brackets",
".",
"getLocale",
"(",
")",
";",
"if",
"(",
"removeCountryPartOfLocale",
")",
"{",
"locale",
"=",
"locale",
".",
"substring",
"(",
"0",
",",
"2",
")",
";",
"}",
"//AUTOUPDATE_PRERELEASE_BEGIN",
"// The following code is needed for supporting Auto Update in prerelease,",
"//and will be removed eventually for stable releases",
"{",
"if",
"(",
"locale",
")",
"{",
"if",
"(",
"locale",
".",
"length",
">",
"2",
")",
"{",
"locale",
"=",
"locale",
".",
"substring",
"(",
"0",
",",
"2",
")",
";",
"}",
"switch",
"(",
"locale",
")",
"{",
"case",
"\"de\"",
":",
"break",
";",
"case",
"\"es\"",
":",
"break",
";",
"case",
"\"fr\"",
":",
"break",
";",
"case",
"\"ja\"",
":",
"break",
";",
"case",
"\"en\"",
":",
"default",
":",
"locale",
"=",
"\"en\"",
";",
"}",
"return",
"brackets",
".",
"config",
".",
"update_info_url",
".",
"replace",
"(",
"\"<locale>\"",
",",
"locale",
")",
";",
"}",
"}",
"//AUTOUPDATE_PRERELEASE_END",
"return",
"brackets",
".",
"config",
".",
"update_info_url",
"+",
"'?locale='",
"+",
"locale",
";",
"}"
] | Construct a new version update url with the given locale.
@param {string=} locale - optional locale, defaults to 'brackets.getLocale()' when omitted.
@param {boolean=} removeCountryPartOfLocale - optional, remove existing country information from locale 'en-gb' => 'en'
return {string} the new version update url | [
"Construct",
"a",
"new",
"version",
"update",
"url",
"with",
"the",
"given",
"locale",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/UpdateNotification.js#L110-L145 |
1,951 | adobe/brackets | src/utils/UpdateNotification.js | _getUpdateInformation | function _getUpdateInformation(force, dontCache, _versionInfoUrl) {
// Last time the versionInfoURL was fetched
var lastInfoURLFetchTime = PreferencesManager.getViewState("lastInfoURLFetchTime");
var result = new $.Deferred();
var fetchData = false;
var data;
// If force is true, always fetch
if (force) {
fetchData = true;
}
// If we don't have data saved in prefs, fetch
data = PreferencesManager.getViewState("updateInfo");
if (!data) {
fetchData = true;
}
// If more than 24 hours have passed since our last fetch, fetch again
if ((new Date()).getTime() > lastInfoURLFetchTime + ONE_DAY) {
fetchData = true;
}
if (fetchData) {
var lookupPromise = new $.Deferred(),
localVersionInfoUrl;
// If the current locale isn't "en" or "en-US", check whether we actually have a
// locale-specific update notification, and fall back to "en" if not.
// Note: we check for both "en" and "en-US" to watch for the general case or
// country-specific English locale. The former appears default on Mac, while
// the latter appears default on Windows.
var locale = brackets.getLocale().toLowerCase();
if (locale !== "en" && locale !== "en-us") {
localVersionInfoUrl = _versionInfoUrl || _getVersionInfoUrl();
$.ajax({
url: localVersionInfoUrl,
cache: false,
type: "HEAD"
}).fail(function (jqXHR, status, error) {
// get rid of any country information from locale and try again
var tmpUrl = _getVersionInfoUrl(brackets.getLocale(), true);
if (tmpUrl !== localVersionInfoUrl) {
$.ajax({
url: tmpUrl,
cache: false,
type: "HEAD"
}).fail(function (jqXHR, status, error) {
localVersionInfoUrl = _getVersionInfoUrl("en");
}).done(function (jqXHR, status, error) {
localVersionInfoUrl = tmpUrl;
}).always(function (jqXHR, status, error) {
lookupPromise.resolve();
});
} else {
localVersionInfoUrl = _getVersionInfoUrl("en");
lookupPromise.resolve();
}
}).done(function (jqXHR, status, error) {
lookupPromise.resolve();
});
} else {
localVersionInfoUrl = _versionInfoUrl || _getVersionInfoUrl("en");
lookupPromise.resolve();
}
lookupPromise.done(function () {
$.ajax({
url: localVersionInfoUrl,
dataType: "json",
cache: false
}).done(function (updateInfo, textStatus, jqXHR) {
if (!dontCache) {
lastInfoURLFetchTime = (new Date()).getTime();
PreferencesManager.setViewState("lastInfoURLFetchTime", lastInfoURLFetchTime);
PreferencesManager.setViewState("updateInfo", updateInfo);
}
result.resolve(updateInfo);
}).fail(function (jqXHR, status, error) {
// When loading data for unit tests, the error handler is
// called but the responseText is valid. Try to use it here,
// but *don't* save the results in prefs.
if (!jqXHR.responseText) {
// Text is NULL or empty string, reject().
result.reject();
return;
}
try {
data = JSON.parse(jqXHR.responseText);
result.resolve(data);
} catch (e) {
result.reject();
}
});
});
} else {
result.resolve(data);
}
return result.promise();
} | javascript | function _getUpdateInformation(force, dontCache, _versionInfoUrl) {
// Last time the versionInfoURL was fetched
var lastInfoURLFetchTime = PreferencesManager.getViewState("lastInfoURLFetchTime");
var result = new $.Deferred();
var fetchData = false;
var data;
// If force is true, always fetch
if (force) {
fetchData = true;
}
// If we don't have data saved in prefs, fetch
data = PreferencesManager.getViewState("updateInfo");
if (!data) {
fetchData = true;
}
// If more than 24 hours have passed since our last fetch, fetch again
if ((new Date()).getTime() > lastInfoURLFetchTime + ONE_DAY) {
fetchData = true;
}
if (fetchData) {
var lookupPromise = new $.Deferred(),
localVersionInfoUrl;
// If the current locale isn't "en" or "en-US", check whether we actually have a
// locale-specific update notification, and fall back to "en" if not.
// Note: we check for both "en" and "en-US" to watch for the general case or
// country-specific English locale. The former appears default on Mac, while
// the latter appears default on Windows.
var locale = brackets.getLocale().toLowerCase();
if (locale !== "en" && locale !== "en-us") {
localVersionInfoUrl = _versionInfoUrl || _getVersionInfoUrl();
$.ajax({
url: localVersionInfoUrl,
cache: false,
type: "HEAD"
}).fail(function (jqXHR, status, error) {
// get rid of any country information from locale and try again
var tmpUrl = _getVersionInfoUrl(brackets.getLocale(), true);
if (tmpUrl !== localVersionInfoUrl) {
$.ajax({
url: tmpUrl,
cache: false,
type: "HEAD"
}).fail(function (jqXHR, status, error) {
localVersionInfoUrl = _getVersionInfoUrl("en");
}).done(function (jqXHR, status, error) {
localVersionInfoUrl = tmpUrl;
}).always(function (jqXHR, status, error) {
lookupPromise.resolve();
});
} else {
localVersionInfoUrl = _getVersionInfoUrl("en");
lookupPromise.resolve();
}
}).done(function (jqXHR, status, error) {
lookupPromise.resolve();
});
} else {
localVersionInfoUrl = _versionInfoUrl || _getVersionInfoUrl("en");
lookupPromise.resolve();
}
lookupPromise.done(function () {
$.ajax({
url: localVersionInfoUrl,
dataType: "json",
cache: false
}).done(function (updateInfo, textStatus, jqXHR) {
if (!dontCache) {
lastInfoURLFetchTime = (new Date()).getTime();
PreferencesManager.setViewState("lastInfoURLFetchTime", lastInfoURLFetchTime);
PreferencesManager.setViewState("updateInfo", updateInfo);
}
result.resolve(updateInfo);
}).fail(function (jqXHR, status, error) {
// When loading data for unit tests, the error handler is
// called but the responseText is valid. Try to use it here,
// but *don't* save the results in prefs.
if (!jqXHR.responseText) {
// Text is NULL or empty string, reject().
result.reject();
return;
}
try {
data = JSON.parse(jqXHR.responseText);
result.resolve(data);
} catch (e) {
result.reject();
}
});
});
} else {
result.resolve(data);
}
return result.promise();
} | [
"function",
"_getUpdateInformation",
"(",
"force",
",",
"dontCache",
",",
"_versionInfoUrl",
")",
"{",
"// Last time the versionInfoURL was fetched",
"var",
"lastInfoURLFetchTime",
"=",
"PreferencesManager",
".",
"getViewState",
"(",
"\"lastInfoURLFetchTime\"",
")",
";",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"var",
"fetchData",
"=",
"false",
";",
"var",
"data",
";",
"// If force is true, always fetch",
"if",
"(",
"force",
")",
"{",
"fetchData",
"=",
"true",
";",
"}",
"// If we don't have data saved in prefs, fetch",
"data",
"=",
"PreferencesManager",
".",
"getViewState",
"(",
"\"updateInfo\"",
")",
";",
"if",
"(",
"!",
"data",
")",
"{",
"fetchData",
"=",
"true",
";",
"}",
"// If more than 24 hours have passed since our last fetch, fetch again",
"if",
"(",
"(",
"new",
"Date",
"(",
")",
")",
".",
"getTime",
"(",
")",
">",
"lastInfoURLFetchTime",
"+",
"ONE_DAY",
")",
"{",
"fetchData",
"=",
"true",
";",
"}",
"if",
"(",
"fetchData",
")",
"{",
"var",
"lookupPromise",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"localVersionInfoUrl",
";",
"// If the current locale isn't \"en\" or \"en-US\", check whether we actually have a",
"// locale-specific update notification, and fall back to \"en\" if not.",
"// Note: we check for both \"en\" and \"en-US\" to watch for the general case or",
"// country-specific English locale. The former appears default on Mac, while",
"// the latter appears default on Windows.",
"var",
"locale",
"=",
"brackets",
".",
"getLocale",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"locale",
"!==",
"\"en\"",
"&&",
"locale",
"!==",
"\"en-us\"",
")",
"{",
"localVersionInfoUrl",
"=",
"_versionInfoUrl",
"||",
"_getVersionInfoUrl",
"(",
")",
";",
"$",
".",
"ajax",
"(",
"{",
"url",
":",
"localVersionInfoUrl",
",",
"cache",
":",
"false",
",",
"type",
":",
"\"HEAD\"",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"jqXHR",
",",
"status",
",",
"error",
")",
"{",
"// get rid of any country information from locale and try again",
"var",
"tmpUrl",
"=",
"_getVersionInfoUrl",
"(",
"brackets",
".",
"getLocale",
"(",
")",
",",
"true",
")",
";",
"if",
"(",
"tmpUrl",
"!==",
"localVersionInfoUrl",
")",
"{",
"$",
".",
"ajax",
"(",
"{",
"url",
":",
"tmpUrl",
",",
"cache",
":",
"false",
",",
"type",
":",
"\"HEAD\"",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"jqXHR",
",",
"status",
",",
"error",
")",
"{",
"localVersionInfoUrl",
"=",
"_getVersionInfoUrl",
"(",
"\"en\"",
")",
";",
"}",
")",
".",
"done",
"(",
"function",
"(",
"jqXHR",
",",
"status",
",",
"error",
")",
"{",
"localVersionInfoUrl",
"=",
"tmpUrl",
";",
"}",
")",
".",
"always",
"(",
"function",
"(",
"jqXHR",
",",
"status",
",",
"error",
")",
"{",
"lookupPromise",
".",
"resolve",
"(",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"localVersionInfoUrl",
"=",
"_getVersionInfoUrl",
"(",
"\"en\"",
")",
";",
"lookupPromise",
".",
"resolve",
"(",
")",
";",
"}",
"}",
")",
".",
"done",
"(",
"function",
"(",
"jqXHR",
",",
"status",
",",
"error",
")",
"{",
"lookupPromise",
".",
"resolve",
"(",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"localVersionInfoUrl",
"=",
"_versionInfoUrl",
"||",
"_getVersionInfoUrl",
"(",
"\"en\"",
")",
";",
"lookupPromise",
".",
"resolve",
"(",
")",
";",
"}",
"lookupPromise",
".",
"done",
"(",
"function",
"(",
")",
"{",
"$",
".",
"ajax",
"(",
"{",
"url",
":",
"localVersionInfoUrl",
",",
"dataType",
":",
"\"json\"",
",",
"cache",
":",
"false",
"}",
")",
".",
"done",
"(",
"function",
"(",
"updateInfo",
",",
"textStatus",
",",
"jqXHR",
")",
"{",
"if",
"(",
"!",
"dontCache",
")",
"{",
"lastInfoURLFetchTime",
"=",
"(",
"new",
"Date",
"(",
")",
")",
".",
"getTime",
"(",
")",
";",
"PreferencesManager",
".",
"setViewState",
"(",
"\"lastInfoURLFetchTime\"",
",",
"lastInfoURLFetchTime",
")",
";",
"PreferencesManager",
".",
"setViewState",
"(",
"\"updateInfo\"",
",",
"updateInfo",
")",
";",
"}",
"result",
".",
"resolve",
"(",
"updateInfo",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"jqXHR",
",",
"status",
",",
"error",
")",
"{",
"// When loading data for unit tests, the error handler is",
"// called but the responseText is valid. Try to use it here,",
"// but *don't* save the results in prefs.",
"if",
"(",
"!",
"jqXHR",
".",
"responseText",
")",
"{",
"// Text is NULL or empty string, reject().",
"result",
".",
"reject",
"(",
")",
";",
"return",
";",
"}",
"try",
"{",
"data",
"=",
"JSON",
".",
"parse",
"(",
"jqXHR",
".",
"responseText",
")",
";",
"result",
".",
"resolve",
"(",
"data",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"result",
".",
"reject",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"result",
".",
"resolve",
"(",
"data",
")",
";",
"}",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] | Get a data structure that has information for all builds of Brackets.
If force is true, the information is always fetched from _versionInfoURL.
If force is false, we try to use cached information. If more than
24 hours have passed since the last fetch, or if cached data can't be found,
the data is fetched again.
If new data is fetched and dontCache is false, the data is saved in preferences
for quick fetching later.
_versionInfoUrl is used for unit testing. | [
"Get",
"a",
"data",
"structure",
"that",
"has",
"information",
"for",
"all",
"builds",
"of",
"Brackets",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/UpdateNotification.js#L159-L262 |
1,952 | adobe/brackets | src/utils/UpdateNotification.js | _stripOldVersionInfo | function _stripOldVersionInfo(versionInfo, buildNumber) {
// Do a simple linear search. Since we are going in reverse-chronological order, we
// should get through the search quickly.
var lastIndex = 0;
var len = versionInfo.length;
var versionEntry;
var validBuildEntries;
while (lastIndex < len) {
versionEntry = versionInfo[lastIndex];
if (versionEntry.buildNumber <= buildNumber) {
break;
}
lastIndex++;
}
if (lastIndex > 0) {
// Filter recent update entries based on applicability to current platform
validBuildEntries = versionInfo.slice(0, lastIndex).filter(_checkBuildApplicability);
}
return validBuildEntries;
} | javascript | function _stripOldVersionInfo(versionInfo, buildNumber) {
// Do a simple linear search. Since we are going in reverse-chronological order, we
// should get through the search quickly.
var lastIndex = 0;
var len = versionInfo.length;
var versionEntry;
var validBuildEntries;
while (lastIndex < len) {
versionEntry = versionInfo[lastIndex];
if (versionEntry.buildNumber <= buildNumber) {
break;
}
lastIndex++;
}
if (lastIndex > 0) {
// Filter recent update entries based on applicability to current platform
validBuildEntries = versionInfo.slice(0, lastIndex).filter(_checkBuildApplicability);
}
return validBuildEntries;
} | [
"function",
"_stripOldVersionInfo",
"(",
"versionInfo",
",",
"buildNumber",
")",
"{",
"// Do a simple linear search. Since we are going in reverse-chronological order, we",
"// should get through the search quickly.",
"var",
"lastIndex",
"=",
"0",
";",
"var",
"len",
"=",
"versionInfo",
".",
"length",
";",
"var",
"versionEntry",
";",
"var",
"validBuildEntries",
";",
"while",
"(",
"lastIndex",
"<",
"len",
")",
"{",
"versionEntry",
"=",
"versionInfo",
"[",
"lastIndex",
"]",
";",
"if",
"(",
"versionEntry",
".",
"buildNumber",
"<=",
"buildNumber",
")",
"{",
"break",
";",
"}",
"lastIndex",
"++",
";",
"}",
"if",
"(",
"lastIndex",
">",
"0",
")",
"{",
"// Filter recent update entries based on applicability to current platform",
"validBuildEntries",
"=",
"versionInfo",
".",
"slice",
"(",
"0",
",",
"lastIndex",
")",
".",
"filter",
"(",
"_checkBuildApplicability",
")",
";",
"}",
"return",
"validBuildEntries",
";",
"}"
] | Return a new array of version information that is newer than "buildNumber".
Returns null if there is no new version information. | [
"Return",
"a",
"new",
"array",
"of",
"version",
"information",
"that",
"is",
"newer",
"than",
"buildNumber",
".",
"Returns",
"null",
"if",
"there",
"is",
"no",
"new",
"version",
"information",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/UpdateNotification.js#L275-L297 |
1,953 | adobe/brackets | src/utils/UpdateNotification.js | _showUpdateNotificationDialog | function _showUpdateNotificationDialog(updates, force) {
Dialogs.showModalDialogUsingTemplate(Mustache.render(UpdateDialogTemplate, Strings))
.done(function (id) {
if (id === Dialogs.DIALOG_BTN_DOWNLOAD) {
HealthLogger.sendAnalyticsData(
eventNames.AUTOUPDATE_UPDATENOW_CLICK,
"autoUpdate",
"updateNotification",
"updateNow",
"click"
);
handleUpdateProcess(updates);
} else {
HealthLogger.sendAnalyticsData(
eventNames.AUTOUPDATE_CANCEL_CLICK,
"autoUpdate",
"updateNotification",
"cancel",
"click"
);
}
});
// Populate the update data
var $dlg = $(".update-dialog.instance"),
$updateList = $dlg.find(".update-info"),
subTypeString = force ? "userAction" : "auto";
// Make the update notification icon clickable again
_addedClickHandler = false;
updates.Strings = Strings;
$updateList.html(Mustache.render(UpdateListTemplate, updates));
HealthLogger.sendAnalyticsData(
eventNames.AUTOUPDATE_UPDATE_AVAILABLE_DIALOG_BOX_RENDERED,
"autoUpdate",
"updateNotification",
"render",
subTypeString
);
} | javascript | function _showUpdateNotificationDialog(updates, force) {
Dialogs.showModalDialogUsingTemplate(Mustache.render(UpdateDialogTemplate, Strings))
.done(function (id) {
if (id === Dialogs.DIALOG_BTN_DOWNLOAD) {
HealthLogger.sendAnalyticsData(
eventNames.AUTOUPDATE_UPDATENOW_CLICK,
"autoUpdate",
"updateNotification",
"updateNow",
"click"
);
handleUpdateProcess(updates);
} else {
HealthLogger.sendAnalyticsData(
eventNames.AUTOUPDATE_CANCEL_CLICK,
"autoUpdate",
"updateNotification",
"cancel",
"click"
);
}
});
// Populate the update data
var $dlg = $(".update-dialog.instance"),
$updateList = $dlg.find(".update-info"),
subTypeString = force ? "userAction" : "auto";
// Make the update notification icon clickable again
_addedClickHandler = false;
updates.Strings = Strings;
$updateList.html(Mustache.render(UpdateListTemplate, updates));
HealthLogger.sendAnalyticsData(
eventNames.AUTOUPDATE_UPDATE_AVAILABLE_DIALOG_BOX_RENDERED,
"autoUpdate",
"updateNotification",
"render",
subTypeString
);
} | [
"function",
"_showUpdateNotificationDialog",
"(",
"updates",
",",
"force",
")",
"{",
"Dialogs",
".",
"showModalDialogUsingTemplate",
"(",
"Mustache",
".",
"render",
"(",
"UpdateDialogTemplate",
",",
"Strings",
")",
")",
".",
"done",
"(",
"function",
"(",
"id",
")",
"{",
"if",
"(",
"id",
"===",
"Dialogs",
".",
"DIALOG_BTN_DOWNLOAD",
")",
"{",
"HealthLogger",
".",
"sendAnalyticsData",
"(",
"eventNames",
".",
"AUTOUPDATE_UPDATENOW_CLICK",
",",
"\"autoUpdate\"",
",",
"\"updateNotification\"",
",",
"\"updateNow\"",
",",
"\"click\"",
")",
";",
"handleUpdateProcess",
"(",
"updates",
")",
";",
"}",
"else",
"{",
"HealthLogger",
".",
"sendAnalyticsData",
"(",
"eventNames",
".",
"AUTOUPDATE_CANCEL_CLICK",
",",
"\"autoUpdate\"",
",",
"\"updateNotification\"",
",",
"\"cancel\"",
",",
"\"click\"",
")",
";",
"}",
"}",
")",
";",
"// Populate the update data",
"var",
"$dlg",
"=",
"$",
"(",
"\".update-dialog.instance\"",
")",
",",
"$updateList",
"=",
"$dlg",
".",
"find",
"(",
"\".update-info\"",
")",
",",
"subTypeString",
"=",
"force",
"?",
"\"userAction\"",
":",
"\"auto\"",
";",
"// Make the update notification icon clickable again",
"_addedClickHandler",
"=",
"false",
";",
"updates",
".",
"Strings",
"=",
"Strings",
";",
"$updateList",
".",
"html",
"(",
"Mustache",
".",
"render",
"(",
"UpdateListTemplate",
",",
"updates",
")",
")",
";",
"HealthLogger",
".",
"sendAnalyticsData",
"(",
"eventNames",
".",
"AUTOUPDATE_UPDATE_AVAILABLE_DIALOG_BOX_RENDERED",
",",
"\"autoUpdate\"",
",",
"\"updateNotification\"",
",",
"\"render\"",
",",
"subTypeString",
")",
";",
"}"
] | Show a dialog that shows the update | [
"Show",
"a",
"dialog",
"that",
"shows",
"the",
"update"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/UpdateNotification.js#L302-L342 |
1,954 | adobe/brackets | src/utils/UpdateNotification.js | _onRegistryDownloaded | function _onRegistryDownloaded() {
var availableUpdates = ExtensionManager.getAvailableUpdates();
PreferencesManager.setViewState("extensionUpdateInfo", availableUpdates);
PreferencesManager.setViewState("lastExtensionRegistryCheckTime", (new Date()).getTime());
$("#toolbar-extension-manager").toggleClass("updatesAvailable", availableUpdates.length > 0);
} | javascript | function _onRegistryDownloaded() {
var availableUpdates = ExtensionManager.getAvailableUpdates();
PreferencesManager.setViewState("extensionUpdateInfo", availableUpdates);
PreferencesManager.setViewState("lastExtensionRegistryCheckTime", (new Date()).getTime());
$("#toolbar-extension-manager").toggleClass("updatesAvailable", availableUpdates.length > 0);
} | [
"function",
"_onRegistryDownloaded",
"(",
")",
"{",
"var",
"availableUpdates",
"=",
"ExtensionManager",
".",
"getAvailableUpdates",
"(",
")",
";",
"PreferencesManager",
".",
"setViewState",
"(",
"\"extensionUpdateInfo\"",
",",
"availableUpdates",
")",
";",
"PreferencesManager",
".",
"setViewState",
"(",
"\"lastExtensionRegistryCheckTime\"",
",",
"(",
"new",
"Date",
"(",
")",
")",
".",
"getTime",
"(",
")",
")",
";",
"$",
"(",
"\"#toolbar-extension-manager\"",
")",
".",
"toggleClass",
"(",
"\"updatesAvailable\"",
",",
"availableUpdates",
".",
"length",
">",
"0",
")",
";",
"}"
] | Calculate state of notification everytime registries are downloaded - no matter who triggered the download | [
"Calculate",
"state",
"of",
"notification",
"everytime",
"registries",
"are",
"downloaded",
"-",
"no",
"matter",
"who",
"triggered",
"the",
"download"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/UpdateNotification.js#L347-L352 |
1,955 | adobe/brackets | src/utils/UpdateNotification.js | handleUpdateProcess | function handleUpdateProcess(updates) {
var handler = _updateProcessHandler || _defaultUpdateProcessHandler;
var initSuccess = handler(updates);
if (_updateProcessHandler && !initSuccess) {
// Give a chance to default handler in case
// the auot update mechanism has failed.
_defaultUpdateProcessHandler(updates);
}
} | javascript | function handleUpdateProcess(updates) {
var handler = _updateProcessHandler || _defaultUpdateProcessHandler;
var initSuccess = handler(updates);
if (_updateProcessHandler && !initSuccess) {
// Give a chance to default handler in case
// the auot update mechanism has failed.
_defaultUpdateProcessHandler(updates);
}
} | [
"function",
"handleUpdateProcess",
"(",
"updates",
")",
"{",
"var",
"handler",
"=",
"_updateProcessHandler",
"||",
"_defaultUpdateProcessHandler",
";",
"var",
"initSuccess",
"=",
"handler",
"(",
"updates",
")",
";",
"if",
"(",
"_updateProcessHandler",
"&&",
"!",
"initSuccess",
")",
"{",
"// Give a chance to default handler in case",
"// the auot update mechanism has failed.",
"_defaultUpdateProcessHandler",
"(",
"updates",
")",
";",
"}",
"}"
] | Handles the update process
@param {Array} updates - array object containing info of updates | [
"Handles",
"the",
"update",
"process"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/UpdateNotification.js#L523-L531 |
1,956 | adobe/brackets | src/extensions/default/InlineColorEditor/ColorEditor.js | _0xColorToHex | function _0xColorToHex(color, convertToStr) {
var hexColor = tinycolor(color.replace("0x", "#"));
hexColor._format = "0x";
if (convertToStr) {
return hexColor.toString();
}
return hexColor;
} | javascript | function _0xColorToHex(color, convertToStr) {
var hexColor = tinycolor(color.replace("0x", "#"));
hexColor._format = "0x";
if (convertToStr) {
return hexColor.toString();
}
return hexColor;
} | [
"function",
"_0xColorToHex",
"(",
"color",
",",
"convertToStr",
")",
"{",
"var",
"hexColor",
"=",
"tinycolor",
"(",
"color",
".",
"replace",
"(",
"\"0x\"",
",",
"\"#\"",
")",
")",
";",
"hexColor",
".",
"_format",
"=",
"\"0x\"",
";",
"if",
"(",
"convertToStr",
")",
"{",
"return",
"hexColor",
".",
"toString",
"(",
")",
";",
"}",
"return",
"hexColor",
";",
"}"
] | Converts 0x-prefixed color to hex
@param {string} color - Color to convert
@param {boolean} convertToString - true if color should
be returned as string
@returns {tinycolor|string} - Hex color as a Tinycolor object
or a hex string | [
"Converts",
"0x",
"-",
"prefixed",
"color",
"to",
"hex"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineColorEditor/ColorEditor.js#L71-L79 |
1,957 | adobe/brackets | src/extensions/default/InlineColorEditor/ColorEditor.js | checkSetFormat | function checkSetFormat(color, convertToStr) {
if ((/^0x/).test(color)) {
return _0xColorToHex(color, convertToStr);
}
if (convertToStr) {
return tinycolor(color).toString();
}
return tinycolor(color);
} | javascript | function checkSetFormat(color, convertToStr) {
if ((/^0x/).test(color)) {
return _0xColorToHex(color, convertToStr);
}
if (convertToStr) {
return tinycolor(color).toString();
}
return tinycolor(color);
} | [
"function",
"checkSetFormat",
"(",
"color",
",",
"convertToStr",
")",
"{",
"if",
"(",
"(",
"/",
"^0x",
"/",
")",
".",
"test",
"(",
"color",
")",
")",
"{",
"return",
"_0xColorToHex",
"(",
"color",
",",
"convertToStr",
")",
";",
"}",
"if",
"(",
"convertToStr",
")",
"{",
"return",
"tinycolor",
"(",
"color",
")",
".",
"toString",
"(",
")",
";",
"}",
"return",
"tinycolor",
"(",
"color",
")",
";",
"}"
] | Ensures that a string is in Tinycolor supported format
@param {string} color - Color to check the format for
@param {boolean} convertToString - true if color should
be returned as string
@returns {tinycolor|string} - Color as a Tinycolor object
or a hex string | [
"Ensures",
"that",
"a",
"string",
"is",
"in",
"Tinycolor",
"supported",
"format"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineColorEditor/ColorEditor.js#L89-L97 |
1,958 | adobe/brackets | src/extensions/default/InlineColorEditor/ColorEditor.js | ColorEditor | function ColorEditor($parent, color, callback, swatches) {
// Create the DOM structure, filling in localized strings via Mustache
this.$element = $(Mustache.render(ColorEditorTemplate, Strings));
$parent.append(this.$element);
this._callback = callback;
this._handleKeydown = this._handleKeydown.bind(this);
this._handleOpacityKeydown = this._handleOpacityKeydown.bind(this);
this._handleHslKeydown = this._handleHslKeydown.bind(this);
this._handleHueKeydown = this._handleHueKeydown.bind(this);
this._handleSelectionKeydown = this._handleSelectionKeydown.bind(this);
this._handleOpacityDrag = this._handleOpacityDrag.bind(this);
this._handleHueDrag = this._handleHueDrag.bind(this);
this._handleSelectionFieldDrag = this._handleSelectionFieldDrag.bind(this);
this._originalColor = color;
this._color = checkSetFormat(color);
this._redoColor = null;
this._isUpperCase = PreferencesManager.get("uppercaseColors");
PreferencesManager.on("change", "uppercaseColors", function () {
this._isUpperCase = PreferencesManager.get("uppercaseColors");
}.bind(this));
this.$colorValue = this.$element.find(".color-value");
this.$buttonList = this.$element.find("ul.button-bar");
this.$rgbaButton = this.$element.find(".rgba");
this.$hexButton = this.$element.find(".hex");
this.$hslButton = this.$element.find(".hsla");
this.$0xButton = this.$element.find(".0x");
this.$currentColor = this.$element.find(".current-color");
this.$originalColor = this.$element.find(".original-color");
this.$selection = this.$element.find(".color-selection-field");
this.$selectionBase = this.$element.find(".color-selection-field .selector-base");
this.$hueBase = this.$element.find(".hue-slider .selector-base");
this.$opacityGradient = this.$element.find(".opacity-gradient");
this.$hueSlider = this.$element.find(".hue-slider");
this.$hueSelector = this.$element.find(".hue-slider .selector-base");
this.$opacitySlider = this.$element.find(".opacity-slider");
this.$opacitySelector = this.$element.find(".opacity-slider .selector-base");
this.$swatches = this.$element.find(".swatches");
// Create quick-access color swatches
this._addSwatches(swatches);
// Attach event listeners to main UI elements
this._addListeners();
// Initially selected color
this.$originalColor.css("background-color", checkSetFormat(this._originalColor));
this._commitColor(color);
} | javascript | function ColorEditor($parent, color, callback, swatches) {
// Create the DOM structure, filling in localized strings via Mustache
this.$element = $(Mustache.render(ColorEditorTemplate, Strings));
$parent.append(this.$element);
this._callback = callback;
this._handleKeydown = this._handleKeydown.bind(this);
this._handleOpacityKeydown = this._handleOpacityKeydown.bind(this);
this._handleHslKeydown = this._handleHslKeydown.bind(this);
this._handleHueKeydown = this._handleHueKeydown.bind(this);
this._handleSelectionKeydown = this._handleSelectionKeydown.bind(this);
this._handleOpacityDrag = this._handleOpacityDrag.bind(this);
this._handleHueDrag = this._handleHueDrag.bind(this);
this._handleSelectionFieldDrag = this._handleSelectionFieldDrag.bind(this);
this._originalColor = color;
this._color = checkSetFormat(color);
this._redoColor = null;
this._isUpperCase = PreferencesManager.get("uppercaseColors");
PreferencesManager.on("change", "uppercaseColors", function () {
this._isUpperCase = PreferencesManager.get("uppercaseColors");
}.bind(this));
this.$colorValue = this.$element.find(".color-value");
this.$buttonList = this.$element.find("ul.button-bar");
this.$rgbaButton = this.$element.find(".rgba");
this.$hexButton = this.$element.find(".hex");
this.$hslButton = this.$element.find(".hsla");
this.$0xButton = this.$element.find(".0x");
this.$currentColor = this.$element.find(".current-color");
this.$originalColor = this.$element.find(".original-color");
this.$selection = this.$element.find(".color-selection-field");
this.$selectionBase = this.$element.find(".color-selection-field .selector-base");
this.$hueBase = this.$element.find(".hue-slider .selector-base");
this.$opacityGradient = this.$element.find(".opacity-gradient");
this.$hueSlider = this.$element.find(".hue-slider");
this.$hueSelector = this.$element.find(".hue-slider .selector-base");
this.$opacitySlider = this.$element.find(".opacity-slider");
this.$opacitySelector = this.$element.find(".opacity-slider .selector-base");
this.$swatches = this.$element.find(".swatches");
// Create quick-access color swatches
this._addSwatches(swatches);
// Attach event listeners to main UI elements
this._addListeners();
// Initially selected color
this.$originalColor.css("background-color", checkSetFormat(this._originalColor));
this._commitColor(color);
} | [
"function",
"ColorEditor",
"(",
"$parent",
",",
"color",
",",
"callback",
",",
"swatches",
")",
"{",
"// Create the DOM structure, filling in localized strings via Mustache",
"this",
".",
"$element",
"=",
"$",
"(",
"Mustache",
".",
"render",
"(",
"ColorEditorTemplate",
",",
"Strings",
")",
")",
";",
"$parent",
".",
"append",
"(",
"this",
".",
"$element",
")",
";",
"this",
".",
"_callback",
"=",
"callback",
";",
"this",
".",
"_handleKeydown",
"=",
"this",
".",
"_handleKeydown",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_handleOpacityKeydown",
"=",
"this",
".",
"_handleOpacityKeydown",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_handleHslKeydown",
"=",
"this",
".",
"_handleHslKeydown",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_handleHueKeydown",
"=",
"this",
".",
"_handleHueKeydown",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_handleSelectionKeydown",
"=",
"this",
".",
"_handleSelectionKeydown",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_handleOpacityDrag",
"=",
"this",
".",
"_handleOpacityDrag",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_handleHueDrag",
"=",
"this",
".",
"_handleHueDrag",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_handleSelectionFieldDrag",
"=",
"this",
".",
"_handleSelectionFieldDrag",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_originalColor",
"=",
"color",
";",
"this",
".",
"_color",
"=",
"checkSetFormat",
"(",
"color",
")",
";",
"this",
".",
"_redoColor",
"=",
"null",
";",
"this",
".",
"_isUpperCase",
"=",
"PreferencesManager",
".",
"get",
"(",
"\"uppercaseColors\"",
")",
";",
"PreferencesManager",
".",
"on",
"(",
"\"change\"",
",",
"\"uppercaseColors\"",
",",
"function",
"(",
")",
"{",
"this",
".",
"_isUpperCase",
"=",
"PreferencesManager",
".",
"get",
"(",
"\"uppercaseColors\"",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"this",
".",
"$colorValue",
"=",
"this",
".",
"$element",
".",
"find",
"(",
"\".color-value\"",
")",
";",
"this",
".",
"$buttonList",
"=",
"this",
".",
"$element",
".",
"find",
"(",
"\"ul.button-bar\"",
")",
";",
"this",
".",
"$rgbaButton",
"=",
"this",
".",
"$element",
".",
"find",
"(",
"\".rgba\"",
")",
";",
"this",
".",
"$hexButton",
"=",
"this",
".",
"$element",
".",
"find",
"(",
"\".hex\"",
")",
";",
"this",
".",
"$hslButton",
"=",
"this",
".",
"$element",
".",
"find",
"(",
"\".hsla\"",
")",
";",
"this",
".",
"$0xButton",
"=",
"this",
".",
"$element",
".",
"find",
"(",
"\".0x\"",
")",
";",
"this",
".",
"$currentColor",
"=",
"this",
".",
"$element",
".",
"find",
"(",
"\".current-color\"",
")",
";",
"this",
".",
"$originalColor",
"=",
"this",
".",
"$element",
".",
"find",
"(",
"\".original-color\"",
")",
";",
"this",
".",
"$selection",
"=",
"this",
".",
"$element",
".",
"find",
"(",
"\".color-selection-field\"",
")",
";",
"this",
".",
"$selectionBase",
"=",
"this",
".",
"$element",
".",
"find",
"(",
"\".color-selection-field .selector-base\"",
")",
";",
"this",
".",
"$hueBase",
"=",
"this",
".",
"$element",
".",
"find",
"(",
"\".hue-slider .selector-base\"",
")",
";",
"this",
".",
"$opacityGradient",
"=",
"this",
".",
"$element",
".",
"find",
"(",
"\".opacity-gradient\"",
")",
";",
"this",
".",
"$hueSlider",
"=",
"this",
".",
"$element",
".",
"find",
"(",
"\".hue-slider\"",
")",
";",
"this",
".",
"$hueSelector",
"=",
"this",
".",
"$element",
".",
"find",
"(",
"\".hue-slider .selector-base\"",
")",
";",
"this",
".",
"$opacitySlider",
"=",
"this",
".",
"$element",
".",
"find",
"(",
"\".opacity-slider\"",
")",
";",
"this",
".",
"$opacitySelector",
"=",
"this",
".",
"$element",
".",
"find",
"(",
"\".opacity-slider .selector-base\"",
")",
";",
"this",
".",
"$swatches",
"=",
"this",
".",
"$element",
".",
"find",
"(",
"\".swatches\"",
")",
";",
"// Create quick-access color swatches",
"this",
".",
"_addSwatches",
"(",
"swatches",
")",
";",
"// Attach event listeners to main UI elements",
"this",
".",
"_addListeners",
"(",
")",
";",
"// Initially selected color",
"this",
".",
"$originalColor",
".",
"css",
"(",
"\"background-color\"",
",",
"checkSetFormat",
"(",
"this",
".",
"_originalColor",
")",
")",
";",
"this",
".",
"_commitColor",
"(",
"color",
")",
";",
"}"
] | Color picker control; may be used standalone or within an InlineColorEditor inline widget.
@param {!jQuery} $parent DOM node into which to append the root of the color picker UI
@param {!string} color Initially selected color
@param {!function(string)} callback Called whenever selected color changes
@param {!Array.<{value:string, count:number}>} swatches Quick-access color swatches to include in UI | [
"Color",
"picker",
"control",
";",
"may",
"be",
"used",
"standalone",
"or",
"within",
"an",
"InlineColorEditor",
"inline",
"widget",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineColorEditor/ColorEditor.js#L106-L159 |
1,959 | adobe/brackets | src/search/FindBar.js | _handleKeydown | function _handleKeydown(e) {
if (e.keyCode === KeyEvent.DOM_VK_ESCAPE) {
e.stopPropagation();
e.preventDefault();
self.close();
}
} | javascript | function _handleKeydown(e) {
if (e.keyCode === KeyEvent.DOM_VK_ESCAPE) {
e.stopPropagation();
e.preventDefault();
self.close();
}
} | [
"function",
"_handleKeydown",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"keyCode",
"===",
"KeyEvent",
".",
"DOM_VK_ESCAPE",
")",
"{",
"e",
".",
"stopPropagation",
"(",
")",
";",
"e",
".",
"preventDefault",
"(",
")",
";",
"self",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Done this way because ModalBar.js seems to react unreliably when modifying it to handle the escape key - the findbar wasn't getting closed as it should, instead persisting in the background | [
"Done",
"this",
"way",
"because",
"ModalBar",
".",
"js",
"seems",
"to",
"react",
"unreliably",
"when",
"modifying",
"it",
"to",
"handle",
"the",
"escape",
"key",
"-",
"the",
"findbar",
"wasn",
"t",
"getting",
"closed",
"as",
"it",
"should",
"instead",
"persisting",
"in",
"the",
"background"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindBar.js#L288-L294 |
1,960 | adobe/brackets | src/extensions/default/RemoteFileAdapter/main.js | _setMenuItemsVisible | function _setMenuItemsVisible() {
var file = MainViewManager.getCurrentlyViewedFile(MainViewManager.ACTIVE_PANE),
cMenuItems = [Commands.FILE_SAVE, Commands.FILE_RENAME, Commands.NAVIGATE_SHOW_IN_FILE_TREE, Commands.NAVIGATE_SHOW_IN_OS],
// Enable menu options when no file is present in active pane
enable = !file || (file.constructor.name !== "RemoteFile");
// Enable or disable commands based on whether the file is a remoteFile or not.
cMenuItems.forEach(function (item) {
CommandManager.get(item).setEnabled(enable);
});
} | javascript | function _setMenuItemsVisible() {
var file = MainViewManager.getCurrentlyViewedFile(MainViewManager.ACTIVE_PANE),
cMenuItems = [Commands.FILE_SAVE, Commands.FILE_RENAME, Commands.NAVIGATE_SHOW_IN_FILE_TREE, Commands.NAVIGATE_SHOW_IN_OS],
// Enable menu options when no file is present in active pane
enable = !file || (file.constructor.name !== "RemoteFile");
// Enable or disable commands based on whether the file is a remoteFile or not.
cMenuItems.forEach(function (item) {
CommandManager.get(item).setEnabled(enable);
});
} | [
"function",
"_setMenuItemsVisible",
"(",
")",
"{",
"var",
"file",
"=",
"MainViewManager",
".",
"getCurrentlyViewedFile",
"(",
"MainViewManager",
".",
"ACTIVE_PANE",
")",
",",
"cMenuItems",
"=",
"[",
"Commands",
".",
"FILE_SAVE",
",",
"Commands",
".",
"FILE_RENAME",
",",
"Commands",
".",
"NAVIGATE_SHOW_IN_FILE_TREE",
",",
"Commands",
".",
"NAVIGATE_SHOW_IN_OS",
"]",
",",
"// Enable menu options when no file is present in active pane",
"enable",
"=",
"!",
"file",
"||",
"(",
"file",
".",
"constructor",
".",
"name",
"!==",
"\"RemoteFile\"",
")",
";",
"// Enable or disable commands based on whether the file is a remoteFile or not.",
"cMenuItems",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"CommandManager",
".",
"get",
"(",
"item",
")",
".",
"setEnabled",
"(",
"enable",
")",
";",
"}",
")",
";",
"}"
] | Disable context menus which are not useful for remote file | [
"Disable",
"context",
"menus",
"which",
"are",
"not",
"useful",
"for",
"remote",
"file"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/RemoteFileAdapter/main.js#L59-L69 |
1,961 | adobe/brackets | src/extensions/default/JavaScriptRefactoring/RefactoringUtils.js | getUniqueIdentifierName | function getUniqueIdentifierName(scopes, prefix, num) {
if (!scopes) {
return prefix;
}
var props = scopes.reduce(function(props, scope) {
return _.union(props, _.keys(scope.props));
}, []);
if (!props) {
return prefix;
}
num = num || "1";
var name;
while (num < 100) { // limit search length
name = prefix + num;
if (props.indexOf(name) === -1) {
break;
}
++num;
}
return name;
} | javascript | function getUniqueIdentifierName(scopes, prefix, num) {
if (!scopes) {
return prefix;
}
var props = scopes.reduce(function(props, scope) {
return _.union(props, _.keys(scope.props));
}, []);
if (!props) {
return prefix;
}
num = num || "1";
var name;
while (num < 100) { // limit search length
name = prefix + num;
if (props.indexOf(name) === -1) {
break;
}
++num;
}
return name;
} | [
"function",
"getUniqueIdentifierName",
"(",
"scopes",
",",
"prefix",
",",
"num",
")",
"{",
"if",
"(",
"!",
"scopes",
")",
"{",
"return",
"prefix",
";",
"}",
"var",
"props",
"=",
"scopes",
".",
"reduce",
"(",
"function",
"(",
"props",
",",
"scope",
")",
"{",
"return",
"_",
".",
"union",
"(",
"props",
",",
"_",
".",
"keys",
"(",
"scope",
".",
"props",
")",
")",
";",
"}",
",",
"[",
"]",
")",
";",
"if",
"(",
"!",
"props",
")",
"{",
"return",
"prefix",
";",
"}",
"num",
"=",
"num",
"||",
"\"1\"",
";",
"var",
"name",
";",
"while",
"(",
"num",
"<",
"100",
")",
"{",
"// limit search length",
"name",
"=",
"prefix",
"+",
"num",
";",
"if",
"(",
"props",
".",
"indexOf",
"(",
"name",
")",
"===",
"-",
"1",
")",
"{",
"break",
";",
"}",
"++",
"num",
";",
"}",
"return",
"name",
";",
"}"
] | Gets a unique identifier name in the scope that starts with prefix
@param {!Scope} scopes - an array of all scopes returned from tern (each element contains 'props' with identifiers
in that scope)
@param {!string} prefix - prefix of the identifier
@param {number} num - number to start checking for
@return {!string} identifier name | [
"Gets",
"a",
"unique",
"identifier",
"name",
"in",
"the",
"scope",
"that",
"starts",
"with",
"prefix"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptRefactoring/RefactoringUtils.js#L148-L171 |
1,962 | adobe/brackets | src/extensions/default/JavaScriptRefactoring/RefactoringUtils.js | isStandAloneExpression | function isStandAloneExpression(text) {
var found = ASTWalker.findNodeAt(getAST(text), 0, text.length, function (nodeType, node) {
if (nodeType === "Expression") {
return true;
}
return false;
});
return found && found.node;
} | javascript | function isStandAloneExpression(text) {
var found = ASTWalker.findNodeAt(getAST(text), 0, text.length, function (nodeType, node) {
if (nodeType === "Expression") {
return true;
}
return false;
});
return found && found.node;
} | [
"function",
"isStandAloneExpression",
"(",
"text",
")",
"{",
"var",
"found",
"=",
"ASTWalker",
".",
"findNodeAt",
"(",
"getAST",
"(",
"text",
")",
",",
"0",
",",
"text",
".",
"length",
",",
"function",
"(",
"nodeType",
",",
"node",
")",
"{",
"if",
"(",
"nodeType",
"===",
"\"Expression\"",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
")",
";",
"return",
"found",
"&&",
"found",
".",
"node",
";",
"}"
] | Checks whether the text forms a stand alone expression without considering the context of text
@param {!string} text
@return {boolean} | [
"Checks",
"whether",
"the",
"text",
"forms",
"a",
"stand",
"alone",
"expression",
"without",
"considering",
"the",
"context",
"of",
"text"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptRefactoring/RefactoringUtils.js#L187-L195 |
1,963 | adobe/brackets | src/extensions/default/JavaScriptRefactoring/RefactoringUtils.js | getScopeData | function getScopeData(session, offset) {
var path = session.path,
fileInfo = {
type: MessageIds.TERN_FILE_INFO_TYPE_FULL,
name: path,
offsetLines: 0,
text: ScopeManager.filterText(session.getJavascriptText())
};
ScopeManager.postMessage({
type: MessageIds.TERN_SCOPEDATA_MSG,
fileInfo: fileInfo,
offset: offset
});
var ternPromise = ScopeManager.addPendingRequest(fileInfo.name, offset, MessageIds.TERN_SCOPEDATA_MSG);
var result = new $.Deferred();
ternPromise.done(function (response) {
result.resolveWith(null, [response.scope]);
}).fail(function () {
result.reject();
});
return result;
} | javascript | function getScopeData(session, offset) {
var path = session.path,
fileInfo = {
type: MessageIds.TERN_FILE_INFO_TYPE_FULL,
name: path,
offsetLines: 0,
text: ScopeManager.filterText(session.getJavascriptText())
};
ScopeManager.postMessage({
type: MessageIds.TERN_SCOPEDATA_MSG,
fileInfo: fileInfo,
offset: offset
});
var ternPromise = ScopeManager.addPendingRequest(fileInfo.name, offset, MessageIds.TERN_SCOPEDATA_MSG);
var result = new $.Deferred();
ternPromise.done(function (response) {
result.resolveWith(null, [response.scope]);
}).fail(function () {
result.reject();
});
return result;
} | [
"function",
"getScopeData",
"(",
"session",
",",
"offset",
")",
"{",
"var",
"path",
"=",
"session",
".",
"path",
",",
"fileInfo",
"=",
"{",
"type",
":",
"MessageIds",
".",
"TERN_FILE_INFO_TYPE_FULL",
",",
"name",
":",
"path",
",",
"offsetLines",
":",
"0",
",",
"text",
":",
"ScopeManager",
".",
"filterText",
"(",
"session",
".",
"getJavascriptText",
"(",
")",
")",
"}",
";",
"ScopeManager",
".",
"postMessage",
"(",
"{",
"type",
":",
"MessageIds",
".",
"TERN_SCOPEDATA_MSG",
",",
"fileInfo",
":",
"fileInfo",
",",
"offset",
":",
"offset",
"}",
")",
";",
"var",
"ternPromise",
"=",
"ScopeManager",
".",
"addPendingRequest",
"(",
"fileInfo",
".",
"name",
",",
"offset",
",",
"MessageIds",
".",
"TERN_SCOPEDATA_MSG",
")",
";",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"ternPromise",
".",
"done",
"(",
"function",
"(",
"response",
")",
"{",
"result",
".",
"resolveWith",
"(",
"null",
",",
"[",
"response",
".",
"scope",
"]",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"result",
".",
"reject",
"(",
")",
";",
"}",
")",
";",
"return",
"result",
";",
"}"
] | Requests scope data from tern
@param {!Session} session
@param {!{line: number, ch: number}} offset
@return {!$.Promise} a jQuery promise that will be resolved with the scope data | [
"Requests",
"scope",
"data",
"from",
"tern"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptRefactoring/RefactoringUtils.js#L203-L229 |
1,964 | adobe/brackets | src/extensions/default/JavaScriptRefactoring/RefactoringUtils.js | normalizeText | function normalizeText(text, start, end, removeTrailingSemiColons) {
var trimmedText;
// Remove leading spaces
trimmedText = _.trimLeft(text);
if (trimmedText.length < text.length) {
start += (text.length - trimmedText.length);
}
text = trimmedText;
// Remove trailing spaces
trimmedText = _.trimRight(text);
if (trimmedText.length < text.length) {
end -= (text.length - trimmedText.length);
}
text = trimmedText;
// Remove trailing semicolons
if (removeTrailingSemiColons) {
trimmedText = _.trimRight(text, ';');
if (trimmedText.length < text.length) {
end -= (text.length - trimmedText.length);
}
}
return {
text: trimmedText,
start: start,
end: end
};
} | javascript | function normalizeText(text, start, end, removeTrailingSemiColons) {
var trimmedText;
// Remove leading spaces
trimmedText = _.trimLeft(text);
if (trimmedText.length < text.length) {
start += (text.length - trimmedText.length);
}
text = trimmedText;
// Remove trailing spaces
trimmedText = _.trimRight(text);
if (trimmedText.length < text.length) {
end -= (text.length - trimmedText.length);
}
text = trimmedText;
// Remove trailing semicolons
if (removeTrailingSemiColons) {
trimmedText = _.trimRight(text, ';');
if (trimmedText.length < text.length) {
end -= (text.length - trimmedText.length);
}
}
return {
text: trimmedText,
start: start,
end: end
};
} | [
"function",
"normalizeText",
"(",
"text",
",",
"start",
",",
"end",
",",
"removeTrailingSemiColons",
")",
"{",
"var",
"trimmedText",
";",
"// Remove leading spaces",
"trimmedText",
"=",
"_",
".",
"trimLeft",
"(",
"text",
")",
";",
"if",
"(",
"trimmedText",
".",
"length",
"<",
"text",
".",
"length",
")",
"{",
"start",
"+=",
"(",
"text",
".",
"length",
"-",
"trimmedText",
".",
"length",
")",
";",
"}",
"text",
"=",
"trimmedText",
";",
"// Remove trailing spaces",
"trimmedText",
"=",
"_",
".",
"trimRight",
"(",
"text",
")",
";",
"if",
"(",
"trimmedText",
".",
"length",
"<",
"text",
".",
"length",
")",
"{",
"end",
"-=",
"(",
"text",
".",
"length",
"-",
"trimmedText",
".",
"length",
")",
";",
"}",
"text",
"=",
"trimmedText",
";",
"// Remove trailing semicolons",
"if",
"(",
"removeTrailingSemiColons",
")",
"{",
"trimmedText",
"=",
"_",
".",
"trimRight",
"(",
"text",
",",
"';'",
")",
";",
"if",
"(",
"trimmedText",
".",
"length",
"<",
"text",
".",
"length",
")",
"{",
"end",
"-=",
"(",
"text",
".",
"length",
"-",
"trimmedText",
".",
"length",
")",
";",
"}",
"}",
"return",
"{",
"text",
":",
"trimmedText",
",",
"start",
":",
"start",
",",
"end",
":",
"end",
"}",
";",
"}"
] | Normalize text by removing leading and trailing whitespace characters
and moves the start and end offset to reflect the new offset
@param {!string} text - selected text
@param {!number} start - the start offset of the text
@param {!number} end - the end offset of the text
@param {!boolean} removeTrailingSemiColons - removes trailing semicolons also if true
@return {!{text: string, start: number, end: number}} | [
"Normalize",
"text",
"by",
"removing",
"leading",
"and",
"trailing",
"whitespace",
"characters",
"and",
"moves",
"the",
"start",
"and",
"end",
"offset",
"to",
"reflect",
"the",
"new",
"offset"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptRefactoring/RefactoringUtils.js#L240-L275 |
1,965 | adobe/brackets | src/extensions/default/JavaScriptRefactoring/RefactoringUtils.js | findSurroundASTNode | function findSurroundASTNode(ast, expn, types) {
var foundNode = ASTWalker.findNodeAround(ast, expn.start, function (nodeType, node) {
if (expn.end) {
return types.includes(nodeType) && node.end >= expn.end;
} else {
return types.includes(nodeType);
}
});
return foundNode && _.clone(foundNode.node);
} | javascript | function findSurroundASTNode(ast, expn, types) {
var foundNode = ASTWalker.findNodeAround(ast, expn.start, function (nodeType, node) {
if (expn.end) {
return types.includes(nodeType) && node.end >= expn.end;
} else {
return types.includes(nodeType);
}
});
return foundNode && _.clone(foundNode.node);
} | [
"function",
"findSurroundASTNode",
"(",
"ast",
",",
"expn",
",",
"types",
")",
"{",
"var",
"foundNode",
"=",
"ASTWalker",
".",
"findNodeAround",
"(",
"ast",
",",
"expn",
".",
"start",
",",
"function",
"(",
"nodeType",
",",
"node",
")",
"{",
"if",
"(",
"expn",
".",
"end",
")",
"{",
"return",
"types",
".",
"includes",
"(",
"nodeType",
")",
"&&",
"node",
".",
"end",
">=",
"expn",
".",
"end",
";",
"}",
"else",
"{",
"return",
"types",
".",
"includes",
"(",
"nodeType",
")",
";",
"}",
"}",
")",
";",
"return",
"foundNode",
"&&",
"_",
".",
"clone",
"(",
"foundNode",
".",
"node",
")",
";",
"}"
] | Finds the surrounding ast node of the given expression of any of the given types
@param {!ASTNode} ast
@param {!{start: number, end: number}} expn - contains start and end offsets of expn
@param {!Array.<string>} types
@return {?ASTNode} | [
"Finds",
"the",
"surrounding",
"ast",
"node",
"of",
"the",
"given",
"expression",
"of",
"any",
"of",
"the",
"given",
"types"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptRefactoring/RefactoringUtils.js#L322-L331 |
1,966 | adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/transports/remote/NodeSocketTransportRemote.js | function (url) {
var self = this;
this._ws = new WebSocket(url);
// One potential source of confusion: the transport sends two "types" of messages -
// these are distinct from the protocol's own messages. This is because this transport
// needs to send an initial "connect" message telling the Brackets side of the transport
// the URL of the page that it's connecting from, distinct from the actual protocol
// message traffic. Actual protocol messages are sent as a JSON payload in a message of
// type "message".
//
// Other transports might not need to do this - for example, a transport that simply
// talks to an iframe within the same process already knows what URL that iframe is
// pointing to, so the only comunication that needs to happen via postMessage() is the
// actual protocol message strings, and no extra wrapping is necessary.
this._ws.onopen = function (event) {
// Send the initial "connect" message to tell the other end what URL we're from.
self._ws.send(JSON.stringify({
type: "connect",
url: global.location.href
}));
console.log("[Brackets LiveDev] Connected to Brackets at " + url);
if (self._callbacks && self._callbacks.connect) {
self._callbacks.connect();
}
};
this._ws.onmessage = function (event) {
console.log("[Brackets LiveDev] Got message: " + event.data);
if (self._callbacks && self._callbacks.message) {
self._callbacks.message(event.data);
}
};
this._ws.onclose = function (event) {
self._ws = null;
if (self._callbacks && self._callbacks.close) {
self._callbacks.close();
}
};
// TODO: onerror
} | javascript | function (url) {
var self = this;
this._ws = new WebSocket(url);
// One potential source of confusion: the transport sends two "types" of messages -
// these are distinct from the protocol's own messages. This is because this transport
// needs to send an initial "connect" message telling the Brackets side of the transport
// the URL of the page that it's connecting from, distinct from the actual protocol
// message traffic. Actual protocol messages are sent as a JSON payload in a message of
// type "message".
//
// Other transports might not need to do this - for example, a transport that simply
// talks to an iframe within the same process already knows what URL that iframe is
// pointing to, so the only comunication that needs to happen via postMessage() is the
// actual protocol message strings, and no extra wrapping is necessary.
this._ws.onopen = function (event) {
// Send the initial "connect" message to tell the other end what URL we're from.
self._ws.send(JSON.stringify({
type: "connect",
url: global.location.href
}));
console.log("[Brackets LiveDev] Connected to Brackets at " + url);
if (self._callbacks && self._callbacks.connect) {
self._callbacks.connect();
}
};
this._ws.onmessage = function (event) {
console.log("[Brackets LiveDev] Got message: " + event.data);
if (self._callbacks && self._callbacks.message) {
self._callbacks.message(event.data);
}
};
this._ws.onclose = function (event) {
self._ws = null;
if (self._callbacks && self._callbacks.close) {
self._callbacks.close();
}
};
// TODO: onerror
} | [
"function",
"(",
"url",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"_ws",
"=",
"new",
"WebSocket",
"(",
"url",
")",
";",
"// One potential source of confusion: the transport sends two \"types\" of messages -",
"// these are distinct from the protocol's own messages. This is because this transport",
"// needs to send an initial \"connect\" message telling the Brackets side of the transport",
"// the URL of the page that it's connecting from, distinct from the actual protocol",
"// message traffic. Actual protocol messages are sent as a JSON payload in a message of",
"// type \"message\".",
"//",
"// Other transports might not need to do this - for example, a transport that simply",
"// talks to an iframe within the same process already knows what URL that iframe is",
"// pointing to, so the only comunication that needs to happen via postMessage() is the",
"// actual protocol message strings, and no extra wrapping is necessary.",
"this",
".",
"_ws",
".",
"onopen",
"=",
"function",
"(",
"event",
")",
"{",
"// Send the initial \"connect\" message to tell the other end what URL we're from.",
"self",
".",
"_ws",
".",
"send",
"(",
"JSON",
".",
"stringify",
"(",
"{",
"type",
":",
"\"connect\"",
",",
"url",
":",
"global",
".",
"location",
".",
"href",
"}",
")",
")",
";",
"console",
".",
"log",
"(",
"\"[Brackets LiveDev] Connected to Brackets at \"",
"+",
"url",
")",
";",
"if",
"(",
"self",
".",
"_callbacks",
"&&",
"self",
".",
"_callbacks",
".",
"connect",
")",
"{",
"self",
".",
"_callbacks",
".",
"connect",
"(",
")",
";",
"}",
"}",
";",
"this",
".",
"_ws",
".",
"onmessage",
"=",
"function",
"(",
"event",
")",
"{",
"console",
".",
"log",
"(",
"\"[Brackets LiveDev] Got message: \"",
"+",
"event",
".",
"data",
")",
";",
"if",
"(",
"self",
".",
"_callbacks",
"&&",
"self",
".",
"_callbacks",
".",
"message",
")",
"{",
"self",
".",
"_callbacks",
".",
"message",
"(",
"event",
".",
"data",
")",
";",
"}",
"}",
";",
"this",
".",
"_ws",
".",
"onclose",
"=",
"function",
"(",
"event",
")",
"{",
"self",
".",
"_ws",
"=",
"null",
";",
"if",
"(",
"self",
".",
"_callbacks",
"&&",
"self",
".",
"_callbacks",
".",
"close",
")",
"{",
"self",
".",
"_callbacks",
".",
"close",
"(",
")",
";",
"}",
"}",
";",
"// TODO: onerror",
"}"
] | Connects to the NodeSocketTransport in Brackets at the given WebSocket URL.
@param {string} url | [
"Connects",
"to",
"the",
"NodeSocketTransport",
"in",
"Brackets",
"at",
"the",
"given",
"WebSocket",
"URL",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/transports/remote/NodeSocketTransportRemote.js#L68-L108 |
|
1,967 | adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/transports/remote/NodeSocketTransportRemote.js | function (msgStr) {
if (this._ws) {
// See comment in `connect()` above about why we wrap the message in a transport message
// object.
this._ws.send(JSON.stringify({
type: "message",
message: msgStr
}));
} else {
console.log("[Brackets LiveDev] Tried to send message over closed connection: " + msgStr);
}
} | javascript | function (msgStr) {
if (this._ws) {
// See comment in `connect()` above about why we wrap the message in a transport message
// object.
this._ws.send(JSON.stringify({
type: "message",
message: msgStr
}));
} else {
console.log("[Brackets LiveDev] Tried to send message over closed connection: " + msgStr);
}
} | [
"function",
"(",
"msgStr",
")",
"{",
"if",
"(",
"this",
".",
"_ws",
")",
"{",
"// See comment in `connect()` above about why we wrap the message in a transport message",
"// object.",
"this",
".",
"_ws",
".",
"send",
"(",
"JSON",
".",
"stringify",
"(",
"{",
"type",
":",
"\"message\"",
",",
"message",
":",
"msgStr",
"}",
")",
")",
";",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"\"[Brackets LiveDev] Tried to send message over closed connection: \"",
"+",
"msgStr",
")",
";",
"}",
"}"
] | Sends a message over the transport.
@param {string} msgStr The message to send. | [
"Sends",
"a",
"message",
"over",
"the",
"transport",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/transports/remote/NodeSocketTransportRemote.js#L114-L125 |
|
1,968 | adobe/brackets | src/extensions/default/CloseOthers/main.js | handleClose | function handleClose(mode) {
var targetIndex = MainViewManager.findInWorkingSet(MainViewManager.ACTIVE_PANE, MainViewManager.getCurrentlyViewedPath(MainViewManager.ACTIVE_PANE)),
workingSetList = MainViewManager.getWorkingSet(MainViewManager.ACTIVE_PANE),
start = (mode === closeBelow) ? (targetIndex + 1) : 0,
end = (mode === closeAbove) ? (targetIndex) : (workingSetList.length),
files = [],
i;
for (i = start; i < end; i++) {
if ((mode === closeOthers && i !== targetIndex) || (mode !== closeOthers)) {
files.push(workingSetList[i]);
}
}
CommandManager.execute(Commands.FILE_CLOSE_LIST, {fileList: files});
} | javascript | function handleClose(mode) {
var targetIndex = MainViewManager.findInWorkingSet(MainViewManager.ACTIVE_PANE, MainViewManager.getCurrentlyViewedPath(MainViewManager.ACTIVE_PANE)),
workingSetList = MainViewManager.getWorkingSet(MainViewManager.ACTIVE_PANE),
start = (mode === closeBelow) ? (targetIndex + 1) : 0,
end = (mode === closeAbove) ? (targetIndex) : (workingSetList.length),
files = [],
i;
for (i = start; i < end; i++) {
if ((mode === closeOthers && i !== targetIndex) || (mode !== closeOthers)) {
files.push(workingSetList[i]);
}
}
CommandManager.execute(Commands.FILE_CLOSE_LIST, {fileList: files});
} | [
"function",
"handleClose",
"(",
"mode",
")",
"{",
"var",
"targetIndex",
"=",
"MainViewManager",
".",
"findInWorkingSet",
"(",
"MainViewManager",
".",
"ACTIVE_PANE",
",",
"MainViewManager",
".",
"getCurrentlyViewedPath",
"(",
"MainViewManager",
".",
"ACTIVE_PANE",
")",
")",
",",
"workingSetList",
"=",
"MainViewManager",
".",
"getWorkingSet",
"(",
"MainViewManager",
".",
"ACTIVE_PANE",
")",
",",
"start",
"=",
"(",
"mode",
"===",
"closeBelow",
")",
"?",
"(",
"targetIndex",
"+",
"1",
")",
":",
"0",
",",
"end",
"=",
"(",
"mode",
"===",
"closeAbove",
")",
"?",
"(",
"targetIndex",
")",
":",
"(",
"workingSetList",
".",
"length",
")",
",",
"files",
"=",
"[",
"]",
",",
"i",
";",
"for",
"(",
"i",
"=",
"start",
";",
"i",
"<",
"end",
";",
"i",
"++",
")",
"{",
"if",
"(",
"(",
"mode",
"===",
"closeOthers",
"&&",
"i",
"!==",
"targetIndex",
")",
"||",
"(",
"mode",
"!==",
"closeOthers",
")",
")",
"{",
"files",
".",
"push",
"(",
"workingSetList",
"[",
"i",
"]",
")",
";",
"}",
"}",
"CommandManager",
".",
"execute",
"(",
"Commands",
".",
"FILE_CLOSE_LIST",
",",
"{",
"fileList",
":",
"files",
"}",
")",
";",
"}"
] | Handle the different Close Other commands
@param {string} mode | [
"Handle",
"the",
"different",
"Close",
"Other",
"commands"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CloseOthers/main.js#L59-L74 |
1,969 | adobe/brackets | src/extensions/default/CloseOthers/main.js | initializeCommands | function initializeCommands() {
var prefs = getPreferences();
CommandManager.register(Strings.CMD_FILE_CLOSE_BELOW, closeBelow, function () {
handleClose(closeBelow);
});
CommandManager.register(Strings.CMD_FILE_CLOSE_OTHERS, closeOthers, function () {
handleClose(closeOthers);
});
CommandManager.register(Strings.CMD_FILE_CLOSE_ABOVE, closeAbove, function () {
handleClose(closeAbove);
});
if (prefs.closeBelow) {
workingSetListCmenu.addMenuItem(closeBelow, "", Menus.AFTER, Commands.FILE_CLOSE);
}
if (prefs.closeOthers) {
workingSetListCmenu.addMenuItem(closeOthers, "", Menus.AFTER, Commands.FILE_CLOSE);
}
if (prefs.closeAbove) {
workingSetListCmenu.addMenuItem(closeAbove, "", Menus.AFTER, Commands.FILE_CLOSE);
}
menuEntriesShown = prefs;
} | javascript | function initializeCommands() {
var prefs = getPreferences();
CommandManager.register(Strings.CMD_FILE_CLOSE_BELOW, closeBelow, function () {
handleClose(closeBelow);
});
CommandManager.register(Strings.CMD_FILE_CLOSE_OTHERS, closeOthers, function () {
handleClose(closeOthers);
});
CommandManager.register(Strings.CMD_FILE_CLOSE_ABOVE, closeAbove, function () {
handleClose(closeAbove);
});
if (prefs.closeBelow) {
workingSetListCmenu.addMenuItem(closeBelow, "", Menus.AFTER, Commands.FILE_CLOSE);
}
if (prefs.closeOthers) {
workingSetListCmenu.addMenuItem(closeOthers, "", Menus.AFTER, Commands.FILE_CLOSE);
}
if (prefs.closeAbove) {
workingSetListCmenu.addMenuItem(closeAbove, "", Menus.AFTER, Commands.FILE_CLOSE);
}
menuEntriesShown = prefs;
} | [
"function",
"initializeCommands",
"(",
")",
"{",
"var",
"prefs",
"=",
"getPreferences",
"(",
")",
";",
"CommandManager",
".",
"register",
"(",
"Strings",
".",
"CMD_FILE_CLOSE_BELOW",
",",
"closeBelow",
",",
"function",
"(",
")",
"{",
"handleClose",
"(",
"closeBelow",
")",
";",
"}",
")",
";",
"CommandManager",
".",
"register",
"(",
"Strings",
".",
"CMD_FILE_CLOSE_OTHERS",
",",
"closeOthers",
",",
"function",
"(",
")",
"{",
"handleClose",
"(",
"closeOthers",
")",
";",
"}",
")",
";",
"CommandManager",
".",
"register",
"(",
"Strings",
".",
"CMD_FILE_CLOSE_ABOVE",
",",
"closeAbove",
",",
"function",
"(",
")",
"{",
"handleClose",
"(",
"closeAbove",
")",
";",
"}",
")",
";",
"if",
"(",
"prefs",
".",
"closeBelow",
")",
"{",
"workingSetListCmenu",
".",
"addMenuItem",
"(",
"closeBelow",
",",
"\"\"",
",",
"Menus",
".",
"AFTER",
",",
"Commands",
".",
"FILE_CLOSE",
")",
";",
"}",
"if",
"(",
"prefs",
".",
"closeOthers",
")",
"{",
"workingSetListCmenu",
".",
"addMenuItem",
"(",
"closeOthers",
",",
"\"\"",
",",
"Menus",
".",
"AFTER",
",",
"Commands",
".",
"FILE_CLOSE",
")",
";",
"}",
"if",
"(",
"prefs",
".",
"closeAbove",
")",
"{",
"workingSetListCmenu",
".",
"addMenuItem",
"(",
"closeAbove",
",",
"\"\"",
",",
"Menus",
".",
"AFTER",
",",
"Commands",
".",
"FILE_CLOSE",
")",
";",
"}",
"menuEntriesShown",
"=",
"prefs",
";",
"}"
] | Register the Commands and add the Menu Items, if required | [
"Register",
"the",
"Commands",
"and",
"add",
"the",
"Menu",
"Items",
"if",
"required"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CloseOthers/main.js#L157-L180 |
1,970 | adobe/brackets | src/view/Pane.js | _ensurePaneIsFocused | function _ensurePaneIsFocused(paneId) {
var pane = MainViewManager._getPane(paneId);
// Defer the focusing until other focus events have occurred.
setTimeout(function () {
// Focus has most likely changed: give it back to the given pane.
pane.focus();
this._lastFocusedElement = pane.$el[0];
MainViewManager.setActivePaneId(paneId);
}, 1);
} | javascript | function _ensurePaneIsFocused(paneId) {
var pane = MainViewManager._getPane(paneId);
// Defer the focusing until other focus events have occurred.
setTimeout(function () {
// Focus has most likely changed: give it back to the given pane.
pane.focus();
this._lastFocusedElement = pane.$el[0];
MainViewManager.setActivePaneId(paneId);
}, 1);
} | [
"function",
"_ensurePaneIsFocused",
"(",
"paneId",
")",
"{",
"var",
"pane",
"=",
"MainViewManager",
".",
"_getPane",
"(",
"paneId",
")",
";",
"// Defer the focusing until other focus events have occurred.",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"// Focus has most likely changed: give it back to the given pane.",
"pane",
".",
"focus",
"(",
")",
";",
"this",
".",
"_lastFocusedElement",
"=",
"pane",
".",
"$el",
"[",
"0",
"]",
";",
"MainViewManager",
".",
"setActivePaneId",
"(",
"paneId",
")",
";",
"}",
",",
"1",
")",
";",
"}"
] | Ensures that the given pane is focused after other focus related events occur
@params {string} paneId - paneId of the pane to focus
@private | [
"Ensures",
"that",
"the",
"given",
"pane",
"is",
"focused",
"after",
"other",
"focus",
"related",
"events",
"occur"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/Pane.js#L216-L226 |
1,971 | adobe/brackets | src/view/Pane.js | tryFocusingCurrentView | function tryFocusingCurrentView() {
if (self._currentView) {
if (self._currentView.focus) {
// Views can implement a focus
// method for focusing a complex
// DOM like codemirror
self._currentView.focus();
} else {
// Otherwise, no focus method
// just try and give the DOM
// element focus
self._currentView.$el.focus();
}
} else {
// no view so just focus the pane
self.$el.focus();
}
} | javascript | function tryFocusingCurrentView() {
if (self._currentView) {
if (self._currentView.focus) {
// Views can implement a focus
// method for focusing a complex
// DOM like codemirror
self._currentView.focus();
} else {
// Otherwise, no focus method
// just try and give the DOM
// element focus
self._currentView.$el.focus();
}
} else {
// no view so just focus the pane
self.$el.focus();
}
} | [
"function",
"tryFocusingCurrentView",
"(",
")",
"{",
"if",
"(",
"self",
".",
"_currentView",
")",
"{",
"if",
"(",
"self",
".",
"_currentView",
".",
"focus",
")",
"{",
"// Views can implement a focus",
"// method for focusing a complex",
"// DOM like codemirror",
"self",
".",
"_currentView",
".",
"focus",
"(",
")",
";",
"}",
"else",
"{",
"// Otherwise, no focus method",
"// just try and give the DOM",
"// element focus",
"self",
".",
"_currentView",
".",
"$el",
".",
"focus",
"(",
")",
";",
"}",
"}",
"else",
"{",
"// no view so just focus the pane",
"self",
".",
"$el",
".",
"focus",
"(",
")",
";",
"}",
"}"
] | Helper to focus the current view if it can | [
"Helper",
"to",
"focus",
"the",
"current",
"view",
"if",
"it",
"can"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/Pane.js#L1428-L1445 |
1,972 | adobe/brackets | src/editor/CodeHintManager.js | registerHintProvider | function registerHintProvider(providerInfo, languageIds, priority) {
var providerObj = { provider: providerInfo,
priority: priority || 0 };
if (languageIds.indexOf("all") !== -1) {
// Ignore anything else in languageIds and just register for every language. This includes
// the special "all" language since its key is in the hintProviders map from the beginning.
var languageId;
for (languageId in hintProviders) {
if (hintProviders.hasOwnProperty(languageId)) {
hintProviders[languageId].push(providerObj);
hintProviders[languageId].sort(_providerSort);
}
}
} else {
languageIds.forEach(function (languageId) {
if (!hintProviders[languageId]) {
// Initialize provider list with any existing all-language providers
hintProviders[languageId] = Array.prototype.concat(hintProviders.all);
}
hintProviders[languageId].push(providerObj);
hintProviders[languageId].sort(_providerSort);
});
}
} | javascript | function registerHintProvider(providerInfo, languageIds, priority) {
var providerObj = { provider: providerInfo,
priority: priority || 0 };
if (languageIds.indexOf("all") !== -1) {
// Ignore anything else in languageIds and just register for every language. This includes
// the special "all" language since its key is in the hintProviders map from the beginning.
var languageId;
for (languageId in hintProviders) {
if (hintProviders.hasOwnProperty(languageId)) {
hintProviders[languageId].push(providerObj);
hintProviders[languageId].sort(_providerSort);
}
}
} else {
languageIds.forEach(function (languageId) {
if (!hintProviders[languageId]) {
// Initialize provider list with any existing all-language providers
hintProviders[languageId] = Array.prototype.concat(hintProviders.all);
}
hintProviders[languageId].push(providerObj);
hintProviders[languageId].sort(_providerSort);
});
}
} | [
"function",
"registerHintProvider",
"(",
"providerInfo",
",",
"languageIds",
",",
"priority",
")",
"{",
"var",
"providerObj",
"=",
"{",
"provider",
":",
"providerInfo",
",",
"priority",
":",
"priority",
"||",
"0",
"}",
";",
"if",
"(",
"languageIds",
".",
"indexOf",
"(",
"\"all\"",
")",
"!==",
"-",
"1",
")",
"{",
"// Ignore anything else in languageIds and just register for every language. This includes",
"// the special \"all\" language since its key is in the hintProviders map from the beginning.",
"var",
"languageId",
";",
"for",
"(",
"languageId",
"in",
"hintProviders",
")",
"{",
"if",
"(",
"hintProviders",
".",
"hasOwnProperty",
"(",
"languageId",
")",
")",
"{",
"hintProviders",
"[",
"languageId",
"]",
".",
"push",
"(",
"providerObj",
")",
";",
"hintProviders",
"[",
"languageId",
"]",
".",
"sort",
"(",
"_providerSort",
")",
";",
"}",
"}",
"}",
"else",
"{",
"languageIds",
".",
"forEach",
"(",
"function",
"(",
"languageId",
")",
"{",
"if",
"(",
"!",
"hintProviders",
"[",
"languageId",
"]",
")",
"{",
"// Initialize provider list with any existing all-language providers",
"hintProviders",
"[",
"languageId",
"]",
"=",
"Array",
".",
"prototype",
".",
"concat",
"(",
"hintProviders",
".",
"all",
")",
";",
"}",
"hintProviders",
"[",
"languageId",
"]",
".",
"push",
"(",
"providerObj",
")",
";",
"hintProviders",
"[",
"languageId",
"]",
".",
"sort",
"(",
"_providerSort",
")",
";",
"}",
")",
";",
"}",
"}"
] | The method by which a CodeHintProvider registers its willingness to
providing hints for editors in a given language.
@param {!CodeHintProvider} provider
The hint provider to be registered, described below.
@param {!Array.<string>} languageIds
The set of language ids for which the provider is capable of
providing hints. If the special language id name "all" is included then
the provider may be called for any language.
@param {?number} priority
Used to break ties among hint providers for a particular language.
Providers with a higher number will be asked for hints before those
with a lower priority value. Defaults to zero. | [
"The",
"method",
"by",
"which",
"a",
"CodeHintProvider",
"registers",
"its",
"willingness",
"to",
"providing",
"hints",
"for",
"editors",
"in",
"a",
"given",
"language",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/CodeHintManager.js#L290-L314 |
1,973 | adobe/brackets | src/editor/CodeHintManager.js | _endSession | function _endSession() {
if (!hintList) {
return;
}
hintList.close();
hintList = null;
codeHintOpened = false;
keyDownEditor = null;
sessionProvider = null;
sessionEditor = null;
if (deferredHints) {
deferredHints.reject();
deferredHints = null;
}
} | javascript | function _endSession() {
if (!hintList) {
return;
}
hintList.close();
hintList = null;
codeHintOpened = false;
keyDownEditor = null;
sessionProvider = null;
sessionEditor = null;
if (deferredHints) {
deferredHints.reject();
deferredHints = null;
}
} | [
"function",
"_endSession",
"(",
")",
"{",
"if",
"(",
"!",
"hintList",
")",
"{",
"return",
";",
"}",
"hintList",
".",
"close",
"(",
")",
";",
"hintList",
"=",
"null",
";",
"codeHintOpened",
"=",
"false",
";",
"keyDownEditor",
"=",
"null",
";",
"sessionProvider",
"=",
"null",
";",
"sessionEditor",
"=",
"null",
";",
"if",
"(",
"deferredHints",
")",
"{",
"deferredHints",
".",
"reject",
"(",
")",
";",
"deferredHints",
"=",
"null",
";",
"}",
"}"
] | End the current hinting session | [
"End",
"the",
"current",
"hinting",
"session"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/CodeHintManager.js#L373-L387 |
1,974 | adobe/brackets | src/editor/CodeHintManager.js | _inSession | function _inSession(editor) {
if (sessionEditor) {
if (sessionEditor === editor &&
(hintList.isOpen() ||
(deferredHints && deferredHints.state() === "pending"))) {
return true;
} else {
// the editor has changed
_endSession();
}
}
return false;
} | javascript | function _inSession(editor) {
if (sessionEditor) {
if (sessionEditor === editor &&
(hintList.isOpen() ||
(deferredHints && deferredHints.state() === "pending"))) {
return true;
} else {
// the editor has changed
_endSession();
}
}
return false;
} | [
"function",
"_inSession",
"(",
"editor",
")",
"{",
"if",
"(",
"sessionEditor",
")",
"{",
"if",
"(",
"sessionEditor",
"===",
"editor",
"&&",
"(",
"hintList",
".",
"isOpen",
"(",
")",
"||",
"(",
"deferredHints",
"&&",
"deferredHints",
".",
"state",
"(",
")",
"===",
"\"pending\"",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"// the editor has changed",
"_endSession",
"(",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Is there a hinting session active for a given editor?
NOTE: the sessionEditor, sessionProvider and hintList objects are
only guaranteed to be initialized during an active session.
@param {Editor} editor
@return boolean | [
"Is",
"there",
"a",
"hinting",
"session",
"active",
"for",
"a",
"given",
"editor?"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/CodeHintManager.js#L398-L410 |
1,975 | adobe/brackets | src/editor/CodeHintManager.js | _updateHintList | function _updateHintList(callMoveUpEvent) {
callMoveUpEvent = typeof callMoveUpEvent === "undefined" ? false : callMoveUpEvent;
if (deferredHints) {
deferredHints.reject();
deferredHints = null;
}
if (callMoveUpEvent) {
return hintList.callMoveUp(callMoveUpEvent);
}
var response = sessionProvider.getHints(lastChar);
lastChar = null;
if (!response) {
// the provider wishes to close the session
_endSession();
} else {
// if the response is true, end the session and begin another
if (response === true) {
var previousEditor = sessionEditor;
_endSession();
_beginSession(previousEditor);
} else if (response.hasOwnProperty("hints")) { // a synchronous response
if (hintList.isOpen()) {
// the session is open
hintList.update(response);
} else {
hintList.open(response);
}
} else { // response is a deferred
deferredHints = response;
response.done(function (hints) {
// Guard against timing issues where the session ends before the
// response gets a chance to execute the callback. If the session
// ends first while still waiting on the response, then hintList
// will get cleared up.
if (!hintList) {
return;
}
if (hintList.isOpen()) {
// the session is open
hintList.update(hints);
} else {
hintList.open(hints);
}
});
}
}
} | javascript | function _updateHintList(callMoveUpEvent) {
callMoveUpEvent = typeof callMoveUpEvent === "undefined" ? false : callMoveUpEvent;
if (deferredHints) {
deferredHints.reject();
deferredHints = null;
}
if (callMoveUpEvent) {
return hintList.callMoveUp(callMoveUpEvent);
}
var response = sessionProvider.getHints(lastChar);
lastChar = null;
if (!response) {
// the provider wishes to close the session
_endSession();
} else {
// if the response is true, end the session and begin another
if (response === true) {
var previousEditor = sessionEditor;
_endSession();
_beginSession(previousEditor);
} else if (response.hasOwnProperty("hints")) { // a synchronous response
if (hintList.isOpen()) {
// the session is open
hintList.update(response);
} else {
hintList.open(response);
}
} else { // response is a deferred
deferredHints = response;
response.done(function (hints) {
// Guard against timing issues where the session ends before the
// response gets a chance to execute the callback. If the session
// ends first while still waiting on the response, then hintList
// will get cleared up.
if (!hintList) {
return;
}
if (hintList.isOpen()) {
// the session is open
hintList.update(hints);
} else {
hintList.open(hints);
}
});
}
}
} | [
"function",
"_updateHintList",
"(",
"callMoveUpEvent",
")",
"{",
"callMoveUpEvent",
"=",
"typeof",
"callMoveUpEvent",
"===",
"\"undefined\"",
"?",
"false",
":",
"callMoveUpEvent",
";",
"if",
"(",
"deferredHints",
")",
"{",
"deferredHints",
".",
"reject",
"(",
")",
";",
"deferredHints",
"=",
"null",
";",
"}",
"if",
"(",
"callMoveUpEvent",
")",
"{",
"return",
"hintList",
".",
"callMoveUp",
"(",
"callMoveUpEvent",
")",
";",
"}",
"var",
"response",
"=",
"sessionProvider",
".",
"getHints",
"(",
"lastChar",
")",
";",
"lastChar",
"=",
"null",
";",
"if",
"(",
"!",
"response",
")",
"{",
"// the provider wishes to close the session",
"_endSession",
"(",
")",
";",
"}",
"else",
"{",
"// if the response is true, end the session and begin another",
"if",
"(",
"response",
"===",
"true",
")",
"{",
"var",
"previousEditor",
"=",
"sessionEditor",
";",
"_endSession",
"(",
")",
";",
"_beginSession",
"(",
"previousEditor",
")",
";",
"}",
"else",
"if",
"(",
"response",
".",
"hasOwnProperty",
"(",
"\"hints\"",
")",
")",
"{",
"// a synchronous response",
"if",
"(",
"hintList",
".",
"isOpen",
"(",
")",
")",
"{",
"// the session is open",
"hintList",
".",
"update",
"(",
"response",
")",
";",
"}",
"else",
"{",
"hintList",
".",
"open",
"(",
"response",
")",
";",
"}",
"}",
"else",
"{",
"// response is a deferred",
"deferredHints",
"=",
"response",
";",
"response",
".",
"done",
"(",
"function",
"(",
"hints",
")",
"{",
"// Guard against timing issues where the session ends before the",
"// response gets a chance to execute the callback. If the session",
"// ends first while still waiting on the response, then hintList",
"// will get cleared up.",
"if",
"(",
"!",
"hintList",
")",
"{",
"return",
";",
"}",
"if",
"(",
"hintList",
".",
"isOpen",
"(",
")",
")",
"{",
"// the session is open",
"hintList",
".",
"update",
"(",
"hints",
")",
";",
"}",
"else",
"{",
"hintList",
".",
"open",
"(",
"hints",
")",
";",
"}",
"}",
")",
";",
"}",
"}",
"}"
] | From an active hinting session, get hints from the current provider and
render the hint list window.
Assumes that it is called when a session is active (i.e. sessionProvider is not null). | [
"From",
"an",
"active",
"hinting",
"session",
"get",
"hints",
"from",
"the",
"current",
"provider",
"and",
"render",
"the",
"hint",
"list",
"window",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/CodeHintManager.js#L417-L470 |
1,976 | adobe/brackets | src/editor/CodeHintManager.js | _handleKeydownEvent | function _handleKeydownEvent(jqEvent, editor, event) {
keyDownEditor = editor;
if (!(event.ctrlKey || event.altKey || event.metaKey) &&
(event.keyCode === KeyEvent.DOM_VK_ENTER ||
event.keyCode === KeyEvent.DOM_VK_RETURN ||
event.keyCode === KeyEvent.DOM_VK_TAB)) {
lastChar = String.fromCharCode(event.keyCode);
}
} | javascript | function _handleKeydownEvent(jqEvent, editor, event) {
keyDownEditor = editor;
if (!(event.ctrlKey || event.altKey || event.metaKey) &&
(event.keyCode === KeyEvent.DOM_VK_ENTER ||
event.keyCode === KeyEvent.DOM_VK_RETURN ||
event.keyCode === KeyEvent.DOM_VK_TAB)) {
lastChar = String.fromCharCode(event.keyCode);
}
} | [
"function",
"_handleKeydownEvent",
"(",
"jqEvent",
",",
"editor",
",",
"event",
")",
"{",
"keyDownEditor",
"=",
"editor",
";",
"if",
"(",
"!",
"(",
"event",
".",
"ctrlKey",
"||",
"event",
".",
"altKey",
"||",
"event",
".",
"metaKey",
")",
"&&",
"(",
"event",
".",
"keyCode",
"===",
"KeyEvent",
".",
"DOM_VK_ENTER",
"||",
"event",
".",
"keyCode",
"===",
"KeyEvent",
".",
"DOM_VK_RETURN",
"||",
"event",
".",
"keyCode",
"===",
"KeyEvent",
".",
"DOM_VK_TAB",
")",
")",
"{",
"lastChar",
"=",
"String",
".",
"fromCharCode",
"(",
"event",
".",
"keyCode",
")",
";",
"}",
"}"
] | Handles keys related to displaying, searching, and navigating the hint list.
This gets called before handleChange.
TODO: Ideally, we'd get a more semantic event from the editor that told us
what changed so that we could do all of this logic without looking at
key events. Then, the purposes of handleKeyEvent and handleChange could be
combined. Doing this well requires changing CodeMirror.
@param {Event} jqEvent
@param {Editor} editor
@param {KeyboardEvent} event | [
"Handles",
"keys",
"related",
"to",
"displaying",
"searching",
"and",
"navigating",
"the",
"hint",
"list",
".",
"This",
"gets",
"called",
"before",
"handleChange",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/CodeHintManager.js#L556-L564 |
1,977 | adobe/brackets | src/editor/CodeHintManager.js | _startNewSession | function _startNewSession(editor) {
if (isOpen()) {
return;
}
if (!editor) {
editor = EditorManager.getFocusedEditor();
}
if (editor) {
lastChar = null;
if (_inSession(editor)) {
_endSession();
}
// Begin a new explicit session
_beginSession(editor);
}
} | javascript | function _startNewSession(editor) {
if (isOpen()) {
return;
}
if (!editor) {
editor = EditorManager.getFocusedEditor();
}
if (editor) {
lastChar = null;
if (_inSession(editor)) {
_endSession();
}
// Begin a new explicit session
_beginSession(editor);
}
} | [
"function",
"_startNewSession",
"(",
"editor",
")",
"{",
"if",
"(",
"isOpen",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"editor",
")",
"{",
"editor",
"=",
"EditorManager",
".",
"getFocusedEditor",
"(",
")",
";",
"}",
"if",
"(",
"editor",
")",
"{",
"lastChar",
"=",
"null",
";",
"if",
"(",
"_inSession",
"(",
"editor",
")",
")",
"{",
"_endSession",
"(",
")",
";",
"}",
"// Begin a new explicit session",
"_beginSession",
"(",
"editor",
")",
";",
"}",
"}"
] | Explicitly start a new session. If we have an existing session,
then close the current one and restart a new one.
@param {Editor} editor | [
"Explicitly",
"start",
"a",
"new",
"session",
".",
"If",
"we",
"have",
"an",
"existing",
"session",
"then",
"close",
"the",
"current",
"one",
"and",
"restart",
"a",
"new",
"one",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/CodeHintManager.js#L680-L697 |
1,978 | adobe/brackets | src/features/JumpToDefManager.js | _doJumpToDef | function _doJumpToDef() {
var request = null,
result = new $.Deferred(),
jumpToDefProvider = null,
editor = EditorManager.getActiveEditor();
if (editor) {
// Find a suitable provider, if any
var language = editor.getLanguageForSelection(),
enabledProviders = _providerRegistrationHandler.getProvidersForLanguageId(language.getId());
enabledProviders.some(function (item, index) {
if (item.provider.canJumpToDef(editor)) {
jumpToDefProvider = item.provider;
return true;
}
});
if (jumpToDefProvider) {
request = jumpToDefProvider.doJumpToDef(editor);
if (request) {
request.done(function () {
result.resolve();
}).fail(function () {
result.reject();
});
} else {
result.reject();
}
} else {
result.reject();
}
} else {
result.reject();
}
return result.promise();
} | javascript | function _doJumpToDef() {
var request = null,
result = new $.Deferred(),
jumpToDefProvider = null,
editor = EditorManager.getActiveEditor();
if (editor) {
// Find a suitable provider, if any
var language = editor.getLanguageForSelection(),
enabledProviders = _providerRegistrationHandler.getProvidersForLanguageId(language.getId());
enabledProviders.some(function (item, index) {
if (item.provider.canJumpToDef(editor)) {
jumpToDefProvider = item.provider;
return true;
}
});
if (jumpToDefProvider) {
request = jumpToDefProvider.doJumpToDef(editor);
if (request) {
request.done(function () {
result.resolve();
}).fail(function () {
result.reject();
});
} else {
result.reject();
}
} else {
result.reject();
}
} else {
result.reject();
}
return result.promise();
} | [
"function",
"_doJumpToDef",
"(",
")",
"{",
"var",
"request",
"=",
"null",
",",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"jumpToDefProvider",
"=",
"null",
",",
"editor",
"=",
"EditorManager",
".",
"getActiveEditor",
"(",
")",
";",
"if",
"(",
"editor",
")",
"{",
"// Find a suitable provider, if any",
"var",
"language",
"=",
"editor",
".",
"getLanguageForSelection",
"(",
")",
",",
"enabledProviders",
"=",
"_providerRegistrationHandler",
".",
"getProvidersForLanguageId",
"(",
"language",
".",
"getId",
"(",
")",
")",
";",
"enabledProviders",
".",
"some",
"(",
"function",
"(",
"item",
",",
"index",
")",
"{",
"if",
"(",
"item",
".",
"provider",
".",
"canJumpToDef",
"(",
"editor",
")",
")",
"{",
"jumpToDefProvider",
"=",
"item",
".",
"provider",
";",
"return",
"true",
";",
"}",
"}",
")",
";",
"if",
"(",
"jumpToDefProvider",
")",
"{",
"request",
"=",
"jumpToDefProvider",
".",
"doJumpToDef",
"(",
"editor",
")",
";",
"if",
"(",
"request",
")",
"{",
"request",
".",
"done",
"(",
"function",
"(",
")",
"{",
"result",
".",
"resolve",
"(",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"result",
".",
"reject",
"(",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"result",
".",
"reject",
"(",
")",
";",
"}",
"}",
"else",
"{",
"result",
".",
"reject",
"(",
")",
";",
"}",
"}",
"else",
"{",
"result",
".",
"reject",
"(",
")",
";",
"}",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] | Asynchronously asks providers to handle jump-to-definition.
@return {!Promise} Resolved when the provider signals that it's done; rejected if no
provider responded or the provider that responded failed. | [
"Asynchronously",
"asks",
"providers",
"to",
"handle",
"jump",
"-",
"to",
"-",
"definition",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/features/JumpToDefManager.js#L44-L83 |
1,979 | adobe/brackets | src/features/ParameterHintsManager.js | positionHint | function positionHint(xpos, ypos, ybot) {
var hintWidth = $hintContainer.width(),
hintHeight = $hintContainer.height(),
top = ypos - hintHeight - POINTER_TOP_OFFSET,
left = xpos,
$editorHolder = $("#editor-holder"),
editorLeft;
if ($editorHolder.offset() === undefined) {
// this happens in jasmine tests that run
// without a windowed document.
return;
}
editorLeft = $editorHolder.offset().left;
left = Math.max(left, editorLeft);
left = Math.min(left, editorLeft + $editorHolder.width() - hintWidth);
if (top < 0) {
$hintContainer.removeClass("preview-bubble-above");
$hintContainer.addClass("preview-bubble-below");
top = ybot + POSITION_BELOW_OFFSET;
$hintContainer.offset({
left: left,
top: top
});
} else {
$hintContainer.removeClass("preview-bubble-below");
$hintContainer.addClass("preview-bubble-above");
$hintContainer.offset({
left: left,
top: top - POINTER_TOP_OFFSET
});
}
} | javascript | function positionHint(xpos, ypos, ybot) {
var hintWidth = $hintContainer.width(),
hintHeight = $hintContainer.height(),
top = ypos - hintHeight - POINTER_TOP_OFFSET,
left = xpos,
$editorHolder = $("#editor-holder"),
editorLeft;
if ($editorHolder.offset() === undefined) {
// this happens in jasmine tests that run
// without a windowed document.
return;
}
editorLeft = $editorHolder.offset().left;
left = Math.max(left, editorLeft);
left = Math.min(left, editorLeft + $editorHolder.width() - hintWidth);
if (top < 0) {
$hintContainer.removeClass("preview-bubble-above");
$hintContainer.addClass("preview-bubble-below");
top = ybot + POSITION_BELOW_OFFSET;
$hintContainer.offset({
left: left,
top: top
});
} else {
$hintContainer.removeClass("preview-bubble-below");
$hintContainer.addClass("preview-bubble-above");
$hintContainer.offset({
left: left,
top: top - POINTER_TOP_OFFSET
});
}
} | [
"function",
"positionHint",
"(",
"xpos",
",",
"ypos",
",",
"ybot",
")",
"{",
"var",
"hintWidth",
"=",
"$hintContainer",
".",
"width",
"(",
")",
",",
"hintHeight",
"=",
"$hintContainer",
".",
"height",
"(",
")",
",",
"top",
"=",
"ypos",
"-",
"hintHeight",
"-",
"POINTER_TOP_OFFSET",
",",
"left",
"=",
"xpos",
",",
"$editorHolder",
"=",
"$",
"(",
"\"#editor-holder\"",
")",
",",
"editorLeft",
";",
"if",
"(",
"$editorHolder",
".",
"offset",
"(",
")",
"===",
"undefined",
")",
"{",
"// this happens in jasmine tests that run",
"// without a windowed document.",
"return",
";",
"}",
"editorLeft",
"=",
"$editorHolder",
".",
"offset",
"(",
")",
".",
"left",
";",
"left",
"=",
"Math",
".",
"max",
"(",
"left",
",",
"editorLeft",
")",
";",
"left",
"=",
"Math",
".",
"min",
"(",
"left",
",",
"editorLeft",
"+",
"$editorHolder",
".",
"width",
"(",
")",
"-",
"hintWidth",
")",
";",
"if",
"(",
"top",
"<",
"0",
")",
"{",
"$hintContainer",
".",
"removeClass",
"(",
"\"preview-bubble-above\"",
")",
";",
"$hintContainer",
".",
"addClass",
"(",
"\"preview-bubble-below\"",
")",
";",
"top",
"=",
"ybot",
"+",
"POSITION_BELOW_OFFSET",
";",
"$hintContainer",
".",
"offset",
"(",
"{",
"left",
":",
"left",
",",
"top",
":",
"top",
"}",
")",
";",
"}",
"else",
"{",
"$hintContainer",
".",
"removeClass",
"(",
"\"preview-bubble-below\"",
")",
";",
"$hintContainer",
".",
"addClass",
"(",
"\"preview-bubble-above\"",
")",
";",
"$hintContainer",
".",
"offset",
"(",
"{",
"left",
":",
"left",
",",
"top",
":",
"top",
"-",
"POINTER_TOP_OFFSET",
"}",
")",
";",
"}",
"}"
] | Position a function hint.
@param {number} xpos
@param {number} ypos
@param {number} ybot | [
"Position",
"a",
"function",
"hint",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/features/ParameterHintsManager.js#L81-L115 |
1,980 | adobe/brackets | src/features/ParameterHintsManager.js | formatHint | function formatHint(hints) {
$hintContent.empty();
$hintContent.addClass("brackets-hints");
function appendSeparators(separators) {
$hintContent.append(separators);
}
function appendParameter(param, documentation, index) {
if (hints.currentIndex === index) {
$hintContent.append($("<span>")
.append(_.escape(param))
.addClass("current-parameter"));
} else {
$hintContent.append($("<span>")
.append(_.escape(param))
.addClass("parameter"));
}
}
if (hints.parameters.length > 0) {
_formatParameterHint(hints.parameters, appendSeparators, appendParameter);
} else {
$hintContent.append(_.escape(Strings.NO_ARGUMENTS));
}
} | javascript | function formatHint(hints) {
$hintContent.empty();
$hintContent.addClass("brackets-hints");
function appendSeparators(separators) {
$hintContent.append(separators);
}
function appendParameter(param, documentation, index) {
if (hints.currentIndex === index) {
$hintContent.append($("<span>")
.append(_.escape(param))
.addClass("current-parameter"));
} else {
$hintContent.append($("<span>")
.append(_.escape(param))
.addClass("parameter"));
}
}
if (hints.parameters.length > 0) {
_formatParameterHint(hints.parameters, appendSeparators, appendParameter);
} else {
$hintContent.append(_.escape(Strings.NO_ARGUMENTS));
}
} | [
"function",
"formatHint",
"(",
"hints",
")",
"{",
"$hintContent",
".",
"empty",
"(",
")",
";",
"$hintContent",
".",
"addClass",
"(",
"\"brackets-hints\"",
")",
";",
"function",
"appendSeparators",
"(",
"separators",
")",
"{",
"$hintContent",
".",
"append",
"(",
"separators",
")",
";",
"}",
"function",
"appendParameter",
"(",
"param",
",",
"documentation",
",",
"index",
")",
"{",
"if",
"(",
"hints",
".",
"currentIndex",
"===",
"index",
")",
"{",
"$hintContent",
".",
"append",
"(",
"$",
"(",
"\"<span>\"",
")",
".",
"append",
"(",
"_",
".",
"escape",
"(",
"param",
")",
")",
".",
"addClass",
"(",
"\"current-parameter\"",
")",
")",
";",
"}",
"else",
"{",
"$hintContent",
".",
"append",
"(",
"$",
"(",
"\"<span>\"",
")",
".",
"append",
"(",
"_",
".",
"escape",
"(",
"param",
")",
")",
".",
"addClass",
"(",
"\"parameter\"",
")",
")",
";",
"}",
"}",
"if",
"(",
"hints",
".",
"parameters",
".",
"length",
">",
"0",
")",
"{",
"_formatParameterHint",
"(",
"hints",
".",
"parameters",
",",
"appendSeparators",
",",
"appendParameter",
")",
";",
"}",
"else",
"{",
"$hintContent",
".",
"append",
"(",
"_",
".",
"escape",
"(",
"Strings",
".",
"NO_ARGUMENTS",
")",
")",
";",
"}",
"}"
] | Bold the parameter at the caret.
@param {{inFunctionCall: boolean, functionCallPos: {line: number, ch: number}}} functionInfo -
tells if the caret is in a function call and the position
of the function call. | [
"Bold",
"the",
"parameter",
"at",
"the",
"caret",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/features/ParameterHintsManager.js#L199-L224 |
1,981 | adobe/brackets | src/features/ParameterHintsManager.js | dismissHint | function dismissHint(editor) {
if (hintState.visible) {
$hintContainer.hide();
$hintContent.empty();
hintState = {};
if (editor) {
editor.off("cursorActivity.ParameterHinting", handleCursorActivity);
sessionEditor = null;
} else if (sessionEditor) {
sessionEditor.off("cursorActivity.ParameterHinting", handleCursorActivity);
sessionEditor = null;
}
}
} | javascript | function dismissHint(editor) {
if (hintState.visible) {
$hintContainer.hide();
$hintContent.empty();
hintState = {};
if (editor) {
editor.off("cursorActivity.ParameterHinting", handleCursorActivity);
sessionEditor = null;
} else if (sessionEditor) {
sessionEditor.off("cursorActivity.ParameterHinting", handleCursorActivity);
sessionEditor = null;
}
}
} | [
"function",
"dismissHint",
"(",
"editor",
")",
"{",
"if",
"(",
"hintState",
".",
"visible",
")",
"{",
"$hintContainer",
".",
"hide",
"(",
")",
";",
"$hintContent",
".",
"empty",
"(",
")",
";",
"hintState",
"=",
"{",
"}",
";",
"if",
"(",
"editor",
")",
"{",
"editor",
".",
"off",
"(",
"\"cursorActivity.ParameterHinting\"",
",",
"handleCursorActivity",
")",
";",
"sessionEditor",
"=",
"null",
";",
"}",
"else",
"if",
"(",
"sessionEditor",
")",
"{",
"sessionEditor",
".",
"off",
"(",
"\"cursorActivity.ParameterHinting\"",
",",
"handleCursorActivity",
")",
";",
"sessionEditor",
"=",
"null",
";",
"}",
"}",
"}"
] | Dismiss the function hint. | [
"Dismiss",
"the",
"function",
"hint",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/features/ParameterHintsManager.js#L230-L244 |
1,982 | adobe/brackets | src/features/ParameterHintsManager.js | popUpHint | function popUpHint(editor, explicit, onCursorActivity) {
var request = null;
var $deferredPopUp = $.Deferred();
var sessionProvider = null;
dismissHint(editor);
// Find a suitable provider, if any
var language = editor.getLanguageForSelection(),
enabledProviders = _providerRegistrationHandler.getProvidersForLanguageId(language.getId());
enabledProviders.some(function (item, index) {
if (item.provider.hasParameterHints(editor, lastChar)) {
sessionProvider = item.provider;
return true;
}
});
if (sessionProvider) {
request = sessionProvider.getParameterHints(explicit, onCursorActivity);
}
if (request) {
request.done(function (parameterHint) {
var cm = editor._codeMirror,
pos = parameterHint.functionCallPos || editor.getCursorPos();
pos = cm.charCoords(pos);
formatHint(parameterHint);
$hintContainer.show();
positionHint(pos.left, pos.top, pos.bottom);
hintState.visible = true;
sessionEditor = editor;
editor.on("cursorActivity.ParameterHinting", handleCursorActivity);
$deferredPopUp.resolveWith(null);
}).fail(function () {
hintState = {};
});
}
return $deferredPopUp;
} | javascript | function popUpHint(editor, explicit, onCursorActivity) {
var request = null;
var $deferredPopUp = $.Deferred();
var sessionProvider = null;
dismissHint(editor);
// Find a suitable provider, if any
var language = editor.getLanguageForSelection(),
enabledProviders = _providerRegistrationHandler.getProvidersForLanguageId(language.getId());
enabledProviders.some(function (item, index) {
if (item.provider.hasParameterHints(editor, lastChar)) {
sessionProvider = item.provider;
return true;
}
});
if (sessionProvider) {
request = sessionProvider.getParameterHints(explicit, onCursorActivity);
}
if (request) {
request.done(function (parameterHint) {
var cm = editor._codeMirror,
pos = parameterHint.functionCallPos || editor.getCursorPos();
pos = cm.charCoords(pos);
formatHint(parameterHint);
$hintContainer.show();
positionHint(pos.left, pos.top, pos.bottom);
hintState.visible = true;
sessionEditor = editor;
editor.on("cursorActivity.ParameterHinting", handleCursorActivity);
$deferredPopUp.resolveWith(null);
}).fail(function () {
hintState = {};
});
}
return $deferredPopUp;
} | [
"function",
"popUpHint",
"(",
"editor",
",",
"explicit",
",",
"onCursorActivity",
")",
"{",
"var",
"request",
"=",
"null",
";",
"var",
"$deferredPopUp",
"=",
"$",
".",
"Deferred",
"(",
")",
";",
"var",
"sessionProvider",
"=",
"null",
";",
"dismissHint",
"(",
"editor",
")",
";",
"// Find a suitable provider, if any",
"var",
"language",
"=",
"editor",
".",
"getLanguageForSelection",
"(",
")",
",",
"enabledProviders",
"=",
"_providerRegistrationHandler",
".",
"getProvidersForLanguageId",
"(",
"language",
".",
"getId",
"(",
")",
")",
";",
"enabledProviders",
".",
"some",
"(",
"function",
"(",
"item",
",",
"index",
")",
"{",
"if",
"(",
"item",
".",
"provider",
".",
"hasParameterHints",
"(",
"editor",
",",
"lastChar",
")",
")",
"{",
"sessionProvider",
"=",
"item",
".",
"provider",
";",
"return",
"true",
";",
"}",
"}",
")",
";",
"if",
"(",
"sessionProvider",
")",
"{",
"request",
"=",
"sessionProvider",
".",
"getParameterHints",
"(",
"explicit",
",",
"onCursorActivity",
")",
";",
"}",
"if",
"(",
"request",
")",
"{",
"request",
".",
"done",
"(",
"function",
"(",
"parameterHint",
")",
"{",
"var",
"cm",
"=",
"editor",
".",
"_codeMirror",
",",
"pos",
"=",
"parameterHint",
".",
"functionCallPos",
"||",
"editor",
".",
"getCursorPos",
"(",
")",
";",
"pos",
"=",
"cm",
".",
"charCoords",
"(",
"pos",
")",
";",
"formatHint",
"(",
"parameterHint",
")",
";",
"$hintContainer",
".",
"show",
"(",
")",
";",
"positionHint",
"(",
"pos",
".",
"left",
",",
"pos",
".",
"top",
",",
"pos",
".",
"bottom",
")",
";",
"hintState",
".",
"visible",
"=",
"true",
";",
"sessionEditor",
"=",
"editor",
";",
"editor",
".",
"on",
"(",
"\"cursorActivity.ParameterHinting\"",
",",
"handleCursorActivity",
")",
";",
"$deferredPopUp",
".",
"resolveWith",
"(",
"null",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"hintState",
"=",
"{",
"}",
";",
"}",
")",
";",
"}",
"return",
"$deferredPopUp",
";",
"}"
] | Pop up a function hint on the line above the caret position.
@param {object=} editor - current Active Editor
@param {boolean} True if hints are invoked through cursor activity.
@return {jQuery.Promise} - The promise will not complete until the
hint has completed. Returns null, if the function hint is already
displayed or there is no function hint at the cursor. | [
"Pop",
"up",
"a",
"function",
"hint",
"on",
"the",
"line",
"above",
"the",
"caret",
"position",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/features/ParameterHintsManager.js#L256-L298 |
1,983 | adobe/brackets | src/features/ParameterHintsManager.js | installListeners | function installListeners(editor) {
editor.on("keydown.ParameterHinting", function (event, editor, domEvent) {
if (domEvent.keyCode === KeyEvent.DOM_VK_ESCAPE) {
dismissHint(editor);
}
}).on("scroll.ParameterHinting", function () {
dismissHint(editor);
})
.on("editorChange.ParameterHinting", _handleChange)
.on("keypress.ParameterHinting", _handleKeypressEvent);
} | javascript | function installListeners(editor) {
editor.on("keydown.ParameterHinting", function (event, editor, domEvent) {
if (domEvent.keyCode === KeyEvent.DOM_VK_ESCAPE) {
dismissHint(editor);
}
}).on("scroll.ParameterHinting", function () {
dismissHint(editor);
})
.on("editorChange.ParameterHinting", _handleChange)
.on("keypress.ParameterHinting", _handleKeypressEvent);
} | [
"function",
"installListeners",
"(",
"editor",
")",
"{",
"editor",
".",
"on",
"(",
"\"keydown.ParameterHinting\"",
",",
"function",
"(",
"event",
",",
"editor",
",",
"domEvent",
")",
"{",
"if",
"(",
"domEvent",
".",
"keyCode",
"===",
"KeyEvent",
".",
"DOM_VK_ESCAPE",
")",
"{",
"dismissHint",
"(",
"editor",
")",
";",
"}",
"}",
")",
".",
"on",
"(",
"\"scroll.ParameterHinting\"",
",",
"function",
"(",
")",
"{",
"dismissHint",
"(",
"editor",
")",
";",
"}",
")",
".",
"on",
"(",
"\"editorChange.ParameterHinting\"",
",",
"_handleChange",
")",
".",
"on",
"(",
"\"keypress.ParameterHinting\"",
",",
"_handleKeypressEvent",
")",
";",
"}"
] | Install function hint listeners.
@param {Editor} editor - editor context on which to listen for
changes | [
"Install",
"function",
"hint",
"listeners",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/features/ParameterHintsManager.js#L318-L328 |
1,984 | adobe/brackets | src/file/FileUtils.js | readAsText | function readAsText(file) {
var result = new $.Deferred();
// Measure performance
var perfTimerName = PerfUtils.markStart("readAsText:\t" + file.fullPath);
result.always(function () {
PerfUtils.addMeasurement(perfTimerName);
});
// Read file
file.read(function (err, data, encoding, stat) {
if (!err) {
result.resolve(data, stat.mtime);
} else {
result.reject(err);
}
});
return result.promise();
} | javascript | function readAsText(file) {
var result = new $.Deferred();
// Measure performance
var perfTimerName = PerfUtils.markStart("readAsText:\t" + file.fullPath);
result.always(function () {
PerfUtils.addMeasurement(perfTimerName);
});
// Read file
file.read(function (err, data, encoding, stat) {
if (!err) {
result.resolve(data, stat.mtime);
} else {
result.reject(err);
}
});
return result.promise();
} | [
"function",
"readAsText",
"(",
"file",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"// Measure performance",
"var",
"perfTimerName",
"=",
"PerfUtils",
".",
"markStart",
"(",
"\"readAsText:\\t\"",
"+",
"file",
".",
"fullPath",
")",
";",
"result",
".",
"always",
"(",
"function",
"(",
")",
"{",
"PerfUtils",
".",
"addMeasurement",
"(",
"perfTimerName",
")",
";",
"}",
")",
";",
"// Read file",
"file",
".",
"read",
"(",
"function",
"(",
"err",
",",
"data",
",",
"encoding",
",",
"stat",
")",
"{",
"if",
"(",
"!",
"err",
")",
"{",
"result",
".",
"resolve",
"(",
"data",
",",
"stat",
".",
"mtime",
")",
";",
"}",
"else",
"{",
"result",
".",
"reject",
"(",
"err",
")",
";",
"}",
"}",
")",
";",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] | Asynchronously reads a file as UTF-8 encoded text.
@param {!File} file File to read
@return {$.Promise} a jQuery promise that will be resolved with the
file's text content plus its timestamp, or rejected with a FileSystemError string
constant if the file can not be read. | [
"Asynchronously",
"reads",
"a",
"file",
"as",
"UTF",
"-",
"8",
"encoded",
"text",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/file/FileUtils.js#L70-L89 |
1,985 | adobe/brackets | src/file/FileUtils.js | writeText | function writeText(file, text, allowBlindWrite) {
var result = new $.Deferred(),
options = {};
if (allowBlindWrite) {
options.blind = true;
}
file.write(text, options, function (err) {
if (!err) {
result.resolve();
} else {
result.reject(err);
}
});
return result.promise();
} | javascript | function writeText(file, text, allowBlindWrite) {
var result = new $.Deferred(),
options = {};
if (allowBlindWrite) {
options.blind = true;
}
file.write(text, options, function (err) {
if (!err) {
result.resolve();
} else {
result.reject(err);
}
});
return result.promise();
} | [
"function",
"writeText",
"(",
"file",
",",
"text",
",",
"allowBlindWrite",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"options",
"=",
"{",
"}",
";",
"if",
"(",
"allowBlindWrite",
")",
"{",
"options",
".",
"blind",
"=",
"true",
";",
"}",
"file",
".",
"write",
"(",
"text",
",",
"options",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"!",
"err",
")",
"{",
"result",
".",
"resolve",
"(",
")",
";",
"}",
"else",
"{",
"result",
".",
"reject",
"(",
"err",
")",
";",
"}",
"}",
")",
";",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] | Asynchronously writes a file as UTF-8 encoded text.
@param {!File} file File to write
@param {!string} text
@param {boolean=} allowBlindWrite Indicates whether or not CONTENTS_MODIFIED
errors---which can be triggered if the actual file contents differ from
the FileSystem's last-known contents---should be ignored.
@return {$.Promise} a jQuery promise that will be resolved when
file writing completes, or rejected with a FileSystemError string constant. | [
"Asynchronously",
"writes",
"a",
"file",
"as",
"UTF",
"-",
"8",
"encoded",
"text",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/file/FileUtils.js#L101-L118 |
1,986 | adobe/brackets | src/file/FileUtils.js | sniffLineEndings | function sniffLineEndings(text) {
var subset = text.substr(0, 1000); // (length is clipped to text.length)
var hasCRLF = /\r\n/.test(subset);
var hasLF = /[^\r]\n/.test(subset);
if ((hasCRLF && hasLF) || (!hasCRLF && !hasLF)) {
return null;
} else {
return hasCRLF ? LINE_ENDINGS_CRLF : LINE_ENDINGS_LF;
}
} | javascript | function sniffLineEndings(text) {
var subset = text.substr(0, 1000); // (length is clipped to text.length)
var hasCRLF = /\r\n/.test(subset);
var hasLF = /[^\r]\n/.test(subset);
if ((hasCRLF && hasLF) || (!hasCRLF && !hasLF)) {
return null;
} else {
return hasCRLF ? LINE_ENDINGS_CRLF : LINE_ENDINGS_LF;
}
} | [
"function",
"sniffLineEndings",
"(",
"text",
")",
"{",
"var",
"subset",
"=",
"text",
".",
"substr",
"(",
"0",
",",
"1000",
")",
";",
"// (length is clipped to text.length)",
"var",
"hasCRLF",
"=",
"/",
"\\r\\n",
"/",
".",
"test",
"(",
"subset",
")",
";",
"var",
"hasLF",
"=",
"/",
"[^\\r]\\n",
"/",
".",
"test",
"(",
"subset",
")",
";",
"if",
"(",
"(",
"hasCRLF",
"&&",
"hasLF",
")",
"||",
"(",
"!",
"hasCRLF",
"&&",
"!",
"hasLF",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"hasCRLF",
"?",
"LINE_ENDINGS_CRLF",
":",
"LINE_ENDINGS_LF",
";",
"}",
"}"
] | Scans the first 1000 chars of the text to determine how it encodes line endings. Returns
null if usage is mixed or if no line endings found.
@param {!string} text
@return {null|LINE_ENDINGS_CRLF|LINE_ENDINGS_LF} | [
"Scans",
"the",
"first",
"1000",
"chars",
"of",
"the",
"text",
"to",
"determine",
"how",
"it",
"encodes",
"line",
"endings",
".",
"Returns",
"null",
"if",
"usage",
"is",
"mixed",
"or",
"if",
"no",
"line",
"endings",
"found",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/file/FileUtils.js#L141-L151 |
1,987 | adobe/brackets | src/file/FileUtils.js | translateLineEndings | function translateLineEndings(text, lineEndings) {
if (lineEndings !== LINE_ENDINGS_CRLF && lineEndings !== LINE_ENDINGS_LF) {
lineEndings = getPlatformLineEndings();
}
var eolStr = (lineEndings === LINE_ENDINGS_CRLF ? "\r\n" : "\n");
var findAnyEol = /\r\n|\r|\n/g;
return text.replace(findAnyEol, eolStr);
} | javascript | function translateLineEndings(text, lineEndings) {
if (lineEndings !== LINE_ENDINGS_CRLF && lineEndings !== LINE_ENDINGS_LF) {
lineEndings = getPlatformLineEndings();
}
var eolStr = (lineEndings === LINE_ENDINGS_CRLF ? "\r\n" : "\n");
var findAnyEol = /\r\n|\r|\n/g;
return text.replace(findAnyEol, eolStr);
} | [
"function",
"translateLineEndings",
"(",
"text",
",",
"lineEndings",
")",
"{",
"if",
"(",
"lineEndings",
"!==",
"LINE_ENDINGS_CRLF",
"&&",
"lineEndings",
"!==",
"LINE_ENDINGS_LF",
")",
"{",
"lineEndings",
"=",
"getPlatformLineEndings",
"(",
")",
";",
"}",
"var",
"eolStr",
"=",
"(",
"lineEndings",
"===",
"LINE_ENDINGS_CRLF",
"?",
"\"\\r\\n\"",
":",
"\"\\n\"",
")",
";",
"var",
"findAnyEol",
"=",
"/",
"\\r\\n|\\r|\\n",
"/",
"g",
";",
"return",
"text",
".",
"replace",
"(",
"findAnyEol",
",",
"eolStr",
")",
";",
"}"
] | Translates any line ending types in the given text to the be the single form specified
@param {!string} text
@param {null|LINE_ENDINGS_CRLF|LINE_ENDINGS_LF} lineEndings
@return {string} | [
"Translates",
"any",
"line",
"ending",
"types",
"in",
"the",
"given",
"text",
"to",
"the",
"be",
"the",
"single",
"form",
"specified"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/file/FileUtils.js#L159-L168 |
1,988 | adobe/brackets | src/file/FileUtils.js | makeDialogFileList | function makeDialogFileList(paths) {
var result = "<ul class='dialog-list'>";
paths.forEach(function (path) {
result += "<li><span class='dialog-filename'>";
result += StringUtils.breakableUrl(path);
result += "</span></li>";
});
result += "</ul>";
return result;
} | javascript | function makeDialogFileList(paths) {
var result = "<ul class='dialog-list'>";
paths.forEach(function (path) {
result += "<li><span class='dialog-filename'>";
result += StringUtils.breakableUrl(path);
result += "</span></li>";
});
result += "</ul>";
return result;
} | [
"function",
"makeDialogFileList",
"(",
"paths",
")",
"{",
"var",
"result",
"=",
"\"<ul class='dialog-list'>\"",
";",
"paths",
".",
"forEach",
"(",
"function",
"(",
"path",
")",
"{",
"result",
"+=",
"\"<li><span class='dialog-filename'>\"",
";",
"result",
"+=",
"StringUtils",
".",
"breakableUrl",
"(",
"path",
")",
";",
"result",
"+=",
"\"</span></li>\"",
";",
"}",
")",
";",
"result",
"+=",
"\"</ul>\"",
";",
"return",
"result",
";",
"}"
] | Creates an HTML string for a list of files to be reported on, suitable for use in a dialog.
@param {Array.<string>} Array of filenames or paths to display. | [
"Creates",
"an",
"HTML",
"string",
"for",
"a",
"list",
"of",
"files",
"to",
"be",
"reported",
"on",
"suitable",
"for",
"use",
"in",
"a",
"dialog",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/file/FileUtils.js#L221-L230 |
1,989 | adobe/brackets | src/file/FileUtils.js | getBaseName | function getBaseName(fullPath) {
var lastSlash = fullPath.lastIndexOf("/");
if (lastSlash === fullPath.length - 1) { // directory: exclude trailing "/" too
return fullPath.slice(fullPath.lastIndexOf("/", fullPath.length - 2) + 1, -1);
} else {
return fullPath.slice(lastSlash + 1);
}
} | javascript | function getBaseName(fullPath) {
var lastSlash = fullPath.lastIndexOf("/");
if (lastSlash === fullPath.length - 1) { // directory: exclude trailing "/" too
return fullPath.slice(fullPath.lastIndexOf("/", fullPath.length - 2) + 1, -1);
} else {
return fullPath.slice(lastSlash + 1);
}
} | [
"function",
"getBaseName",
"(",
"fullPath",
")",
"{",
"var",
"lastSlash",
"=",
"fullPath",
".",
"lastIndexOf",
"(",
"\"/\"",
")",
";",
"if",
"(",
"lastSlash",
"===",
"fullPath",
".",
"length",
"-",
"1",
")",
"{",
"// directory: exclude trailing \"/\" too",
"return",
"fullPath",
".",
"slice",
"(",
"fullPath",
".",
"lastIndexOf",
"(",
"\"/\"",
",",
"fullPath",
".",
"length",
"-",
"2",
")",
"+",
"1",
",",
"-",
"1",
")",
";",
"}",
"else",
"{",
"return",
"fullPath",
".",
"slice",
"(",
"lastSlash",
"+",
"1",
")",
";",
"}",
"}"
] | Get the name of a file or a directory, removing any preceding path.
@param {string} fullPath full path to a file or directory
@return {string} Returns the base name of a file or the name of a
directory | [
"Get",
"the",
"name",
"of",
"a",
"file",
"or",
"a",
"directory",
"removing",
"any",
"preceding",
"path",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/file/FileUtils.js#L287-L294 |
1,990 | adobe/brackets | src/file/FileUtils.js | getNativeModuleDirectoryPath | function getNativeModuleDirectoryPath(module) {
var path;
if (module && module.uri) {
path = decodeURI(module.uri);
// Remove module name and trailing slash from path.
path = path.substr(0, path.lastIndexOf("/"));
}
return path;
} | javascript | function getNativeModuleDirectoryPath(module) {
var path;
if (module && module.uri) {
path = decodeURI(module.uri);
// Remove module name and trailing slash from path.
path = path.substr(0, path.lastIndexOf("/"));
}
return path;
} | [
"function",
"getNativeModuleDirectoryPath",
"(",
"module",
")",
"{",
"var",
"path",
";",
"if",
"(",
"module",
"&&",
"module",
".",
"uri",
")",
"{",
"path",
"=",
"decodeURI",
"(",
"module",
".",
"uri",
")",
";",
"// Remove module name and trailing slash from path.",
"path",
"=",
"path",
".",
"substr",
"(",
"0",
",",
"path",
".",
"lastIndexOf",
"(",
"\"/\"",
")",
")",
";",
"}",
"return",
"path",
";",
"}"
] | Given the module object passed to JS module define function,
convert the path to a native absolute path.
Returns a native absolute path to the module folder.
WARNING: unlike most paths in Brackets, this path EXCLUDES the trailing "/".
@return {string} | [
"Given",
"the",
"module",
"object",
"passed",
"to",
"JS",
"module",
"define",
"function",
"convert",
"the",
"path",
"to",
"a",
"native",
"absolute",
"path",
".",
"Returns",
"a",
"native",
"absolute",
"path",
"to",
"the",
"module",
"folder",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/file/FileUtils.js#L318-L328 |
1,991 | adobe/brackets | src/file/FileUtils.js | getFilenameWithoutExtension | function getFilenameWithoutExtension(filename) {
var index = filename.lastIndexOf(".");
return index === -1 ? filename : filename.slice(0, index);
} | javascript | function getFilenameWithoutExtension(filename) {
var index = filename.lastIndexOf(".");
return index === -1 ? filename : filename.slice(0, index);
} | [
"function",
"getFilenameWithoutExtension",
"(",
"filename",
")",
"{",
"var",
"index",
"=",
"filename",
".",
"lastIndexOf",
"(",
"\".\"",
")",
";",
"return",
"index",
"===",
"-",
"1",
"?",
"filename",
":",
"filename",
".",
"slice",
"(",
"0",
",",
"index",
")",
";",
"}"
] | Get the file name without the extension. Returns "" if name starts with "."
@param {string} filename File name of a file or directory, without preceding path
@return {string} Returns the file name without the extension | [
"Get",
"the",
"file",
"name",
"without",
"the",
"extension",
".",
"Returns",
"if",
"name",
"starts",
"with",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/file/FileUtils.js#L428-L431 |
1,992 | adobe/brackets | src/utils/DropdownEventHandler.js | DropdownEventHandler | function DropdownEventHandler($list, selectionCallback, closeCallback) {
this.$list = $list;
this.$items = $list.find("li");
this.selectionCallback = selectionCallback;
this.closeCallback = closeCallback;
this.scrolling = false;
/**
* @private
* The selected position in the list; otherwise -1.
* @type {number}
*/
this._selectedIndex = -1;
} | javascript | function DropdownEventHandler($list, selectionCallback, closeCallback) {
this.$list = $list;
this.$items = $list.find("li");
this.selectionCallback = selectionCallback;
this.closeCallback = closeCallback;
this.scrolling = false;
/**
* @private
* The selected position in the list; otherwise -1.
* @type {number}
*/
this._selectedIndex = -1;
} | [
"function",
"DropdownEventHandler",
"(",
"$list",
",",
"selectionCallback",
",",
"closeCallback",
")",
"{",
"this",
".",
"$list",
"=",
"$list",
";",
"this",
".",
"$items",
"=",
"$list",
".",
"find",
"(",
"\"li\"",
")",
";",
"this",
".",
"selectionCallback",
"=",
"selectionCallback",
";",
"this",
".",
"closeCallback",
"=",
"closeCallback",
";",
"this",
".",
"scrolling",
"=",
"false",
";",
"/**\n * @private\n * The selected position in the list; otherwise -1.\n * @type {number}\n */",
"this",
".",
"_selectedIndex",
"=",
"-",
"1",
";",
"}"
] | Object to handle events for a dropdown list.
DropdownEventHandler handles these events:
Mouse:
- click - execute selection callback and dismiss list
- mouseover - highlight item
- mouseleave - remove mouse highlighting
Keyboard:
- Enter - execute selection callback and dismiss list
- Esc - dismiss list
- Up/Down - change selection
- PageUp/Down - change selection
Items whose <a> has the .disabled class do not respond to selection.
@constructor
@param {jQueryObject} $list associated list object
@param {Function} selectionCallback function called when list item is selected. | [
"Object",
"to",
"handle",
"events",
"for",
"a",
"dropdown",
"list",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/DropdownEventHandler.js#L54-L68 |
1,993 | adobe/brackets | src/utils/DropdownEventHandler.js | _keydownHook | function _keydownHook(event) {
var keyCode;
// (page) up, (page) down, enter and tab key are handled by the list
if (event.type === "keydown") {
keyCode = event.keyCode;
if (keyCode === KeyEvent.DOM_VK_TAB) {
self.close();
} else if (keyCode === KeyEvent.DOM_VK_UP) {
// Move up one, wrapping at edges (if nothing selected, select the last item)
self._tryToSelect(self._selectedIndex === -1 ? -1 : self._selectedIndex - 1, -1);
} else if (keyCode === KeyEvent.DOM_VK_DOWN) {
// Move down one, wrapping at edges (if nothing selected, select the first item)
self._tryToSelect(self._selectedIndex === -1 ? 0 : self._selectedIndex + 1, +1);
} else if (keyCode === KeyEvent.DOM_VK_PAGE_UP) {
// Move up roughly one 'page', stopping at edges (not wrapping) (if nothing selected, selects the first item)
self._tryToSelect((self._selectedIndex || 0) - self._itemsPerPage(), -1, true);
} else if (keyCode === KeyEvent.DOM_VK_PAGE_DOWN) {
// Move down roughly one 'page', stopping at edges (not wrapping) (if nothing selected, selects the item one page down from the top)
self._tryToSelect((self._selectedIndex || 0) + self._itemsPerPage(), +1, true);
} else if (keyCode === KeyEvent.DOM_VK_HOME) {
self._tryToSelect(0, +1);
} else if (keyCode === KeyEvent.DOM_VK_END) {
self._tryToSelect(self.$items.length - 1, -1);
} else if (self._selectedIndex !== -1 &&
(keyCode === KeyEvent.DOM_VK_RETURN)) {
// Trigger a click handler to commmit the selected item
self._selectionHandler();
} else {
// Let the event bubble.
return false;
}
event.stopImmediatePropagation();
event.preventDefault();
return true;
}
// If we didn't handle it, let other global keydown hooks handle it.
return false;
} | javascript | function _keydownHook(event) {
var keyCode;
// (page) up, (page) down, enter and tab key are handled by the list
if (event.type === "keydown") {
keyCode = event.keyCode;
if (keyCode === KeyEvent.DOM_VK_TAB) {
self.close();
} else if (keyCode === KeyEvent.DOM_VK_UP) {
// Move up one, wrapping at edges (if nothing selected, select the last item)
self._tryToSelect(self._selectedIndex === -1 ? -1 : self._selectedIndex - 1, -1);
} else if (keyCode === KeyEvent.DOM_VK_DOWN) {
// Move down one, wrapping at edges (if nothing selected, select the first item)
self._tryToSelect(self._selectedIndex === -1 ? 0 : self._selectedIndex + 1, +1);
} else if (keyCode === KeyEvent.DOM_VK_PAGE_UP) {
// Move up roughly one 'page', stopping at edges (not wrapping) (if nothing selected, selects the first item)
self._tryToSelect((self._selectedIndex || 0) - self._itemsPerPage(), -1, true);
} else if (keyCode === KeyEvent.DOM_VK_PAGE_DOWN) {
// Move down roughly one 'page', stopping at edges (not wrapping) (if nothing selected, selects the item one page down from the top)
self._tryToSelect((self._selectedIndex || 0) + self._itemsPerPage(), +1, true);
} else if (keyCode === KeyEvent.DOM_VK_HOME) {
self._tryToSelect(0, +1);
} else if (keyCode === KeyEvent.DOM_VK_END) {
self._tryToSelect(self.$items.length - 1, -1);
} else if (self._selectedIndex !== -1 &&
(keyCode === KeyEvent.DOM_VK_RETURN)) {
// Trigger a click handler to commmit the selected item
self._selectionHandler();
} else {
// Let the event bubble.
return false;
}
event.stopImmediatePropagation();
event.preventDefault();
return true;
}
// If we didn't handle it, let other global keydown hooks handle it.
return false;
} | [
"function",
"_keydownHook",
"(",
"event",
")",
"{",
"var",
"keyCode",
";",
"// (page) up, (page) down, enter and tab key are handled by the list",
"if",
"(",
"event",
".",
"type",
"===",
"\"keydown\"",
")",
"{",
"keyCode",
"=",
"event",
".",
"keyCode",
";",
"if",
"(",
"keyCode",
"===",
"KeyEvent",
".",
"DOM_VK_TAB",
")",
"{",
"self",
".",
"close",
"(",
")",
";",
"}",
"else",
"if",
"(",
"keyCode",
"===",
"KeyEvent",
".",
"DOM_VK_UP",
")",
"{",
"// Move up one, wrapping at edges (if nothing selected, select the last item)",
"self",
".",
"_tryToSelect",
"(",
"self",
".",
"_selectedIndex",
"===",
"-",
"1",
"?",
"-",
"1",
":",
"self",
".",
"_selectedIndex",
"-",
"1",
",",
"-",
"1",
")",
";",
"}",
"else",
"if",
"(",
"keyCode",
"===",
"KeyEvent",
".",
"DOM_VK_DOWN",
")",
"{",
"// Move down one, wrapping at edges (if nothing selected, select the first item)",
"self",
".",
"_tryToSelect",
"(",
"self",
".",
"_selectedIndex",
"===",
"-",
"1",
"?",
"0",
":",
"self",
".",
"_selectedIndex",
"+",
"1",
",",
"+",
"1",
")",
";",
"}",
"else",
"if",
"(",
"keyCode",
"===",
"KeyEvent",
".",
"DOM_VK_PAGE_UP",
")",
"{",
"// Move up roughly one 'page', stopping at edges (not wrapping) (if nothing selected, selects the first item)",
"self",
".",
"_tryToSelect",
"(",
"(",
"self",
".",
"_selectedIndex",
"||",
"0",
")",
"-",
"self",
".",
"_itemsPerPage",
"(",
")",
",",
"-",
"1",
",",
"true",
")",
";",
"}",
"else",
"if",
"(",
"keyCode",
"===",
"KeyEvent",
".",
"DOM_VK_PAGE_DOWN",
")",
"{",
"// Move down roughly one 'page', stopping at edges (not wrapping) (if nothing selected, selects the item one page down from the top)",
"self",
".",
"_tryToSelect",
"(",
"(",
"self",
".",
"_selectedIndex",
"||",
"0",
")",
"+",
"self",
".",
"_itemsPerPage",
"(",
")",
",",
"+",
"1",
",",
"true",
")",
";",
"}",
"else",
"if",
"(",
"keyCode",
"===",
"KeyEvent",
".",
"DOM_VK_HOME",
")",
"{",
"self",
".",
"_tryToSelect",
"(",
"0",
",",
"+",
"1",
")",
";",
"}",
"else",
"if",
"(",
"keyCode",
"===",
"KeyEvent",
".",
"DOM_VK_END",
")",
"{",
"self",
".",
"_tryToSelect",
"(",
"self",
".",
"$items",
".",
"length",
"-",
"1",
",",
"-",
"1",
")",
";",
"}",
"else",
"if",
"(",
"self",
".",
"_selectedIndex",
"!==",
"-",
"1",
"&&",
"(",
"keyCode",
"===",
"KeyEvent",
".",
"DOM_VK_RETURN",
")",
")",
"{",
"// Trigger a click handler to commmit the selected item",
"self",
".",
"_selectionHandler",
"(",
")",
";",
"}",
"else",
"{",
"// Let the event bubble.",
"return",
"false",
";",
"}",
"event",
".",
"stopImmediatePropagation",
"(",
")",
";",
"event",
".",
"preventDefault",
"(",
")",
";",
"return",
"true",
";",
"}",
"// If we didn't handle it, let other global keydown hooks handle it.",
"return",
"false",
";",
"}"
] | Convert keydown events into hint list navigation actions.
@param {KeyboardEvent} event
@return {boolean} true if key was handled, otherwise false. | [
"Convert",
"keydown",
"events",
"into",
"hint",
"list",
"navigation",
"actions",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/DropdownEventHandler.js#L82-L126 |
1,994 | adobe/brackets | src/language/XMLUtils.js | _createTagInfo | function _createTagInfo(token, tokenType, offset, exclusionList, tagName, attrName, shouldReplace) {
return {
token: token || null,
tokenType: tokenType || null,
offset: offset || 0,
exclusionList: exclusionList || [],
tagName: tagName || "",
attrName: attrName || "",
shouldReplace: shouldReplace || false
};
} | javascript | function _createTagInfo(token, tokenType, offset, exclusionList, tagName, attrName, shouldReplace) {
return {
token: token || null,
tokenType: tokenType || null,
offset: offset || 0,
exclusionList: exclusionList || [],
tagName: tagName || "",
attrName: attrName || "",
shouldReplace: shouldReplace || false
};
} | [
"function",
"_createTagInfo",
"(",
"token",
",",
"tokenType",
",",
"offset",
",",
"exclusionList",
",",
"tagName",
",",
"attrName",
",",
"shouldReplace",
")",
"{",
"return",
"{",
"token",
":",
"token",
"||",
"null",
",",
"tokenType",
":",
"tokenType",
"||",
"null",
",",
"offset",
":",
"offset",
"||",
"0",
",",
"exclusionList",
":",
"exclusionList",
"||",
"[",
"]",
",",
"tagName",
":",
"tagName",
"||",
"\"\"",
",",
"attrName",
":",
"attrName",
"||",
"\"\"",
",",
"shouldReplace",
":",
"shouldReplace",
"||",
"false",
"}",
";",
"}"
] | Returns an object that represents all its params.
@param {!Token} token CodeMirror token at the current pos
@param {number} tokenType Type of current token
@param {number} offset Offset in current token
@param {Array.<string>} exclusionList List of attributes of a tag or attribute options used by an attribute
@param {string} tagName Name of the current tag
@param {string} attrName Name of the current attribute
@param {boolean} shouldReplace true if we don't want to append ="" to an attribute
@return {!{token: Token, tokenType: int, offset: int, exclusionList: Array.<string>, tagName: string, attrName: string, shouldReplace: boolean}} | [
"Returns",
"an",
"object",
"that",
"represents",
"all",
"its",
"params",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/XMLUtils.js#L50-L60 |
1,995 | adobe/brackets | src/language/XMLUtils.js | _getTagAttributes | function _getTagAttributes(editor, constPos) {
var pos, ctx, ctxPrev, ctxNext, ctxTemp, tagName, exclusionList = [], shouldReplace;
pos = $.extend({}, constPos);
ctx = TokenUtils.getInitialContext(editor._codeMirror, pos);
// Stop if the cursor is before = or an attribute value.
ctxTemp = $.extend(true, {}, ctx);
if (ctxTemp.token.type === null && regexWhitespace.test(ctxTemp.token.string)) {
if (TokenUtils.moveSkippingWhitespace(TokenUtils.moveNextToken, ctxTemp)) {
if ((ctxTemp.token.type === null && ctxTemp.token.string === "=") ||
ctxTemp.token.type === "string") {
return null;
}
TokenUtils.moveSkippingWhitespace(TokenUtils.movePrevToken, ctxTemp);
}
}
// Incase an attribute is followed by an equal sign, shouldReplace will be used
// to prevent from appending ="" again.
if (ctxTemp.token.type === "attribute") {
if (TokenUtils.moveSkippingWhitespace(TokenUtils.moveNextToken, ctxTemp)) {
if (ctxTemp.token.type === null && ctxTemp.token.string === "=") {
shouldReplace = true;
}
}
}
// Look-Back and get the attributes and tag name.
pos = $.extend({}, constPos);
ctxPrev = TokenUtils.getInitialContext(editor._codeMirror, pos);
while (TokenUtils.movePrevToken(ctxPrev)) {
if (ctxPrev.token.type && ctxPrev.token.type.indexOf("tag bracket") >= 0) {
// Disallow hints in closed tag and inside tag content
if (ctxPrev.token.string === "</" || ctxPrev.token.string.indexOf(">") !== -1) {
return null;
}
}
// Get attributes.
if (ctxPrev.token.type === "attribute") {
exclusionList.push(ctxPrev.token.string);
}
// Get tag.
if (ctxPrev.token.type === "tag") {
tagName = ctxPrev.token.string;
if (TokenUtils.movePrevToken(ctxPrev)) {
if (ctxPrev.token.type === "tag bracket" && ctxPrev.token.string === "<") {
break;
}
return null;
}
}
}
// Look-Ahead and find rest of the attributes.
pos = $.extend({}, constPos);
ctxNext = TokenUtils.getInitialContext(editor._codeMirror, pos);
while (TokenUtils.moveNextToken(ctxNext)) {
if (ctxNext.token.type === "string" && ctxNext.token.string === "\"") {
return null;
}
// Stop on closing bracket of its own tag or opening bracket of next tag.
if (ctxNext.token.type === "tag bracket" &&
(ctxNext.token.string.indexOf(">") >= 0 || ctxNext.token.string === "<")) {
break;
}
if (ctxNext.token.type === "attribute" && exclusionList.indexOf(ctxNext.token.string) === -1) {
exclusionList.push(ctxNext.token.string);
}
}
return {
tagName: tagName,
exclusionList: exclusionList,
shouldReplace: shouldReplace
};
} | javascript | function _getTagAttributes(editor, constPos) {
var pos, ctx, ctxPrev, ctxNext, ctxTemp, tagName, exclusionList = [], shouldReplace;
pos = $.extend({}, constPos);
ctx = TokenUtils.getInitialContext(editor._codeMirror, pos);
// Stop if the cursor is before = or an attribute value.
ctxTemp = $.extend(true, {}, ctx);
if (ctxTemp.token.type === null && regexWhitespace.test(ctxTemp.token.string)) {
if (TokenUtils.moveSkippingWhitespace(TokenUtils.moveNextToken, ctxTemp)) {
if ((ctxTemp.token.type === null && ctxTemp.token.string === "=") ||
ctxTemp.token.type === "string") {
return null;
}
TokenUtils.moveSkippingWhitespace(TokenUtils.movePrevToken, ctxTemp);
}
}
// Incase an attribute is followed by an equal sign, shouldReplace will be used
// to prevent from appending ="" again.
if (ctxTemp.token.type === "attribute") {
if (TokenUtils.moveSkippingWhitespace(TokenUtils.moveNextToken, ctxTemp)) {
if (ctxTemp.token.type === null && ctxTemp.token.string === "=") {
shouldReplace = true;
}
}
}
// Look-Back and get the attributes and tag name.
pos = $.extend({}, constPos);
ctxPrev = TokenUtils.getInitialContext(editor._codeMirror, pos);
while (TokenUtils.movePrevToken(ctxPrev)) {
if (ctxPrev.token.type && ctxPrev.token.type.indexOf("tag bracket") >= 0) {
// Disallow hints in closed tag and inside tag content
if (ctxPrev.token.string === "</" || ctxPrev.token.string.indexOf(">") !== -1) {
return null;
}
}
// Get attributes.
if (ctxPrev.token.type === "attribute") {
exclusionList.push(ctxPrev.token.string);
}
// Get tag.
if (ctxPrev.token.type === "tag") {
tagName = ctxPrev.token.string;
if (TokenUtils.movePrevToken(ctxPrev)) {
if (ctxPrev.token.type === "tag bracket" && ctxPrev.token.string === "<") {
break;
}
return null;
}
}
}
// Look-Ahead and find rest of the attributes.
pos = $.extend({}, constPos);
ctxNext = TokenUtils.getInitialContext(editor._codeMirror, pos);
while (TokenUtils.moveNextToken(ctxNext)) {
if (ctxNext.token.type === "string" && ctxNext.token.string === "\"") {
return null;
}
// Stop on closing bracket of its own tag or opening bracket of next tag.
if (ctxNext.token.type === "tag bracket" &&
(ctxNext.token.string.indexOf(">") >= 0 || ctxNext.token.string === "<")) {
break;
}
if (ctxNext.token.type === "attribute" && exclusionList.indexOf(ctxNext.token.string) === -1) {
exclusionList.push(ctxNext.token.string);
}
}
return {
tagName: tagName,
exclusionList: exclusionList,
shouldReplace: shouldReplace
};
} | [
"function",
"_getTagAttributes",
"(",
"editor",
",",
"constPos",
")",
"{",
"var",
"pos",
",",
"ctx",
",",
"ctxPrev",
",",
"ctxNext",
",",
"ctxTemp",
",",
"tagName",
",",
"exclusionList",
"=",
"[",
"]",
",",
"shouldReplace",
";",
"pos",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"constPos",
")",
";",
"ctx",
"=",
"TokenUtils",
".",
"getInitialContext",
"(",
"editor",
".",
"_codeMirror",
",",
"pos",
")",
";",
"// Stop if the cursor is before = or an attribute value.",
"ctxTemp",
"=",
"$",
".",
"extend",
"(",
"true",
",",
"{",
"}",
",",
"ctx",
")",
";",
"if",
"(",
"ctxTemp",
".",
"token",
".",
"type",
"===",
"null",
"&&",
"regexWhitespace",
".",
"test",
"(",
"ctxTemp",
".",
"token",
".",
"string",
")",
")",
"{",
"if",
"(",
"TokenUtils",
".",
"moveSkippingWhitespace",
"(",
"TokenUtils",
".",
"moveNextToken",
",",
"ctxTemp",
")",
")",
"{",
"if",
"(",
"(",
"ctxTemp",
".",
"token",
".",
"type",
"===",
"null",
"&&",
"ctxTemp",
".",
"token",
".",
"string",
"===",
"\"=\"",
")",
"||",
"ctxTemp",
".",
"token",
".",
"type",
"===",
"\"string\"",
")",
"{",
"return",
"null",
";",
"}",
"TokenUtils",
".",
"moveSkippingWhitespace",
"(",
"TokenUtils",
".",
"movePrevToken",
",",
"ctxTemp",
")",
";",
"}",
"}",
"// Incase an attribute is followed by an equal sign, shouldReplace will be used",
"// to prevent from appending =\"\" again.",
"if",
"(",
"ctxTemp",
".",
"token",
".",
"type",
"===",
"\"attribute\"",
")",
"{",
"if",
"(",
"TokenUtils",
".",
"moveSkippingWhitespace",
"(",
"TokenUtils",
".",
"moveNextToken",
",",
"ctxTemp",
")",
")",
"{",
"if",
"(",
"ctxTemp",
".",
"token",
".",
"type",
"===",
"null",
"&&",
"ctxTemp",
".",
"token",
".",
"string",
"===",
"\"=\"",
")",
"{",
"shouldReplace",
"=",
"true",
";",
"}",
"}",
"}",
"// Look-Back and get the attributes and tag name.",
"pos",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"constPos",
")",
";",
"ctxPrev",
"=",
"TokenUtils",
".",
"getInitialContext",
"(",
"editor",
".",
"_codeMirror",
",",
"pos",
")",
";",
"while",
"(",
"TokenUtils",
".",
"movePrevToken",
"(",
"ctxPrev",
")",
")",
"{",
"if",
"(",
"ctxPrev",
".",
"token",
".",
"type",
"&&",
"ctxPrev",
".",
"token",
".",
"type",
".",
"indexOf",
"(",
"\"tag bracket\"",
")",
">=",
"0",
")",
"{",
"// Disallow hints in closed tag and inside tag content",
"if",
"(",
"ctxPrev",
".",
"token",
".",
"string",
"===",
"\"</\"",
"||",
"ctxPrev",
".",
"token",
".",
"string",
".",
"indexOf",
"(",
"\">\"",
")",
"!==",
"-",
"1",
")",
"{",
"return",
"null",
";",
"}",
"}",
"// Get attributes.",
"if",
"(",
"ctxPrev",
".",
"token",
".",
"type",
"===",
"\"attribute\"",
")",
"{",
"exclusionList",
".",
"push",
"(",
"ctxPrev",
".",
"token",
".",
"string",
")",
";",
"}",
"// Get tag.",
"if",
"(",
"ctxPrev",
".",
"token",
".",
"type",
"===",
"\"tag\"",
")",
"{",
"tagName",
"=",
"ctxPrev",
".",
"token",
".",
"string",
";",
"if",
"(",
"TokenUtils",
".",
"movePrevToken",
"(",
"ctxPrev",
")",
")",
"{",
"if",
"(",
"ctxPrev",
".",
"token",
".",
"type",
"===",
"\"tag bracket\"",
"&&",
"ctxPrev",
".",
"token",
".",
"string",
"===",
"\"<\"",
")",
"{",
"break",
";",
"}",
"return",
"null",
";",
"}",
"}",
"}",
"// Look-Ahead and find rest of the attributes.",
"pos",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"constPos",
")",
";",
"ctxNext",
"=",
"TokenUtils",
".",
"getInitialContext",
"(",
"editor",
".",
"_codeMirror",
",",
"pos",
")",
";",
"while",
"(",
"TokenUtils",
".",
"moveNextToken",
"(",
"ctxNext",
")",
")",
"{",
"if",
"(",
"ctxNext",
".",
"token",
".",
"type",
"===",
"\"string\"",
"&&",
"ctxNext",
".",
"token",
".",
"string",
"===",
"\"\\\"\"",
")",
"{",
"return",
"null",
";",
"}",
"// Stop on closing bracket of its own tag or opening bracket of next tag.",
"if",
"(",
"ctxNext",
".",
"token",
".",
"type",
"===",
"\"tag bracket\"",
"&&",
"(",
"ctxNext",
".",
"token",
".",
"string",
".",
"indexOf",
"(",
"\">\"",
")",
">=",
"0",
"||",
"ctxNext",
".",
"token",
".",
"string",
"===",
"\"<\"",
")",
")",
"{",
"break",
";",
"}",
"if",
"(",
"ctxNext",
".",
"token",
".",
"type",
"===",
"\"attribute\"",
"&&",
"exclusionList",
".",
"indexOf",
"(",
"ctxNext",
".",
"token",
".",
"string",
")",
"===",
"-",
"1",
")",
"{",
"exclusionList",
".",
"push",
"(",
"ctxNext",
".",
"token",
".",
"string",
")",
";",
"}",
"}",
"return",
"{",
"tagName",
":",
"tagName",
",",
"exclusionList",
":",
"exclusionList",
",",
"shouldReplace",
":",
"shouldReplace",
"}",
";",
"}"
] | Return the tagName and a list of attributes used by the tag.
@param {!Editor} editor An instance of active editor
@param {!{line: number, ch: number}} constPos The position of cursor in the active editor
@return {!{tagName: string, exclusionList: Array.<string>, shouldReplace: boolean}} | [
"Return",
"the",
"tagName",
"and",
"a",
"list",
"of",
"attributes",
"used",
"by",
"the",
"tag",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/XMLUtils.js#L69-L147 |
1,996 | adobe/brackets | src/language/XMLUtils.js | _getTagAttributeValue | function _getTagAttributeValue(editor, pos) {
var ctx, tagName, attrName, exclusionList = [], offset, textBefore, textAfter;
ctx = TokenUtils.getInitialContext(editor._codeMirror, pos);
offset = TokenUtils.offsetInToken(ctx);
// To support multiple options on the same attribute, we have
// to break the value, these values will not be available then.
if (ctx.token.type === "string" && /\s+/.test(ctx.token.string)) {
textBefore = ctx.token.string.substr(1, offset);
textAfter = ctx.token.string.substr(offset);
// Remove quote from end of the string.
if (/^['"]$/.test(ctx.token.string.substr(-1, 1))) {
textAfter = textAfter.substr(0, textAfter.length - 1);
}
// Split the text before and after the offset, skipping the current query.
exclusionList = exclusionList.concat(textBefore.split(/\s+/).slice(0, -1));
exclusionList = exclusionList.concat(textAfter.split(/\s+/));
// Filter through the list removing empty strings.
exclusionList = exclusionList.filter(function (value) {
if (value.length > 0) {
return true;
}
});
}
// Look-back and find tag and attributes.
while (TokenUtils.movePrevToken(ctx)) {
if (ctx.token.type === "tag bracket") {
// Disallow hints in closing tags.
if (ctx.token.string === "</") {
return null;
}
// Stop when closing bracket of another tag or opening bracket of its own in encountered.
if (ctx.token.string.indexOf(">") >= 0 || ctx.token.string === "<") {
break;
}
}
// Get the first previous attribute.
if (ctx.token.type === "attribute" && !attrName) {
attrName = ctx.token.string;
}
// Stop if we get a bracket after tag.
if (ctx.token.type === "tag") {
tagName = ctx.token.string;
if (TokenUtils.movePrevToken(ctx)) {
if (ctx.token.type === "tag bracket" && ctx.token.string === "<") {
break;
}
return null;
}
}
}
return {
tagName: tagName,
attrName: attrName,
exclusionList: exclusionList
};
} | javascript | function _getTagAttributeValue(editor, pos) {
var ctx, tagName, attrName, exclusionList = [], offset, textBefore, textAfter;
ctx = TokenUtils.getInitialContext(editor._codeMirror, pos);
offset = TokenUtils.offsetInToken(ctx);
// To support multiple options on the same attribute, we have
// to break the value, these values will not be available then.
if (ctx.token.type === "string" && /\s+/.test(ctx.token.string)) {
textBefore = ctx.token.string.substr(1, offset);
textAfter = ctx.token.string.substr(offset);
// Remove quote from end of the string.
if (/^['"]$/.test(ctx.token.string.substr(-1, 1))) {
textAfter = textAfter.substr(0, textAfter.length - 1);
}
// Split the text before and after the offset, skipping the current query.
exclusionList = exclusionList.concat(textBefore.split(/\s+/).slice(0, -1));
exclusionList = exclusionList.concat(textAfter.split(/\s+/));
// Filter through the list removing empty strings.
exclusionList = exclusionList.filter(function (value) {
if (value.length > 0) {
return true;
}
});
}
// Look-back and find tag and attributes.
while (TokenUtils.movePrevToken(ctx)) {
if (ctx.token.type === "tag bracket") {
// Disallow hints in closing tags.
if (ctx.token.string === "</") {
return null;
}
// Stop when closing bracket of another tag or opening bracket of its own in encountered.
if (ctx.token.string.indexOf(">") >= 0 || ctx.token.string === "<") {
break;
}
}
// Get the first previous attribute.
if (ctx.token.type === "attribute" && !attrName) {
attrName = ctx.token.string;
}
// Stop if we get a bracket after tag.
if (ctx.token.type === "tag") {
tagName = ctx.token.string;
if (TokenUtils.movePrevToken(ctx)) {
if (ctx.token.type === "tag bracket" && ctx.token.string === "<") {
break;
}
return null;
}
}
}
return {
tagName: tagName,
attrName: attrName,
exclusionList: exclusionList
};
} | [
"function",
"_getTagAttributeValue",
"(",
"editor",
",",
"pos",
")",
"{",
"var",
"ctx",
",",
"tagName",
",",
"attrName",
",",
"exclusionList",
"=",
"[",
"]",
",",
"offset",
",",
"textBefore",
",",
"textAfter",
";",
"ctx",
"=",
"TokenUtils",
".",
"getInitialContext",
"(",
"editor",
".",
"_codeMirror",
",",
"pos",
")",
";",
"offset",
"=",
"TokenUtils",
".",
"offsetInToken",
"(",
"ctx",
")",
";",
"// To support multiple options on the same attribute, we have",
"// to break the value, these values will not be available then.",
"if",
"(",
"ctx",
".",
"token",
".",
"type",
"===",
"\"string\"",
"&&",
"/",
"\\s+",
"/",
".",
"test",
"(",
"ctx",
".",
"token",
".",
"string",
")",
")",
"{",
"textBefore",
"=",
"ctx",
".",
"token",
".",
"string",
".",
"substr",
"(",
"1",
",",
"offset",
")",
";",
"textAfter",
"=",
"ctx",
".",
"token",
".",
"string",
".",
"substr",
"(",
"offset",
")",
";",
"// Remove quote from end of the string.",
"if",
"(",
"/",
"^['\"]$",
"/",
".",
"test",
"(",
"ctx",
".",
"token",
".",
"string",
".",
"substr",
"(",
"-",
"1",
",",
"1",
")",
")",
")",
"{",
"textAfter",
"=",
"textAfter",
".",
"substr",
"(",
"0",
",",
"textAfter",
".",
"length",
"-",
"1",
")",
";",
"}",
"// Split the text before and after the offset, skipping the current query.",
"exclusionList",
"=",
"exclusionList",
".",
"concat",
"(",
"textBefore",
".",
"split",
"(",
"/",
"\\s+",
"/",
")",
".",
"slice",
"(",
"0",
",",
"-",
"1",
")",
")",
";",
"exclusionList",
"=",
"exclusionList",
".",
"concat",
"(",
"textAfter",
".",
"split",
"(",
"/",
"\\s+",
"/",
")",
")",
";",
"// Filter through the list removing empty strings.",
"exclusionList",
"=",
"exclusionList",
".",
"filter",
"(",
"function",
"(",
"value",
")",
"{",
"if",
"(",
"value",
".",
"length",
">",
"0",
")",
"{",
"return",
"true",
";",
"}",
"}",
")",
";",
"}",
"// Look-back and find tag and attributes.",
"while",
"(",
"TokenUtils",
".",
"movePrevToken",
"(",
"ctx",
")",
")",
"{",
"if",
"(",
"ctx",
".",
"token",
".",
"type",
"===",
"\"tag bracket\"",
")",
"{",
"// Disallow hints in closing tags.",
"if",
"(",
"ctx",
".",
"token",
".",
"string",
"===",
"\"</\"",
")",
"{",
"return",
"null",
";",
"}",
"// Stop when closing bracket of another tag or opening bracket of its own in encountered.",
"if",
"(",
"ctx",
".",
"token",
".",
"string",
".",
"indexOf",
"(",
"\">\"",
")",
">=",
"0",
"||",
"ctx",
".",
"token",
".",
"string",
"===",
"\"<\"",
")",
"{",
"break",
";",
"}",
"}",
"// Get the first previous attribute.",
"if",
"(",
"ctx",
".",
"token",
".",
"type",
"===",
"\"attribute\"",
"&&",
"!",
"attrName",
")",
"{",
"attrName",
"=",
"ctx",
".",
"token",
".",
"string",
";",
"}",
"// Stop if we get a bracket after tag.",
"if",
"(",
"ctx",
".",
"token",
".",
"type",
"===",
"\"tag\"",
")",
"{",
"tagName",
"=",
"ctx",
".",
"token",
".",
"string",
";",
"if",
"(",
"TokenUtils",
".",
"movePrevToken",
"(",
"ctx",
")",
")",
"{",
"if",
"(",
"ctx",
".",
"token",
".",
"type",
"===",
"\"tag bracket\"",
"&&",
"ctx",
".",
"token",
".",
"string",
"===",
"\"<\"",
")",
"{",
"break",
";",
"}",
"return",
"null",
";",
"}",
"}",
"}",
"return",
"{",
"tagName",
":",
"tagName",
",",
"attrName",
":",
"attrName",
",",
"exclusionList",
":",
"exclusionList",
"}",
";",
"}"
] | Return the tag name, attribute name and a list of options used by the attribute
@param {!Editor} editor An instance of active editor
@param {!{line: number, ch: number}} pos Position of cursor in the editor
@return {!{tagName: string, attrName: string, exclusionList: Array.<string>}} | [
"Return",
"the",
"tag",
"name",
"attribute",
"name",
"and",
"a",
"list",
"of",
"options",
"used",
"by",
"the",
"attribute"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/XMLUtils.js#L156-L220 |
1,997 | adobe/brackets | src/language/XMLUtils.js | getTagInfo | function getTagInfo(editor, pos) {
var ctx, offset, tagAttrs, tagAttrValue;
ctx = TokenUtils.getInitialContext(editor._codeMirror, pos);
offset = TokenUtils.offsetInToken(ctx);
if (ctx.token && ctx.token.type === "tag bracket" && ctx.token.string === "<") {
// Returns tagInfo when an angle bracket is created.
return _createTagInfo(ctx.token, TOKEN_TAG);
} else if (ctx.token && ctx.token.type === "tag") {
// Return tagInfo when a tag is created.
if (TokenUtils.movePrevToken(ctx)) {
if (ctx.token.type === "tag bracket" && ctx.token.string === "<") {
TokenUtils.moveNextToken(ctx);
return _createTagInfo(ctx.token, TOKEN_TAG, offset);
}
}
} else if (ctx.token && (ctx.token.type === "attribute" ||
(ctx.token.type === null && regexWhitespace.test(ctx.token.string)))) {
// Return tagInfo when an attribute is created.
tagAttrs = _getTagAttributes(editor, pos);
if (tagAttrs && tagAttrs.tagName) {
return _createTagInfo(ctx.token, TOKEN_ATTR, offset, tagAttrs.exclusionList, tagAttrs.tagName, null, tagAttrs.shouldReplace);
}
} else if (ctx.token && ((ctx.token.type === null && ctx.token.string === "=") ||
(ctx.token.type === "string" && /^['"]$/.test(ctx.token.string.charAt(0))))) {
// Return tag info when an attribute value is created.
// Allow no hints if the cursor is outside the value.
if (ctx.token.type === "string" &&
/^['"]$/.test(ctx.token.string.substr(-1, 1)) &&
ctx.token.string.length !== 1 &&
ctx.token.end === pos.ch) {
return _createTagInfo();
}
tagAttrValue = _getTagAttributeValue(editor, pos);
if (tagAttrValue && tagAttrValue.tagName && tagAttrValue.attrName) {
return _createTagInfo(ctx.token, TOKEN_VALUE, offset, tagAttrValue.exclusionList, tagAttrValue.tagName, tagAttrValue.attrName);
}
}
return _createTagInfo();
} | javascript | function getTagInfo(editor, pos) {
var ctx, offset, tagAttrs, tagAttrValue;
ctx = TokenUtils.getInitialContext(editor._codeMirror, pos);
offset = TokenUtils.offsetInToken(ctx);
if (ctx.token && ctx.token.type === "tag bracket" && ctx.token.string === "<") {
// Returns tagInfo when an angle bracket is created.
return _createTagInfo(ctx.token, TOKEN_TAG);
} else if (ctx.token && ctx.token.type === "tag") {
// Return tagInfo when a tag is created.
if (TokenUtils.movePrevToken(ctx)) {
if (ctx.token.type === "tag bracket" && ctx.token.string === "<") {
TokenUtils.moveNextToken(ctx);
return _createTagInfo(ctx.token, TOKEN_TAG, offset);
}
}
} else if (ctx.token && (ctx.token.type === "attribute" ||
(ctx.token.type === null && regexWhitespace.test(ctx.token.string)))) {
// Return tagInfo when an attribute is created.
tagAttrs = _getTagAttributes(editor, pos);
if (tagAttrs && tagAttrs.tagName) {
return _createTagInfo(ctx.token, TOKEN_ATTR, offset, tagAttrs.exclusionList, tagAttrs.tagName, null, tagAttrs.shouldReplace);
}
} else if (ctx.token && ((ctx.token.type === null && ctx.token.string === "=") ||
(ctx.token.type === "string" && /^['"]$/.test(ctx.token.string.charAt(0))))) {
// Return tag info when an attribute value is created.
// Allow no hints if the cursor is outside the value.
if (ctx.token.type === "string" &&
/^['"]$/.test(ctx.token.string.substr(-1, 1)) &&
ctx.token.string.length !== 1 &&
ctx.token.end === pos.ch) {
return _createTagInfo();
}
tagAttrValue = _getTagAttributeValue(editor, pos);
if (tagAttrValue && tagAttrValue.tagName && tagAttrValue.attrName) {
return _createTagInfo(ctx.token, TOKEN_VALUE, offset, tagAttrValue.exclusionList, tagAttrValue.tagName, tagAttrValue.attrName);
}
}
return _createTagInfo();
} | [
"function",
"getTagInfo",
"(",
"editor",
",",
"pos",
")",
"{",
"var",
"ctx",
",",
"offset",
",",
"tagAttrs",
",",
"tagAttrValue",
";",
"ctx",
"=",
"TokenUtils",
".",
"getInitialContext",
"(",
"editor",
".",
"_codeMirror",
",",
"pos",
")",
";",
"offset",
"=",
"TokenUtils",
".",
"offsetInToken",
"(",
"ctx",
")",
";",
"if",
"(",
"ctx",
".",
"token",
"&&",
"ctx",
".",
"token",
".",
"type",
"===",
"\"tag bracket\"",
"&&",
"ctx",
".",
"token",
".",
"string",
"===",
"\"<\"",
")",
"{",
"// Returns tagInfo when an angle bracket is created.",
"return",
"_createTagInfo",
"(",
"ctx",
".",
"token",
",",
"TOKEN_TAG",
")",
";",
"}",
"else",
"if",
"(",
"ctx",
".",
"token",
"&&",
"ctx",
".",
"token",
".",
"type",
"===",
"\"tag\"",
")",
"{",
"// Return tagInfo when a tag is created.",
"if",
"(",
"TokenUtils",
".",
"movePrevToken",
"(",
"ctx",
")",
")",
"{",
"if",
"(",
"ctx",
".",
"token",
".",
"type",
"===",
"\"tag bracket\"",
"&&",
"ctx",
".",
"token",
".",
"string",
"===",
"\"<\"",
")",
"{",
"TokenUtils",
".",
"moveNextToken",
"(",
"ctx",
")",
";",
"return",
"_createTagInfo",
"(",
"ctx",
".",
"token",
",",
"TOKEN_TAG",
",",
"offset",
")",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"ctx",
".",
"token",
"&&",
"(",
"ctx",
".",
"token",
".",
"type",
"===",
"\"attribute\"",
"||",
"(",
"ctx",
".",
"token",
".",
"type",
"===",
"null",
"&&",
"regexWhitespace",
".",
"test",
"(",
"ctx",
".",
"token",
".",
"string",
")",
")",
")",
")",
"{",
"// Return tagInfo when an attribute is created.",
"tagAttrs",
"=",
"_getTagAttributes",
"(",
"editor",
",",
"pos",
")",
";",
"if",
"(",
"tagAttrs",
"&&",
"tagAttrs",
".",
"tagName",
")",
"{",
"return",
"_createTagInfo",
"(",
"ctx",
".",
"token",
",",
"TOKEN_ATTR",
",",
"offset",
",",
"tagAttrs",
".",
"exclusionList",
",",
"tagAttrs",
".",
"tagName",
",",
"null",
",",
"tagAttrs",
".",
"shouldReplace",
")",
";",
"}",
"}",
"else",
"if",
"(",
"ctx",
".",
"token",
"&&",
"(",
"(",
"ctx",
".",
"token",
".",
"type",
"===",
"null",
"&&",
"ctx",
".",
"token",
".",
"string",
"===",
"\"=\"",
")",
"||",
"(",
"ctx",
".",
"token",
".",
"type",
"===",
"\"string\"",
"&&",
"/",
"^['\"]$",
"/",
".",
"test",
"(",
"ctx",
".",
"token",
".",
"string",
".",
"charAt",
"(",
"0",
")",
")",
")",
")",
")",
"{",
"// Return tag info when an attribute value is created.",
"// Allow no hints if the cursor is outside the value.",
"if",
"(",
"ctx",
".",
"token",
".",
"type",
"===",
"\"string\"",
"&&",
"/",
"^['\"]$",
"/",
".",
"test",
"(",
"ctx",
".",
"token",
".",
"string",
".",
"substr",
"(",
"-",
"1",
",",
"1",
")",
")",
"&&",
"ctx",
".",
"token",
".",
"string",
".",
"length",
"!==",
"1",
"&&",
"ctx",
".",
"token",
".",
"end",
"===",
"pos",
".",
"ch",
")",
"{",
"return",
"_createTagInfo",
"(",
")",
";",
"}",
"tagAttrValue",
"=",
"_getTagAttributeValue",
"(",
"editor",
",",
"pos",
")",
";",
"if",
"(",
"tagAttrValue",
"&&",
"tagAttrValue",
".",
"tagName",
"&&",
"tagAttrValue",
".",
"attrName",
")",
"{",
"return",
"_createTagInfo",
"(",
"ctx",
".",
"token",
",",
"TOKEN_VALUE",
",",
"offset",
",",
"tagAttrValue",
".",
"exclusionList",
",",
"tagAttrValue",
".",
"tagName",
",",
"tagAttrValue",
".",
"attrName",
")",
";",
"}",
"}",
"return",
"_createTagInfo",
"(",
")",
";",
"}"
] | Return the tag info at a given position in the active editor
@param {!Editor} editor Instance of active editor
@param {!{line: number, ch: number}} pos Position of cursor in the editor
@return {!{token: Object, tokenType: number, offset: number, exclusionList: Array.<string>, tagName: string, attrName: string, shouldReplace: boolean}} | [
"Return",
"the",
"tag",
"info",
"at",
"a",
"given",
"position",
"in",
"the",
"active",
"editor"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/XMLUtils.js#L229-L270 |
1,998 | adobe/brackets | src/language/XMLUtils.js | getValueQuery | function getValueQuery(tagInfo) {
var query;
if (tagInfo.token.string === "=") {
return "";
}
// Remove quotation marks in query.
query = tagInfo.token.string.substr(1, tagInfo.offset - 1);
// Get the last option to use as a query to support multiple options.
return query.split(/\s+/).slice(-1)[0];
} | javascript | function getValueQuery(tagInfo) {
var query;
if (tagInfo.token.string === "=") {
return "";
}
// Remove quotation marks in query.
query = tagInfo.token.string.substr(1, tagInfo.offset - 1);
// Get the last option to use as a query to support multiple options.
return query.split(/\s+/).slice(-1)[0];
} | [
"function",
"getValueQuery",
"(",
"tagInfo",
")",
"{",
"var",
"query",
";",
"if",
"(",
"tagInfo",
".",
"token",
".",
"string",
"===",
"\"=\"",
")",
"{",
"return",
"\"\"",
";",
"}",
"// Remove quotation marks in query.",
"query",
"=",
"tagInfo",
".",
"token",
".",
"string",
".",
"substr",
"(",
"1",
",",
"tagInfo",
".",
"offset",
"-",
"1",
")",
";",
"// Get the last option to use as a query to support multiple options.",
"return",
"query",
".",
"split",
"(",
"/",
"\\s+",
"/",
")",
".",
"slice",
"(",
"-",
"1",
")",
"[",
"0",
"]",
";",
"}"
] | Return the query text of a value.
@param {!{token: Object, tokenType: number, offset: number, exclusionList: Array.<string>, tagName: string, attrName: string, shouldReplace: boolean}}
@return {string} The query to use to matching hints. | [
"Return",
"the",
"query",
"text",
"of",
"a",
"value",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/XMLUtils.js#L278-L288 |
1,999 | adobe/brackets | src/utils/ExtensionUtils.js | isAbsolutePathOrUrl | function isAbsolutePathOrUrl(pathOrUrl) {
return brackets.platform === "win" ? PathUtils.isAbsoluteUrl(pathOrUrl) : FileSystem.isAbsolutePath(pathOrUrl);
} | javascript | function isAbsolutePathOrUrl(pathOrUrl) {
return brackets.platform === "win" ? PathUtils.isAbsoluteUrl(pathOrUrl) : FileSystem.isAbsolutePath(pathOrUrl);
} | [
"function",
"isAbsolutePathOrUrl",
"(",
"pathOrUrl",
")",
"{",
"return",
"brackets",
".",
"platform",
"===",
"\"win\"",
"?",
"PathUtils",
".",
"isAbsoluteUrl",
"(",
"pathOrUrl",
")",
":",
"FileSystem",
".",
"isAbsolutePath",
"(",
"pathOrUrl",
")",
";",
"}"
] | getModuleUrl returns different urls for win platform
so that's why we need a different check here
@see #getModuleUrl
@param {!string} pathOrUrl that should be checked if it's absolute
@return {!boolean} returns true if pathOrUrl is absolute url on win platform
or when it's absolute path on other platforms | [
"getModuleUrl",
"returns",
"different",
"urls",
"for",
"win",
"platform",
"so",
"that",
"s",
"why",
"we",
"need",
"a",
"different",
"check",
"here"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ExtensionUtils.js#L81-L83 |
Subsets and Splits