id
int32 0
58k
| repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
sequence | docstring
stringlengths 4
11.8k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 86
226
|
---|---|---|---|---|---|---|---|---|---|---|---|
2,200 | adobe/brackets | src/extensibility/node/ExtensionManagerDomain.js | _cmdDownloadFile | function _cmdDownloadFile(downloadId, url, proxy, callback, pCallback) {
// Backwards compatibility check, added in 0.37
if (typeof proxy === "function") {
callback = proxy;
proxy = undefined;
}
if (pendingDownloads[downloadId]) {
callback(Errors.DOWNLOAD_ID_IN_USE, null);
return;
}
var req = request.get({
url: url,
encoding: null,
proxy: proxy
},
// Note: we could use the traditional "response"/"data"/"end" events too if we wanted to stream data
// incrementally, limit download size, etc. - but the simple callback is good enough for our needs.
function (error, response, body) {
if (error) {
// Usually means we never got a response - server is down, no DNS entry, etc.
_endDownload(downloadId, Errors.NO_SERVER_RESPONSE);
return;
}
if (response.statusCode !== 200) {
_endDownload(downloadId, [Errors.BAD_HTTP_STATUS, response.statusCode]);
return;
}
var stream = temp.createWriteStream("brackets");
if (!stream) {
_endDownload(downloadId, Errors.CANNOT_WRITE_TEMP);
return;
}
pendingDownloads[downloadId].localPath = stream.path;
pendingDownloads[downloadId].outStream = stream;
stream.write(body);
_endDownload(downloadId);
});
pendingDownloads[downloadId] = { request: req, callback: callback };
} | javascript | function _cmdDownloadFile(downloadId, url, proxy, callback, pCallback) {
// Backwards compatibility check, added in 0.37
if (typeof proxy === "function") {
callback = proxy;
proxy = undefined;
}
if (pendingDownloads[downloadId]) {
callback(Errors.DOWNLOAD_ID_IN_USE, null);
return;
}
var req = request.get({
url: url,
encoding: null,
proxy: proxy
},
// Note: we could use the traditional "response"/"data"/"end" events too if we wanted to stream data
// incrementally, limit download size, etc. - but the simple callback is good enough for our needs.
function (error, response, body) {
if (error) {
// Usually means we never got a response - server is down, no DNS entry, etc.
_endDownload(downloadId, Errors.NO_SERVER_RESPONSE);
return;
}
if (response.statusCode !== 200) {
_endDownload(downloadId, [Errors.BAD_HTTP_STATUS, response.statusCode]);
return;
}
var stream = temp.createWriteStream("brackets");
if (!stream) {
_endDownload(downloadId, Errors.CANNOT_WRITE_TEMP);
return;
}
pendingDownloads[downloadId].localPath = stream.path;
pendingDownloads[downloadId].outStream = stream;
stream.write(body);
_endDownload(downloadId);
});
pendingDownloads[downloadId] = { request: req, callback: callback };
} | [
"function",
"_cmdDownloadFile",
"(",
"downloadId",
",",
"url",
",",
"proxy",
",",
"callback",
",",
"pCallback",
")",
"{",
"// Backwards compatibility check, added in 0.37",
"if",
"(",
"typeof",
"proxy",
"===",
"\"function\"",
")",
"{",
"callback",
"=",
"proxy",
";",
"proxy",
"=",
"undefined",
";",
"}",
"if",
"(",
"pendingDownloads",
"[",
"downloadId",
"]",
")",
"{",
"callback",
"(",
"Errors",
".",
"DOWNLOAD_ID_IN_USE",
",",
"null",
")",
";",
"return",
";",
"}",
"var",
"req",
"=",
"request",
".",
"get",
"(",
"{",
"url",
":",
"url",
",",
"encoding",
":",
"null",
",",
"proxy",
":",
"proxy",
"}",
",",
"// Note: we could use the traditional \"response\"/\"data\"/\"end\" events too if we wanted to stream data",
"// incrementally, limit download size, etc. - but the simple callback is good enough for our needs.",
"function",
"(",
"error",
",",
"response",
",",
"body",
")",
"{",
"if",
"(",
"error",
")",
"{",
"// Usually means we never got a response - server is down, no DNS entry, etc.",
"_endDownload",
"(",
"downloadId",
",",
"Errors",
".",
"NO_SERVER_RESPONSE",
")",
";",
"return",
";",
"}",
"if",
"(",
"response",
".",
"statusCode",
"!==",
"200",
")",
"{",
"_endDownload",
"(",
"downloadId",
",",
"[",
"Errors",
".",
"BAD_HTTP_STATUS",
",",
"response",
".",
"statusCode",
"]",
")",
";",
"return",
";",
"}",
"var",
"stream",
"=",
"temp",
".",
"createWriteStream",
"(",
"\"brackets\"",
")",
";",
"if",
"(",
"!",
"stream",
")",
"{",
"_endDownload",
"(",
"downloadId",
",",
"Errors",
".",
"CANNOT_WRITE_TEMP",
")",
";",
"return",
";",
"}",
"pendingDownloads",
"[",
"downloadId",
"]",
".",
"localPath",
"=",
"stream",
".",
"path",
";",
"pendingDownloads",
"[",
"downloadId",
"]",
".",
"outStream",
"=",
"stream",
";",
"stream",
".",
"write",
"(",
"body",
")",
";",
"_endDownload",
"(",
"downloadId",
")",
";",
"}",
")",
";",
"pendingDownloads",
"[",
"downloadId",
"]",
"=",
"{",
"request",
":",
"req",
",",
"callback",
":",
"callback",
"}",
";",
"}"
] | Implements "downloadFile" command, asynchronously. | [
"Implements",
"downloadFile",
"command",
"asynchronously",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/node/ExtensionManagerDomain.js#L386-L429 |
2,201 | adobe/brackets | src/extensibility/node/ExtensionManagerDomain.js | _cmdAbortDownload | function _cmdAbortDownload(downloadId) {
if (!pendingDownloads[downloadId]) {
// This may mean the download already completed
return false;
} else {
_endDownload(downloadId, Errors.CANCELED);
return true;
}
} | javascript | function _cmdAbortDownload(downloadId) {
if (!pendingDownloads[downloadId]) {
// This may mean the download already completed
return false;
} else {
_endDownload(downloadId, Errors.CANCELED);
return true;
}
} | [
"function",
"_cmdAbortDownload",
"(",
"downloadId",
")",
"{",
"if",
"(",
"!",
"pendingDownloads",
"[",
"downloadId",
"]",
")",
"{",
"// This may mean the download already completed",
"return",
"false",
";",
"}",
"else",
"{",
"_endDownload",
"(",
"downloadId",
",",
"Errors",
".",
"CANCELED",
")",
";",
"return",
"true",
";",
"}",
"}"
] | Implements "abortDownload" command, synchronously. | [
"Implements",
"abortDownload",
"command",
"synchronously",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/node/ExtensionManagerDomain.js#L434-L442 |
2,202 | adobe/brackets | src/extensibility/node/ExtensionManagerDomain.js | _cmdRemove | function _cmdRemove(extensionDir, callback, pCallback) {
fs.remove(extensionDir, function (err) {
if (err) {
callback(err);
} else {
callback(null);
}
});
} | javascript | function _cmdRemove(extensionDir, callback, pCallback) {
fs.remove(extensionDir, function (err) {
if (err) {
callback(err);
} else {
callback(null);
}
});
} | [
"function",
"_cmdRemove",
"(",
"extensionDir",
",",
"callback",
",",
"pCallback",
")",
"{",
"fs",
".",
"remove",
"(",
"extensionDir",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"null",
")",
";",
"}",
"}",
")",
";",
"}"
] | Implements the remove extension command. | [
"Implements",
"the",
"remove",
"extension",
"command",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/node/ExtensionManagerDomain.js#L447-L455 |
2,203 | adobe/brackets | src/filesystem/FileSystem.js | registerProtocolAdapter | function registerProtocolAdapter(protocol, adapter) {
var adapters;
if (protocol) {
adapters = _fileProtocolPlugins[protocol] || [];
adapters.push(adapter);
// We will keep a sorted adapter list on 'priority'
// If priority is not provided a default of '0' is assumed
adapters.sort(function (a, b) {
return (b.priority || 0) - (a.priority || 0);
});
_fileProtocolPlugins[protocol] = adapters;
}
} | javascript | function registerProtocolAdapter(protocol, adapter) {
var adapters;
if (protocol) {
adapters = _fileProtocolPlugins[protocol] || [];
adapters.push(adapter);
// We will keep a sorted adapter list on 'priority'
// If priority is not provided a default of '0' is assumed
adapters.sort(function (a, b) {
return (b.priority || 0) - (a.priority || 0);
});
_fileProtocolPlugins[protocol] = adapters;
}
} | [
"function",
"registerProtocolAdapter",
"(",
"protocol",
",",
"adapter",
")",
"{",
"var",
"adapters",
";",
"if",
"(",
"protocol",
")",
"{",
"adapters",
"=",
"_fileProtocolPlugins",
"[",
"protocol",
"]",
"||",
"[",
"]",
";",
"adapters",
".",
"push",
"(",
"adapter",
")",
";",
"// We will keep a sorted adapter list on 'priority'",
"// If priority is not provided a default of '0' is assumed",
"adapters",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"return",
"(",
"b",
".",
"priority",
"||",
"0",
")",
"-",
"(",
"a",
".",
"priority",
"||",
"0",
")",
";",
"}",
")",
";",
"_fileProtocolPlugins",
"[",
"protocol",
"]",
"=",
"adapters",
";",
"}",
"}"
] | Typical signature of a file protocol adapter.
@typedef {Object} FileProtocol~Adapter
@property {Number} priority - Indicates the priority.
@property {Object} fileImpl - Handle for the custom file implementation prototype.
@property {function} canRead - To check if this impl can read a file for a given path.
FileSystem hook to register file protocol adapter
@param {string} protocol ex: "https:"|"http:"|"ftp:"|"file:"
@param {...FileProtocol~Adapter} adapter wrapper over file implementation | [
"Typical",
"signature",
"of",
"a",
"file",
"protocol",
"adapter",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/filesystem/FileSystem.js#L118-L132 |
2,204 | adobe/brackets | src/extensibility/ExtensionManager.js | downloadRegistry | function downloadRegistry() {
if (pendingDownloadRegistry) {
return pendingDownloadRegistry.promise();
}
pendingDownloadRegistry = new $.Deferred();
$.ajax({
url: brackets.config.extension_registry,
dataType: "json",
cache: false
})
.done(function (data) {
exports.hasDownloadedRegistry = true;
Object.keys(data).forEach(function (id) {
if (!extensions[id]) {
extensions[id] = {};
}
extensions[id].registryInfo = data[id];
synchronizeEntry(id);
});
exports.trigger("registryDownload");
pendingDownloadRegistry.resolve();
})
.fail(function () {
pendingDownloadRegistry.reject();
})
.always(function () {
// Make sure to clean up the pending registry so that new requests can be made.
pendingDownloadRegistry = null;
});
return pendingDownloadRegistry.promise();
} | javascript | function downloadRegistry() {
if (pendingDownloadRegistry) {
return pendingDownloadRegistry.promise();
}
pendingDownloadRegistry = new $.Deferred();
$.ajax({
url: brackets.config.extension_registry,
dataType: "json",
cache: false
})
.done(function (data) {
exports.hasDownloadedRegistry = true;
Object.keys(data).forEach(function (id) {
if (!extensions[id]) {
extensions[id] = {};
}
extensions[id].registryInfo = data[id];
synchronizeEntry(id);
});
exports.trigger("registryDownload");
pendingDownloadRegistry.resolve();
})
.fail(function () {
pendingDownloadRegistry.reject();
})
.always(function () {
// Make sure to clean up the pending registry so that new requests can be made.
pendingDownloadRegistry = null;
});
return pendingDownloadRegistry.promise();
} | [
"function",
"downloadRegistry",
"(",
")",
"{",
"if",
"(",
"pendingDownloadRegistry",
")",
"{",
"return",
"pendingDownloadRegistry",
".",
"promise",
"(",
")",
";",
"}",
"pendingDownloadRegistry",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"$",
".",
"ajax",
"(",
"{",
"url",
":",
"brackets",
".",
"config",
".",
"extension_registry",
",",
"dataType",
":",
"\"json\"",
",",
"cache",
":",
"false",
"}",
")",
".",
"done",
"(",
"function",
"(",
"data",
")",
"{",
"exports",
".",
"hasDownloadedRegistry",
"=",
"true",
";",
"Object",
".",
"keys",
"(",
"data",
")",
".",
"forEach",
"(",
"function",
"(",
"id",
")",
"{",
"if",
"(",
"!",
"extensions",
"[",
"id",
"]",
")",
"{",
"extensions",
"[",
"id",
"]",
"=",
"{",
"}",
";",
"}",
"extensions",
"[",
"id",
"]",
".",
"registryInfo",
"=",
"data",
"[",
"id",
"]",
";",
"synchronizeEntry",
"(",
"id",
")",
";",
"}",
")",
";",
"exports",
".",
"trigger",
"(",
"\"registryDownload\"",
")",
";",
"pendingDownloadRegistry",
".",
"resolve",
"(",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"pendingDownloadRegistry",
".",
"reject",
"(",
")",
";",
"}",
")",
".",
"always",
"(",
"function",
"(",
")",
"{",
"// Make sure to clean up the pending registry so that new requests can be made.",
"pendingDownloadRegistry",
"=",
"null",
";",
"}",
")",
";",
"return",
"pendingDownloadRegistry",
".",
"promise",
"(",
")",
";",
"}"
] | Downloads the registry of Brackets extensions and stores the information in our
extension info.
@return {$.Promise} a promise that's resolved with the registry JSON data
or rejected if the server can't be reached. | [
"Downloads",
"the",
"registry",
"of",
"Brackets",
"extensions",
"and",
"stores",
"the",
"information",
"in",
"our",
"extension",
"info",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManager.js#L205-L238 |
2,205 | adobe/brackets | src/extensibility/ExtensionManager.js | getCompatibilityInfo | function getCompatibilityInfo(entry, apiVersion) {
if (!entry.versions) {
var fallback = getCompatibilityInfoForVersion(entry.metadata, apiVersion);
if (fallback.isCompatible) {
fallback.isLatestVersion = true;
}
return fallback;
}
var i = entry.versions.length - 1,
latestInfo = getCompatibilityInfoForVersion(entry.versions[i], apiVersion);
if (latestInfo.isCompatible) {
latestInfo.isLatestVersion = true;
return latestInfo;
} else {
// Look at earlier versions (skipping very latest version since we already checked it)
for (i--; i >= 0; i--) {
var compatInfo = getCompatibilityInfoForVersion(entry.versions[i], apiVersion);
if (compatInfo.isCompatible) {
compatInfo.isLatestVersion = false;
compatInfo.requiresNewer = latestInfo.requiresNewer;
return compatInfo;
}
}
// No version is compatible, so just return info for the latest version
return latestInfo;
}
} | javascript | function getCompatibilityInfo(entry, apiVersion) {
if (!entry.versions) {
var fallback = getCompatibilityInfoForVersion(entry.metadata, apiVersion);
if (fallback.isCompatible) {
fallback.isLatestVersion = true;
}
return fallback;
}
var i = entry.versions.length - 1,
latestInfo = getCompatibilityInfoForVersion(entry.versions[i], apiVersion);
if (latestInfo.isCompatible) {
latestInfo.isLatestVersion = true;
return latestInfo;
} else {
// Look at earlier versions (skipping very latest version since we already checked it)
for (i--; i >= 0; i--) {
var compatInfo = getCompatibilityInfoForVersion(entry.versions[i], apiVersion);
if (compatInfo.isCompatible) {
compatInfo.isLatestVersion = false;
compatInfo.requiresNewer = latestInfo.requiresNewer;
return compatInfo;
}
}
// No version is compatible, so just return info for the latest version
return latestInfo;
}
} | [
"function",
"getCompatibilityInfo",
"(",
"entry",
",",
"apiVersion",
")",
"{",
"if",
"(",
"!",
"entry",
".",
"versions",
")",
"{",
"var",
"fallback",
"=",
"getCompatibilityInfoForVersion",
"(",
"entry",
".",
"metadata",
",",
"apiVersion",
")",
";",
"if",
"(",
"fallback",
".",
"isCompatible",
")",
"{",
"fallback",
".",
"isLatestVersion",
"=",
"true",
";",
"}",
"return",
"fallback",
";",
"}",
"var",
"i",
"=",
"entry",
".",
"versions",
".",
"length",
"-",
"1",
",",
"latestInfo",
"=",
"getCompatibilityInfoForVersion",
"(",
"entry",
".",
"versions",
"[",
"i",
"]",
",",
"apiVersion",
")",
";",
"if",
"(",
"latestInfo",
".",
"isCompatible",
")",
"{",
"latestInfo",
".",
"isLatestVersion",
"=",
"true",
";",
"return",
"latestInfo",
";",
"}",
"else",
"{",
"// Look at earlier versions (skipping very latest version since we already checked it)",
"for",
"(",
"i",
"--",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"var",
"compatInfo",
"=",
"getCompatibilityInfoForVersion",
"(",
"entry",
".",
"versions",
"[",
"i",
"]",
",",
"apiVersion",
")",
";",
"if",
"(",
"compatInfo",
".",
"isCompatible",
")",
"{",
"compatInfo",
".",
"isLatestVersion",
"=",
"false",
";",
"compatInfo",
".",
"requiresNewer",
"=",
"latestInfo",
".",
"requiresNewer",
";",
"return",
"compatInfo",
";",
"}",
"}",
"// No version is compatible, so just return info for the latest version",
"return",
"latestInfo",
";",
"}",
"}"
] | Finds the newest version of the entry that is compatible with the given Brackets API version, if any.
@param {Object} entry The registry entry to check.
@param {string} apiVersion The Brackets API version to check against.
@return {{isCompatible: boolean, requiresNewer: ?boolean, compatibleVersion: ?string, isLatestVersion: boolean}}
Result contains an "isCompatible" member saying whether it's compatible. If compatible, "compatibleVersion"
specifies the newest version that is compatible and "isLatestVersion" indicates if this is the absolute
latest version of the extension or not. If !isCompatible or !isLatestVersion, "requiresNewer" says whether
the latest version is incompatible due to requiring a newer (vs. older) version of Brackets. | [
"Finds",
"the",
"newest",
"version",
"of",
"the",
"entry",
"that",
"is",
"compatible",
"with",
"the",
"given",
"Brackets",
"API",
"version",
"if",
"any",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManager.js#L348-L377 |
2,206 | adobe/brackets | src/extensibility/ExtensionManager.js | getExtensionURL | function getExtensionURL(id, version) {
return StringUtils.format(brackets.config.extension_url, id, version);
} | javascript | function getExtensionURL(id, version) {
return StringUtils.format(brackets.config.extension_url, id, version);
} | [
"function",
"getExtensionURL",
"(",
"id",
",",
"version",
")",
"{",
"return",
"StringUtils",
".",
"format",
"(",
"brackets",
".",
"config",
".",
"extension_url",
",",
"id",
",",
"version",
")",
";",
"}"
] | Given an extension id and version number, returns the URL for downloading that extension from
the repository. Does not guarantee that the extension exists at that URL.
@param {string} id The extension's name from the metadata.
@param {string} version The version to download.
@return {string} The URL to download the extension from. | [
"Given",
"an",
"extension",
"id",
"and",
"version",
"number",
"returns",
"the",
"URL",
"for",
"downloading",
"that",
"extension",
"from",
"the",
"repository",
".",
"Does",
"not",
"guarantee",
"that",
"the",
"extension",
"exists",
"at",
"that",
"URL",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManager.js#L386-L388 |
2,207 | adobe/brackets | src/extensibility/ExtensionManager.js | remove | function remove(id) {
var result = new $.Deferred();
if (extensions[id] && extensions[id].installInfo) {
Package.remove(extensions[id].installInfo.path)
.done(function () {
extensions[id].installInfo = null;
result.resolve();
exports.trigger("statusChange", id);
})
.fail(function (err) {
result.reject(err);
});
} else {
result.reject(StringUtils.format(Strings.EXTENSION_NOT_INSTALLED, id));
}
return result.promise();
} | javascript | function remove(id) {
var result = new $.Deferred();
if (extensions[id] && extensions[id].installInfo) {
Package.remove(extensions[id].installInfo.path)
.done(function () {
extensions[id].installInfo = null;
result.resolve();
exports.trigger("statusChange", id);
})
.fail(function (err) {
result.reject(err);
});
} else {
result.reject(StringUtils.format(Strings.EXTENSION_NOT_INSTALLED, id));
}
return result.promise();
} | [
"function",
"remove",
"(",
"id",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"if",
"(",
"extensions",
"[",
"id",
"]",
"&&",
"extensions",
"[",
"id",
"]",
".",
"installInfo",
")",
"{",
"Package",
".",
"remove",
"(",
"extensions",
"[",
"id",
"]",
".",
"installInfo",
".",
"path",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"extensions",
"[",
"id",
"]",
".",
"installInfo",
"=",
"null",
";",
"result",
".",
"resolve",
"(",
")",
";",
"exports",
".",
"trigger",
"(",
"\"statusChange\"",
",",
"id",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"err",
")",
"{",
"result",
".",
"reject",
"(",
"err",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"result",
".",
"reject",
"(",
"StringUtils",
".",
"format",
"(",
"Strings",
".",
"EXTENSION_NOT_INSTALLED",
",",
"id",
")",
")",
";",
"}",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] | Removes the installed extension with the given id.
@param {string} id The id of the extension to remove.
@return {$.Promise} A promise that's resolved when the extension is removed or
rejected with an error if there's a problem with the removal. | [
"Removes",
"the",
"installed",
"extension",
"with",
"the",
"given",
"id",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManager.js#L396-L412 |
2,208 | adobe/brackets | src/extensibility/ExtensionManager.js | update | function update(id, packagePath, keepFile) {
return Package.installUpdate(packagePath, id).done(function () {
if (!keepFile) {
FileSystem.getFileForPath(packagePath).unlink();
}
});
} | javascript | function update(id, packagePath, keepFile) {
return Package.installUpdate(packagePath, id).done(function () {
if (!keepFile) {
FileSystem.getFileForPath(packagePath).unlink();
}
});
} | [
"function",
"update",
"(",
"id",
",",
"packagePath",
",",
"keepFile",
")",
"{",
"return",
"Package",
".",
"installUpdate",
"(",
"packagePath",
",",
"id",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"keepFile",
")",
"{",
"FileSystem",
".",
"getFileForPath",
"(",
"packagePath",
")",
".",
"unlink",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Updates an installed extension with the given package file.
@param {string} id of the extension
@param {string} packagePath path to the package file
@param {boolean=} keepFile Flag to keep extension package file, default=false
@return {$.Promise} A promise that's resolved when the extension is updated or
rejected with an error if there's a problem with the update. | [
"Updates",
"an",
"installed",
"extension",
"with",
"the",
"given",
"package",
"file",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManager.js#L474-L480 |
2,209 | adobe/brackets | src/extensibility/ExtensionManager.js | cleanupUpdates | function cleanupUpdates() {
Object.keys(_idsToUpdate).forEach(function (id) {
var installResult = _idsToUpdate[id],
keepFile = installResult.keepFile,
filename = installResult.localPath;
if (filename && !keepFile) {
FileSystem.getFileForPath(filename).unlink();
}
});
_idsToUpdate = {};
} | javascript | function cleanupUpdates() {
Object.keys(_idsToUpdate).forEach(function (id) {
var installResult = _idsToUpdate[id],
keepFile = installResult.keepFile,
filename = installResult.localPath;
if (filename && !keepFile) {
FileSystem.getFileForPath(filename).unlink();
}
});
_idsToUpdate = {};
} | [
"function",
"cleanupUpdates",
"(",
")",
"{",
"Object",
".",
"keys",
"(",
"_idsToUpdate",
")",
".",
"forEach",
"(",
"function",
"(",
"id",
")",
"{",
"var",
"installResult",
"=",
"_idsToUpdate",
"[",
"id",
"]",
",",
"keepFile",
"=",
"installResult",
".",
"keepFile",
",",
"filename",
"=",
"installResult",
".",
"localPath",
";",
"if",
"(",
"filename",
"&&",
"!",
"keepFile",
")",
"{",
"FileSystem",
".",
"getFileForPath",
"(",
"filename",
")",
".",
"unlink",
"(",
")",
";",
"}",
"}",
")",
";",
"_idsToUpdate",
"=",
"{",
"}",
";",
"}"
] | Deletes any temporary files left behind by extensions that
were marked for update. | [
"Deletes",
"any",
"temporary",
"files",
"left",
"behind",
"by",
"extensions",
"that",
"were",
"marked",
"for",
"update",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManager.js#L486-L497 |
2,210 | adobe/brackets | src/extensibility/ExtensionManager.js | markForRemoval | function markForRemoval(id, mark) {
if (mark) {
_idsToRemove[id] = true;
} else {
delete _idsToRemove[id];
}
exports.trigger("statusChange", id);
} | javascript | function markForRemoval(id, mark) {
if (mark) {
_idsToRemove[id] = true;
} else {
delete _idsToRemove[id];
}
exports.trigger("statusChange", id);
} | [
"function",
"markForRemoval",
"(",
"id",
",",
"mark",
")",
"{",
"if",
"(",
"mark",
")",
"{",
"_idsToRemove",
"[",
"id",
"]",
"=",
"true",
";",
"}",
"else",
"{",
"delete",
"_idsToRemove",
"[",
"id",
"]",
";",
"}",
"exports",
".",
"trigger",
"(",
"\"statusChange\"",
",",
"id",
")",
";",
"}"
] | Marks an extension for later removal, or unmarks an extension previously marked.
@param {string} id The id of the extension to mark for removal.
@param {boolean} mark Whether to mark or unmark it. | [
"Marks",
"an",
"extension",
"for",
"later",
"removal",
"or",
"unmarks",
"an",
"extension",
"previously",
"marked",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManager.js#L511-L518 |
2,211 | adobe/brackets | src/extensibility/ExtensionManager.js | markForDisabling | function markForDisabling(id, mark) {
if (mark) {
_idsToDisable[id] = true;
} else {
delete _idsToDisable[id];
}
exports.trigger("statusChange", id);
} | javascript | function markForDisabling(id, mark) {
if (mark) {
_idsToDisable[id] = true;
} else {
delete _idsToDisable[id];
}
exports.trigger("statusChange", id);
} | [
"function",
"markForDisabling",
"(",
"id",
",",
"mark",
")",
"{",
"if",
"(",
"mark",
")",
"{",
"_idsToDisable",
"[",
"id",
"]",
"=",
"true",
";",
"}",
"else",
"{",
"delete",
"_idsToDisable",
"[",
"id",
"]",
";",
"}",
"exports",
".",
"trigger",
"(",
"\"statusChange\"",
",",
"id",
")",
";",
"}"
] | Marks an extension for disabling later, or unmarks an extension previously marked.
@param {string} id The id of the extension
@param {boolean} mark Whether to mark or unmark the extension. | [
"Marks",
"an",
"extension",
"for",
"disabling",
"later",
"or",
"unmarks",
"an",
"extension",
"previously",
"marked",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManager.js#L543-L550 |
2,212 | adobe/brackets | src/extensibility/ExtensionManager.js | updateFromDownload | function updateFromDownload(installationResult) {
if (installationResult.keepFile === undefined) {
installationResult.keepFile = false;
}
var installationStatus = installationResult.installationStatus;
if (installationStatus === Package.InstallationStatuses.ALREADY_INSTALLED ||
installationStatus === Package.InstallationStatuses.NEEDS_UPDATE ||
installationStatus === Package.InstallationStatuses.SAME_VERSION ||
installationStatus === Package.InstallationStatuses.OLDER_VERSION) {
var id = installationResult.name;
delete _idsToRemove[id];
_idsToUpdate[id] = installationResult;
exports.trigger("statusChange", id);
}
} | javascript | function updateFromDownload(installationResult) {
if (installationResult.keepFile === undefined) {
installationResult.keepFile = false;
}
var installationStatus = installationResult.installationStatus;
if (installationStatus === Package.InstallationStatuses.ALREADY_INSTALLED ||
installationStatus === Package.InstallationStatuses.NEEDS_UPDATE ||
installationStatus === Package.InstallationStatuses.SAME_VERSION ||
installationStatus === Package.InstallationStatuses.OLDER_VERSION) {
var id = installationResult.name;
delete _idsToRemove[id];
_idsToUpdate[id] = installationResult;
exports.trigger("statusChange", id);
}
} | [
"function",
"updateFromDownload",
"(",
"installationResult",
")",
"{",
"if",
"(",
"installationResult",
".",
"keepFile",
"===",
"undefined",
")",
"{",
"installationResult",
".",
"keepFile",
"=",
"false",
";",
"}",
"var",
"installationStatus",
"=",
"installationResult",
".",
"installationStatus",
";",
"if",
"(",
"installationStatus",
"===",
"Package",
".",
"InstallationStatuses",
".",
"ALREADY_INSTALLED",
"||",
"installationStatus",
"===",
"Package",
".",
"InstallationStatuses",
".",
"NEEDS_UPDATE",
"||",
"installationStatus",
"===",
"Package",
".",
"InstallationStatuses",
".",
"SAME_VERSION",
"||",
"installationStatus",
"===",
"Package",
".",
"InstallationStatuses",
".",
"OLDER_VERSION",
")",
"{",
"var",
"id",
"=",
"installationResult",
".",
"name",
";",
"delete",
"_idsToRemove",
"[",
"id",
"]",
";",
"_idsToUpdate",
"[",
"id",
"]",
"=",
"installationResult",
";",
"exports",
".",
"trigger",
"(",
"\"statusChange\"",
",",
"id",
")",
";",
"}",
"}"
] | If a downloaded package appears to be an update, mark the extension for update.
If an extension was previously marked for removal, marking for update will
turn off the removal mark.
@param {Object} installationResult info about the install provided by the Package.download function | [
"If",
"a",
"downloaded",
"package",
"appears",
"to",
"be",
"an",
"update",
"mark",
"the",
"extension",
"for",
"update",
".",
"If",
"an",
"extension",
"was",
"previously",
"marked",
"for",
"removal",
"marking",
"for",
"update",
"will",
"turn",
"off",
"the",
"removal",
"mark",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManager.js#L583-L598 |
2,213 | adobe/brackets | src/extensibility/ExtensionManager.js | removeUpdate | function removeUpdate(id) {
var installationResult = _idsToUpdate[id];
if (!installationResult) {
return;
}
if (installationResult.localPath && !installationResult.keepFile) {
FileSystem.getFileForPath(installationResult.localPath).unlink();
}
delete _idsToUpdate[id];
exports.trigger("statusChange", id);
} | javascript | function removeUpdate(id) {
var installationResult = _idsToUpdate[id];
if (!installationResult) {
return;
}
if (installationResult.localPath && !installationResult.keepFile) {
FileSystem.getFileForPath(installationResult.localPath).unlink();
}
delete _idsToUpdate[id];
exports.trigger("statusChange", id);
} | [
"function",
"removeUpdate",
"(",
"id",
")",
"{",
"var",
"installationResult",
"=",
"_idsToUpdate",
"[",
"id",
"]",
";",
"if",
"(",
"!",
"installationResult",
")",
"{",
"return",
";",
"}",
"if",
"(",
"installationResult",
".",
"localPath",
"&&",
"!",
"installationResult",
".",
"keepFile",
")",
"{",
"FileSystem",
".",
"getFileForPath",
"(",
"installationResult",
".",
"localPath",
")",
".",
"unlink",
"(",
")",
";",
"}",
"delete",
"_idsToUpdate",
"[",
"id",
"]",
";",
"exports",
".",
"trigger",
"(",
"\"statusChange\"",
",",
"id",
")",
";",
"}"
] | Removes the mark for an extension to be updated on restart. Also deletes the
downloaded package file.
@param {string} id The id of the extension for which the update is being removed | [
"Removes",
"the",
"mark",
"for",
"an",
"extension",
"to",
"be",
"updated",
"on",
"restart",
".",
"Also",
"deletes",
"the",
"downloaded",
"package",
"file",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManager.js#L605-L615 |
2,214 | adobe/brackets | src/extensibility/ExtensionManager.js | updateExtensions | function updateExtensions() {
return Async.doInParallel_aggregateErrors(
Object.keys(_idsToUpdate),
function (id) {
var installationResult = _idsToUpdate[id];
return update(installationResult.name, installationResult.localPath, installationResult.keepFile);
}
);
} | javascript | function updateExtensions() {
return Async.doInParallel_aggregateErrors(
Object.keys(_idsToUpdate),
function (id) {
var installationResult = _idsToUpdate[id];
return update(installationResult.name, installationResult.localPath, installationResult.keepFile);
}
);
} | [
"function",
"updateExtensions",
"(",
")",
"{",
"return",
"Async",
".",
"doInParallel_aggregateErrors",
"(",
"Object",
".",
"keys",
"(",
"_idsToUpdate",
")",
",",
"function",
"(",
"id",
")",
"{",
"var",
"installationResult",
"=",
"_idsToUpdate",
"[",
"id",
"]",
";",
"return",
"update",
"(",
"installationResult",
".",
"name",
",",
"installationResult",
".",
"localPath",
",",
"installationResult",
".",
"keepFile",
")",
";",
"}",
")",
";",
"}"
] | Updates extensions previously marked for update.
@return {$.Promise} A promise that's resolved when all extensions are updated, or rejected
if one or more extensions can't be updated. When rejected, the argument will be an
array of error objects, each of which contains an "item" property with the id of the
failed extension and an "error" property with the actual error. | [
"Updates",
"extensions",
"previously",
"marked",
"for",
"update",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManager.js#L676-L684 |
2,215 | adobe/brackets | src/extensibility/ExtensionManager.js | getAvailableUpdates | function getAvailableUpdates() {
var result = [];
Object.keys(extensions).forEach(function (extensionId) {
var extensionInfo = extensions[extensionId];
// skip extensions that are not installed or are not in the registry
if (!extensionInfo.installInfo || !extensionInfo.registryInfo) {
return;
}
if (extensionInfo.registryInfo.updateCompatible) {
result.push({
id: extensionId,
installVersion: extensionInfo.installInfo.metadata.version,
registryVersion: extensionInfo.registryInfo.lastCompatibleVersion
});
}
});
return result;
} | javascript | function getAvailableUpdates() {
var result = [];
Object.keys(extensions).forEach(function (extensionId) {
var extensionInfo = extensions[extensionId];
// skip extensions that are not installed or are not in the registry
if (!extensionInfo.installInfo || !extensionInfo.registryInfo) {
return;
}
if (extensionInfo.registryInfo.updateCompatible) {
result.push({
id: extensionId,
installVersion: extensionInfo.installInfo.metadata.version,
registryVersion: extensionInfo.registryInfo.lastCompatibleVersion
});
}
});
return result;
} | [
"function",
"getAvailableUpdates",
"(",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"Object",
".",
"keys",
"(",
"extensions",
")",
".",
"forEach",
"(",
"function",
"(",
"extensionId",
")",
"{",
"var",
"extensionInfo",
"=",
"extensions",
"[",
"extensionId",
"]",
";",
"// skip extensions that are not installed or are not in the registry",
"if",
"(",
"!",
"extensionInfo",
".",
"installInfo",
"||",
"!",
"extensionInfo",
".",
"registryInfo",
")",
"{",
"return",
";",
"}",
"if",
"(",
"extensionInfo",
".",
"registryInfo",
".",
"updateCompatible",
")",
"{",
"result",
".",
"push",
"(",
"{",
"id",
":",
"extensionId",
",",
"installVersion",
":",
"extensionInfo",
".",
"installInfo",
".",
"metadata",
".",
"version",
",",
"registryVersion",
":",
"extensionInfo",
".",
"registryInfo",
".",
"lastCompatibleVersion",
"}",
")",
";",
"}",
"}",
")",
";",
"return",
"result",
";",
"}"
] | Gets an array of extensions that are currently installed and can be updated to a new version
@return {Array.<{id: string, installVersion: string, registryVersion: string}>}
where id = extensionId
installVersion = currently installed version of extension
registryVersion = latest version compatible with current Brackets | [
"Gets",
"an",
"array",
"of",
"extensions",
"that",
"are",
"currently",
"installed",
"and",
"can",
"be",
"updated",
"to",
"a",
"new",
"version"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManager.js#L693-L710 |
2,216 | adobe/brackets | src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js | extract | function extract(scopes, parentStatement, expns, text, insertPosition) {
var varType = "var",
varName = RefactoringUtils.getUniqueIdentifierName(scopes, "extracted"),
varDeclaration = varType + " " + varName + " = " + text + ";\n",
parentStatementStartPos = session.editor.posFromIndex(parentStatement.start),
insertStartPos = insertPosition || parentStatementStartPos,
selections = [],
doc = session.editor.document,
replaceExpnIndex = 0,
posToIndent,
edits = [];
// If parent statement is expression statement, then just append var declaration
// Ex: "add(1, 2)" will become "var extracted = add(1, 2)"
if (parentStatement.type === "ExpressionStatement" &&
RefactoringUtils.isEqual(parentStatement.expression, expns[0]) &&
insertStartPos.line === parentStatementStartPos.line &&
insertStartPos.ch === parentStatementStartPos.ch) {
varDeclaration = varType + " " + varName + " = ";
replaceExpnIndex = 1;
}
posToIndent = doc.adjustPosForChange(insertStartPos, varDeclaration.split("\n"), insertStartPos, insertStartPos);
// adjust pos for change
for (var i = replaceExpnIndex; i < expns.length; ++i) {
expns[i].start = session.editor.posFromIndex(expns[i].start);
expns[i].end = session.editor.posFromIndex(expns[i].end);
expns[i].start = doc.adjustPosForChange(expns[i].start, varDeclaration.split("\n"), insertStartPos, insertStartPos);
expns[i].end = doc.adjustPosForChange(expns[i].end, varDeclaration.split("\n"), insertStartPos, insertStartPos);
edits.push({
edit: {
text: varName,
start: expns[i].start,
end: expns[i].end
},
selection: {
start: expns[i].start,
end: {line: expns[i].start.line, ch: expns[i].start.ch + varName.length}
}
});
}
// Replace and multi-select
doc.batchOperation(function() {
doc.replaceRange(varDeclaration, insertStartPos);
selections = doc.doMultipleEdits(edits);
selections.push({
start: {line: insertStartPos.line, ch: insertStartPos.ch + varType.length + 1},
end: {line: insertStartPos.line, ch: insertStartPos.ch + varType.length + varName.length + 1},
primary: true
});
session.editor.setSelections(selections);
session.editor._codeMirror.indentLine(posToIndent.line, "smart");
});
} | javascript | function extract(scopes, parentStatement, expns, text, insertPosition) {
var varType = "var",
varName = RefactoringUtils.getUniqueIdentifierName(scopes, "extracted"),
varDeclaration = varType + " " + varName + " = " + text + ";\n",
parentStatementStartPos = session.editor.posFromIndex(parentStatement.start),
insertStartPos = insertPosition || parentStatementStartPos,
selections = [],
doc = session.editor.document,
replaceExpnIndex = 0,
posToIndent,
edits = [];
// If parent statement is expression statement, then just append var declaration
// Ex: "add(1, 2)" will become "var extracted = add(1, 2)"
if (parentStatement.type === "ExpressionStatement" &&
RefactoringUtils.isEqual(parentStatement.expression, expns[0]) &&
insertStartPos.line === parentStatementStartPos.line &&
insertStartPos.ch === parentStatementStartPos.ch) {
varDeclaration = varType + " " + varName + " = ";
replaceExpnIndex = 1;
}
posToIndent = doc.adjustPosForChange(insertStartPos, varDeclaration.split("\n"), insertStartPos, insertStartPos);
// adjust pos for change
for (var i = replaceExpnIndex; i < expns.length; ++i) {
expns[i].start = session.editor.posFromIndex(expns[i].start);
expns[i].end = session.editor.posFromIndex(expns[i].end);
expns[i].start = doc.adjustPosForChange(expns[i].start, varDeclaration.split("\n"), insertStartPos, insertStartPos);
expns[i].end = doc.adjustPosForChange(expns[i].end, varDeclaration.split("\n"), insertStartPos, insertStartPos);
edits.push({
edit: {
text: varName,
start: expns[i].start,
end: expns[i].end
},
selection: {
start: expns[i].start,
end: {line: expns[i].start.line, ch: expns[i].start.ch + varName.length}
}
});
}
// Replace and multi-select
doc.batchOperation(function() {
doc.replaceRange(varDeclaration, insertStartPos);
selections = doc.doMultipleEdits(edits);
selections.push({
start: {line: insertStartPos.line, ch: insertStartPos.ch + varType.length + 1},
end: {line: insertStartPos.line, ch: insertStartPos.ch + varType.length + varName.length + 1},
primary: true
});
session.editor.setSelections(selections);
session.editor._codeMirror.indentLine(posToIndent.line, "smart");
});
} | [
"function",
"extract",
"(",
"scopes",
",",
"parentStatement",
",",
"expns",
",",
"text",
",",
"insertPosition",
")",
"{",
"var",
"varType",
"=",
"\"var\"",
",",
"varName",
"=",
"RefactoringUtils",
".",
"getUniqueIdentifierName",
"(",
"scopes",
",",
"\"extracted\"",
")",
",",
"varDeclaration",
"=",
"varType",
"+",
"\" \"",
"+",
"varName",
"+",
"\" = \"",
"+",
"text",
"+",
"\";\\n\"",
",",
"parentStatementStartPos",
"=",
"session",
".",
"editor",
".",
"posFromIndex",
"(",
"parentStatement",
".",
"start",
")",
",",
"insertStartPos",
"=",
"insertPosition",
"||",
"parentStatementStartPos",
",",
"selections",
"=",
"[",
"]",
",",
"doc",
"=",
"session",
".",
"editor",
".",
"document",
",",
"replaceExpnIndex",
"=",
"0",
",",
"posToIndent",
",",
"edits",
"=",
"[",
"]",
";",
"// If parent statement is expression statement, then just append var declaration",
"// Ex: \"add(1, 2)\" will become \"var extracted = add(1, 2)\"",
"if",
"(",
"parentStatement",
".",
"type",
"===",
"\"ExpressionStatement\"",
"&&",
"RefactoringUtils",
".",
"isEqual",
"(",
"parentStatement",
".",
"expression",
",",
"expns",
"[",
"0",
"]",
")",
"&&",
"insertStartPos",
".",
"line",
"===",
"parentStatementStartPos",
".",
"line",
"&&",
"insertStartPos",
".",
"ch",
"===",
"parentStatementStartPos",
".",
"ch",
")",
"{",
"varDeclaration",
"=",
"varType",
"+",
"\" \"",
"+",
"varName",
"+",
"\" = \"",
";",
"replaceExpnIndex",
"=",
"1",
";",
"}",
"posToIndent",
"=",
"doc",
".",
"adjustPosForChange",
"(",
"insertStartPos",
",",
"varDeclaration",
".",
"split",
"(",
"\"\\n\"",
")",
",",
"insertStartPos",
",",
"insertStartPos",
")",
";",
"// adjust pos for change",
"for",
"(",
"var",
"i",
"=",
"replaceExpnIndex",
";",
"i",
"<",
"expns",
".",
"length",
";",
"++",
"i",
")",
"{",
"expns",
"[",
"i",
"]",
".",
"start",
"=",
"session",
".",
"editor",
".",
"posFromIndex",
"(",
"expns",
"[",
"i",
"]",
".",
"start",
")",
";",
"expns",
"[",
"i",
"]",
".",
"end",
"=",
"session",
".",
"editor",
".",
"posFromIndex",
"(",
"expns",
"[",
"i",
"]",
".",
"end",
")",
";",
"expns",
"[",
"i",
"]",
".",
"start",
"=",
"doc",
".",
"adjustPosForChange",
"(",
"expns",
"[",
"i",
"]",
".",
"start",
",",
"varDeclaration",
".",
"split",
"(",
"\"\\n\"",
")",
",",
"insertStartPos",
",",
"insertStartPos",
")",
";",
"expns",
"[",
"i",
"]",
".",
"end",
"=",
"doc",
".",
"adjustPosForChange",
"(",
"expns",
"[",
"i",
"]",
".",
"end",
",",
"varDeclaration",
".",
"split",
"(",
"\"\\n\"",
")",
",",
"insertStartPos",
",",
"insertStartPos",
")",
";",
"edits",
".",
"push",
"(",
"{",
"edit",
":",
"{",
"text",
":",
"varName",
",",
"start",
":",
"expns",
"[",
"i",
"]",
".",
"start",
",",
"end",
":",
"expns",
"[",
"i",
"]",
".",
"end",
"}",
",",
"selection",
":",
"{",
"start",
":",
"expns",
"[",
"i",
"]",
".",
"start",
",",
"end",
":",
"{",
"line",
":",
"expns",
"[",
"i",
"]",
".",
"start",
".",
"line",
",",
"ch",
":",
"expns",
"[",
"i",
"]",
".",
"start",
".",
"ch",
"+",
"varName",
".",
"length",
"}",
"}",
"}",
")",
";",
"}",
"// Replace and multi-select",
"doc",
".",
"batchOperation",
"(",
"function",
"(",
")",
"{",
"doc",
".",
"replaceRange",
"(",
"varDeclaration",
",",
"insertStartPos",
")",
";",
"selections",
"=",
"doc",
".",
"doMultipleEdits",
"(",
"edits",
")",
";",
"selections",
".",
"push",
"(",
"{",
"start",
":",
"{",
"line",
":",
"insertStartPos",
".",
"line",
",",
"ch",
":",
"insertStartPos",
".",
"ch",
"+",
"varType",
".",
"length",
"+",
"1",
"}",
",",
"end",
":",
"{",
"line",
":",
"insertStartPos",
".",
"line",
",",
"ch",
":",
"insertStartPos",
".",
"ch",
"+",
"varType",
".",
"length",
"+",
"varName",
".",
"length",
"+",
"1",
"}",
",",
"primary",
":",
"true",
"}",
")",
";",
"session",
".",
"editor",
".",
"setSelections",
"(",
"selections",
")",
";",
"session",
".",
"editor",
".",
"_codeMirror",
".",
"indentLine",
"(",
"posToIndent",
".",
"line",
",",
"\"smart\"",
")",
";",
"}",
")",
";",
"}"
] | Does the actual extraction. i.e Replacing the text, Creating a variable
and multi select variable names | [
"Does",
"the",
"actual",
"extraction",
".",
"i",
".",
"e",
"Replacing",
"the",
"text",
"Creating",
"a",
"variable",
"and",
"multi",
"select",
"variable",
"names"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js#L40-L97 |
2,217 | adobe/brackets | src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js | findAllExpressions | function findAllExpressions(parentBlockStatement, expn, text) {
var doc = session.editor.document,
obj = {},
expns = [];
// find all references of the expression
obj[expn.type] = function(node) {
if (text === doc.getText().substr(node.start, node.end - node.start)) {
expns.push(node);
}
};
ASTWalker.simple(parentBlockStatement, obj);
return expns;
} | javascript | function findAllExpressions(parentBlockStatement, expn, text) {
var doc = session.editor.document,
obj = {},
expns = [];
// find all references of the expression
obj[expn.type] = function(node) {
if (text === doc.getText().substr(node.start, node.end - node.start)) {
expns.push(node);
}
};
ASTWalker.simple(parentBlockStatement, obj);
return expns;
} | [
"function",
"findAllExpressions",
"(",
"parentBlockStatement",
",",
"expn",
",",
"text",
")",
"{",
"var",
"doc",
"=",
"session",
".",
"editor",
".",
"document",
",",
"obj",
"=",
"{",
"}",
",",
"expns",
"=",
"[",
"]",
";",
"// find all references of the expression",
"obj",
"[",
"expn",
".",
"type",
"]",
"=",
"function",
"(",
"node",
")",
"{",
"if",
"(",
"text",
"===",
"doc",
".",
"getText",
"(",
")",
".",
"substr",
"(",
"node",
".",
"start",
",",
"node",
".",
"end",
"-",
"node",
".",
"start",
")",
")",
"{",
"expns",
".",
"push",
"(",
"node",
")",
";",
"}",
"}",
";",
"ASTWalker",
".",
"simple",
"(",
"parentBlockStatement",
",",
"obj",
")",
";",
"return",
"expns",
";",
"}"
] | Find all expressions in the parentBlockStatement that are same as expn
@param {!ASTNode} parentBlockStatement
@param {!ASTNode} expn
@param {!string} text - text of the expression
@return {!Array.<ASTNode>} | [
"Find",
"all",
"expressions",
"in",
"the",
"parentBlockStatement",
"that",
"are",
"same",
"as",
"expn"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js#L106-L120 |
2,218 | adobe/brackets | src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js | getExpressions | function getExpressions(ast, start, end) {
var expns = [],
s = start,
e = end,
expn;
while (true) {
expn = RefactoringUtils.findSurroundExpression(ast, {start: s, end: e});
if (!expn) {
break;
}
expns.push(expn);
s = expn.start - 1;
}
s = start;
e = end;
function checkExpnEquality(e) {
return e.start === expn.start && e.end === expn.end;
}
while (true) {
expn = RefactoringUtils.findSurroundExpression(ast, {start: s, end: e});
if (!expn) {
break;
}
e = expn.end + 1;
// if expn already added, continue
if (expns.find(checkExpnEquality)) {
continue;
}
expns.push(expn);
}
return expns;
} | javascript | function getExpressions(ast, start, end) {
var expns = [],
s = start,
e = end,
expn;
while (true) {
expn = RefactoringUtils.findSurroundExpression(ast, {start: s, end: e});
if (!expn) {
break;
}
expns.push(expn);
s = expn.start - 1;
}
s = start;
e = end;
function checkExpnEquality(e) {
return e.start === expn.start && e.end === expn.end;
}
while (true) {
expn = RefactoringUtils.findSurroundExpression(ast, {start: s, end: e});
if (!expn) {
break;
}
e = expn.end + 1;
// if expn already added, continue
if (expns.find(checkExpnEquality)) {
continue;
}
expns.push(expn);
}
return expns;
} | [
"function",
"getExpressions",
"(",
"ast",
",",
"start",
",",
"end",
")",
"{",
"var",
"expns",
"=",
"[",
"]",
",",
"s",
"=",
"start",
",",
"e",
"=",
"end",
",",
"expn",
";",
"while",
"(",
"true",
")",
"{",
"expn",
"=",
"RefactoringUtils",
".",
"findSurroundExpression",
"(",
"ast",
",",
"{",
"start",
":",
"s",
",",
"end",
":",
"e",
"}",
")",
";",
"if",
"(",
"!",
"expn",
")",
"{",
"break",
";",
"}",
"expns",
".",
"push",
"(",
"expn",
")",
";",
"s",
"=",
"expn",
".",
"start",
"-",
"1",
";",
"}",
"s",
"=",
"start",
";",
"e",
"=",
"end",
";",
"function",
"checkExpnEquality",
"(",
"e",
")",
"{",
"return",
"e",
".",
"start",
"===",
"expn",
".",
"start",
"&&",
"e",
".",
"end",
"===",
"expn",
".",
"end",
";",
"}",
"while",
"(",
"true",
")",
"{",
"expn",
"=",
"RefactoringUtils",
".",
"findSurroundExpression",
"(",
"ast",
",",
"{",
"start",
":",
"s",
",",
"end",
":",
"e",
"}",
")",
";",
"if",
"(",
"!",
"expn",
")",
"{",
"break",
";",
"}",
"e",
"=",
"expn",
".",
"end",
"+",
"1",
";",
"// if expn already added, continue",
"if",
"(",
"expns",
".",
"find",
"(",
"checkExpnEquality",
")",
")",
"{",
"continue",
";",
"}",
"expns",
".",
"push",
"(",
"expn",
")",
";",
"}",
"return",
"expns",
";",
"}"
] | Gets the surrounding expressions of start and end offset
@param {!ASTNode} ast - the ast of the complete file
@param {!number} start - the start offset
@param {!number} end - the end offset
@return {!Array.<ASTNode>} | [
"Gets",
"the",
"surrounding",
"expressions",
"of",
"start",
"and",
"end",
"offset"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js#L129-L167 |
2,219 | adobe/brackets | src/command/Menus.js | removeMenuItemEventListeners | function removeMenuItemEventListeners(menuItem) {
menuItem._command
.off("enabledStateChange", menuItem._enabledChanged)
.off("checkedStateChange", menuItem._checkedChanged)
.off("nameChange", menuItem._nameChanged)
.off("keyBindingAdded", menuItem._keyBindingAdded)
.off("keyBindingRemoved", menuItem._keyBindingRemoved);
} | javascript | function removeMenuItemEventListeners(menuItem) {
menuItem._command
.off("enabledStateChange", menuItem._enabledChanged)
.off("checkedStateChange", menuItem._checkedChanged)
.off("nameChange", menuItem._nameChanged)
.off("keyBindingAdded", menuItem._keyBindingAdded)
.off("keyBindingRemoved", menuItem._keyBindingRemoved);
} | [
"function",
"removeMenuItemEventListeners",
"(",
"menuItem",
")",
"{",
"menuItem",
".",
"_command",
".",
"off",
"(",
"\"enabledStateChange\"",
",",
"menuItem",
".",
"_enabledChanged",
")",
".",
"off",
"(",
"\"checkedStateChange\"",
",",
"menuItem",
".",
"_checkedChanged",
")",
".",
"off",
"(",
"\"nameChange\"",
",",
"menuItem",
".",
"_nameChanged",
")",
".",
"off",
"(",
"\"keyBindingAdded\"",
",",
"menuItem",
".",
"_keyBindingAdded",
")",
".",
"off",
"(",
"\"keyBindingRemoved\"",
",",
"menuItem",
".",
"_keyBindingRemoved",
")",
";",
"}"
] | Removes the attached event listeners from the corresponding object.
@param {ManuItem} menuItem | [
"Removes",
"the",
"attached",
"event",
"listeners",
"from",
"the",
"corresponding",
"object",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/Menus.js#L186-L193 |
2,220 | adobe/brackets | src/command/Menus.js | _insertInList | function _insertInList($list, $element, position, $relativeElement) {
// Determine where to insert. Default is LAST.
var inserted = false;
if (position) {
// Adjust relative position for menu section positions since $relativeElement
// has already been resolved by _getRelativeMenuItem() to a menuItem
if (position === FIRST_IN_SECTION) {
position = BEFORE;
} else if (position === LAST_IN_SECTION) {
position = AFTER;
}
if (position === FIRST) {
$list.prepend($element);
inserted = true;
} else if ($relativeElement && $relativeElement.length > 0) {
if (position === AFTER) {
$relativeElement.after($element);
inserted = true;
} else if (position === BEFORE) {
$relativeElement.before($element);
inserted = true;
}
}
}
// Default to LAST
if (!inserted) {
$list.append($element);
}
} | javascript | function _insertInList($list, $element, position, $relativeElement) {
// Determine where to insert. Default is LAST.
var inserted = false;
if (position) {
// Adjust relative position for menu section positions since $relativeElement
// has already been resolved by _getRelativeMenuItem() to a menuItem
if (position === FIRST_IN_SECTION) {
position = BEFORE;
} else if (position === LAST_IN_SECTION) {
position = AFTER;
}
if (position === FIRST) {
$list.prepend($element);
inserted = true;
} else if ($relativeElement && $relativeElement.length > 0) {
if (position === AFTER) {
$relativeElement.after($element);
inserted = true;
} else if (position === BEFORE) {
$relativeElement.before($element);
inserted = true;
}
}
}
// Default to LAST
if (!inserted) {
$list.append($element);
}
} | [
"function",
"_insertInList",
"(",
"$list",
",",
"$element",
",",
"position",
",",
"$relativeElement",
")",
"{",
"// Determine where to insert. Default is LAST.",
"var",
"inserted",
"=",
"false",
";",
"if",
"(",
"position",
")",
"{",
"// Adjust relative position for menu section positions since $relativeElement",
"// has already been resolved by _getRelativeMenuItem() to a menuItem",
"if",
"(",
"position",
"===",
"FIRST_IN_SECTION",
")",
"{",
"position",
"=",
"BEFORE",
";",
"}",
"else",
"if",
"(",
"position",
"===",
"LAST_IN_SECTION",
")",
"{",
"position",
"=",
"AFTER",
";",
"}",
"if",
"(",
"position",
"===",
"FIRST",
")",
"{",
"$list",
".",
"prepend",
"(",
"$element",
")",
";",
"inserted",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"$relativeElement",
"&&",
"$relativeElement",
".",
"length",
">",
"0",
")",
"{",
"if",
"(",
"position",
"===",
"AFTER",
")",
"{",
"$relativeElement",
".",
"after",
"(",
"$element",
")",
";",
"inserted",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"position",
"===",
"BEFORE",
")",
"{",
"$relativeElement",
".",
"before",
"(",
"$element",
")",
";",
"inserted",
"=",
"true",
";",
"}",
"}",
"}",
"// Default to LAST",
"if",
"(",
"!",
"inserted",
")",
"{",
"$list",
".",
"append",
"(",
"$element",
")",
";",
"}",
"}"
] | Help function for inserting elements into a list | [
"Help",
"function",
"for",
"inserting",
"elements",
"into",
"a",
"list"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/Menus.js#L256-L287 |
2,221 | adobe/brackets | src/command/Menus.js | MenuItem | function MenuItem(id, command) {
this.id = id;
this.isDivider = (command === DIVIDER);
this.isNative = false;
if (!this.isDivider && command !== SUBMENU) {
// Bind event handlers
this._enabledChanged = this._enabledChanged.bind(this);
this._checkedChanged = this._checkedChanged.bind(this);
this._nameChanged = this._nameChanged.bind(this);
this._keyBindingAdded = this._keyBindingAdded.bind(this);
this._keyBindingRemoved = this._keyBindingRemoved.bind(this);
this._command = command;
this._command
.on("enabledStateChange", this._enabledChanged)
.on("checkedStateChange", this._checkedChanged)
.on("nameChange", this._nameChanged)
.on("keyBindingAdded", this._keyBindingAdded)
.on("keyBindingRemoved", this._keyBindingRemoved);
}
} | javascript | function MenuItem(id, command) {
this.id = id;
this.isDivider = (command === DIVIDER);
this.isNative = false;
if (!this.isDivider && command !== SUBMENU) {
// Bind event handlers
this._enabledChanged = this._enabledChanged.bind(this);
this._checkedChanged = this._checkedChanged.bind(this);
this._nameChanged = this._nameChanged.bind(this);
this._keyBindingAdded = this._keyBindingAdded.bind(this);
this._keyBindingRemoved = this._keyBindingRemoved.bind(this);
this._command = command;
this._command
.on("enabledStateChange", this._enabledChanged)
.on("checkedStateChange", this._checkedChanged)
.on("nameChange", this._nameChanged)
.on("keyBindingAdded", this._keyBindingAdded)
.on("keyBindingRemoved", this._keyBindingRemoved);
}
} | [
"function",
"MenuItem",
"(",
"id",
",",
"command",
")",
"{",
"this",
".",
"id",
"=",
"id",
";",
"this",
".",
"isDivider",
"=",
"(",
"command",
"===",
"DIVIDER",
")",
";",
"this",
".",
"isNative",
"=",
"false",
";",
"if",
"(",
"!",
"this",
".",
"isDivider",
"&&",
"command",
"!==",
"SUBMENU",
")",
"{",
"// Bind event handlers",
"this",
".",
"_enabledChanged",
"=",
"this",
".",
"_enabledChanged",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_checkedChanged",
"=",
"this",
".",
"_checkedChanged",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_nameChanged",
"=",
"this",
".",
"_nameChanged",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_keyBindingAdded",
"=",
"this",
".",
"_keyBindingAdded",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_keyBindingRemoved",
"=",
"this",
".",
"_keyBindingRemoved",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_command",
"=",
"command",
";",
"this",
".",
"_command",
".",
"on",
"(",
"\"enabledStateChange\"",
",",
"this",
".",
"_enabledChanged",
")",
".",
"on",
"(",
"\"checkedStateChange\"",
",",
"this",
".",
"_checkedChanged",
")",
".",
"on",
"(",
"\"nameChange\"",
",",
"this",
".",
"_nameChanged",
")",
".",
"on",
"(",
"\"keyBindingAdded\"",
",",
"this",
".",
"_keyBindingAdded",
")",
".",
"on",
"(",
"\"keyBindingRemoved\"",
",",
"this",
".",
"_keyBindingRemoved",
")",
";",
"}",
"}"
] | MenuItem represents a single menu item that executes a Command or a menu divider. MenuItems
may have a sub-menu. A MenuItem may correspond to an HTML-based
menu item or a native menu item if Brackets is running in a native application shell
Since MenuItems may have a native implementation clients should create MenuItems through
addMenuItem() and should NOT construct a MenuItem object directly.
Clients should also not access HTML content of a menu directly and instead use
the MenuItem API to query and modify menus items.
MenuItems are views on to Command objects so modify the underlying Command to modify the
name, enabled, and checked state of a MenuItem. The MenuItem will update automatically
@constructor
@private
@param {string} id
@param {string|Command} command - the Command this MenuItem will reflect.
Use DIVIDER to specify a menu divider | [
"MenuItem",
"represents",
"a",
"single",
"menu",
"item",
"that",
"executes",
"a",
"Command",
"or",
"a",
"menu",
"divider",
".",
"MenuItems",
"may",
"have",
"a",
"sub",
"-",
"menu",
".",
"A",
"MenuItem",
"may",
"correspond",
"to",
"an",
"HTML",
"-",
"based",
"menu",
"item",
"or",
"a",
"native",
"menu",
"item",
"if",
"Brackets",
"is",
"running",
"in",
"a",
"native",
"application",
"shell"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/Menus.js#L309-L330 |
2,222 | adobe/brackets | src/command/Menus.js | addMenu | function addMenu(name, id, position, relativeID) {
name = _.escape(name);
var $menubar = $("#titlebar .nav"),
menu;
if (!name || !id) {
console.error("call to addMenu() is missing required parameters");
return null;
}
// Guard against duplicate menu ids
if (menuMap[id]) {
console.log("Menu added with same name and id of existing Menu: " + id);
return null;
}
menu = new Menu(id);
menuMap[id] = menu;
if (!_isHTMLMenu(id)) {
brackets.app.addMenu(name, id, position, relativeID, function (err) {
switch (err) {
case NO_ERROR:
// Make sure name is up to date
brackets.app.setMenuTitle(id, name, function (err) {
if (err) {
console.error("setMenuTitle() -- error: " + err);
}
});
break;
case ERR_UNKNOWN:
console.error("addMenu(): Unknown Error when adding the menu " + id);
break;
case ERR_INVALID_PARAMS:
console.error("addMenu(): Invalid Parameters when adding the menu " + id);
break;
case ERR_NOT_FOUND:
console.error("addMenu(): Menu with command " + relativeID + " could not be found when adding the menu " + id);
break;
default:
console.error("addMenu(): Unknown Error (" + err + ") when adding the menu " + id);
}
});
return menu;
}
var $toggle = $("<a href='#' class='dropdown-toggle' data-toggle='dropdown'>" + name + "</a>"),
$popUp = $("<ul class='dropdown-menu'></ul>"),
$newMenu = $("<li class='dropdown' id='" + id + "'></li>").append($toggle).append($popUp);
// Insert menu
var $relativeElement = relativeID && $(_getHTMLMenu(relativeID));
_insertInList($menubar, $newMenu, position, $relativeElement);
// Install ESC key handling
PopUpManager.addPopUp($popUp, closeAll, false);
// todo error handling
return menu;
} | javascript | function addMenu(name, id, position, relativeID) {
name = _.escape(name);
var $menubar = $("#titlebar .nav"),
menu;
if (!name || !id) {
console.error("call to addMenu() is missing required parameters");
return null;
}
// Guard against duplicate menu ids
if (menuMap[id]) {
console.log("Menu added with same name and id of existing Menu: " + id);
return null;
}
menu = new Menu(id);
menuMap[id] = menu;
if (!_isHTMLMenu(id)) {
brackets.app.addMenu(name, id, position, relativeID, function (err) {
switch (err) {
case NO_ERROR:
// Make sure name is up to date
brackets.app.setMenuTitle(id, name, function (err) {
if (err) {
console.error("setMenuTitle() -- error: " + err);
}
});
break;
case ERR_UNKNOWN:
console.error("addMenu(): Unknown Error when adding the menu " + id);
break;
case ERR_INVALID_PARAMS:
console.error("addMenu(): Invalid Parameters when adding the menu " + id);
break;
case ERR_NOT_FOUND:
console.error("addMenu(): Menu with command " + relativeID + " could not be found when adding the menu " + id);
break;
default:
console.error("addMenu(): Unknown Error (" + err + ") when adding the menu " + id);
}
});
return menu;
}
var $toggle = $("<a href='#' class='dropdown-toggle' data-toggle='dropdown'>" + name + "</a>"),
$popUp = $("<ul class='dropdown-menu'></ul>"),
$newMenu = $("<li class='dropdown' id='" + id + "'></li>").append($toggle).append($popUp);
// Insert menu
var $relativeElement = relativeID && $(_getHTMLMenu(relativeID));
_insertInList($menubar, $newMenu, position, $relativeElement);
// Install ESC key handling
PopUpManager.addPopUp($popUp, closeAll, false);
// todo error handling
return menu;
} | [
"function",
"addMenu",
"(",
"name",
",",
"id",
",",
"position",
",",
"relativeID",
")",
"{",
"name",
"=",
"_",
".",
"escape",
"(",
"name",
")",
";",
"var",
"$menubar",
"=",
"$",
"(",
"\"#titlebar .nav\"",
")",
",",
"menu",
";",
"if",
"(",
"!",
"name",
"||",
"!",
"id",
")",
"{",
"console",
".",
"error",
"(",
"\"call to addMenu() is missing required parameters\"",
")",
";",
"return",
"null",
";",
"}",
"// Guard against duplicate menu ids",
"if",
"(",
"menuMap",
"[",
"id",
"]",
")",
"{",
"console",
".",
"log",
"(",
"\"Menu added with same name and id of existing Menu: \"",
"+",
"id",
")",
";",
"return",
"null",
";",
"}",
"menu",
"=",
"new",
"Menu",
"(",
"id",
")",
";",
"menuMap",
"[",
"id",
"]",
"=",
"menu",
";",
"if",
"(",
"!",
"_isHTMLMenu",
"(",
"id",
")",
")",
"{",
"brackets",
".",
"app",
".",
"addMenu",
"(",
"name",
",",
"id",
",",
"position",
",",
"relativeID",
",",
"function",
"(",
"err",
")",
"{",
"switch",
"(",
"err",
")",
"{",
"case",
"NO_ERROR",
":",
"// Make sure name is up to date",
"brackets",
".",
"app",
".",
"setMenuTitle",
"(",
"id",
",",
"name",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"console",
".",
"error",
"(",
"\"setMenuTitle() -- error: \"",
"+",
"err",
")",
";",
"}",
"}",
")",
";",
"break",
";",
"case",
"ERR_UNKNOWN",
":",
"console",
".",
"error",
"(",
"\"addMenu(): Unknown Error when adding the menu \"",
"+",
"id",
")",
";",
"break",
";",
"case",
"ERR_INVALID_PARAMS",
":",
"console",
".",
"error",
"(",
"\"addMenu(): Invalid Parameters when adding the menu \"",
"+",
"id",
")",
";",
"break",
";",
"case",
"ERR_NOT_FOUND",
":",
"console",
".",
"error",
"(",
"\"addMenu(): Menu with command \"",
"+",
"relativeID",
"+",
"\" could not be found when adding the menu \"",
"+",
"id",
")",
";",
"break",
";",
"default",
":",
"console",
".",
"error",
"(",
"\"addMenu(): Unknown Error (\"",
"+",
"err",
"+",
"\") when adding the menu \"",
"+",
"id",
")",
";",
"}",
"}",
")",
";",
"return",
"menu",
";",
"}",
"var",
"$toggle",
"=",
"$",
"(",
"\"<a href='#' class='dropdown-toggle' data-toggle='dropdown'>\"",
"+",
"name",
"+",
"\"</a>\"",
")",
",",
"$popUp",
"=",
"$",
"(",
"\"<ul class='dropdown-menu'></ul>\"",
")",
",",
"$newMenu",
"=",
"$",
"(",
"\"<li class='dropdown' id='\"",
"+",
"id",
"+",
"\"'></li>\"",
")",
".",
"append",
"(",
"$toggle",
")",
".",
"append",
"(",
"$popUp",
")",
";",
"// Insert menu",
"var",
"$relativeElement",
"=",
"relativeID",
"&&",
"$",
"(",
"_getHTMLMenu",
"(",
"relativeID",
")",
")",
";",
"_insertInList",
"(",
"$menubar",
",",
"$newMenu",
",",
"position",
",",
"$relativeElement",
")",
";",
"// Install ESC key handling",
"PopUpManager",
".",
"addPopUp",
"(",
"$popUp",
",",
"closeAll",
",",
"false",
")",
";",
"// todo error handling",
"return",
"menu",
";",
"}"
] | Adds a top-level menu to the application menu bar which may be native or HTML-based.
@param {!string} name - display text for menu
@param {!string} id - unique identifier for a menu.
Core Menus in Brackets use a simple title as an id, for example "file-menu".
Extensions should use the following format: "author.myextension.mymenuname".
@param {?string} position - constant defining the position of new the Menu relative
to other Menus. Default is LAST (see Insertion position constants).
@param {?string} relativeID - id of Menu the new Menu will be positioned relative to. Required
when position is AFTER or BEFORE, ignored when position is FIRST or LAST
@return {?Menu} the newly created Menu | [
"Adds",
"a",
"top",
"-",
"level",
"menu",
"to",
"the",
"application",
"menu",
"bar",
"which",
"may",
"be",
"native",
"or",
"HTML",
"-",
"based",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/Menus.js#L1044-L1104 |
2,223 | adobe/brackets | src/command/Menus.js | removeMenu | function removeMenu(id) {
var menu,
commandID = "";
if (!id) {
console.error("removeMenu(): missing required parameter: id");
return;
}
if (!menuMap[id]) {
console.error("removeMenu(): menu id not found: %s", id);
return;
}
// Remove all of the menu items in the menu
menu = getMenu(id);
_.forEach(menuItemMap, function (value, key) {
if (_.startsWith(key, id)) {
if (value.isDivider) {
menu.removeMenuDivider(key);
} else {
commandID = value.getCommand();
menu.removeMenuItem(commandID);
}
}
});
if (_isHTMLMenu(id)) {
$(_getHTMLMenu(id)).remove();
} else {
brackets.app.removeMenu(id, function (err) {
if (err) {
console.error("removeMenu() -- id not found: " + id + " (error: " + err + ")");
}
});
}
delete menuMap[id];
} | javascript | function removeMenu(id) {
var menu,
commandID = "";
if (!id) {
console.error("removeMenu(): missing required parameter: id");
return;
}
if (!menuMap[id]) {
console.error("removeMenu(): menu id not found: %s", id);
return;
}
// Remove all of the menu items in the menu
menu = getMenu(id);
_.forEach(menuItemMap, function (value, key) {
if (_.startsWith(key, id)) {
if (value.isDivider) {
menu.removeMenuDivider(key);
} else {
commandID = value.getCommand();
menu.removeMenuItem(commandID);
}
}
});
if (_isHTMLMenu(id)) {
$(_getHTMLMenu(id)).remove();
} else {
brackets.app.removeMenu(id, function (err) {
if (err) {
console.error("removeMenu() -- id not found: " + id + " (error: " + err + ")");
}
});
}
delete menuMap[id];
} | [
"function",
"removeMenu",
"(",
"id",
")",
"{",
"var",
"menu",
",",
"commandID",
"=",
"\"\"",
";",
"if",
"(",
"!",
"id",
")",
"{",
"console",
".",
"error",
"(",
"\"removeMenu(): missing required parameter: id\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"menuMap",
"[",
"id",
"]",
")",
"{",
"console",
".",
"error",
"(",
"\"removeMenu(): menu id not found: %s\"",
",",
"id",
")",
";",
"return",
";",
"}",
"// Remove all of the menu items in the menu",
"menu",
"=",
"getMenu",
"(",
"id",
")",
";",
"_",
".",
"forEach",
"(",
"menuItemMap",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"if",
"(",
"_",
".",
"startsWith",
"(",
"key",
",",
"id",
")",
")",
"{",
"if",
"(",
"value",
".",
"isDivider",
")",
"{",
"menu",
".",
"removeMenuDivider",
"(",
"key",
")",
";",
"}",
"else",
"{",
"commandID",
"=",
"value",
".",
"getCommand",
"(",
")",
";",
"menu",
".",
"removeMenuItem",
"(",
"commandID",
")",
";",
"}",
"}",
"}",
")",
";",
"if",
"(",
"_isHTMLMenu",
"(",
"id",
")",
")",
"{",
"$",
"(",
"_getHTMLMenu",
"(",
"id",
")",
")",
".",
"remove",
"(",
")",
";",
"}",
"else",
"{",
"brackets",
".",
"app",
".",
"removeMenu",
"(",
"id",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"console",
".",
"error",
"(",
"\"removeMenu() -- id not found: \"",
"+",
"id",
"+",
"\" (error: \"",
"+",
"err",
"+",
"\")\"",
")",
";",
"}",
"}",
")",
";",
"}",
"delete",
"menuMap",
"[",
"id",
"]",
";",
"}"
] | Removes a top-level menu from the application menu bar which may be native or HTML-based.
@param {!string} id - unique identifier for a menu.
Core Menus in Brackets use a simple title as an id, for example "file-menu".
Extensions should use the following format: "author.myextension.mymenuname". | [
"Removes",
"a",
"top",
"-",
"level",
"menu",
"from",
"the",
"application",
"menu",
"bar",
"which",
"may",
"be",
"native",
"or",
"HTML",
"-",
"based",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/Menus.js#L1113-L1152 |
2,224 | adobe/brackets | src/command/Menus.js | ContextMenu | function ContextMenu(id) {
Menu.apply(this, arguments);
var $newMenu = $("<li class='dropdown context-menu' id='" + StringUtils.jQueryIdEscape(id) + "'></li>"),
$popUp = $("<ul class='dropdown-menu'></ul>"),
$toggle = $("<a href='#' class='dropdown-toggle' data-toggle='dropdown'></a>").hide();
// assemble the menu fragments
$newMenu.append($toggle).append($popUp);
// insert into DOM
$("#context-menu-bar > ul").append($newMenu);
var self = this;
PopUpManager.addPopUp($popUp,
function () {
self.close();
},
false);
// Listen to ContextMenu's beforeContextMenuOpen event to first close other popups
PopUpManager.listenToContextMenu(this);
} | javascript | function ContextMenu(id) {
Menu.apply(this, arguments);
var $newMenu = $("<li class='dropdown context-menu' id='" + StringUtils.jQueryIdEscape(id) + "'></li>"),
$popUp = $("<ul class='dropdown-menu'></ul>"),
$toggle = $("<a href='#' class='dropdown-toggle' data-toggle='dropdown'></a>").hide();
// assemble the menu fragments
$newMenu.append($toggle).append($popUp);
// insert into DOM
$("#context-menu-bar > ul").append($newMenu);
var self = this;
PopUpManager.addPopUp($popUp,
function () {
self.close();
},
false);
// Listen to ContextMenu's beforeContextMenuOpen event to first close other popups
PopUpManager.listenToContextMenu(this);
} | [
"function",
"ContextMenu",
"(",
"id",
")",
"{",
"Menu",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"$newMenu",
"=",
"$",
"(",
"\"<li class='dropdown context-menu' id='\"",
"+",
"StringUtils",
".",
"jQueryIdEscape",
"(",
"id",
")",
"+",
"\"'></li>\"",
")",
",",
"$popUp",
"=",
"$",
"(",
"\"<ul class='dropdown-menu'></ul>\"",
")",
",",
"$toggle",
"=",
"$",
"(",
"\"<a href='#' class='dropdown-toggle' data-toggle='dropdown'></a>\"",
")",
".",
"hide",
"(",
")",
";",
"// assemble the menu fragments",
"$newMenu",
".",
"append",
"(",
"$toggle",
")",
".",
"append",
"(",
"$popUp",
")",
";",
"// insert into DOM",
"$",
"(",
"\"#context-menu-bar > ul\"",
")",
".",
"append",
"(",
"$newMenu",
")",
";",
"var",
"self",
"=",
"this",
";",
"PopUpManager",
".",
"addPopUp",
"(",
"$popUp",
",",
"function",
"(",
")",
"{",
"self",
".",
"close",
"(",
")",
";",
"}",
",",
"false",
")",
";",
"// Listen to ContextMenu's beforeContextMenuOpen event to first close other popups",
"PopUpManager",
".",
"listenToContextMenu",
"(",
"this",
")",
";",
"}"
] | Represents a context menu that can open at a specific location in the UI.
Clients should not create this object directly and should instead use registerContextMenu()
to create new ContextMenu objects.
Context menus in brackets may be HTML-based or native so clients should not reach into
the HTML and should instead manipulate ContextMenus through the API.
Events:
- beforeContextMenuOpen
- beforeContextMenuClose
@constructor
@extends {Menu} | [
"Represents",
"a",
"context",
"menu",
"that",
"can",
"open",
"at",
"a",
"specific",
"location",
"in",
"the",
"UI",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/Menus.js#L1170-L1192 |
2,225 | adobe/brackets | src/command/Menus.js | registerContextMenu | function registerContextMenu(id) {
if (!id) {
console.error("call to registerContextMenu() is missing required parameters");
return null;
}
// Guard against duplicate menu ids
if (contextMenuMap[id]) {
console.log("Context Menu added with same name and id of existing Context Menu: " + id);
return null;
}
var cmenu = new ContextMenu(id);
contextMenuMap[id] = cmenu;
return cmenu;
} | javascript | function registerContextMenu(id) {
if (!id) {
console.error("call to registerContextMenu() is missing required parameters");
return null;
}
// Guard against duplicate menu ids
if (contextMenuMap[id]) {
console.log("Context Menu added with same name and id of existing Context Menu: " + id);
return null;
}
var cmenu = new ContextMenu(id);
contextMenuMap[id] = cmenu;
return cmenu;
} | [
"function",
"registerContextMenu",
"(",
"id",
")",
"{",
"if",
"(",
"!",
"id",
")",
"{",
"console",
".",
"error",
"(",
"\"call to registerContextMenu() is missing required parameters\"",
")",
";",
"return",
"null",
";",
"}",
"// Guard against duplicate menu ids",
"if",
"(",
"contextMenuMap",
"[",
"id",
"]",
")",
"{",
"console",
".",
"log",
"(",
"\"Context Menu added with same name and id of existing Context Menu: \"",
"+",
"id",
")",
";",
"return",
"null",
";",
"}",
"var",
"cmenu",
"=",
"new",
"ContextMenu",
"(",
"id",
")",
";",
"contextMenuMap",
"[",
"id",
"]",
"=",
"cmenu",
";",
"return",
"cmenu",
";",
"}"
] | Registers new context menu with Brackets.
Extensions should generally use the predefined context menus built into Brackets. Use this
API to add a new context menu to UI that is specific to an extension.
After registering a new context menu clients should:
- use addMenuItem() to add items to the context menu
- call open() to show the context menu.
For example:
$("#my_ID").contextmenu(function (e) {
if (e.which === 3) {
my_cmenu.open(e);
}
});
To make menu items be contextual to things like selection, listen for the "beforeContextMenuOpen"
to make changes to Command objects before the context menu is shown. MenuItems are views of
Commands, which control a MenuItem's name, enabled state, and checked state.
@param {string} id - unique identifier for context menu.
Core context menus in Brackets use a simple title as an id.
Extensions should use the following format: "author.myextension.mycontextmenu name"
@return {?ContextMenu} the newly created context menu | [
"Registers",
"new",
"context",
"menu",
"with",
"Brackets",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/Menus.js#L1371-L1386 |
2,226 | adobe/brackets | src/LiveDevelopment/LiveDevServerManager.js | getServer | function getServer(localPath) {
var provider, server, i;
for (i = 0; i < _serverProviders.length; i++) {
provider = _serverProviders[i];
server = provider.create();
if (server.canServe(localPath)) {
return server;
}
}
return null;
} | javascript | function getServer(localPath) {
var provider, server, i;
for (i = 0; i < _serverProviders.length; i++) {
provider = _serverProviders[i];
server = provider.create();
if (server.canServe(localPath)) {
return server;
}
}
return null;
} | [
"function",
"getServer",
"(",
"localPath",
")",
"{",
"var",
"provider",
",",
"server",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"_serverProviders",
".",
"length",
";",
"i",
"++",
")",
"{",
"provider",
"=",
"_serverProviders",
"[",
"i",
"]",
";",
"server",
"=",
"provider",
".",
"create",
"(",
")",
";",
"if",
"(",
"server",
".",
"canServe",
"(",
"localPath",
")",
")",
"{",
"return",
"server",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Determines which provider can serve a file with a local path.
@param {string} localPath A local path to file being served.
@return {?BaseServer} A server no null if no servers can serve the file | [
"Determines",
"which",
"provider",
"can",
"serve",
"a",
"file",
"with",
"a",
"local",
"path",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevServerManager.js#L63-L76 |
2,227 | adobe/brackets | src/LiveDevelopment/LiveDevServerManager.js | registerServer | function registerServer(provider, priority) {
if (!provider.create) {
console.error("Incompatible live development server provider");
return;
}
var providerObj = {};
providerObj.create = provider.create;
providerObj.priority = priority || 0;
_serverProviders.push(providerObj);
_serverProviders.sort(_providerSort);
return providerObj;
} | javascript | function registerServer(provider, priority) {
if (!provider.create) {
console.error("Incompatible live development server provider");
return;
}
var providerObj = {};
providerObj.create = provider.create;
providerObj.priority = priority || 0;
_serverProviders.push(providerObj);
_serverProviders.sort(_providerSort);
return providerObj;
} | [
"function",
"registerServer",
"(",
"provider",
",",
"priority",
")",
"{",
"if",
"(",
"!",
"provider",
".",
"create",
")",
"{",
"console",
".",
"error",
"(",
"\"Incompatible live development server provider\"",
")",
";",
"return",
";",
"}",
"var",
"providerObj",
"=",
"{",
"}",
";",
"providerObj",
".",
"create",
"=",
"provider",
".",
"create",
";",
"providerObj",
".",
"priority",
"=",
"priority",
"||",
"0",
";",
"_serverProviders",
".",
"push",
"(",
"providerObj",
")",
";",
"_serverProviders",
".",
"sort",
"(",
"_providerSort",
")",
";",
"return",
"providerObj",
";",
"}"
] | The method by which a server registers itself. It returns an
object handler that can be used to remove that server from the list.
@param {BaseServer|{create: function():BaseServer}} provider
The provider to be registered, described below.
@param {number} priority
A non-negative number used to break ties among providers for a
particular url. Providers that register with a higher priority will
have the opportunity to provide a given url before those with a
lower priority. The higher the number, the higher the priority.
@return {{object}} | [
"The",
"method",
"by",
"which",
"a",
"server",
"registers",
"itself",
".",
"It",
"returns",
"an",
"object",
"handler",
"that",
"can",
"be",
"used",
"to",
"remove",
"that",
"server",
"from",
"the",
"list",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevServerManager.js#L91-L106 |
2,228 | adobe/brackets | src/LiveDevelopment/LiveDevServerManager.js | removeServer | function removeServer(provider) {
var i;
for (i = 0; i < _serverProviders.length; i++) {
if (provider === _serverProviders[i]) {
_serverProviders.splice(i, 1);
}
}
} | javascript | function removeServer(provider) {
var i;
for (i = 0; i < _serverProviders.length; i++) {
if (provider === _serverProviders[i]) {
_serverProviders.splice(i, 1);
}
}
} | [
"function",
"removeServer",
"(",
"provider",
")",
"{",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"_serverProviders",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"provider",
"===",
"_serverProviders",
"[",
"i",
"]",
")",
"{",
"_serverProviders",
".",
"splice",
"(",
"i",
",",
"1",
")",
";",
"}",
"}",
"}"
] | Remove a server from the list of the registered providers.
@param {{object}} provider The provider to be removed. | [
"Remove",
"a",
"server",
"from",
"the",
"list",
"of",
"the",
"registered",
"providers",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevServerManager.js#L113-L120 |
2,229 | adobe/brackets | src/JSUtils/Preferences.js | settingsToRegExp | function settingsToRegExp(settings, baseRegExp, defaultRegExp) {
var regExpString = "";
if (settings instanceof Array && settings.length > 0) {
// Append base settings to user settings. The base
// settings are builtin and cannot be overridden.
if (baseRegExp) {
settings.push("/" + baseRegExp.source + "/");
}
// convert each string, with optional wildcards to an equivalent
// string in a regular expression.
settings.forEach(function (value, index) {
if (typeof value === "string") {
var isRegExp = value[0] === '/' && value[value.length - 1] === '/';
if (isRegExp) {
value = value.substring(1, value.length - 1);
} else {
value = StringUtils.regexEscape(value);
// convert user input wildcard, "*" or "?", to a regular
// expression. We can just replace the escaped "*" or "?"
// since we know it is a wildcard.
value = value.replace("\\?", ".?");
value = value.replace("\\*", ".*");
// Add "^" and "$" to prevent matching in the middle of strings.
value = "^" + value + "$";
}
if (index > 0) {
regExpString += "|";
}
regExpString = regExpString.concat(value);
}
});
}
if (!regExpString) {
var defaultParts = [];
if (baseRegExp) {
defaultParts.push(baseRegExp.source);
}
if (defaultRegExp) {
defaultParts.push(defaultRegExp.source);
}
if (defaultParts.length > 0) {
regExpString = defaultParts.join("|");
} else {
return null;
}
}
return new RegExp(regExpString);
} | javascript | function settingsToRegExp(settings, baseRegExp, defaultRegExp) {
var regExpString = "";
if (settings instanceof Array && settings.length > 0) {
// Append base settings to user settings. The base
// settings are builtin and cannot be overridden.
if (baseRegExp) {
settings.push("/" + baseRegExp.source + "/");
}
// convert each string, with optional wildcards to an equivalent
// string in a regular expression.
settings.forEach(function (value, index) {
if (typeof value === "string") {
var isRegExp = value[0] === '/' && value[value.length - 1] === '/';
if (isRegExp) {
value = value.substring(1, value.length - 1);
} else {
value = StringUtils.regexEscape(value);
// convert user input wildcard, "*" or "?", to a regular
// expression. We can just replace the escaped "*" or "?"
// since we know it is a wildcard.
value = value.replace("\\?", ".?");
value = value.replace("\\*", ".*");
// Add "^" and "$" to prevent matching in the middle of strings.
value = "^" + value + "$";
}
if (index > 0) {
regExpString += "|";
}
regExpString = regExpString.concat(value);
}
});
}
if (!regExpString) {
var defaultParts = [];
if (baseRegExp) {
defaultParts.push(baseRegExp.source);
}
if (defaultRegExp) {
defaultParts.push(defaultRegExp.source);
}
if (defaultParts.length > 0) {
regExpString = defaultParts.join("|");
} else {
return null;
}
}
return new RegExp(regExpString);
} | [
"function",
"settingsToRegExp",
"(",
"settings",
",",
"baseRegExp",
",",
"defaultRegExp",
")",
"{",
"var",
"regExpString",
"=",
"\"\"",
";",
"if",
"(",
"settings",
"instanceof",
"Array",
"&&",
"settings",
".",
"length",
">",
"0",
")",
"{",
"// Append base settings to user settings. The base",
"// settings are builtin and cannot be overridden.",
"if",
"(",
"baseRegExp",
")",
"{",
"settings",
".",
"push",
"(",
"\"/\"",
"+",
"baseRegExp",
".",
"source",
"+",
"\"/\"",
")",
";",
"}",
"// convert each string, with optional wildcards to an equivalent",
"// string in a regular expression.",
"settings",
".",
"forEach",
"(",
"function",
"(",
"value",
",",
"index",
")",
"{",
"if",
"(",
"typeof",
"value",
"===",
"\"string\"",
")",
"{",
"var",
"isRegExp",
"=",
"value",
"[",
"0",
"]",
"===",
"'/'",
"&&",
"value",
"[",
"value",
".",
"length",
"-",
"1",
"]",
"===",
"'/'",
";",
"if",
"(",
"isRegExp",
")",
"{",
"value",
"=",
"value",
".",
"substring",
"(",
"1",
",",
"value",
".",
"length",
"-",
"1",
")",
";",
"}",
"else",
"{",
"value",
"=",
"StringUtils",
".",
"regexEscape",
"(",
"value",
")",
";",
"// convert user input wildcard, \"*\" or \"?\", to a regular",
"// expression. We can just replace the escaped \"*\" or \"?\"",
"// since we know it is a wildcard.",
"value",
"=",
"value",
".",
"replace",
"(",
"\"\\\\?\"",
",",
"\".?\"",
")",
";",
"value",
"=",
"value",
".",
"replace",
"(",
"\"\\\\*\"",
",",
"\".*\"",
")",
";",
"// Add \"^\" and \"$\" to prevent matching in the middle of strings.",
"value",
"=",
"\"^\"",
"+",
"value",
"+",
"\"$\"",
";",
"}",
"if",
"(",
"index",
">",
"0",
")",
"{",
"regExpString",
"+=",
"\"|\"",
";",
"}",
"regExpString",
"=",
"regExpString",
".",
"concat",
"(",
"value",
")",
";",
"}",
"}",
")",
";",
"}",
"if",
"(",
"!",
"regExpString",
")",
"{",
"var",
"defaultParts",
"=",
"[",
"]",
";",
"if",
"(",
"baseRegExp",
")",
"{",
"defaultParts",
".",
"push",
"(",
"baseRegExp",
".",
"source",
")",
";",
"}",
"if",
"(",
"defaultRegExp",
")",
"{",
"defaultParts",
".",
"push",
"(",
"defaultRegExp",
".",
"source",
")",
";",
"}",
"if",
"(",
"defaultParts",
".",
"length",
">",
"0",
")",
"{",
"regExpString",
"=",
"defaultParts",
".",
"join",
"(",
"\"|\"",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"return",
"new",
"RegExp",
"(",
"regExpString",
")",
";",
"}"
] | Convert an array of strings with optional wildcards, to an equivalent
regular expression.
@param {Array.<string|RegExp>} settings from the file (note: this may be mutated by this function)
@param {?RegExp} baseRegExp - base regular expression that is always used
@param {?RegExp} defaultRegExp - additional regular expression that is only used if the user has not configured settings
@return {RegExp} Regular expression that captures the array of string
with optional wildcards. | [
"Convert",
"an",
"array",
"of",
"strings",
"with",
"optional",
"wildcards",
"to",
"an",
"equivalent",
"regular",
"expression",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/Preferences.js#L80-L138 |
2,230 | adobe/brackets | src/JSUtils/Preferences.js | Preferences | function Preferences(prefs) {
var BASE_EXCLUDED_DIRECTORIES = null, /* if the user has settings, we don't exclude anything by default */
// exclude node_modules for performance reasons and because we don't do full hinting for those anyhow.
DEFAULT_EXCLUDED_DIRECTORIES = /node_modules/,
// exclude require and jquery since we have special knowledge of those
BASE_EXCLUDED_FILES = /^require.*\.js$|^jquery.*\.js$/,
DEFAULT_MAX_FILE_COUNT = 100,
DEFAULT_MAX_FILE_SIZE = 512 * 1024;
if (prefs) {
this._excludedDirectories = settingsToRegExp(prefs["excluded-directories"],
BASE_EXCLUDED_DIRECTORIES,
DEFAULT_EXCLUDED_DIRECTORIES);
this._excludedFiles = settingsToRegExp(prefs["excluded-files"],
BASE_EXCLUDED_FILES);
this._maxFileCount = prefs["max-file-count"];
this._maxFileSize = prefs["max-file-size"];
// sanity check values
if (!this._maxFileCount || this._maxFileCount < 0) {
this._maxFileCount = DEFAULT_MAX_FILE_COUNT;
}
if (!this._maxFileSize || this._maxFileSize < 0) {
this._maxFileSize = DEFAULT_MAX_FILE_SIZE;
}
} else {
this._excludedDirectories = DEFAULT_EXCLUDED_DIRECTORIES;
this._excludedFiles = BASE_EXCLUDED_FILES;
this._maxFileCount = DEFAULT_MAX_FILE_COUNT;
this._maxFileSize = DEFAULT_MAX_FILE_SIZE;
}
} | javascript | function Preferences(prefs) {
var BASE_EXCLUDED_DIRECTORIES = null, /* if the user has settings, we don't exclude anything by default */
// exclude node_modules for performance reasons and because we don't do full hinting for those anyhow.
DEFAULT_EXCLUDED_DIRECTORIES = /node_modules/,
// exclude require and jquery since we have special knowledge of those
BASE_EXCLUDED_FILES = /^require.*\.js$|^jquery.*\.js$/,
DEFAULT_MAX_FILE_COUNT = 100,
DEFAULT_MAX_FILE_SIZE = 512 * 1024;
if (prefs) {
this._excludedDirectories = settingsToRegExp(prefs["excluded-directories"],
BASE_EXCLUDED_DIRECTORIES,
DEFAULT_EXCLUDED_DIRECTORIES);
this._excludedFiles = settingsToRegExp(prefs["excluded-files"],
BASE_EXCLUDED_FILES);
this._maxFileCount = prefs["max-file-count"];
this._maxFileSize = prefs["max-file-size"];
// sanity check values
if (!this._maxFileCount || this._maxFileCount < 0) {
this._maxFileCount = DEFAULT_MAX_FILE_COUNT;
}
if (!this._maxFileSize || this._maxFileSize < 0) {
this._maxFileSize = DEFAULT_MAX_FILE_SIZE;
}
} else {
this._excludedDirectories = DEFAULT_EXCLUDED_DIRECTORIES;
this._excludedFiles = BASE_EXCLUDED_FILES;
this._maxFileCount = DEFAULT_MAX_FILE_COUNT;
this._maxFileSize = DEFAULT_MAX_FILE_SIZE;
}
} | [
"function",
"Preferences",
"(",
"prefs",
")",
"{",
"var",
"BASE_EXCLUDED_DIRECTORIES",
"=",
"null",
",",
"/* if the user has settings, we don't exclude anything by default */",
"// exclude node_modules for performance reasons and because we don't do full hinting for those anyhow.",
"DEFAULT_EXCLUDED_DIRECTORIES",
"=",
"/",
"node_modules",
"/",
",",
"// exclude require and jquery since we have special knowledge of those",
"BASE_EXCLUDED_FILES",
"=",
"/",
"^require.*\\.js$|^jquery.*\\.js$",
"/",
",",
"DEFAULT_MAX_FILE_COUNT",
"=",
"100",
",",
"DEFAULT_MAX_FILE_SIZE",
"=",
"512",
"*",
"1024",
";",
"if",
"(",
"prefs",
")",
"{",
"this",
".",
"_excludedDirectories",
"=",
"settingsToRegExp",
"(",
"prefs",
"[",
"\"excluded-directories\"",
"]",
",",
"BASE_EXCLUDED_DIRECTORIES",
",",
"DEFAULT_EXCLUDED_DIRECTORIES",
")",
";",
"this",
".",
"_excludedFiles",
"=",
"settingsToRegExp",
"(",
"prefs",
"[",
"\"excluded-files\"",
"]",
",",
"BASE_EXCLUDED_FILES",
")",
";",
"this",
".",
"_maxFileCount",
"=",
"prefs",
"[",
"\"max-file-count\"",
"]",
";",
"this",
".",
"_maxFileSize",
"=",
"prefs",
"[",
"\"max-file-size\"",
"]",
";",
"// sanity check values",
"if",
"(",
"!",
"this",
".",
"_maxFileCount",
"||",
"this",
".",
"_maxFileCount",
"<",
"0",
")",
"{",
"this",
".",
"_maxFileCount",
"=",
"DEFAULT_MAX_FILE_COUNT",
";",
"}",
"if",
"(",
"!",
"this",
".",
"_maxFileSize",
"||",
"this",
".",
"_maxFileSize",
"<",
"0",
")",
"{",
"this",
".",
"_maxFileSize",
"=",
"DEFAULT_MAX_FILE_SIZE",
";",
"}",
"}",
"else",
"{",
"this",
".",
"_excludedDirectories",
"=",
"DEFAULT_EXCLUDED_DIRECTORIES",
";",
"this",
".",
"_excludedFiles",
"=",
"BASE_EXCLUDED_FILES",
";",
"this",
".",
"_maxFileCount",
"=",
"DEFAULT_MAX_FILE_COUNT",
";",
"this",
".",
"_maxFileSize",
"=",
"DEFAULT_MAX_FILE_SIZE",
";",
"}",
"}"
] | Constructor to create a default preference object.
@constructor
@param {Object=} prefs - preference object | [
"Constructor",
"to",
"create",
"a",
"default",
"preference",
"object",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/Preferences.js#L146-L179 |
2,231 | adobe/brackets | src/widgets/InlineMenu.js | InlineMenu | function InlineMenu(editor, menuText) {
/**
* The list of items to display
*
* @type {Array.<{id: number, name: string>}
*/
this.items = [];
/**
* The selected position in the list; otherwise -1.
*
* @type {number}
*/
this.selectedIndex = -1;
/**
* Is the list currently open?
*
* @type {boolean}
*/
this.opened = false;
/**
* The editor context
*
* @type {Editor}
*/
this.editor = editor;
/**
* The menu selection callback function
*
* @type {Function}
*/
this.handleSelect = null;
/**
* The menu closure callback function
*
* @type {Function}
*/
this.handleClose = null;
/**
* The menu object
*
* @type {jQuery.Object}
*/
this.$menu =
$("<li class='dropdown inlinemenu-menu'></li>")
.append($("<a href='#' class='dropdown-toggle' data-toggle='dropdown'></a>")
.hide())
.append("<ul class='dropdown-menu'>" +
"<li class='inlinemenu-header'>" +
"<a>" + menuText + "</a>" +
"</li>" +
"</ul>");
this._keydownHook = this._keydownHook.bind(this);
} | javascript | function InlineMenu(editor, menuText) {
/**
* The list of items to display
*
* @type {Array.<{id: number, name: string>}
*/
this.items = [];
/**
* The selected position in the list; otherwise -1.
*
* @type {number}
*/
this.selectedIndex = -1;
/**
* Is the list currently open?
*
* @type {boolean}
*/
this.opened = false;
/**
* The editor context
*
* @type {Editor}
*/
this.editor = editor;
/**
* The menu selection callback function
*
* @type {Function}
*/
this.handleSelect = null;
/**
* The menu closure callback function
*
* @type {Function}
*/
this.handleClose = null;
/**
* The menu object
*
* @type {jQuery.Object}
*/
this.$menu =
$("<li class='dropdown inlinemenu-menu'></li>")
.append($("<a href='#' class='dropdown-toggle' data-toggle='dropdown'></a>")
.hide())
.append("<ul class='dropdown-menu'>" +
"<li class='inlinemenu-header'>" +
"<a>" + menuText + "</a>" +
"</li>" +
"</ul>");
this._keydownHook = this._keydownHook.bind(this);
} | [
"function",
"InlineMenu",
"(",
"editor",
",",
"menuText",
")",
"{",
"/**\n * The list of items to display\n *\n * @type {Array.<{id: number, name: string>}\n */",
"this",
".",
"items",
"=",
"[",
"]",
";",
"/**\n * The selected position in the list; otherwise -1.\n *\n * @type {number}\n */",
"this",
".",
"selectedIndex",
"=",
"-",
"1",
";",
"/**\n * Is the list currently open?\n *\n * @type {boolean}\n */",
"this",
".",
"opened",
"=",
"false",
";",
"/**\n * The editor context\n *\n * @type {Editor}\n */",
"this",
".",
"editor",
"=",
"editor",
";",
"/**\n * The menu selection callback function\n *\n * @type {Function}\n */",
"this",
".",
"handleSelect",
"=",
"null",
";",
"/**\n * The menu closure callback function\n *\n * @type {Function}\n */",
"this",
".",
"handleClose",
"=",
"null",
";",
"/**\n * The menu object\n *\n * @type {jQuery.Object}\n */",
"this",
".",
"$menu",
"=",
"$",
"(",
"\"<li class='dropdown inlinemenu-menu'></li>\"",
")",
".",
"append",
"(",
"$",
"(",
"\"<a href='#' class='dropdown-toggle' data-toggle='dropdown'></a>\"",
")",
".",
"hide",
"(",
")",
")",
".",
"append",
"(",
"\"<ul class='dropdown-menu'>\"",
"+",
"\"<li class='inlinemenu-header'>\"",
"+",
"\"<a>\"",
"+",
"menuText",
"+",
"\"</a>\"",
"+",
"\"</li>\"",
"+",
"\"</ul>\"",
")",
";",
"this",
".",
"_keydownHook",
"=",
"this",
".",
"_keydownHook",
".",
"bind",
"(",
"this",
")",
";",
"}"
] | Displays a popup list of items for a given editor context
@constructor
@param {Editor} editor
@param {string} menuText | [
"Displays",
"a",
"popup",
"list",
"of",
"items",
"for",
"a",
"given",
"editor",
"context"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/widgets/InlineMenu.js#L46-L108 |
2,232 | adobe/brackets | src/view/MainViewManager.js | _findFileInMRUList | function _findFileInMRUList(paneId, file) {
return _.findIndex(_mruList, function (record) {
return (record.file.fullPath === file.fullPath && record.paneId === paneId);
});
} | javascript | function _findFileInMRUList(paneId, file) {
return _.findIndex(_mruList, function (record) {
return (record.file.fullPath === file.fullPath && record.paneId === paneId);
});
} | [
"function",
"_findFileInMRUList",
"(",
"paneId",
",",
"file",
")",
"{",
"return",
"_",
".",
"findIndex",
"(",
"_mruList",
",",
"function",
"(",
"record",
")",
"{",
"return",
"(",
"record",
".",
"file",
".",
"fullPath",
"===",
"file",
".",
"fullPath",
"&&",
"record",
".",
"paneId",
"===",
"paneId",
")",
";",
"}",
")",
";",
"}"
] | Locates the first MRU entry of a file for the requested pane
@param {!string} paneId - the paneId
@param {!File} File - the file
@return {{file:File, paneId:string}}
@private | [
"Locates",
"the",
"first",
"MRU",
"entry",
"of",
"a",
"file",
"for",
"the",
"requested",
"pane"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L260-L264 |
2,233 | adobe/brackets | src/view/MainViewManager.js | isExclusiveToPane | function isExclusiveToPane(file, paneId) {
paneId = paneId === ACTIVE_PANE && _activePaneId ? _activePaneId : paneId;
var index = _.findIndex(_mruList, function (record) {
return (record.file.fullPath === file.fullPath && record.paneId !== paneId);
});
return index === -1;
} | javascript | function isExclusiveToPane(file, paneId) {
paneId = paneId === ACTIVE_PANE && _activePaneId ? _activePaneId : paneId;
var index = _.findIndex(_mruList, function (record) {
return (record.file.fullPath === file.fullPath && record.paneId !== paneId);
});
return index === -1;
} | [
"function",
"isExclusiveToPane",
"(",
"file",
",",
"paneId",
")",
"{",
"paneId",
"=",
"paneId",
"===",
"ACTIVE_PANE",
"&&",
"_activePaneId",
"?",
"_activePaneId",
":",
"paneId",
";",
"var",
"index",
"=",
"_",
".",
"findIndex",
"(",
"_mruList",
",",
"function",
"(",
"record",
")",
"{",
"return",
"(",
"record",
".",
"file",
".",
"fullPath",
"===",
"file",
".",
"fullPath",
"&&",
"record",
".",
"paneId",
"!==",
"paneId",
")",
";",
"}",
")",
";",
"return",
"index",
"===",
"-",
"1",
";",
"}"
] | Checks whether a file is listed exclusively in the provided pane
@param {!File} File - the file
@return {{file:File, paneId:string}} | [
"Checks",
"whether",
"a",
"file",
"is",
"listed",
"exclusively",
"in",
"the",
"provided",
"pane"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L271-L277 |
2,234 | adobe/brackets | src/view/MainViewManager.js | _getPane | function _getPane(paneId) {
paneId = _resolvePaneId(paneId);
if (_panes[paneId]) {
return _panes[paneId];
}
return null;
} | javascript | function _getPane(paneId) {
paneId = _resolvePaneId(paneId);
if (_panes[paneId]) {
return _panes[paneId];
}
return null;
} | [
"function",
"_getPane",
"(",
"paneId",
")",
"{",
"paneId",
"=",
"_resolvePaneId",
"(",
"paneId",
")",
";",
"if",
"(",
"_panes",
"[",
"paneId",
"]",
")",
"{",
"return",
"_panes",
"[",
"paneId",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Retrieves the Pane object for the given paneId
@param {!string} paneId - id of the pane to retrieve
@return {?Pane} the Pane object or null if a pane object doesn't exist for the pane
@private | [
"Retrieves",
"the",
"Pane",
"object",
"for",
"the",
"given",
"paneId"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L306-L314 |
2,235 | adobe/brackets | src/view/MainViewManager.js | _makeFileMostRecent | function _makeFileMostRecent(paneId, file) {
var index,
entry,
pane = _getPane(paneId);
if (!_traversingFileList) {
pane.makeViewMostRecent(file);
index = _findFileInMRUList(pane.id, file);
entry = _makeMRUListEntry(file, pane.id);
if (index !== -1) {
_mruList.splice(index, 1);
}
if (_findFileInMRUList(pane.id, file) !== -1) {
console.log(file.fullPath + " duplicated in mru list");
}
// add it to the front of the list
_mruList.unshift(entry);
}
} | javascript | function _makeFileMostRecent(paneId, file) {
var index,
entry,
pane = _getPane(paneId);
if (!_traversingFileList) {
pane.makeViewMostRecent(file);
index = _findFileInMRUList(pane.id, file);
entry = _makeMRUListEntry(file, pane.id);
if (index !== -1) {
_mruList.splice(index, 1);
}
if (_findFileInMRUList(pane.id, file) !== -1) {
console.log(file.fullPath + " duplicated in mru list");
}
// add it to the front of the list
_mruList.unshift(entry);
}
} | [
"function",
"_makeFileMostRecent",
"(",
"paneId",
",",
"file",
")",
"{",
"var",
"index",
",",
"entry",
",",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"if",
"(",
"!",
"_traversingFileList",
")",
"{",
"pane",
".",
"makeViewMostRecent",
"(",
"file",
")",
";",
"index",
"=",
"_findFileInMRUList",
"(",
"pane",
".",
"id",
",",
"file",
")",
";",
"entry",
"=",
"_makeMRUListEntry",
"(",
"file",
",",
"pane",
".",
"id",
")",
";",
"if",
"(",
"index",
"!==",
"-",
"1",
")",
"{",
"_mruList",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"}",
"if",
"(",
"_findFileInMRUList",
"(",
"pane",
".",
"id",
",",
"file",
")",
"!==",
"-",
"1",
")",
"{",
"console",
".",
"log",
"(",
"file",
".",
"fullPath",
"+",
"\" duplicated in mru list\"",
")",
";",
"}",
"// add it to the front of the list",
"_mruList",
".",
"unshift",
"(",
"entry",
")",
";",
"}",
"}"
] | Makes the file the most recent for the pane and the global mru lists
@param {!string} paneId - id of the pane to mae th file most recent or ACTIVE_PANE
@param {!File} file - File object to make most recent
@private | [
"Makes",
"the",
"file",
"the",
"most",
"recent",
"for",
"the",
"pane",
"and",
"the",
"global",
"mru",
"lists"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L338-L361 |
2,236 | adobe/brackets | src/view/MainViewManager.js | _makePaneMostRecent | function _makePaneMostRecent(paneId) {
var pane = _getPane(paneId);
if (pane.getCurrentlyViewedFile()) {
_makeFileMostRecent(paneId, pane.getCurrentlyViewedFile());
}
} | javascript | function _makePaneMostRecent(paneId) {
var pane = _getPane(paneId);
if (pane.getCurrentlyViewedFile()) {
_makeFileMostRecent(paneId, pane.getCurrentlyViewedFile());
}
} | [
"function",
"_makePaneMostRecent",
"(",
"paneId",
")",
"{",
"var",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"if",
"(",
"pane",
".",
"getCurrentlyViewedFile",
"(",
")",
")",
"{",
"_makeFileMostRecent",
"(",
"paneId",
",",
"pane",
".",
"getCurrentlyViewedFile",
"(",
")",
")",
";",
"}",
"}"
] | Makes the Pane's current file the most recent
@param {!string} paneId - id of the pane to make the file most recent, or ACTIVE_PANE
@param {!File} file - File object to make most recent
@private | [
"Makes",
"the",
"Pane",
"s",
"current",
"file",
"the",
"most",
"recent"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L369-L375 |
2,237 | adobe/brackets | src/view/MainViewManager.js | _activeEditorChange | function _activeEditorChange(e, current) {
if (current) {
var $container = current.$el.parent().parent(),
pane = _getPaneFromElement($container);
if (pane) {
// Editor is a full editor
if (pane.id !== _activePaneId) {
// we just need to set the active pane in this case
// it will dispatch the currentFileChange message as well
// as dispatching other events when the active pane changes
setActivePaneId(pane.id);
}
} else {
// Editor is an inline editor, find the parent pane
var parents = $container.parents(".view-pane");
if (parents.length === 1) {
$container = $(parents[0]);
pane = _getPaneFromElement($container);
if (pane) {
if (pane.id !== _activePaneId) {
// activate the pane which will put focus in the pane's doc
setActivePaneId(pane.id);
// reset the focus to the inline editor
current.focus();
}
}
}
}
}
} | javascript | function _activeEditorChange(e, current) {
if (current) {
var $container = current.$el.parent().parent(),
pane = _getPaneFromElement($container);
if (pane) {
// Editor is a full editor
if (pane.id !== _activePaneId) {
// we just need to set the active pane in this case
// it will dispatch the currentFileChange message as well
// as dispatching other events when the active pane changes
setActivePaneId(pane.id);
}
} else {
// Editor is an inline editor, find the parent pane
var parents = $container.parents(".view-pane");
if (parents.length === 1) {
$container = $(parents[0]);
pane = _getPaneFromElement($container);
if (pane) {
if (pane.id !== _activePaneId) {
// activate the pane which will put focus in the pane's doc
setActivePaneId(pane.id);
// reset the focus to the inline editor
current.focus();
}
}
}
}
}
} | [
"function",
"_activeEditorChange",
"(",
"e",
",",
"current",
")",
"{",
"if",
"(",
"current",
")",
"{",
"var",
"$container",
"=",
"current",
".",
"$el",
".",
"parent",
"(",
")",
".",
"parent",
"(",
")",
",",
"pane",
"=",
"_getPaneFromElement",
"(",
"$container",
")",
";",
"if",
"(",
"pane",
")",
"{",
"// Editor is a full editor",
"if",
"(",
"pane",
".",
"id",
"!==",
"_activePaneId",
")",
"{",
"// we just need to set the active pane in this case",
"// it will dispatch the currentFileChange message as well",
"// as dispatching other events when the active pane changes",
"setActivePaneId",
"(",
"pane",
".",
"id",
")",
";",
"}",
"}",
"else",
"{",
"// Editor is an inline editor, find the parent pane",
"var",
"parents",
"=",
"$container",
".",
"parents",
"(",
"\".view-pane\"",
")",
";",
"if",
"(",
"parents",
".",
"length",
"===",
"1",
")",
"{",
"$container",
"=",
"$",
"(",
"parents",
"[",
"0",
"]",
")",
";",
"pane",
"=",
"_getPaneFromElement",
"(",
"$container",
")",
";",
"if",
"(",
"pane",
")",
"{",
"if",
"(",
"pane",
".",
"id",
"!==",
"_activePaneId",
")",
"{",
"// activate the pane which will put focus in the pane's doc",
"setActivePaneId",
"(",
"pane",
".",
"id",
")",
";",
"// reset the focus to the inline editor",
"current",
".",
"focus",
"(",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}"
] | EditorManager.activeEditorChange handler
This event is triggered when an visible editor gains focus
Therefore we need to Activate the pane that the active editor belongs to
@private
@param {!jQuery.Event} e - jQuery Event object
@param {Editor=} current - editor being made the current editor | [
"EditorManager",
".",
"activeEditorChange",
"handler",
"This",
"event",
"is",
"triggered",
"when",
"an",
"visible",
"editor",
"gains",
"focus",
"Therefore",
"we",
"need",
"to",
"Activate",
"the",
"pane",
"that",
"the",
"active",
"editor",
"belongs",
"to"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L446-L476 |
2,238 | adobe/brackets | src/view/MainViewManager.js | _forEachPaneOrPanes | function _forEachPaneOrPanes(paneId, callback) {
if (paneId === ALL_PANES) {
_.forEach(_panes, callback);
} else {
callback(_getPane(paneId));
}
} | javascript | function _forEachPaneOrPanes(paneId, callback) {
if (paneId === ALL_PANES) {
_.forEach(_panes, callback);
} else {
callback(_getPane(paneId));
}
} | [
"function",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"callback",
")",
"{",
"if",
"(",
"paneId",
"===",
"ALL_PANES",
")",
"{",
"_",
".",
"forEach",
"(",
"_panes",
",",
"callback",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"_getPane",
"(",
"paneId",
")",
")",
";",
"}",
"}"
] | Iterates over the pane or ALL_PANES and calls the callback function for each.
@param {!string} paneId - id of the pane in which to adjust the scroll state, ALL_PANES or ACTIVE_PANE
@param {!function(!pane:Pane):boolean} callback - function to callback on to perform work.
The callback will receive a Pane and should return false to stop iterating.
@private | [
"Iterates",
"over",
"the",
"pane",
"or",
"ALL_PANES",
"and",
"calls",
"the",
"callback",
"function",
"for",
"each",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L486-L492 |
2,239 | adobe/brackets | src/view/MainViewManager.js | cacheScrollState | function cacheScrollState(paneId) {
_forEachPaneOrPanes(paneId, function (pane) {
_paneScrollStates[pane.id] = pane.getScrollState();
});
} | javascript | function cacheScrollState(paneId) {
_forEachPaneOrPanes(paneId, function (pane) {
_paneScrollStates[pane.id] = pane.getScrollState();
});
} | [
"function",
"cacheScrollState",
"(",
"paneId",
")",
"{",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"function",
"(",
"pane",
")",
"{",
"_paneScrollStates",
"[",
"pane",
".",
"id",
"]",
"=",
"pane",
".",
"getScrollState",
"(",
")",
";",
"}",
")",
";",
"}"
] | Caches the specified pane's current scroll state
If there was already cached state for the specified pane, it is discarded and overwritten
@param {!string} paneId - id of the pane in which to cache the scroll state,
ALL_PANES or ACTIVE_PANE | [
"Caches",
"the",
"specified",
"pane",
"s",
"current",
"scroll",
"state",
"If",
"there",
"was",
"already",
"cached",
"state",
"for",
"the",
"specified",
"pane",
"it",
"is",
"discarded",
"and",
"overwritten"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L500-L504 |
2,240 | adobe/brackets | src/view/MainViewManager.js | restoreAdjustedScrollState | function restoreAdjustedScrollState(paneId, heightDelta) {
_forEachPaneOrPanes(paneId, function (pane) {
pane.restoreAndAdjustScrollState(_paneScrollStates[pane.id], heightDelta);
delete _paneScrollStates[pane.id];
});
} | javascript | function restoreAdjustedScrollState(paneId, heightDelta) {
_forEachPaneOrPanes(paneId, function (pane) {
pane.restoreAndAdjustScrollState(_paneScrollStates[pane.id], heightDelta);
delete _paneScrollStates[pane.id];
});
} | [
"function",
"restoreAdjustedScrollState",
"(",
"paneId",
",",
"heightDelta",
")",
"{",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"function",
"(",
"pane",
")",
"{",
"pane",
".",
"restoreAndAdjustScrollState",
"(",
"_paneScrollStates",
"[",
"pane",
".",
"id",
"]",
",",
"heightDelta",
")",
";",
"delete",
"_paneScrollStates",
"[",
"pane",
".",
"id",
"]",
";",
"}",
")",
";",
"}"
] | Restores the scroll state from cache and applies the heightDelta
The view implementation is responsible for applying or ignoring the heightDelta.
This is used primarily when a modal bar opens to keep the editor from scrolling the current
page out of view in order to maintain the appearance.
The state is removed from the cache after calling this function.
@param {!string} paneId - id of the pane in which to adjust the scroll state,
ALL_PANES or ACTIVE_PANE
@param {!number} heightDelta - delta H to apply to the scroll state | [
"Restores",
"the",
"scroll",
"state",
"from",
"cache",
"and",
"applies",
"the",
"heightDelta",
"The",
"view",
"implementation",
"is",
"responsible",
"for",
"applying",
"or",
"ignoring",
"the",
"heightDelta",
".",
"This",
"is",
"used",
"primarily",
"when",
"a",
"modal",
"bar",
"opens",
"to",
"keep",
"the",
"editor",
"from",
"scrolling",
"the",
"current",
"page",
"out",
"of",
"view",
"in",
"order",
"to",
"maintain",
"the",
"appearance",
".",
"The",
"state",
"is",
"removed",
"from",
"the",
"cache",
"after",
"calling",
"this",
"function",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L517-L522 |
2,241 | adobe/brackets | src/view/MainViewManager.js | getWorkingSet | function getWorkingSet(paneId) {
var result = [];
_forEachPaneOrPanes(paneId, function (pane) {
var viewList = pane.getViewList();
result = _.union(result, viewList);
});
return result;
} | javascript | function getWorkingSet(paneId) {
var result = [];
_forEachPaneOrPanes(paneId, function (pane) {
var viewList = pane.getViewList();
result = _.union(result, viewList);
});
return result;
} | [
"function",
"getWorkingSet",
"(",
"paneId",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"function",
"(",
"pane",
")",
"{",
"var",
"viewList",
"=",
"pane",
".",
"getViewList",
"(",
")",
";",
"result",
"=",
"_",
".",
"union",
"(",
"result",
",",
"viewList",
")",
";",
"}",
")",
";",
"return",
"result",
";",
"}"
] | Retrieves the WorkingSet for the given paneId not including temporary views
@param {!string} paneId - id of the pane in which to get the view list, ALL_PANES or ACTIVE_PANE
@return {Array.<File>} | [
"Retrieves",
"the",
"WorkingSet",
"for",
"the",
"given",
"paneId",
"not",
"including",
"temporary",
"views"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L530-L539 |
2,242 | adobe/brackets | src/view/MainViewManager.js | getAllOpenFiles | function getAllOpenFiles() {
var result = getWorkingSet(ALL_PANES);
_.forEach(_panes, function (pane) {
var file = pane.getCurrentlyViewedFile();
if (file) {
result = _.union(result, [file]);
}
});
return result;
} | javascript | function getAllOpenFiles() {
var result = getWorkingSet(ALL_PANES);
_.forEach(_panes, function (pane) {
var file = pane.getCurrentlyViewedFile();
if (file) {
result = _.union(result, [file]);
}
});
return result;
} | [
"function",
"getAllOpenFiles",
"(",
")",
"{",
"var",
"result",
"=",
"getWorkingSet",
"(",
"ALL_PANES",
")",
";",
"_",
".",
"forEach",
"(",
"_panes",
",",
"function",
"(",
"pane",
")",
"{",
"var",
"file",
"=",
"pane",
".",
"getCurrentlyViewedFile",
"(",
")",
";",
"if",
"(",
"file",
")",
"{",
"result",
"=",
"_",
".",
"union",
"(",
"result",
",",
"[",
"file",
"]",
")",
";",
"}",
"}",
")",
";",
"return",
"result",
";",
"}"
] | Retrieves the list of all open files including temporary views
@return {array.<File>} the list of all open files in all open panes | [
"Retrieves",
"the",
"list",
"of",
"all",
"open",
"files",
"including",
"temporary",
"views"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L546-L555 |
2,243 | adobe/brackets | src/view/MainViewManager.js | getWorkingSetSize | function getWorkingSetSize(paneId) {
var result = 0;
_forEachPaneOrPanes(paneId, function (pane) {
result += pane.getViewListSize();
});
return result;
} | javascript | function getWorkingSetSize(paneId) {
var result = 0;
_forEachPaneOrPanes(paneId, function (pane) {
result += pane.getViewListSize();
});
return result;
} | [
"function",
"getWorkingSetSize",
"(",
"paneId",
")",
"{",
"var",
"result",
"=",
"0",
";",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"function",
"(",
"pane",
")",
"{",
"result",
"+=",
"pane",
".",
"getViewListSize",
"(",
")",
";",
"}",
")",
";",
"return",
"result",
";",
"}"
] | Retrieves the size of the selected pane's view list
@param {!string} paneId - id of the pane in which to get the workingset size.
Can use `ALL_PANES` or `ACTIVE_PANE`
@return {!number} the number of items in the specified pane | [
"Retrieves",
"the",
"size",
"of",
"the",
"selected",
"pane",
"s",
"view",
"list"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L571-L577 |
2,244 | adobe/brackets | src/view/MainViewManager.js | findInAllWorkingSets | function findInAllWorkingSets(fullPath) {
var index,
result = [];
_.forEach(_panes, function (pane) {
index = pane.findInViewList(fullPath);
if (index >= 0) {
result.push({paneId: pane.id, index: index});
}
});
return result;
} | javascript | function findInAllWorkingSets(fullPath) {
var index,
result = [];
_.forEach(_panes, function (pane) {
index = pane.findInViewList(fullPath);
if (index >= 0) {
result.push({paneId: pane.id, index: index});
}
});
return result;
} | [
"function",
"findInAllWorkingSets",
"(",
"fullPath",
")",
"{",
"var",
"index",
",",
"result",
"=",
"[",
"]",
";",
"_",
".",
"forEach",
"(",
"_panes",
",",
"function",
"(",
"pane",
")",
"{",
"index",
"=",
"pane",
".",
"findInViewList",
"(",
"fullPath",
")",
";",
"if",
"(",
"index",
">=",
"0",
")",
"{",
"result",
".",
"push",
"(",
"{",
"paneId",
":",
"pane",
".",
"id",
",",
"index",
":",
"index",
"}",
")",
";",
"}",
"}",
")",
";",
"return",
"result",
";",
"}"
] | Finds all instances of the specified file in all working sets.
If there is a temporary view of the file, it is not part of the result set
@param {!string} fullPath - path of the file to find views of
@return {Array.<{pane:string, index:number}>} an array of paneId/index records | [
"Finds",
"all",
"instances",
"of",
"the",
"specified",
"file",
"in",
"all",
"working",
"sets",
".",
"If",
"there",
"is",
"a",
"temporary",
"view",
"of",
"the",
"file",
"it",
"is",
"not",
"part",
"of",
"the",
"result",
"set"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L623-L635 |
2,245 | adobe/brackets | src/view/MainViewManager.js | addToWorkingSet | function addToWorkingSet(paneId, file, index, force) {
// look for the file to have already been added to another pane
var pane = _getPane(paneId);
if (!pane) {
throw new Error("invalid pane id: " + paneId);
}
var result = pane.reorderItem(file, index, force),
entry = _makeMRUListEntry(file, pane.id);
// handles the case of save as so that the file remains in the
// the same location in the working set as the file that was renamed
if (result === pane.ITEM_FOUND_NEEDS_SORT) {
console.warn("pane.reorderItem returned pane.ITEM_FOUND_NEEDS_SORT which shouldn't happen " + file);
exports.trigger("workingSetSort", pane.id);
} else if (result === pane.ITEM_NOT_FOUND) {
index = pane.addToViewList(file, index);
if (_findFileInMRUList(pane.id, file) === -1) {
// Add to or update the position in MRU
if (pane.getCurrentlyViewedFile() === file) {
_mruList.unshift(entry);
} else {
_mruList.push(entry);
}
}
exports.trigger("workingSetAdd", file, index, pane.id);
}
} | javascript | function addToWorkingSet(paneId, file, index, force) {
// look for the file to have already been added to another pane
var pane = _getPane(paneId);
if (!pane) {
throw new Error("invalid pane id: " + paneId);
}
var result = pane.reorderItem(file, index, force),
entry = _makeMRUListEntry(file, pane.id);
// handles the case of save as so that the file remains in the
// the same location in the working set as the file that was renamed
if (result === pane.ITEM_FOUND_NEEDS_SORT) {
console.warn("pane.reorderItem returned pane.ITEM_FOUND_NEEDS_SORT which shouldn't happen " + file);
exports.trigger("workingSetSort", pane.id);
} else if (result === pane.ITEM_NOT_FOUND) {
index = pane.addToViewList(file, index);
if (_findFileInMRUList(pane.id, file) === -1) {
// Add to or update the position in MRU
if (pane.getCurrentlyViewedFile() === file) {
_mruList.unshift(entry);
} else {
_mruList.push(entry);
}
}
exports.trigger("workingSetAdd", file, index, pane.id);
}
} | [
"function",
"addToWorkingSet",
"(",
"paneId",
",",
"file",
",",
"index",
",",
"force",
")",
"{",
"// look for the file to have already been added to another pane",
"var",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"if",
"(",
"!",
"pane",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"invalid pane id: \"",
"+",
"paneId",
")",
";",
"}",
"var",
"result",
"=",
"pane",
".",
"reorderItem",
"(",
"file",
",",
"index",
",",
"force",
")",
",",
"entry",
"=",
"_makeMRUListEntry",
"(",
"file",
",",
"pane",
".",
"id",
")",
";",
"// handles the case of save as so that the file remains in the",
"// the same location in the working set as the file that was renamed",
"if",
"(",
"result",
"===",
"pane",
".",
"ITEM_FOUND_NEEDS_SORT",
")",
"{",
"console",
".",
"warn",
"(",
"\"pane.reorderItem returned pane.ITEM_FOUND_NEEDS_SORT which shouldn't happen \"",
"+",
"file",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetSort\"",
",",
"pane",
".",
"id",
")",
";",
"}",
"else",
"if",
"(",
"result",
"===",
"pane",
".",
"ITEM_NOT_FOUND",
")",
"{",
"index",
"=",
"pane",
".",
"addToViewList",
"(",
"file",
",",
"index",
")",
";",
"if",
"(",
"_findFileInMRUList",
"(",
"pane",
".",
"id",
",",
"file",
")",
"===",
"-",
"1",
")",
"{",
"// Add to or update the position in MRU",
"if",
"(",
"pane",
".",
"getCurrentlyViewedFile",
"(",
")",
"===",
"file",
")",
"{",
"_mruList",
".",
"unshift",
"(",
"entry",
")",
";",
"}",
"else",
"{",
"_mruList",
".",
"push",
"(",
"entry",
")",
";",
"}",
"}",
"exports",
".",
"trigger",
"(",
"\"workingSetAdd\"",
",",
"file",
",",
"index",
",",
"pane",
".",
"id",
")",
";",
"}",
"}"
] | Adds the given file to the end of the workingset, if it is not already there.
This API does not create a view of the file, it just adds it to the working set
Views of files in the working set are persisted and are not destroyed until the user
closes the file using FILE_CLOSE; Views are created using FILE_OPEN and, when opened, are
made the current view. If a File is already opened then the file is just made current
and its view is shown.
@param {!string} paneId - The id of the pane in which to add the file object to or ACTIVE_PANE
@param {!File} file - The File object to add to the workingset
@param {number=} index - Position to add to list (defaults to last); -1 is ignored
@param {boolean=} forceRedraw - If true, a workingset change notification is always sent
(useful if suppressRedraw was used with removeView() earlier) | [
"Adds",
"the",
"given",
"file",
"to",
"the",
"end",
"of",
"the",
"workingset",
"if",
"it",
"is",
"not",
"already",
"there",
".",
"This",
"API",
"does",
"not",
"create",
"a",
"view",
"of",
"the",
"file",
"it",
"just",
"adds",
"it",
"to",
"the",
"working",
"set",
"Views",
"of",
"files",
"in",
"the",
"working",
"set",
"are",
"persisted",
"and",
"are",
"not",
"destroyed",
"until",
"the",
"user",
"closes",
"the",
"file",
"using",
"FILE_CLOSE",
";",
"Views",
"are",
"created",
"using",
"FILE_OPEN",
"and",
"when",
"opened",
"are",
"made",
"the",
"current",
"view",
".",
"If",
"a",
"File",
"is",
"already",
"opened",
"then",
"the",
"file",
"is",
"just",
"made",
"current",
"and",
"its",
"view",
"is",
"shown",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L709-L739 |
2,246 | adobe/brackets | src/view/MainViewManager.js | addListToWorkingSet | function addListToWorkingSet(paneId, fileList) {
var uniqueFileList,
pane = _getPane(paneId);
uniqueFileList = pane.addListToViewList(fileList);
uniqueFileList.forEach(function (file) {
if (_findFileInMRUList(pane.id, file) !== -1) {
console.log(file.fullPath + " duplicated in mru list");
}
_mruList.push(_makeMRUListEntry(file, pane.id));
});
exports.trigger("workingSetAddList", uniqueFileList, pane.id);
// find all of the files that could be added but were not
var unsolvedList = fileList.filter(function (item) {
// if the file open in another pane, then add it to the list of unsolvedList
return (pane.findInViewList(item.fullPath) === -1 && _getPaneIdForPath(item.fullPath));
});
// Use the pane id of the first one in the list for pane id and recurse
// if we add more panes, then this will recurse until all items in the list are satisified
if (unsolvedList.length) {
addListToWorkingSet(_getPaneIdForPath(unsolvedList[0].fullPath), unsolvedList);
}
} | javascript | function addListToWorkingSet(paneId, fileList) {
var uniqueFileList,
pane = _getPane(paneId);
uniqueFileList = pane.addListToViewList(fileList);
uniqueFileList.forEach(function (file) {
if (_findFileInMRUList(pane.id, file) !== -1) {
console.log(file.fullPath + " duplicated in mru list");
}
_mruList.push(_makeMRUListEntry(file, pane.id));
});
exports.trigger("workingSetAddList", uniqueFileList, pane.id);
// find all of the files that could be added but were not
var unsolvedList = fileList.filter(function (item) {
// if the file open in another pane, then add it to the list of unsolvedList
return (pane.findInViewList(item.fullPath) === -1 && _getPaneIdForPath(item.fullPath));
});
// Use the pane id of the first one in the list for pane id and recurse
// if we add more panes, then this will recurse until all items in the list are satisified
if (unsolvedList.length) {
addListToWorkingSet(_getPaneIdForPath(unsolvedList[0].fullPath), unsolvedList);
}
} | [
"function",
"addListToWorkingSet",
"(",
"paneId",
",",
"fileList",
")",
"{",
"var",
"uniqueFileList",
",",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"uniqueFileList",
"=",
"pane",
".",
"addListToViewList",
"(",
"fileList",
")",
";",
"uniqueFileList",
".",
"forEach",
"(",
"function",
"(",
"file",
")",
"{",
"if",
"(",
"_findFileInMRUList",
"(",
"pane",
".",
"id",
",",
"file",
")",
"!==",
"-",
"1",
")",
"{",
"console",
".",
"log",
"(",
"file",
".",
"fullPath",
"+",
"\" duplicated in mru list\"",
")",
";",
"}",
"_mruList",
".",
"push",
"(",
"_makeMRUListEntry",
"(",
"file",
",",
"pane",
".",
"id",
")",
")",
";",
"}",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetAddList\"",
",",
"uniqueFileList",
",",
"pane",
".",
"id",
")",
";",
"// find all of the files that could be added but were not",
"var",
"unsolvedList",
"=",
"fileList",
".",
"filter",
"(",
"function",
"(",
"item",
")",
"{",
"// if the file open in another pane, then add it to the list of unsolvedList",
"return",
"(",
"pane",
".",
"findInViewList",
"(",
"item",
".",
"fullPath",
")",
"===",
"-",
"1",
"&&",
"_getPaneIdForPath",
"(",
"item",
".",
"fullPath",
")",
")",
";",
"}",
")",
";",
"// Use the pane id of the first one in the list for pane id and recurse",
"// if we add more panes, then this will recurse until all items in the list are satisified",
"if",
"(",
"unsolvedList",
".",
"length",
")",
"{",
"addListToWorkingSet",
"(",
"_getPaneIdForPath",
"(",
"unsolvedList",
"[",
"0",
"]",
".",
"fullPath",
")",
",",
"unsolvedList",
")",
";",
"}",
"}"
] | Adds the given file list to the end of the workingset.
@param {!string} paneId - The id of the pane in which to add the file object to or ACTIVE_PANE
@param {!Array.<File>} fileList - Array of files to add to the pane | [
"Adds",
"the",
"given",
"file",
"list",
"to",
"the",
"end",
"of",
"the",
"workingset",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L746-L772 |
2,247 | adobe/brackets | src/view/MainViewManager.js | _removeFileFromMRU | function _removeFileFromMRU(paneId, file) {
var index,
compare = function (record) {
return (record.file === file && record.paneId === paneId);
};
// find and remove all instances
do {
index = _.findIndex(_mruList, compare);
if (index !== -1) {
_mruList.splice(index, 1);
}
} while (index !== -1);
} | javascript | function _removeFileFromMRU(paneId, file) {
var index,
compare = function (record) {
return (record.file === file && record.paneId === paneId);
};
// find and remove all instances
do {
index = _.findIndex(_mruList, compare);
if (index !== -1) {
_mruList.splice(index, 1);
}
} while (index !== -1);
} | [
"function",
"_removeFileFromMRU",
"(",
"paneId",
",",
"file",
")",
"{",
"var",
"index",
",",
"compare",
"=",
"function",
"(",
"record",
")",
"{",
"return",
"(",
"record",
".",
"file",
"===",
"file",
"&&",
"record",
".",
"paneId",
"===",
"paneId",
")",
";",
"}",
";",
"// find and remove all instances",
"do",
"{",
"index",
"=",
"_",
".",
"findIndex",
"(",
"_mruList",
",",
"compare",
")",
";",
"if",
"(",
"index",
"!==",
"-",
"1",
")",
"{",
"_mruList",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"}",
"}",
"while",
"(",
"index",
"!==",
"-",
"1",
")",
";",
"}"
] | Removes a file from the global MRU list. Future versions of this
implementation may support the ALL_PANES constant but FOCUS_PANE is not allowed
@param {!string} paneId - Must be a valid paneId (not a shortcut e.g. ALL_PANES)
@ @param {File} file The file object to remove.
@private | [
"Removes",
"a",
"file",
"from",
"the",
"global",
"MRU",
"list",
".",
"Future",
"versions",
"of",
"this",
"implementation",
"may",
"support",
"the",
"ALL_PANES",
"constant",
"but",
"FOCUS_PANE",
"is",
"not",
"allowed"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L781-L794 |
2,248 | adobe/brackets | src/view/MainViewManager.js | _removeView | function _removeView(paneId, file, suppressRedraw) {
var pane = _getPane(paneId);
if (pane.removeView(file)) {
_removeFileFromMRU(pane.id, file);
exports.trigger("workingSetRemove", file, suppressRedraw, pane.id);
}
} | javascript | function _removeView(paneId, file, suppressRedraw) {
var pane = _getPane(paneId);
if (pane.removeView(file)) {
_removeFileFromMRU(pane.id, file);
exports.trigger("workingSetRemove", file, suppressRedraw, pane.id);
}
} | [
"function",
"_removeView",
"(",
"paneId",
",",
"file",
",",
"suppressRedraw",
")",
"{",
"var",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"if",
"(",
"pane",
".",
"removeView",
"(",
"file",
")",
")",
"{",
"_removeFileFromMRU",
"(",
"pane",
".",
"id",
",",
"file",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetRemove\"",
",",
"file",
",",
"suppressRedraw",
",",
"pane",
".",
"id",
")",
";",
"}",
"}"
] | Removes a file the specified pane
@param {!string} paneId - Must be a valid paneId (not a shortcut e.g. ALL_PANES)
@param {!File} file - the File to remove
@param {boolean=} suppressRedraw - true to tell listeners not to redraw
Use the suppressRedraw flag when calling this function along with many changes to prevent flicker
@private | [
"Removes",
"a",
"file",
"the",
"specified",
"pane"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L804-L811 |
2,249 | adobe/brackets | src/view/MainViewManager.js | _moveView | function _moveView(sourcePaneId, destinationPaneId, file, destinationIndex) {
var result = new $.Deferred(),
sourcePane = _getPane(sourcePaneId),
destinationPane = _getPane(destinationPaneId);
sourcePane.moveView(file, destinationPane, destinationIndex)
.done(function () {
// remove existing entry from mrulist for the same document if present
_removeFileFromMRU(destinationPane.id, file);
// update the mru list
_mruList.every(function (record) {
if (record.file === file && record.paneId === sourcePane.id) {
record.paneId = destinationPane.id;
return false;
}
return true;
});
exports.trigger("workingSetMove", file, sourcePane.id, destinationPane.id);
result.resolve();
});
return result.promise();
} | javascript | function _moveView(sourcePaneId, destinationPaneId, file, destinationIndex) {
var result = new $.Deferred(),
sourcePane = _getPane(sourcePaneId),
destinationPane = _getPane(destinationPaneId);
sourcePane.moveView(file, destinationPane, destinationIndex)
.done(function () {
// remove existing entry from mrulist for the same document if present
_removeFileFromMRU(destinationPane.id, file);
// update the mru list
_mruList.every(function (record) {
if (record.file === file && record.paneId === sourcePane.id) {
record.paneId = destinationPane.id;
return false;
}
return true;
});
exports.trigger("workingSetMove", file, sourcePane.id, destinationPane.id);
result.resolve();
});
return result.promise();
} | [
"function",
"_moveView",
"(",
"sourcePaneId",
",",
"destinationPaneId",
",",
"file",
",",
"destinationIndex",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"sourcePane",
"=",
"_getPane",
"(",
"sourcePaneId",
")",
",",
"destinationPane",
"=",
"_getPane",
"(",
"destinationPaneId",
")",
";",
"sourcePane",
".",
"moveView",
"(",
"file",
",",
"destinationPane",
",",
"destinationIndex",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"// remove existing entry from mrulist for the same document if present ",
"_removeFileFromMRU",
"(",
"destinationPane",
".",
"id",
",",
"file",
")",
";",
"// update the mru list",
"_mruList",
".",
"every",
"(",
"function",
"(",
"record",
")",
"{",
"if",
"(",
"record",
".",
"file",
"===",
"file",
"&&",
"record",
".",
"paneId",
"===",
"sourcePane",
".",
"id",
")",
"{",
"record",
".",
"paneId",
"=",
"destinationPane",
".",
"id",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetMove\"",
",",
"file",
",",
"sourcePane",
".",
"id",
",",
"destinationPane",
".",
"id",
")",
";",
"result",
".",
"resolve",
"(",
")",
";",
"}",
")",
";",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] | moves a view from one pane to another
@param {!string} sourcePaneId - id of the source pane
@param {!string} destinationPaneId - id of the destination pane
@param {!File} file - the File to move
@param {Number} destinationIndex - the working set index of the file in the destination pane
@return {jQuery.Promise} a promise that resolves when the move has completed.
@private | [
"moves",
"a",
"view",
"from",
"one",
"pane",
"to",
"another"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L822-L844 |
2,250 | adobe/brackets | src/view/MainViewManager.js | _removeDeletedFileFromMRU | function _removeDeletedFileFromMRU(e, fullPath) {
var index,
compare = function (record) {
return (record.file.fullPath === fullPath);
};
// find and remove all instances
do {
index = _.findIndex(_mruList, compare);
if (index !== -1) {
_mruList.splice(index, 1);
}
} while (index !== -1);
} | javascript | function _removeDeletedFileFromMRU(e, fullPath) {
var index,
compare = function (record) {
return (record.file.fullPath === fullPath);
};
// find and remove all instances
do {
index = _.findIndex(_mruList, compare);
if (index !== -1) {
_mruList.splice(index, 1);
}
} while (index !== -1);
} | [
"function",
"_removeDeletedFileFromMRU",
"(",
"e",
",",
"fullPath",
")",
"{",
"var",
"index",
",",
"compare",
"=",
"function",
"(",
"record",
")",
"{",
"return",
"(",
"record",
".",
"file",
".",
"fullPath",
"===",
"fullPath",
")",
";",
"}",
";",
"// find and remove all instances",
"do",
"{",
"index",
"=",
"_",
".",
"findIndex",
"(",
"_mruList",
",",
"compare",
")",
";",
"if",
"(",
"index",
"!==",
"-",
"1",
")",
"{",
"_mruList",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"}",
"}",
"while",
"(",
"index",
"!==",
"-",
"1",
")",
";",
"}"
] | DocumentManager.pathDeleted Event handler to remove a file
from the MRU list
@param {!jQuery.event} e -
@param {!string} fullPath - path of the file to remove
@private | [
"DocumentManager",
".",
"pathDeleted",
"Event",
"handler",
"to",
"remove",
"a",
"file",
"from",
"the",
"MRU",
"list"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L866-L879 |
2,251 | adobe/brackets | src/view/MainViewManager.js | _sortWorkingSet | function _sortWorkingSet(paneId, compareFn) {
_forEachPaneOrPanes(paneId, function (pane) {
pane.sortViewList(compareFn);
exports.trigger("workingSetSort", pane.id);
});
} | javascript | function _sortWorkingSet(paneId, compareFn) {
_forEachPaneOrPanes(paneId, function (pane) {
pane.sortViewList(compareFn);
exports.trigger("workingSetSort", pane.id);
});
} | [
"function",
"_sortWorkingSet",
"(",
"paneId",
",",
"compareFn",
")",
"{",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"function",
"(",
"pane",
")",
"{",
"pane",
".",
"sortViewList",
"(",
"compareFn",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetSort\"",
",",
"pane",
".",
"id",
")",
";",
"}",
")",
";",
"}"
] | sorts the pane's view list
@param {!string} paneId - id of the pane to sort, ALL_PANES or ACTIVE_PANE
@param {sortFunctionCallback} compareFn - callback to determine sort order (called on each item)
@see {@link Pane#sortViewList} for more information
@see {@link https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/sort|Sort Array - MDN}
@private | [
"sorts",
"the",
"pane",
"s",
"view",
"list"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L889-L894 |
2,252 | adobe/brackets | src/view/MainViewManager.js | _moveWorkingSetItem | function _moveWorkingSetItem(paneId, fromIndex, toIndex) {
var pane = _getPane(paneId);
pane.moveWorkingSetItem(fromIndex, toIndex);
exports.trigger("workingSetSort", pane.id);
exports.trigger("_workingSetDisableAutoSort", pane.id);
} | javascript | function _moveWorkingSetItem(paneId, fromIndex, toIndex) {
var pane = _getPane(paneId);
pane.moveWorkingSetItem(fromIndex, toIndex);
exports.trigger("workingSetSort", pane.id);
exports.trigger("_workingSetDisableAutoSort", pane.id);
} | [
"function",
"_moveWorkingSetItem",
"(",
"paneId",
",",
"fromIndex",
",",
"toIndex",
")",
"{",
"var",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"pane",
".",
"moveWorkingSetItem",
"(",
"fromIndex",
",",
"toIndex",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetSort\"",
",",
"pane",
".",
"id",
")",
";",
"exports",
".",
"trigger",
"(",
"\"_workingSetDisableAutoSort\"",
",",
"pane",
".",
"id",
")",
";",
"}"
] | moves a working set item from one index to another shifting the items
after in the working set up and reinserting it at the desired location
@param {!string} paneId - id of the pane to sort
@param {!number} fromIndex - the index of the item to move
@param {!number} toIndex - the index to move to
@private | [
"moves",
"a",
"working",
"set",
"item",
"from",
"one",
"index",
"to",
"another",
"shifting",
"the",
"items",
"after",
"in",
"the",
"working",
"set",
"up",
"and",
"reinserting",
"it",
"at",
"the",
"desired",
"location"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L904-L910 |
2,253 | adobe/brackets | src/view/MainViewManager.js | _swapWorkingSetListIndexes | function _swapWorkingSetListIndexes(paneId, index1, index2) {
var pane = _getPane(paneId);
pane.swapViewListIndexes(index1, index2);
exports.trigger("workingSetSort", pane.id);
exports.trigger("_workingSetDisableAutoSort", pane.id);
} | javascript | function _swapWorkingSetListIndexes(paneId, index1, index2) {
var pane = _getPane(paneId);
pane.swapViewListIndexes(index1, index2);
exports.trigger("workingSetSort", pane.id);
exports.trigger("_workingSetDisableAutoSort", pane.id);
} | [
"function",
"_swapWorkingSetListIndexes",
"(",
"paneId",
",",
"index1",
",",
"index2",
")",
"{",
"var",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"pane",
".",
"swapViewListIndexes",
"(",
"index1",
",",
"index2",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetSort\"",
",",
"pane",
".",
"id",
")",
";",
"exports",
".",
"trigger",
"(",
"\"_workingSetDisableAutoSort\"",
",",
"pane",
".",
"id",
")",
";",
"}"
] | Mutually exchanges the files at the indexes passed by parameters.
@param {!string} paneId - id of the pane to swap indices or ACTIVE_PANE
@param {!number} index1 - the index on the left
@param {!number} index2 - the index on the rigth
@private | [
"Mutually",
"exchanges",
"the",
"files",
"at",
"the",
"indexes",
"passed",
"by",
"parameters",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L919-L925 |
2,254 | adobe/brackets | src/view/MainViewManager.js | traverseToNextViewByMRU | function traverseToNextViewByMRU(direction) {
var file = getCurrentlyViewedFile(),
paneId = getActivePaneId(),
index = _.findIndex(_mruList, function (record) {
return (record.file === file && record.paneId === paneId);
});
return ViewUtils.traverseViewArray(_mruList, index, direction);
} | javascript | function traverseToNextViewByMRU(direction) {
var file = getCurrentlyViewedFile(),
paneId = getActivePaneId(),
index = _.findIndex(_mruList, function (record) {
return (record.file === file && record.paneId === paneId);
});
return ViewUtils.traverseViewArray(_mruList, index, direction);
} | [
"function",
"traverseToNextViewByMRU",
"(",
"direction",
")",
"{",
"var",
"file",
"=",
"getCurrentlyViewedFile",
"(",
")",
",",
"paneId",
"=",
"getActivePaneId",
"(",
")",
",",
"index",
"=",
"_",
".",
"findIndex",
"(",
"_mruList",
",",
"function",
"(",
"record",
")",
"{",
"return",
"(",
"record",
".",
"file",
"===",
"file",
"&&",
"record",
".",
"paneId",
"===",
"paneId",
")",
";",
"}",
")",
";",
"return",
"ViewUtils",
".",
"traverseViewArray",
"(",
"_mruList",
",",
"index",
",",
"direction",
")",
";",
"}"
] | Get the next or previous file in the MRU list.
@param {!number} direction - Must be 1 or -1 to traverse forward or backward
@return {?{file:File, paneId:string}} The File object of the next item in the traversal order or null if there aren't any files to traverse.
May return current file if there are no other files to traverse. | [
"Get",
"the",
"next",
"or",
"previous",
"file",
"in",
"the",
"MRU",
"list",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L933-L941 |
2,255 | adobe/brackets | src/view/MainViewManager.js | traverseToNextViewInListOrder | function traverseToNextViewInListOrder(direction) {
var file = getCurrentlyViewedFile(),
curPaneId = getActivePaneId(),
allFiles = [],
index;
getPaneIdList().forEach(function (paneId) {
var paneFiles = getWorkingSet(paneId).map(function (file) {
return { file: file, pane: paneId };
});
allFiles = allFiles.concat(paneFiles);
});
index = _.findIndex(allFiles, function (record) {
return (record.file === file && record.pane === curPaneId);
});
return ViewUtils.traverseViewArray(allFiles, index, direction);
} | javascript | function traverseToNextViewInListOrder(direction) {
var file = getCurrentlyViewedFile(),
curPaneId = getActivePaneId(),
allFiles = [],
index;
getPaneIdList().forEach(function (paneId) {
var paneFiles = getWorkingSet(paneId).map(function (file) {
return { file: file, pane: paneId };
});
allFiles = allFiles.concat(paneFiles);
});
index = _.findIndex(allFiles, function (record) {
return (record.file === file && record.pane === curPaneId);
});
return ViewUtils.traverseViewArray(allFiles, index, direction);
} | [
"function",
"traverseToNextViewInListOrder",
"(",
"direction",
")",
"{",
"var",
"file",
"=",
"getCurrentlyViewedFile",
"(",
")",
",",
"curPaneId",
"=",
"getActivePaneId",
"(",
")",
",",
"allFiles",
"=",
"[",
"]",
",",
"index",
";",
"getPaneIdList",
"(",
")",
".",
"forEach",
"(",
"function",
"(",
"paneId",
")",
"{",
"var",
"paneFiles",
"=",
"getWorkingSet",
"(",
"paneId",
")",
".",
"map",
"(",
"function",
"(",
"file",
")",
"{",
"return",
"{",
"file",
":",
"file",
",",
"pane",
":",
"paneId",
"}",
";",
"}",
")",
";",
"allFiles",
"=",
"allFiles",
".",
"concat",
"(",
"paneFiles",
")",
";",
"}",
")",
";",
"index",
"=",
"_",
".",
"findIndex",
"(",
"allFiles",
",",
"function",
"(",
"record",
")",
"{",
"return",
"(",
"record",
".",
"file",
"===",
"file",
"&&",
"record",
".",
"pane",
"===",
"curPaneId",
")",
";",
"}",
")",
";",
"return",
"ViewUtils",
".",
"traverseViewArray",
"(",
"allFiles",
",",
"index",
",",
"direction",
")",
";",
"}"
] | Get the next or previous file in list order.
@param {!number} direction - Must be 1 or -1 to traverse forward or backward
@return {?{file:File, paneId:string}} The File object of the next item in the traversal order or null if there aren't any files to traverse.
May return current file if there are no other files to traverse. | [
"Get",
"the",
"next",
"or",
"previous",
"file",
"in",
"list",
"order",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L949-L967 |
2,256 | adobe/brackets | src/view/MainViewManager.js | _synchronizePaneSize | function _synchronizePaneSize(pane, forceRefresh) {
var available;
if (_orientation === VERTICAL) {
available = _$el.innerWidth();
} else {
available = _$el.innerHeight();
}
// Update the pane's sizer element if it has one and update the max size
Resizer.resyncSizer(pane.$el);
pane.$el.data("maxsize", available - MIN_PANE_SIZE);
pane.updateLayout(forceRefresh);
} | javascript | function _synchronizePaneSize(pane, forceRefresh) {
var available;
if (_orientation === VERTICAL) {
available = _$el.innerWidth();
} else {
available = _$el.innerHeight();
}
// Update the pane's sizer element if it has one and update the max size
Resizer.resyncSizer(pane.$el);
pane.$el.data("maxsize", available - MIN_PANE_SIZE);
pane.updateLayout(forceRefresh);
} | [
"function",
"_synchronizePaneSize",
"(",
"pane",
",",
"forceRefresh",
")",
"{",
"var",
"available",
";",
"if",
"(",
"_orientation",
"===",
"VERTICAL",
")",
"{",
"available",
"=",
"_$el",
".",
"innerWidth",
"(",
")",
";",
"}",
"else",
"{",
"available",
"=",
"_$el",
".",
"innerHeight",
"(",
")",
";",
"}",
"// Update the pane's sizer element if it has one and update the max size",
"Resizer",
".",
"resyncSizer",
"(",
"pane",
".",
"$el",
")",
";",
"pane",
".",
"$el",
".",
"data",
"(",
"\"maxsize\"",
",",
"available",
"-",
"MIN_PANE_SIZE",
")",
";",
"pane",
".",
"updateLayout",
"(",
"forceRefresh",
")",
";",
"}"
] | Synchronizes the pane's sizer element, updates the pane's resizer maxsize value
and tells the pane to update its layout
@param {boolean} forceRefresh - true to force a resize and refresh of the entire view
@private | [
"Synchronizes",
"the",
"pane",
"s",
"sizer",
"element",
"updates",
"the",
"pane",
"s",
"resizer",
"maxsize",
"value",
"and",
"tells",
"the",
"pane",
"to",
"update",
"its",
"layout"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L997-L1010 |
2,257 | adobe/brackets | src/view/MainViewManager.js | _updateLayout | function _updateLayout(event, viewAreaHeight, forceRefresh) {
var available;
if (_orientation === VERTICAL) {
available = _$el.innerWidth();
} else {
available = _$el.innerHeight();
}
_.forEach(_panes, function (pane) {
// For VERTICAL orientation, we set the second pane to be width: auto
// so that it resizes to fill the available space in the containing div
// unfortunately, that doesn't work in the HORIZONTAL orientation so we
// must update the height and convert it into a percentage
if (pane.id === SECOND_PANE && _orientation === HORIZONTAL) {
var percentage = ((_panes[FIRST_PANE].$el.height() + 1) / available);
pane.$el.css("height", 100 - (percentage * 100) + "%");
}
_synchronizePaneSize(pane, forceRefresh);
});
} | javascript | function _updateLayout(event, viewAreaHeight, forceRefresh) {
var available;
if (_orientation === VERTICAL) {
available = _$el.innerWidth();
} else {
available = _$el.innerHeight();
}
_.forEach(_panes, function (pane) {
// For VERTICAL orientation, we set the second pane to be width: auto
// so that it resizes to fill the available space in the containing div
// unfortunately, that doesn't work in the HORIZONTAL orientation so we
// must update the height and convert it into a percentage
if (pane.id === SECOND_PANE && _orientation === HORIZONTAL) {
var percentage = ((_panes[FIRST_PANE].$el.height() + 1) / available);
pane.$el.css("height", 100 - (percentage * 100) + "%");
}
_synchronizePaneSize(pane, forceRefresh);
});
} | [
"function",
"_updateLayout",
"(",
"event",
",",
"viewAreaHeight",
",",
"forceRefresh",
")",
"{",
"var",
"available",
";",
"if",
"(",
"_orientation",
"===",
"VERTICAL",
")",
"{",
"available",
"=",
"_$el",
".",
"innerWidth",
"(",
")",
";",
"}",
"else",
"{",
"available",
"=",
"_$el",
".",
"innerHeight",
"(",
")",
";",
"}",
"_",
".",
"forEach",
"(",
"_panes",
",",
"function",
"(",
"pane",
")",
"{",
"// For VERTICAL orientation, we set the second pane to be width: auto",
"// so that it resizes to fill the available space in the containing div",
"// unfortunately, that doesn't work in the HORIZONTAL orientation so we",
"// must update the height and convert it into a percentage",
"if",
"(",
"pane",
".",
"id",
"===",
"SECOND_PANE",
"&&",
"_orientation",
"===",
"HORIZONTAL",
")",
"{",
"var",
"percentage",
"=",
"(",
"(",
"_panes",
"[",
"FIRST_PANE",
"]",
".",
"$el",
".",
"height",
"(",
")",
"+",
"1",
")",
"/",
"available",
")",
";",
"pane",
".",
"$el",
".",
"css",
"(",
"\"height\"",
",",
"100",
"-",
"(",
"percentage",
"*",
"100",
")",
"+",
"\"%\"",
")",
";",
"}",
"_synchronizePaneSize",
"(",
"pane",
",",
"forceRefresh",
")",
";",
"}",
")",
";",
"}"
] | Event handler for "workspaceUpdateLayout" to update the layout
@param {jQuery.Event} event - jQuery event object
@param {number} viewAreaHeight - unused
@param {boolean} forceRefresh - true to force a resize and refresh of the entire view
@private | [
"Event",
"handler",
"for",
"workspaceUpdateLayout",
"to",
"update",
"the",
"layout"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1020-L1041 |
2,258 | adobe/brackets | src/view/MainViewManager.js | _initialLayout | function _initialLayout(forceRefresh) {
var panes = Object.keys(_panes),
size = 100 / panes.length;
_.forEach(_panes, function (pane) {
if (pane.id === FIRST_PANE) {
if (_orientation === VERTICAL) {
pane.$el.css({height: "100%",
width: size + "%",
float: "left"
});
} else {
pane.$el.css({ height: size + "%",
width: "100%"
});
}
} else {
if (_orientation === VERTICAL) {
pane.$el.css({ height: "100%",
width: "auto",
float: "none"
});
} else {
pane.$el.css({ width: "100%",
height: "50%"
});
}
}
_synchronizePaneSize(pane, forceRefresh);
});
} | javascript | function _initialLayout(forceRefresh) {
var panes = Object.keys(_panes),
size = 100 / panes.length;
_.forEach(_panes, function (pane) {
if (pane.id === FIRST_PANE) {
if (_orientation === VERTICAL) {
pane.$el.css({height: "100%",
width: size + "%",
float: "left"
});
} else {
pane.$el.css({ height: size + "%",
width: "100%"
});
}
} else {
if (_orientation === VERTICAL) {
pane.$el.css({ height: "100%",
width: "auto",
float: "none"
});
} else {
pane.$el.css({ width: "100%",
height: "50%"
});
}
}
_synchronizePaneSize(pane, forceRefresh);
});
} | [
"function",
"_initialLayout",
"(",
"forceRefresh",
")",
"{",
"var",
"panes",
"=",
"Object",
".",
"keys",
"(",
"_panes",
")",
",",
"size",
"=",
"100",
"/",
"panes",
".",
"length",
";",
"_",
".",
"forEach",
"(",
"_panes",
",",
"function",
"(",
"pane",
")",
"{",
"if",
"(",
"pane",
".",
"id",
"===",
"FIRST_PANE",
")",
"{",
"if",
"(",
"_orientation",
"===",
"VERTICAL",
")",
"{",
"pane",
".",
"$el",
".",
"css",
"(",
"{",
"height",
":",
"\"100%\"",
",",
"width",
":",
"size",
"+",
"\"%\"",
",",
"float",
":",
"\"left\"",
"}",
")",
";",
"}",
"else",
"{",
"pane",
".",
"$el",
".",
"css",
"(",
"{",
"height",
":",
"size",
"+",
"\"%\"",
",",
"width",
":",
"\"100%\"",
"}",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"_orientation",
"===",
"VERTICAL",
")",
"{",
"pane",
".",
"$el",
".",
"css",
"(",
"{",
"height",
":",
"\"100%\"",
",",
"width",
":",
"\"auto\"",
",",
"float",
":",
"\"none\"",
"}",
")",
";",
"}",
"else",
"{",
"pane",
".",
"$el",
".",
"css",
"(",
"{",
"width",
":",
"\"100%\"",
",",
"height",
":",
"\"50%\"",
"}",
")",
";",
"}",
"}",
"_synchronizePaneSize",
"(",
"pane",
",",
"forceRefresh",
")",
";",
"}",
")",
";",
"}"
] | Sets up the initial layout so panes are evenly distributed
This also sets css properties that aid in the layout when _updateLayout is called
@param {boolean} forceRefresh - true to force a resize and refresh of the entire view
@private | [
"Sets",
"up",
"the",
"initial",
"layout",
"so",
"panes",
"are",
"evenly",
"distributed",
"This",
"also",
"sets",
"css",
"properties",
"that",
"aid",
"in",
"the",
"layout",
"when",
"_updateLayout",
"is",
"called"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1049-L1080 |
2,259 | adobe/brackets | src/view/MainViewManager.js | _createPaneIfNecessary | function _createPaneIfNecessary(paneId) {
var newPane;
if (!_panes.hasOwnProperty(paneId)) {
newPane = new Pane(paneId, _$el);
_panes[paneId] = newPane;
exports.trigger("paneCreate", newPane.id);
newPane.$el.on("click.mainview dragover.mainview", function () {
setActivePaneId(newPane.id);
});
newPane.on("viewListChange.mainview", function () {
_updatePaneHeaders();
exports.trigger("workingSetUpdate", newPane.id);
});
newPane.on("currentViewChange.mainview", function (e, newView, oldView) {
_updatePaneHeaders();
if (_activePaneId === newPane.id) {
exports.trigger("currentFileChange",
newView && newView.getFile(),
newPane.id, oldView && oldView.getFile(),
newPane.id);
}
});
newPane.on("viewDestroy.mainView", function (e, view) {
_removeFileFromMRU(newPane.id, view.getFile());
});
}
return newPane;
} | javascript | function _createPaneIfNecessary(paneId) {
var newPane;
if (!_panes.hasOwnProperty(paneId)) {
newPane = new Pane(paneId, _$el);
_panes[paneId] = newPane;
exports.trigger("paneCreate", newPane.id);
newPane.$el.on("click.mainview dragover.mainview", function () {
setActivePaneId(newPane.id);
});
newPane.on("viewListChange.mainview", function () {
_updatePaneHeaders();
exports.trigger("workingSetUpdate", newPane.id);
});
newPane.on("currentViewChange.mainview", function (e, newView, oldView) {
_updatePaneHeaders();
if (_activePaneId === newPane.id) {
exports.trigger("currentFileChange",
newView && newView.getFile(),
newPane.id, oldView && oldView.getFile(),
newPane.id);
}
});
newPane.on("viewDestroy.mainView", function (e, view) {
_removeFileFromMRU(newPane.id, view.getFile());
});
}
return newPane;
} | [
"function",
"_createPaneIfNecessary",
"(",
"paneId",
")",
"{",
"var",
"newPane",
";",
"if",
"(",
"!",
"_panes",
".",
"hasOwnProperty",
"(",
"paneId",
")",
")",
"{",
"newPane",
"=",
"new",
"Pane",
"(",
"paneId",
",",
"_$el",
")",
";",
"_panes",
"[",
"paneId",
"]",
"=",
"newPane",
";",
"exports",
".",
"trigger",
"(",
"\"paneCreate\"",
",",
"newPane",
".",
"id",
")",
";",
"newPane",
".",
"$el",
".",
"on",
"(",
"\"click.mainview dragover.mainview\"",
",",
"function",
"(",
")",
"{",
"setActivePaneId",
"(",
"newPane",
".",
"id",
")",
";",
"}",
")",
";",
"newPane",
".",
"on",
"(",
"\"viewListChange.mainview\"",
",",
"function",
"(",
")",
"{",
"_updatePaneHeaders",
"(",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetUpdate\"",
",",
"newPane",
".",
"id",
")",
";",
"}",
")",
";",
"newPane",
".",
"on",
"(",
"\"currentViewChange.mainview\"",
",",
"function",
"(",
"e",
",",
"newView",
",",
"oldView",
")",
"{",
"_updatePaneHeaders",
"(",
")",
";",
"if",
"(",
"_activePaneId",
"===",
"newPane",
".",
"id",
")",
"{",
"exports",
".",
"trigger",
"(",
"\"currentFileChange\"",
",",
"newView",
"&&",
"newView",
".",
"getFile",
"(",
")",
",",
"newPane",
".",
"id",
",",
"oldView",
"&&",
"oldView",
".",
"getFile",
"(",
")",
",",
"newPane",
".",
"id",
")",
";",
"}",
"}",
")",
";",
"newPane",
".",
"on",
"(",
"\"viewDestroy.mainView\"",
",",
"function",
"(",
"e",
",",
"view",
")",
"{",
"_removeFileFromMRU",
"(",
"newPane",
".",
"id",
",",
"view",
".",
"getFile",
"(",
")",
")",
";",
"}",
")",
";",
"}",
"return",
"newPane",
";",
"}"
] | Creates a pane for paneId if one doesn't already exist
@param {!string} paneId - id of the pane to create
@private
@return {?Pane} - the pane object of the new pane, or undefined if no pane created | [
"Creates",
"a",
"pane",
"for",
"paneId",
"if",
"one",
"doesn",
"t",
"already",
"exist"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1098-L1130 |
2,260 | adobe/brackets | src/view/MainViewManager.js | _makeFirstPaneResizable | function _makeFirstPaneResizable() {
var firstPane = _panes[FIRST_PANE];
Resizer.makeResizable(firstPane.$el,
_orientation === HORIZONTAL ? Resizer.DIRECTION_VERTICAL : Resizer.DIRECTION_HORIZONTAL,
_orientation === HORIZONTAL ? Resizer.POSITION_BOTTOM : Resizer.POSITION_RIGHT,
MIN_PANE_SIZE, false, false, false, true, true);
firstPane.$el.on("panelResizeUpdate", function () {
_updateLayout();
});
} | javascript | function _makeFirstPaneResizable() {
var firstPane = _panes[FIRST_PANE];
Resizer.makeResizable(firstPane.$el,
_orientation === HORIZONTAL ? Resizer.DIRECTION_VERTICAL : Resizer.DIRECTION_HORIZONTAL,
_orientation === HORIZONTAL ? Resizer.POSITION_BOTTOM : Resizer.POSITION_RIGHT,
MIN_PANE_SIZE, false, false, false, true, true);
firstPane.$el.on("panelResizeUpdate", function () {
_updateLayout();
});
} | [
"function",
"_makeFirstPaneResizable",
"(",
")",
"{",
"var",
"firstPane",
"=",
"_panes",
"[",
"FIRST_PANE",
"]",
";",
"Resizer",
".",
"makeResizable",
"(",
"firstPane",
".",
"$el",
",",
"_orientation",
"===",
"HORIZONTAL",
"?",
"Resizer",
".",
"DIRECTION_VERTICAL",
":",
"Resizer",
".",
"DIRECTION_HORIZONTAL",
",",
"_orientation",
"===",
"HORIZONTAL",
"?",
"Resizer",
".",
"POSITION_BOTTOM",
":",
"Resizer",
".",
"POSITION_RIGHT",
",",
"MIN_PANE_SIZE",
",",
"false",
",",
"false",
",",
"false",
",",
"true",
",",
"true",
")",
";",
"firstPane",
".",
"$el",
".",
"on",
"(",
"\"panelResizeUpdate\"",
",",
"function",
"(",
")",
"{",
"_updateLayout",
"(",
")",
";",
"}",
")",
";",
"}"
] | Makes the first pane resizable
@private | [
"Makes",
"the",
"first",
"pane",
"resizable"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1136-L1146 |
2,261 | adobe/brackets | src/view/MainViewManager.js | _doSplit | function _doSplit(orientation) {
var firstPane, newPane;
if (orientation === _orientation) {
return;
}
firstPane = _panes[FIRST_PANE];
Resizer.removeSizable(firstPane.$el);
if (_orientation) {
_$el.removeClass("split-" + _orientation.toLowerCase());
}
_$el.addClass("split-" + orientation.toLowerCase());
_orientation = orientation;
newPane = _createPaneIfNecessary(SECOND_PANE);
_makeFirstPaneResizable();
// reset the layout to 50/50 split
// if we changed orientation then
// the percentages are reset as well
_initialLayout();
exports.trigger("paneLayoutChange", _orientation);
// if new pane was created, and original pane is not empty, make new pane the active pane
if (newPane && getCurrentlyViewedFile(firstPane.id)) {
setActivePaneId(newPane.id);
}
} | javascript | function _doSplit(orientation) {
var firstPane, newPane;
if (orientation === _orientation) {
return;
}
firstPane = _panes[FIRST_PANE];
Resizer.removeSizable(firstPane.$el);
if (_orientation) {
_$el.removeClass("split-" + _orientation.toLowerCase());
}
_$el.addClass("split-" + orientation.toLowerCase());
_orientation = orientation;
newPane = _createPaneIfNecessary(SECOND_PANE);
_makeFirstPaneResizable();
// reset the layout to 50/50 split
// if we changed orientation then
// the percentages are reset as well
_initialLayout();
exports.trigger("paneLayoutChange", _orientation);
// if new pane was created, and original pane is not empty, make new pane the active pane
if (newPane && getCurrentlyViewedFile(firstPane.id)) {
setActivePaneId(newPane.id);
}
} | [
"function",
"_doSplit",
"(",
"orientation",
")",
"{",
"var",
"firstPane",
",",
"newPane",
";",
"if",
"(",
"orientation",
"===",
"_orientation",
")",
"{",
"return",
";",
"}",
"firstPane",
"=",
"_panes",
"[",
"FIRST_PANE",
"]",
";",
"Resizer",
".",
"removeSizable",
"(",
"firstPane",
".",
"$el",
")",
";",
"if",
"(",
"_orientation",
")",
"{",
"_$el",
".",
"removeClass",
"(",
"\"split-\"",
"+",
"_orientation",
".",
"toLowerCase",
"(",
")",
")",
";",
"}",
"_$el",
".",
"addClass",
"(",
"\"split-\"",
"+",
"orientation",
".",
"toLowerCase",
"(",
")",
")",
";",
"_orientation",
"=",
"orientation",
";",
"newPane",
"=",
"_createPaneIfNecessary",
"(",
"SECOND_PANE",
")",
";",
"_makeFirstPaneResizable",
"(",
")",
";",
"// reset the layout to 50/50 split",
"// if we changed orientation then",
"// the percentages are reset as well",
"_initialLayout",
"(",
")",
";",
"exports",
".",
"trigger",
"(",
"\"paneLayoutChange\"",
",",
"_orientation",
")",
";",
"// if new pane was created, and original pane is not empty, make new pane the active pane",
"if",
"(",
"newPane",
"&&",
"getCurrentlyViewedFile",
"(",
"firstPane",
".",
"id",
")",
")",
"{",
"setActivePaneId",
"(",
"newPane",
".",
"id",
")",
";",
"}",
"}"
] | Creates a split for the specified orientation
@private
@param {!string} orientation (VERTICAL|HORIZONTAL) | [
"Creates",
"a",
"split",
"for",
"the",
"specified",
"orientation"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1154-L1184 |
2,262 | adobe/brackets | src/view/MainViewManager.js | _open | function _open(paneId, file, optionsIn) {
var result = new $.Deferred(),
options = optionsIn || {};
function doPostOpenActivation() {
if (!options.noPaneActivate) {
setActivePaneId(paneId);
}
}
if (!file || !_getPane(paneId)) {
return result.reject("bad argument").promise();
}
// See if there is already a view for the file
var pane = _getPane(paneId);
// See if there is a factory to create a view for this file
// we want to do this first because, we don't want our internal
// editor to edit files for which there are suitable viewfactories
var factory = MainViewFactory.findSuitableFactoryForPath(file.fullPath);
if (factory) {
file.exists(function (fileError, fileExists) {
if (fileExists) {
// let the factory open the file and create a view for it
factory.openFile(file, pane)
.done(function () {
// if we opened a file that isn't in the project
// then add the file to the working set
if (!ProjectManager.isWithinProject(file.fullPath)) {
addToWorkingSet(paneId, file);
}
doPostOpenActivation();
result.resolve(file);
})
.fail(function (fileError) {
result.reject(fileError);
});
} else {
result.reject(fileError || FileSystemError.NOT_FOUND);
}
});
} else {
DocumentManager.getDocumentForPath(file.fullPath, file)
.done(function (doc) {
if (doc) {
_edit(paneId, doc, $.extend({}, options, {
noPaneActivate: true
}));
doPostOpenActivation();
result.resolve(doc.file);
} else {
result.resolve(null);
}
})
.fail(function (fileError) {
result.reject(fileError);
});
}
result.done(function () {
_makeFileMostRecent(paneId, file);
});
return result;
} | javascript | function _open(paneId, file, optionsIn) {
var result = new $.Deferred(),
options = optionsIn || {};
function doPostOpenActivation() {
if (!options.noPaneActivate) {
setActivePaneId(paneId);
}
}
if (!file || !_getPane(paneId)) {
return result.reject("bad argument").promise();
}
// See if there is already a view for the file
var pane = _getPane(paneId);
// See if there is a factory to create a view for this file
// we want to do this first because, we don't want our internal
// editor to edit files for which there are suitable viewfactories
var factory = MainViewFactory.findSuitableFactoryForPath(file.fullPath);
if (factory) {
file.exists(function (fileError, fileExists) {
if (fileExists) {
// let the factory open the file and create a view for it
factory.openFile(file, pane)
.done(function () {
// if we opened a file that isn't in the project
// then add the file to the working set
if (!ProjectManager.isWithinProject(file.fullPath)) {
addToWorkingSet(paneId, file);
}
doPostOpenActivation();
result.resolve(file);
})
.fail(function (fileError) {
result.reject(fileError);
});
} else {
result.reject(fileError || FileSystemError.NOT_FOUND);
}
});
} else {
DocumentManager.getDocumentForPath(file.fullPath, file)
.done(function (doc) {
if (doc) {
_edit(paneId, doc, $.extend({}, options, {
noPaneActivate: true
}));
doPostOpenActivation();
result.resolve(doc.file);
} else {
result.resolve(null);
}
})
.fail(function (fileError) {
result.reject(fileError);
});
}
result.done(function () {
_makeFileMostRecent(paneId, file);
});
return result;
} | [
"function",
"_open",
"(",
"paneId",
",",
"file",
",",
"optionsIn",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"options",
"=",
"optionsIn",
"||",
"{",
"}",
";",
"function",
"doPostOpenActivation",
"(",
")",
"{",
"if",
"(",
"!",
"options",
".",
"noPaneActivate",
")",
"{",
"setActivePaneId",
"(",
"paneId",
")",
";",
"}",
"}",
"if",
"(",
"!",
"file",
"||",
"!",
"_getPane",
"(",
"paneId",
")",
")",
"{",
"return",
"result",
".",
"reject",
"(",
"\"bad argument\"",
")",
".",
"promise",
"(",
")",
";",
"}",
"// See if there is already a view for the file",
"var",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"// See if there is a factory to create a view for this file",
"// we want to do this first because, we don't want our internal",
"// editor to edit files for which there are suitable viewfactories",
"var",
"factory",
"=",
"MainViewFactory",
".",
"findSuitableFactoryForPath",
"(",
"file",
".",
"fullPath",
")",
";",
"if",
"(",
"factory",
")",
"{",
"file",
".",
"exists",
"(",
"function",
"(",
"fileError",
",",
"fileExists",
")",
"{",
"if",
"(",
"fileExists",
")",
"{",
"// let the factory open the file and create a view for it",
"factory",
".",
"openFile",
"(",
"file",
",",
"pane",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"// if we opened a file that isn't in the project",
"// then add the file to the working set",
"if",
"(",
"!",
"ProjectManager",
".",
"isWithinProject",
"(",
"file",
".",
"fullPath",
")",
")",
"{",
"addToWorkingSet",
"(",
"paneId",
",",
"file",
")",
";",
"}",
"doPostOpenActivation",
"(",
")",
";",
"result",
".",
"resolve",
"(",
"file",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"fileError",
")",
"{",
"result",
".",
"reject",
"(",
"fileError",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"result",
".",
"reject",
"(",
"fileError",
"||",
"FileSystemError",
".",
"NOT_FOUND",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"DocumentManager",
".",
"getDocumentForPath",
"(",
"file",
".",
"fullPath",
",",
"file",
")",
".",
"done",
"(",
"function",
"(",
"doc",
")",
"{",
"if",
"(",
"doc",
")",
"{",
"_edit",
"(",
"paneId",
",",
"doc",
",",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"options",
",",
"{",
"noPaneActivate",
":",
"true",
"}",
")",
")",
";",
"doPostOpenActivation",
"(",
")",
";",
"result",
".",
"resolve",
"(",
"doc",
".",
"file",
")",
";",
"}",
"else",
"{",
"result",
".",
"resolve",
"(",
"null",
")",
";",
"}",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"fileError",
")",
"{",
"result",
".",
"reject",
"(",
"fileError",
")",
";",
"}",
")",
";",
"}",
"result",
".",
"done",
"(",
"function",
"(",
")",
"{",
"_makeFileMostRecent",
"(",
"paneId",
",",
"file",
")",
";",
"}",
")",
";",
"return",
"result",
";",
"}"
] | Opens a file in the specified pane this can be used to open a file with a custom viewer
or a document for editing. If it's a document for editing, edit is called on the document
@param {!string} paneId - id of the pane in which to open the document
@param {!File} file - file to open
@param {{noPaneActivate:boolean=}=} optionsIn - options
@return {jQuery.Promise} promise that resolves to a File object or
rejects with a File error or string | [
"Opens",
"a",
"file",
"in",
"the",
"specified",
"pane",
"this",
"can",
"be",
"used",
"to",
"open",
"a",
"file",
"with",
"a",
"custom",
"viewer",
"or",
"a",
"document",
"for",
"editing",
".",
"If",
"it",
"s",
"a",
"document",
"for",
"editing",
"edit",
"is",
"called",
"on",
"the",
"document"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1227-L1294 |
2,263 | adobe/brackets | src/view/MainViewManager.js | _mergePanes | function _mergePanes() {
if (_panes.hasOwnProperty(SECOND_PANE)) {
var firstPane = _panes[FIRST_PANE],
secondPane = _panes[SECOND_PANE],
fileList = secondPane.getViewList(),
lastViewed = getCurrentlyViewedFile();
Resizer.removeSizable(firstPane.$el);
firstPane.mergeFrom(secondPane);
exports.trigger("workingSetRemoveList", fileList, secondPane.id);
setActivePaneId(firstPane.id);
secondPane.$el.off(".mainview");
secondPane.off(".mainview");
secondPane.destroy();
delete _panes[SECOND_PANE];
exports.trigger("paneDestroy", secondPane.id);
exports.trigger("workingSetAddList", fileList, firstPane.id);
_mruList.forEach(function (record) {
if (record.paneId === secondPane.id) {
record.paneId = firstPane.id;
}
});
_$el.removeClass("split-" + _orientation.toLowerCase());
_orientation = null;
// this will set the remaining pane to 100%
_initialLayout();
exports.trigger("paneLayoutChange", _orientation);
// if the current view before the merger was in the pane
// that went away then reopen it so that it's now the current view again
if (lastViewed && getCurrentlyViewedFile() !== lastViewed) {
exports._open(firstPane.id, lastViewed);
}
}
} | javascript | function _mergePanes() {
if (_panes.hasOwnProperty(SECOND_PANE)) {
var firstPane = _panes[FIRST_PANE],
secondPane = _panes[SECOND_PANE],
fileList = secondPane.getViewList(),
lastViewed = getCurrentlyViewedFile();
Resizer.removeSizable(firstPane.$el);
firstPane.mergeFrom(secondPane);
exports.trigger("workingSetRemoveList", fileList, secondPane.id);
setActivePaneId(firstPane.id);
secondPane.$el.off(".mainview");
secondPane.off(".mainview");
secondPane.destroy();
delete _panes[SECOND_PANE];
exports.trigger("paneDestroy", secondPane.id);
exports.trigger("workingSetAddList", fileList, firstPane.id);
_mruList.forEach(function (record) {
if (record.paneId === secondPane.id) {
record.paneId = firstPane.id;
}
});
_$el.removeClass("split-" + _orientation.toLowerCase());
_orientation = null;
// this will set the remaining pane to 100%
_initialLayout();
exports.trigger("paneLayoutChange", _orientation);
// if the current view before the merger was in the pane
// that went away then reopen it so that it's now the current view again
if (lastViewed && getCurrentlyViewedFile() !== lastViewed) {
exports._open(firstPane.id, lastViewed);
}
}
} | [
"function",
"_mergePanes",
"(",
")",
"{",
"if",
"(",
"_panes",
".",
"hasOwnProperty",
"(",
"SECOND_PANE",
")",
")",
"{",
"var",
"firstPane",
"=",
"_panes",
"[",
"FIRST_PANE",
"]",
",",
"secondPane",
"=",
"_panes",
"[",
"SECOND_PANE",
"]",
",",
"fileList",
"=",
"secondPane",
".",
"getViewList",
"(",
")",
",",
"lastViewed",
"=",
"getCurrentlyViewedFile",
"(",
")",
";",
"Resizer",
".",
"removeSizable",
"(",
"firstPane",
".",
"$el",
")",
";",
"firstPane",
".",
"mergeFrom",
"(",
"secondPane",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetRemoveList\"",
",",
"fileList",
",",
"secondPane",
".",
"id",
")",
";",
"setActivePaneId",
"(",
"firstPane",
".",
"id",
")",
";",
"secondPane",
".",
"$el",
".",
"off",
"(",
"\".mainview\"",
")",
";",
"secondPane",
".",
"off",
"(",
"\".mainview\"",
")",
";",
"secondPane",
".",
"destroy",
"(",
")",
";",
"delete",
"_panes",
"[",
"SECOND_PANE",
"]",
";",
"exports",
".",
"trigger",
"(",
"\"paneDestroy\"",
",",
"secondPane",
".",
"id",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetAddList\"",
",",
"fileList",
",",
"firstPane",
".",
"id",
")",
";",
"_mruList",
".",
"forEach",
"(",
"function",
"(",
"record",
")",
"{",
"if",
"(",
"record",
".",
"paneId",
"===",
"secondPane",
".",
"id",
")",
"{",
"record",
".",
"paneId",
"=",
"firstPane",
".",
"id",
";",
"}",
"}",
")",
";",
"_$el",
".",
"removeClass",
"(",
"\"split-\"",
"+",
"_orientation",
".",
"toLowerCase",
"(",
")",
")",
";",
"_orientation",
"=",
"null",
";",
"// this will set the remaining pane to 100%",
"_initialLayout",
"(",
")",
";",
"exports",
".",
"trigger",
"(",
"\"paneLayoutChange\"",
",",
"_orientation",
")",
";",
"// if the current view before the merger was in the pane",
"// that went away then reopen it so that it's now the current view again",
"if",
"(",
"lastViewed",
"&&",
"getCurrentlyViewedFile",
"(",
")",
"!==",
"lastViewed",
")",
"{",
"exports",
".",
"_open",
"(",
"firstPane",
".",
"id",
",",
"lastViewed",
")",
";",
"}",
"}",
"}"
] | Merges second pane into first pane and opens the current file
@private | [
"Merges",
"second",
"pane",
"into",
"first",
"pane",
"and",
"opens",
"the",
"current",
"file"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1300-L1342 |
2,264 | adobe/brackets | src/view/MainViewManager.js | _close | function _close(paneId, file, optionsIn) {
var options = optionsIn || {};
_forEachPaneOrPanes(paneId, function (pane) {
if (pane.removeView(file, options.noOpenNextFile) && (paneId === ACTIVE_PANE || pane.id === paneId)) {
_removeFileFromMRU(pane.id, file);
exports.trigger("workingSetRemove", file, false, pane.id);
return false;
}
});
} | javascript | function _close(paneId, file, optionsIn) {
var options = optionsIn || {};
_forEachPaneOrPanes(paneId, function (pane) {
if (pane.removeView(file, options.noOpenNextFile) && (paneId === ACTIVE_PANE || pane.id === paneId)) {
_removeFileFromMRU(pane.id, file);
exports.trigger("workingSetRemove", file, false, pane.id);
return false;
}
});
} | [
"function",
"_close",
"(",
"paneId",
",",
"file",
",",
"optionsIn",
")",
"{",
"var",
"options",
"=",
"optionsIn",
"||",
"{",
"}",
";",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"function",
"(",
"pane",
")",
"{",
"if",
"(",
"pane",
".",
"removeView",
"(",
"file",
",",
"options",
".",
"noOpenNextFile",
")",
"&&",
"(",
"paneId",
"===",
"ACTIVE_PANE",
"||",
"pane",
".",
"id",
"===",
"paneId",
")",
")",
"{",
"_removeFileFromMRU",
"(",
"pane",
".",
"id",
",",
"file",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetRemove\"",
",",
"file",
",",
"false",
",",
"pane",
".",
"id",
")",
";",
"return",
"false",
";",
"}",
"}",
")",
";",
"}"
] | Closes a file in the specified pane or panes
@param {!string} paneId - id of the pane in which to open the document
@param {!File} file - file to close
@param {Object={noOpenNextFile:boolean}} optionsIn - options
This function does not fail if the file is not open | [
"Closes",
"a",
"file",
"in",
"the",
"specified",
"pane",
"or",
"panes"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1351-L1360 |
2,265 | adobe/brackets | src/view/MainViewManager.js | _closeList | function _closeList(paneId, fileList) {
_forEachPaneOrPanes(paneId, function (pane) {
var closedList = pane.removeViews(fileList);
closedList.forEach(function (file) {
_removeFileFromMRU(pane.id, file);
});
exports.trigger("workingSetRemoveList", closedList, pane.id);
});
} | javascript | function _closeList(paneId, fileList) {
_forEachPaneOrPanes(paneId, function (pane) {
var closedList = pane.removeViews(fileList);
closedList.forEach(function (file) {
_removeFileFromMRU(pane.id, file);
});
exports.trigger("workingSetRemoveList", closedList, pane.id);
});
} | [
"function",
"_closeList",
"(",
"paneId",
",",
"fileList",
")",
"{",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"function",
"(",
"pane",
")",
"{",
"var",
"closedList",
"=",
"pane",
".",
"removeViews",
"(",
"fileList",
")",
";",
"closedList",
".",
"forEach",
"(",
"function",
"(",
"file",
")",
"{",
"_removeFileFromMRU",
"(",
"pane",
".",
"id",
",",
"file",
")",
";",
"}",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetRemoveList\"",
",",
"closedList",
",",
"pane",
".",
"id",
")",
";",
"}",
")",
";",
"}"
] | Closes a list of file in the specified pane or panes
@param {!string} paneId - id of the pane in which to open the document
@param {!Array.<File>} fileList - files to close
This function does not fail if the file is not open | [
"Closes",
"a",
"list",
"of",
"file",
"in",
"the",
"specified",
"pane",
"or",
"panes"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1368-L1377 |
2,266 | adobe/brackets | src/view/MainViewManager.js | _closeAll | function _closeAll(paneId) {
_forEachPaneOrPanes(paneId, function (pane) {
var closedList = pane.getViewList();
closedList.forEach(function (file) {
_removeFileFromMRU(pane.id, file);
});
pane._reset();
exports.trigger("workingSetRemoveList", closedList, pane.id);
});
} | javascript | function _closeAll(paneId) {
_forEachPaneOrPanes(paneId, function (pane) {
var closedList = pane.getViewList();
closedList.forEach(function (file) {
_removeFileFromMRU(pane.id, file);
});
pane._reset();
exports.trigger("workingSetRemoveList", closedList, pane.id);
});
} | [
"function",
"_closeAll",
"(",
"paneId",
")",
"{",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"function",
"(",
"pane",
")",
"{",
"var",
"closedList",
"=",
"pane",
".",
"getViewList",
"(",
")",
";",
"closedList",
".",
"forEach",
"(",
"function",
"(",
"file",
")",
"{",
"_removeFileFromMRU",
"(",
"pane",
".",
"id",
",",
"file",
")",
";",
"}",
")",
";",
"pane",
".",
"_reset",
"(",
")",
";",
"exports",
".",
"trigger",
"(",
"\"workingSetRemoveList\"",
",",
"closedList",
",",
"pane",
".",
"id",
")",
";",
"}",
")",
";",
"}"
] | Closes all files in the specified pane or panes
@param {!string} paneId - id of the pane in which to open the document
This function does not fail if the file is not open | [
"Closes",
"all",
"files",
"in",
"the",
"specified",
"pane",
"or",
"panes"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1384-L1394 |
2,267 | adobe/brackets | src/view/MainViewManager.js | _findPaneForDocument | function _findPaneForDocument(document) {
// First check for an editor view of the document
var pane = _getPaneFromElement($(document._masterEditor.$el.parent().parent()));
if (!pane) {
// No view of the document, it may be in a working set and not yet opened
var info = findInAllWorkingSets(document.file.fullPath).shift();
if (info) {
pane = _panes[info.paneId];
}
}
return pane;
} | javascript | function _findPaneForDocument(document) {
// First check for an editor view of the document
var pane = _getPaneFromElement($(document._masterEditor.$el.parent().parent()));
if (!pane) {
// No view of the document, it may be in a working set and not yet opened
var info = findInAllWorkingSets(document.file.fullPath).shift();
if (info) {
pane = _panes[info.paneId];
}
}
return pane;
} | [
"function",
"_findPaneForDocument",
"(",
"document",
")",
"{",
"// First check for an editor view of the document",
"var",
"pane",
"=",
"_getPaneFromElement",
"(",
"$",
"(",
"document",
".",
"_masterEditor",
".",
"$el",
".",
"parent",
"(",
")",
".",
"parent",
"(",
")",
")",
")",
";",
"if",
"(",
"!",
"pane",
")",
"{",
"// No view of the document, it may be in a working set and not yet opened",
"var",
"info",
"=",
"findInAllWorkingSets",
"(",
"document",
".",
"file",
".",
"fullPath",
")",
".",
"shift",
"(",
")",
";",
"if",
"(",
"info",
")",
"{",
"pane",
"=",
"_panes",
"[",
"info",
".",
"paneId",
"]",
";",
"}",
"}",
"return",
"pane",
";",
"}"
] | Finds which pane a document belongs to
@param {!Document} document - the document to locate
@return {?Pane} the pane where the document lives or NULL if it isn't in a pane
@private | [
"Finds",
"which",
"pane",
"a",
"document",
"belongs",
"to"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1403-L1416 |
2,268 | adobe/brackets | src/view/MainViewManager.js | _destroyEditorIfNotNeeded | function _destroyEditorIfNotNeeded(document) {
if (!(document instanceof DocumentManager.Document)) {
throw new Error("_destroyEditorIfUnneeded() should be passed a Document");
}
if (document._masterEditor) {
// findPaneForDocument tries to locate the pane in which the document
// is either opened or will be opened (in the event that the document is
// in a working set but has yet to be opened) and then asks the pane
// to destroy the view if it doesn't need it anymore
var pane = _findPaneForDocument(document);
if (pane) {
// let the pane deceide if it wants to destroy the view if it's no needed
pane.destroyViewIfNotNeeded(document._masterEditor);
} else {
// in this case, the document isn't referenced at all so just destroy it
document._masterEditor.destroy();
}
}
} | javascript | function _destroyEditorIfNotNeeded(document) {
if (!(document instanceof DocumentManager.Document)) {
throw new Error("_destroyEditorIfUnneeded() should be passed a Document");
}
if (document._masterEditor) {
// findPaneForDocument tries to locate the pane in which the document
// is either opened or will be opened (in the event that the document is
// in a working set but has yet to be opened) and then asks the pane
// to destroy the view if it doesn't need it anymore
var pane = _findPaneForDocument(document);
if (pane) {
// let the pane deceide if it wants to destroy the view if it's no needed
pane.destroyViewIfNotNeeded(document._masterEditor);
} else {
// in this case, the document isn't referenced at all so just destroy it
document._masterEditor.destroy();
}
}
} | [
"function",
"_destroyEditorIfNotNeeded",
"(",
"document",
")",
"{",
"if",
"(",
"!",
"(",
"document",
"instanceof",
"DocumentManager",
".",
"Document",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"_destroyEditorIfUnneeded() should be passed a Document\"",
")",
";",
"}",
"if",
"(",
"document",
".",
"_masterEditor",
")",
"{",
"// findPaneForDocument tries to locate the pane in which the document",
"// is either opened or will be opened (in the event that the document is",
"// in a working set but has yet to be opened) and then asks the pane",
"// to destroy the view if it doesn't need it anymore",
"var",
"pane",
"=",
"_findPaneForDocument",
"(",
"document",
")",
";",
"if",
"(",
"pane",
")",
"{",
"// let the pane deceide if it wants to destroy the view if it's no needed",
"pane",
".",
"destroyViewIfNotNeeded",
"(",
"document",
".",
"_masterEditor",
")",
";",
"}",
"else",
"{",
"// in this case, the document isn't referenced at all so just destroy it",
"document",
".",
"_masterEditor",
".",
"destroy",
"(",
")",
";",
"}",
"}",
"}"
] | Destroys an editor object if a document is no longer referenced
@param {!Document} doc - document to destroy | [
"Destroys",
"an",
"editor",
"object",
"if",
"a",
"document",
"is",
"no",
"longer",
"referenced"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1422-L1441 |
2,269 | adobe/brackets | src/view/MainViewManager.js | _saveViewState | function _saveViewState() {
function _computeSplitPercentage() {
var available,
used;
if (getPaneCount() === 1) {
// just short-circuit here and
// return 100% to avoid any rounding issues
return 1;
} else {
if (_orientation === VERTICAL) {
available = _$el.innerWidth();
used = _panes[FIRST_PANE].$el.width();
} else {
available = _$el.innerHeight();
used = _panes[FIRST_PANE].$el.height();
}
return used / available;
}
}
var projectRoot = ProjectManager.getProjectRoot(),
context = { location : { scope: "user",
layer: "project",
layerID: projectRoot.fullPath } },
state = {
orientation: _orientation,
activePaneId: getActivePaneId(),
splitPercentage: _computeSplitPercentage(),
panes: {
}
};
if (!projectRoot) {
return;
}
_.forEach(_panes, function (pane) {
state.panes[pane.id] = pane.saveState();
});
PreferencesManager.setViewState(PREFS_NAME, state, context);
} | javascript | function _saveViewState() {
function _computeSplitPercentage() {
var available,
used;
if (getPaneCount() === 1) {
// just short-circuit here and
// return 100% to avoid any rounding issues
return 1;
} else {
if (_orientation === VERTICAL) {
available = _$el.innerWidth();
used = _panes[FIRST_PANE].$el.width();
} else {
available = _$el.innerHeight();
used = _panes[FIRST_PANE].$el.height();
}
return used / available;
}
}
var projectRoot = ProjectManager.getProjectRoot(),
context = { location : { scope: "user",
layer: "project",
layerID: projectRoot.fullPath } },
state = {
orientation: _orientation,
activePaneId: getActivePaneId(),
splitPercentage: _computeSplitPercentage(),
panes: {
}
};
if (!projectRoot) {
return;
}
_.forEach(_panes, function (pane) {
state.panes[pane.id] = pane.saveState();
});
PreferencesManager.setViewState(PREFS_NAME, state, context);
} | [
"function",
"_saveViewState",
"(",
")",
"{",
"function",
"_computeSplitPercentage",
"(",
")",
"{",
"var",
"available",
",",
"used",
";",
"if",
"(",
"getPaneCount",
"(",
")",
"===",
"1",
")",
"{",
"// just short-circuit here and",
"// return 100% to avoid any rounding issues",
"return",
"1",
";",
"}",
"else",
"{",
"if",
"(",
"_orientation",
"===",
"VERTICAL",
")",
"{",
"available",
"=",
"_$el",
".",
"innerWidth",
"(",
")",
";",
"used",
"=",
"_panes",
"[",
"FIRST_PANE",
"]",
".",
"$el",
".",
"width",
"(",
")",
";",
"}",
"else",
"{",
"available",
"=",
"_$el",
".",
"innerHeight",
"(",
")",
";",
"used",
"=",
"_panes",
"[",
"FIRST_PANE",
"]",
".",
"$el",
".",
"height",
"(",
")",
";",
"}",
"return",
"used",
"/",
"available",
";",
"}",
"}",
"var",
"projectRoot",
"=",
"ProjectManager",
".",
"getProjectRoot",
"(",
")",
",",
"context",
"=",
"{",
"location",
":",
"{",
"scope",
":",
"\"user\"",
",",
"layer",
":",
"\"project\"",
",",
"layerID",
":",
"projectRoot",
".",
"fullPath",
"}",
"}",
",",
"state",
"=",
"{",
"orientation",
":",
"_orientation",
",",
"activePaneId",
":",
"getActivePaneId",
"(",
")",
",",
"splitPercentage",
":",
"_computeSplitPercentage",
"(",
")",
",",
"panes",
":",
"{",
"}",
"}",
";",
"if",
"(",
"!",
"projectRoot",
")",
"{",
"return",
";",
"}",
"_",
".",
"forEach",
"(",
"_panes",
",",
"function",
"(",
"pane",
")",
"{",
"state",
".",
"panes",
"[",
"pane",
".",
"id",
"]",
"=",
"pane",
".",
"saveState",
"(",
")",
";",
"}",
")",
";",
"PreferencesManager",
".",
"setViewState",
"(",
"PREFS_NAME",
",",
"state",
",",
"context",
")",
";",
"}"
] | Saves the workingset state
@private | [
"Saves",
"the",
"workingset",
"state"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1567-L1612 |
2,270 | adobe/brackets | src/view/MainViewManager.js | _initialize | function _initialize($container) {
if (_activePaneId) {
throw new Error("MainViewManager has already been initialized");
}
_$el = $container;
_createPaneIfNecessary(FIRST_PANE);
_activePaneId = FIRST_PANE;
// One-time init so the pane has the "active" appearance
_panes[FIRST_PANE]._handleActivePaneChange(undefined, _activePaneId);
_initialLayout();
// This ensures that unit tests that use this function
// get an event handler for workspace events and we don't listen
// to the event before we've been initialized
WorkspaceManager.on("workspaceUpdateLayout", _updateLayout);
// Listen to key Alt-W to toggle between panes
CommandManager.register(Strings.CMD_SWITCH_PANE_FOCUS, Commands.CMD_SWITCH_PANE_FOCUS, switchPaneFocus);
KeyBindingManager.addBinding(Commands.CMD_SWITCH_PANE_FOCUS, {key: 'Alt-W'});
} | javascript | function _initialize($container) {
if (_activePaneId) {
throw new Error("MainViewManager has already been initialized");
}
_$el = $container;
_createPaneIfNecessary(FIRST_PANE);
_activePaneId = FIRST_PANE;
// One-time init so the pane has the "active" appearance
_panes[FIRST_PANE]._handleActivePaneChange(undefined, _activePaneId);
_initialLayout();
// This ensures that unit tests that use this function
// get an event handler for workspace events and we don't listen
// to the event before we've been initialized
WorkspaceManager.on("workspaceUpdateLayout", _updateLayout);
// Listen to key Alt-W to toggle between panes
CommandManager.register(Strings.CMD_SWITCH_PANE_FOCUS, Commands.CMD_SWITCH_PANE_FOCUS, switchPaneFocus);
KeyBindingManager.addBinding(Commands.CMD_SWITCH_PANE_FOCUS, {key: 'Alt-W'});
} | [
"function",
"_initialize",
"(",
"$container",
")",
"{",
"if",
"(",
"_activePaneId",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"MainViewManager has already been initialized\"",
")",
";",
"}",
"_$el",
"=",
"$container",
";",
"_createPaneIfNecessary",
"(",
"FIRST_PANE",
")",
";",
"_activePaneId",
"=",
"FIRST_PANE",
";",
"// One-time init so the pane has the \"active\" appearance",
"_panes",
"[",
"FIRST_PANE",
"]",
".",
"_handleActivePaneChange",
"(",
"undefined",
",",
"_activePaneId",
")",
";",
"_initialLayout",
"(",
")",
";",
"// This ensures that unit tests that use this function",
"// get an event handler for workspace events and we don't listen",
"// to the event before we've been initialized",
"WorkspaceManager",
".",
"on",
"(",
"\"workspaceUpdateLayout\"",
",",
"_updateLayout",
")",
";",
"// Listen to key Alt-W to toggle between panes",
"CommandManager",
".",
"register",
"(",
"Strings",
".",
"CMD_SWITCH_PANE_FOCUS",
",",
"Commands",
".",
"CMD_SWITCH_PANE_FOCUS",
",",
"switchPaneFocus",
")",
";",
"KeyBindingManager",
".",
"addBinding",
"(",
"Commands",
".",
"CMD_SWITCH_PANE_FOCUS",
",",
"{",
"key",
":",
"'Alt-W'",
"}",
")",
";",
"}"
] | Initializes the MainViewManager's view state
@param {jQuery} $container - the container where the main view will live
@private | [
"Initializes",
"the",
"MainViewManager",
"s",
"view",
"state"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1619-L1639 |
2,271 | adobe/brackets | src/view/MainViewManager.js | setLayoutScheme | function setLayoutScheme(rows, columns) {
if ((rows < 1) || (rows > 2) || (columns < 1) || (columns > 2) || (columns === 2 && rows === 2)) {
console.error("setLayoutScheme unsupported layout " + rows + ", " + columns);
return false;
}
if (rows === columns) {
_mergePanes();
} else if (rows > columns) {
_doSplit(HORIZONTAL);
} else {
_doSplit(VERTICAL);
}
return true;
} | javascript | function setLayoutScheme(rows, columns) {
if ((rows < 1) || (rows > 2) || (columns < 1) || (columns > 2) || (columns === 2 && rows === 2)) {
console.error("setLayoutScheme unsupported layout " + rows + ", " + columns);
return false;
}
if (rows === columns) {
_mergePanes();
} else if (rows > columns) {
_doSplit(HORIZONTAL);
} else {
_doSplit(VERTICAL);
}
return true;
} | [
"function",
"setLayoutScheme",
"(",
"rows",
",",
"columns",
")",
"{",
"if",
"(",
"(",
"rows",
"<",
"1",
")",
"||",
"(",
"rows",
">",
"2",
")",
"||",
"(",
"columns",
"<",
"1",
")",
"||",
"(",
"columns",
">",
"2",
")",
"||",
"(",
"columns",
"===",
"2",
"&&",
"rows",
"===",
"2",
")",
")",
"{",
"console",
".",
"error",
"(",
"\"setLayoutScheme unsupported layout \"",
"+",
"rows",
"+",
"\", \"",
"+",
"columns",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"rows",
"===",
"columns",
")",
"{",
"_mergePanes",
"(",
")",
";",
"}",
"else",
"if",
"(",
"rows",
">",
"columns",
")",
"{",
"_doSplit",
"(",
"HORIZONTAL",
")",
";",
"}",
"else",
"{",
"_doSplit",
"(",
"VERTICAL",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Changes the layout scheme
@param {!number} rows (may be 1 or 2)
@param {!number} columns (may be 1 or 2)
@summay Rows or Columns may be 1 or 2 but both cannot be 2. 1x2, 2x1 or 1x1 are the legal values | [
"Changes",
"the",
"layout",
"scheme"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1647-L1661 |
2,272 | adobe/brackets | src/view/MainViewManager.js | getLayoutScheme | function getLayoutScheme() {
var result = {
rows: 1,
columns: 1
};
if (_orientation === HORIZONTAL) {
result.rows = 2;
} else if (_orientation === VERTICAL) {
result.columns = 2;
}
return result;
} | javascript | function getLayoutScheme() {
var result = {
rows: 1,
columns: 1
};
if (_orientation === HORIZONTAL) {
result.rows = 2;
} else if (_orientation === VERTICAL) {
result.columns = 2;
}
return result;
} | [
"function",
"getLayoutScheme",
"(",
")",
"{",
"var",
"result",
"=",
"{",
"rows",
":",
"1",
",",
"columns",
":",
"1",
"}",
";",
"if",
"(",
"_orientation",
"===",
"HORIZONTAL",
")",
"{",
"result",
".",
"rows",
"=",
"2",
";",
"}",
"else",
"if",
"(",
"_orientation",
"===",
"VERTICAL",
")",
"{",
"result",
".",
"columns",
"=",
"2",
";",
"}",
"return",
"result",
";",
"}"
] | Retrieves the current layout scheme
@return {!{rows: number, columns: number>}} | [
"Retrieves",
"the",
"current",
"layout",
"scheme"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1667-L1680 |
2,273 | adobe/brackets | src/extensions/default/InlineTimingFunctionEditor/InlineTimingFunctionEditor.js | InlineTimingFunctionEditor | function InlineTimingFunctionEditor(timingFunction, startBookmark, endBookmark) {
this._timingFunction = timingFunction;
this._startBookmark = startBookmark;
this._endBookmark = endBookmark;
this._isOwnChange = false;
this._isHostChange = false;
this._origin = "+InlineTimingFunctionEditor_" + (lastOriginId++);
this._handleTimingFunctionChange = this._handleTimingFunctionChange.bind(this);
this._handleHostDocumentChange = this._handleHostDocumentChange.bind(this);
InlineWidget.call(this);
} | javascript | function InlineTimingFunctionEditor(timingFunction, startBookmark, endBookmark) {
this._timingFunction = timingFunction;
this._startBookmark = startBookmark;
this._endBookmark = endBookmark;
this._isOwnChange = false;
this._isHostChange = false;
this._origin = "+InlineTimingFunctionEditor_" + (lastOriginId++);
this._handleTimingFunctionChange = this._handleTimingFunctionChange.bind(this);
this._handleHostDocumentChange = this._handleHostDocumentChange.bind(this);
InlineWidget.call(this);
} | [
"function",
"InlineTimingFunctionEditor",
"(",
"timingFunction",
",",
"startBookmark",
",",
"endBookmark",
")",
"{",
"this",
".",
"_timingFunction",
"=",
"timingFunction",
";",
"this",
".",
"_startBookmark",
"=",
"startBookmark",
";",
"this",
".",
"_endBookmark",
"=",
"endBookmark",
";",
"this",
".",
"_isOwnChange",
"=",
"false",
";",
"this",
".",
"_isHostChange",
"=",
"false",
";",
"this",
".",
"_origin",
"=",
"\"+InlineTimingFunctionEditor_\"",
"+",
"(",
"lastOriginId",
"++",
")",
";",
"this",
".",
"_handleTimingFunctionChange",
"=",
"this",
".",
"_handleTimingFunctionChange",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_handleHostDocumentChange",
"=",
"this",
".",
"_handleHostDocumentChange",
".",
"bind",
"(",
"this",
")",
";",
"InlineWidget",
".",
"call",
"(",
"this",
")",
";",
"}"
] | Constructor for inline widget containing a BezierCurveEditor control
@param {!RegExpMatch} timingFunction RegExp match object of initially selected timingFunction
@param {!CodeMirror.Bookmark} startBookmark
@param {!CodeMirror.Bookmark} endBookmark | [
"Constructor",
"for",
"inline",
"widget",
"containing",
"a",
"BezierCurveEditor",
"control"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/InlineTimingFunctionEditor.js#L43-L55 |
2,274 | adobe/brackets | src/extensibility/node/npm-installer.js | performNpmInstallIfRequired | function performNpmInstallIfRequired(npmOptions, validationResult, callback) {
function finish() {
callback(null, validationResult);
}
var installDirectory = path.join(validationResult.extractDir, validationResult.commonPrefix);
var packageJson;
try {
packageJson = fs.readJsonSync(path.join(installDirectory, "package.json"));
} catch (e) {
packageJson = null;
}
if (!packageJson || !packageJson.dependencies || !Object.keys(packageJson.dependencies).length) {
return finish();
}
_performNpmInstall(installDirectory, npmOptions, function (err) {
if (err) {
validationResult.errors.push([Errors.NPM_INSTALL_FAILED, err.toString()]);
}
finish();
});
} | javascript | function performNpmInstallIfRequired(npmOptions, validationResult, callback) {
function finish() {
callback(null, validationResult);
}
var installDirectory = path.join(validationResult.extractDir, validationResult.commonPrefix);
var packageJson;
try {
packageJson = fs.readJsonSync(path.join(installDirectory, "package.json"));
} catch (e) {
packageJson = null;
}
if (!packageJson || !packageJson.dependencies || !Object.keys(packageJson.dependencies).length) {
return finish();
}
_performNpmInstall(installDirectory, npmOptions, function (err) {
if (err) {
validationResult.errors.push([Errors.NPM_INSTALL_FAILED, err.toString()]);
}
finish();
});
} | [
"function",
"performNpmInstallIfRequired",
"(",
"npmOptions",
",",
"validationResult",
",",
"callback",
")",
"{",
"function",
"finish",
"(",
")",
"{",
"callback",
"(",
"null",
",",
"validationResult",
")",
";",
"}",
"var",
"installDirectory",
"=",
"path",
".",
"join",
"(",
"validationResult",
".",
"extractDir",
",",
"validationResult",
".",
"commonPrefix",
")",
";",
"var",
"packageJson",
";",
"try",
"{",
"packageJson",
"=",
"fs",
".",
"readJsonSync",
"(",
"path",
".",
"join",
"(",
"installDirectory",
",",
"\"package.json\"",
")",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"packageJson",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"packageJson",
"||",
"!",
"packageJson",
".",
"dependencies",
"||",
"!",
"Object",
".",
"keys",
"(",
"packageJson",
".",
"dependencies",
")",
".",
"length",
")",
"{",
"return",
"finish",
"(",
")",
";",
"}",
"_performNpmInstall",
"(",
"installDirectory",
",",
"npmOptions",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"validationResult",
".",
"errors",
".",
"push",
"(",
"[",
"Errors",
".",
"NPM_INSTALL_FAILED",
",",
"err",
".",
"toString",
"(",
")",
"]",
")",
";",
"}",
"finish",
"(",
")",
";",
"}",
")",
";",
"}"
] | Checks package.json of the extracted extension for npm dependencies
and runs npm install when required.
@param {Object} validationResult return value of the validation procedure
@param {Function} callback function to be called after the end of validation procedure | [
"Checks",
"package",
".",
"json",
"of",
"the",
"extracted",
"extension",
"for",
"npm",
"dependencies",
"and",
"runs",
"npm",
"install",
"when",
"required",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/node/npm-installer.js#L93-L118 |
2,275 | adobe/brackets | src/view/ThemeSettings.js | showDialog | function showDialog() {
var currentSettings = getValues();
var newSettings = {};
var themes = _.map(loadedThemes, function (theme) { return theme; });
var template = $("<div>").append($settings).html();
var $template = $(Mustache.render(template, {"settings": currentSettings, "themes": themes, "Strings": Strings}));
// Select the correct theme.
var $currentThemeOption = $template
.find("[value='" + currentSettings.theme + "']");
if ($currentThemeOption.length === 0) {
$currentThemeOption = $template.find("[value='" + defaults.theme + "']");
}
$currentThemeOption.attr("selected", "selected");
$template
.find("[data-toggle=tab].default")
.tab("show");
$template
.on("change", "[data-target]:checkbox", function () {
var $target = $(this);
var attr = $target.attr("data-target");
newSettings[attr] = $target.is(":checked");
})
.on("input", "[data-target='fontSize']", function () {
var target = this;
var targetValue = $(this).val();
var $btn = $("#theme-settings-done-btn")[0];
// Make sure that the font size is expressed in terms
// we can handle (px or em). If not, 'done' button is
// disabled until input has been corrected.
if (target.checkValidity() === true) {
$btn.disabled = false;
newSettings["fontSize"] = targetValue;
} else {
$btn.disabled = true;
}
})
.on("input", "[data-target='fontFamily']", function () {
var targetValue = $(this).val();
newSettings["fontFamily"] = targetValue;
})
.on("change", "select", function () {
var $target = $(":selected", this);
var attr = $target.attr("data-target");
if (attr) {
prefs.set(attr, $target.val());
}
});
Dialogs.showModalDialogUsingTemplate($template).done(function (id) {
var setterFn;
if (id === "save") {
// Go through each new setting and apply it
Object.keys(newSettings).forEach(function (setting) {
if (defaults.hasOwnProperty(setting)) {
prefs.set(setting, newSettings[setting]);
} else {
// Figure out if the setting is in the ViewCommandHandlers, which means it is
// a font setting
setterFn = "set" + setting[0].toLocaleUpperCase() + setting.substr(1);
if (typeof ViewCommandHandlers[setterFn] === "function") {
ViewCommandHandlers[setterFn](newSettings[setting]);
}
}
});
} else if (id === "cancel") {
// Make sure we revert any changes to theme selection
prefs.set("theme", currentSettings.theme);
}
});
} | javascript | function showDialog() {
var currentSettings = getValues();
var newSettings = {};
var themes = _.map(loadedThemes, function (theme) { return theme; });
var template = $("<div>").append($settings).html();
var $template = $(Mustache.render(template, {"settings": currentSettings, "themes": themes, "Strings": Strings}));
// Select the correct theme.
var $currentThemeOption = $template
.find("[value='" + currentSettings.theme + "']");
if ($currentThemeOption.length === 0) {
$currentThemeOption = $template.find("[value='" + defaults.theme + "']");
}
$currentThemeOption.attr("selected", "selected");
$template
.find("[data-toggle=tab].default")
.tab("show");
$template
.on("change", "[data-target]:checkbox", function () {
var $target = $(this);
var attr = $target.attr("data-target");
newSettings[attr] = $target.is(":checked");
})
.on("input", "[data-target='fontSize']", function () {
var target = this;
var targetValue = $(this).val();
var $btn = $("#theme-settings-done-btn")[0];
// Make sure that the font size is expressed in terms
// we can handle (px or em). If not, 'done' button is
// disabled until input has been corrected.
if (target.checkValidity() === true) {
$btn.disabled = false;
newSettings["fontSize"] = targetValue;
} else {
$btn.disabled = true;
}
})
.on("input", "[data-target='fontFamily']", function () {
var targetValue = $(this).val();
newSettings["fontFamily"] = targetValue;
})
.on("change", "select", function () {
var $target = $(":selected", this);
var attr = $target.attr("data-target");
if (attr) {
prefs.set(attr, $target.val());
}
});
Dialogs.showModalDialogUsingTemplate($template).done(function (id) {
var setterFn;
if (id === "save") {
// Go through each new setting and apply it
Object.keys(newSettings).forEach(function (setting) {
if (defaults.hasOwnProperty(setting)) {
prefs.set(setting, newSettings[setting]);
} else {
// Figure out if the setting is in the ViewCommandHandlers, which means it is
// a font setting
setterFn = "set" + setting[0].toLocaleUpperCase() + setting.substr(1);
if (typeof ViewCommandHandlers[setterFn] === "function") {
ViewCommandHandlers[setterFn](newSettings[setting]);
}
}
});
} else if (id === "cancel") {
// Make sure we revert any changes to theme selection
prefs.set("theme", currentSettings.theme);
}
});
} | [
"function",
"showDialog",
"(",
")",
"{",
"var",
"currentSettings",
"=",
"getValues",
"(",
")",
";",
"var",
"newSettings",
"=",
"{",
"}",
";",
"var",
"themes",
"=",
"_",
".",
"map",
"(",
"loadedThemes",
",",
"function",
"(",
"theme",
")",
"{",
"return",
"theme",
";",
"}",
")",
";",
"var",
"template",
"=",
"$",
"(",
"\"<div>\"",
")",
".",
"append",
"(",
"$settings",
")",
".",
"html",
"(",
")",
";",
"var",
"$template",
"=",
"$",
"(",
"Mustache",
".",
"render",
"(",
"template",
",",
"{",
"\"settings\"",
":",
"currentSettings",
",",
"\"themes\"",
":",
"themes",
",",
"\"Strings\"",
":",
"Strings",
"}",
")",
")",
";",
"// Select the correct theme.",
"var",
"$currentThemeOption",
"=",
"$template",
".",
"find",
"(",
"\"[value='\"",
"+",
"currentSettings",
".",
"theme",
"+",
"\"']\"",
")",
";",
"if",
"(",
"$currentThemeOption",
".",
"length",
"===",
"0",
")",
"{",
"$currentThemeOption",
"=",
"$template",
".",
"find",
"(",
"\"[value='\"",
"+",
"defaults",
".",
"theme",
"+",
"\"']\"",
")",
";",
"}",
"$currentThemeOption",
".",
"attr",
"(",
"\"selected\"",
",",
"\"selected\"",
")",
";",
"$template",
".",
"find",
"(",
"\"[data-toggle=tab].default\"",
")",
".",
"tab",
"(",
"\"show\"",
")",
";",
"$template",
".",
"on",
"(",
"\"change\"",
",",
"\"[data-target]:checkbox\"",
",",
"function",
"(",
")",
"{",
"var",
"$target",
"=",
"$",
"(",
"this",
")",
";",
"var",
"attr",
"=",
"$target",
".",
"attr",
"(",
"\"data-target\"",
")",
";",
"newSettings",
"[",
"attr",
"]",
"=",
"$target",
".",
"is",
"(",
"\":checked\"",
")",
";",
"}",
")",
".",
"on",
"(",
"\"input\"",
",",
"\"[data-target='fontSize']\"",
",",
"function",
"(",
")",
"{",
"var",
"target",
"=",
"this",
";",
"var",
"targetValue",
"=",
"$",
"(",
"this",
")",
".",
"val",
"(",
")",
";",
"var",
"$btn",
"=",
"$",
"(",
"\"#theme-settings-done-btn\"",
")",
"[",
"0",
"]",
";",
"// Make sure that the font size is expressed in terms",
"// we can handle (px or em). If not, 'done' button is",
"// disabled until input has been corrected.",
"if",
"(",
"target",
".",
"checkValidity",
"(",
")",
"===",
"true",
")",
"{",
"$btn",
".",
"disabled",
"=",
"false",
";",
"newSettings",
"[",
"\"fontSize\"",
"]",
"=",
"targetValue",
";",
"}",
"else",
"{",
"$btn",
".",
"disabled",
"=",
"true",
";",
"}",
"}",
")",
".",
"on",
"(",
"\"input\"",
",",
"\"[data-target='fontFamily']\"",
",",
"function",
"(",
")",
"{",
"var",
"targetValue",
"=",
"$",
"(",
"this",
")",
".",
"val",
"(",
")",
";",
"newSettings",
"[",
"\"fontFamily\"",
"]",
"=",
"targetValue",
";",
"}",
")",
".",
"on",
"(",
"\"change\"",
",",
"\"select\"",
",",
"function",
"(",
")",
"{",
"var",
"$target",
"=",
"$",
"(",
"\":selected\"",
",",
"this",
")",
";",
"var",
"attr",
"=",
"$target",
".",
"attr",
"(",
"\"data-target\"",
")",
";",
"if",
"(",
"attr",
")",
"{",
"prefs",
".",
"set",
"(",
"attr",
",",
"$target",
".",
"val",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"Dialogs",
".",
"showModalDialogUsingTemplate",
"(",
"$template",
")",
".",
"done",
"(",
"function",
"(",
"id",
")",
"{",
"var",
"setterFn",
";",
"if",
"(",
"id",
"===",
"\"save\"",
")",
"{",
"// Go through each new setting and apply it",
"Object",
".",
"keys",
"(",
"newSettings",
")",
".",
"forEach",
"(",
"function",
"(",
"setting",
")",
"{",
"if",
"(",
"defaults",
".",
"hasOwnProperty",
"(",
"setting",
")",
")",
"{",
"prefs",
".",
"set",
"(",
"setting",
",",
"newSettings",
"[",
"setting",
"]",
")",
";",
"}",
"else",
"{",
"// Figure out if the setting is in the ViewCommandHandlers, which means it is",
"// a font setting",
"setterFn",
"=",
"\"set\"",
"+",
"setting",
"[",
"0",
"]",
".",
"toLocaleUpperCase",
"(",
")",
"+",
"setting",
".",
"substr",
"(",
"1",
")",
";",
"if",
"(",
"typeof",
"ViewCommandHandlers",
"[",
"setterFn",
"]",
"===",
"\"function\"",
")",
"{",
"ViewCommandHandlers",
"[",
"setterFn",
"]",
"(",
"newSettings",
"[",
"setting",
"]",
")",
";",
"}",
"}",
"}",
")",
";",
"}",
"else",
"if",
"(",
"id",
"===",
"\"cancel\"",
")",
"{",
"// Make sure we revert any changes to theme selection",
"prefs",
".",
"set",
"(",
"\"theme\"",
",",
"currentSettings",
".",
"theme",
")",
";",
"}",
"}",
")",
";",
"}"
] | Opens the settings dialog | [
"Opens",
"the",
"settings",
"dialog"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/ThemeSettings.js#L78-L155 |
2,276 | adobe/brackets | src/document/DocumentManager.js | getCurrentDocument | function getCurrentDocument() {
var file = MainViewManager.getCurrentlyViewedFile(MainViewManager.ACTIVE_PANE);
if (file) {
return getOpenDocumentForPath(file.fullPath);
}
return null;
} | javascript | function getCurrentDocument() {
var file = MainViewManager.getCurrentlyViewedFile(MainViewManager.ACTIVE_PANE);
if (file) {
return getOpenDocumentForPath(file.fullPath);
}
return null;
} | [
"function",
"getCurrentDocument",
"(",
")",
"{",
"var",
"file",
"=",
"MainViewManager",
".",
"getCurrentlyViewedFile",
"(",
"MainViewManager",
".",
"ACTIVE_PANE",
")",
";",
"if",
"(",
"file",
")",
"{",
"return",
"getOpenDocumentForPath",
"(",
"file",
".",
"fullPath",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Returns the Document that is currently open in the editor UI. May be null.
@return {?Document} | [
"Returns",
"the",
"Document",
"that",
"is",
"currently",
"open",
"in",
"the",
"editor",
"UI",
".",
"May",
"be",
"null",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L140-L148 |
2,277 | adobe/brackets | src/document/DocumentManager.js | getWorkingSet | function getWorkingSet() {
DeprecationWarning.deprecationWarning("Use MainViewManager.getWorkingSet() instead of DocumentManager.getWorkingSet()", true);
return MainViewManager.getWorkingSet(MainViewManager.ALL_PANES)
.filter(function (file) {
// Legacy didn't allow for files with custom viewers
return !MainViewFactory.findSuitableFactoryForPath(file.fullPath);
});
} | javascript | function getWorkingSet() {
DeprecationWarning.deprecationWarning("Use MainViewManager.getWorkingSet() instead of DocumentManager.getWorkingSet()", true);
return MainViewManager.getWorkingSet(MainViewManager.ALL_PANES)
.filter(function (file) {
// Legacy didn't allow for files with custom viewers
return !MainViewFactory.findSuitableFactoryForPath(file.fullPath);
});
} | [
"function",
"getWorkingSet",
"(",
")",
"{",
"DeprecationWarning",
".",
"deprecationWarning",
"(",
"\"Use MainViewManager.getWorkingSet() instead of DocumentManager.getWorkingSet()\"",
",",
"true",
")",
";",
"return",
"MainViewManager",
".",
"getWorkingSet",
"(",
"MainViewManager",
".",
"ALL_PANES",
")",
".",
"filter",
"(",
"function",
"(",
"file",
")",
"{",
"// Legacy didn't allow for files with custom viewers",
"return",
"!",
"MainViewFactory",
".",
"findSuitableFactoryForPath",
"(",
"file",
".",
"fullPath",
")",
";",
"}",
")",
";",
"}"
] | Returns a list of items in the working set in UI list order. May be 0-length, but never null.
@deprecated Use MainViewManager.getWorkingSet() instead
@return {Array.<File>} | [
"Returns",
"a",
"list",
"of",
"items",
"in",
"the",
"working",
"set",
"in",
"UI",
"list",
"order",
".",
"May",
"be",
"0",
"-",
"length",
"but",
"never",
"null",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L156-L163 |
2,278 | adobe/brackets | src/document/DocumentManager.js | findInWorkingSet | function findInWorkingSet(fullPath) {
DeprecationWarning.deprecationWarning("Use MainViewManager.findInWorkingSet() instead of DocumentManager.findInWorkingSet()", true);
return MainViewManager.findInWorkingSet(MainViewManager.ACTIVE_PANE, fullPath);
} | javascript | function findInWorkingSet(fullPath) {
DeprecationWarning.deprecationWarning("Use MainViewManager.findInWorkingSet() instead of DocumentManager.findInWorkingSet()", true);
return MainViewManager.findInWorkingSet(MainViewManager.ACTIVE_PANE, fullPath);
} | [
"function",
"findInWorkingSet",
"(",
"fullPath",
")",
"{",
"DeprecationWarning",
".",
"deprecationWarning",
"(",
"\"Use MainViewManager.findInWorkingSet() instead of DocumentManager.findInWorkingSet()\"",
",",
"true",
")",
";",
"return",
"MainViewManager",
".",
"findInWorkingSet",
"(",
"MainViewManager",
".",
"ACTIVE_PANE",
",",
"fullPath",
")",
";",
"}"
] | Returns the index of the file matching fullPath in the working set.
@deprecated Use MainViewManager.findInWorkingSet() instead
@param {!string} fullPath
@return {number} index, -1 if not found | [
"Returns",
"the",
"index",
"of",
"the",
"file",
"matching",
"fullPath",
"in",
"the",
"working",
"set",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L171-L174 |
2,279 | adobe/brackets | src/document/DocumentManager.js | addToWorkingSet | function addToWorkingSet(file, index, forceRedraw) {
DeprecationWarning.deprecationWarning("Use MainViewManager.addToWorkingSet() instead of DocumentManager.addToWorkingSet()", true);
MainViewManager.addToWorkingSet(MainViewManager.ACTIVE_PANE, file, index, forceRedraw);
} | javascript | function addToWorkingSet(file, index, forceRedraw) {
DeprecationWarning.deprecationWarning("Use MainViewManager.addToWorkingSet() instead of DocumentManager.addToWorkingSet()", true);
MainViewManager.addToWorkingSet(MainViewManager.ACTIVE_PANE, file, index, forceRedraw);
} | [
"function",
"addToWorkingSet",
"(",
"file",
",",
"index",
",",
"forceRedraw",
")",
"{",
"DeprecationWarning",
".",
"deprecationWarning",
"(",
"\"Use MainViewManager.addToWorkingSet() instead of DocumentManager.addToWorkingSet()\"",
",",
"true",
")",
";",
"MainViewManager",
".",
"addToWorkingSet",
"(",
"MainViewManager",
".",
"ACTIVE_PANE",
",",
"file",
",",
"index",
",",
"forceRedraw",
")",
";",
"}"
] | Adds the given file to the end of the working set list.
@deprecated Use MainViewManager.addToWorkingSet() instead
@param {!File} file
@param {number=} index Position to add to list (defaults to last); -1 is ignored
@param {boolean=} forceRedraw If true, a working set change notification is always sent
(useful if suppressRedraw was used with removeFromWorkingSet() earlier) | [
"Adds",
"the",
"given",
"file",
"to",
"the",
"end",
"of",
"the",
"working",
"set",
"list",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L202-L205 |
2,280 | adobe/brackets | src/document/DocumentManager.js | removeListFromWorkingSet | function removeListFromWorkingSet(list) {
DeprecationWarning.deprecationWarning("Use CommandManager.execute(Commands.FILE_CLOSE_LIST, {PaneId: MainViewManager.ALL_PANES, fileList: list}) instead of DocumentManager.removeListFromWorkingSet()", true);
CommandManager.execute(Commands.FILE_CLOSE_LIST, {PaneId: MainViewManager.ALL_PANES, fileList: list});
} | javascript | function removeListFromWorkingSet(list) {
DeprecationWarning.deprecationWarning("Use CommandManager.execute(Commands.FILE_CLOSE_LIST, {PaneId: MainViewManager.ALL_PANES, fileList: list}) instead of DocumentManager.removeListFromWorkingSet()", true);
CommandManager.execute(Commands.FILE_CLOSE_LIST, {PaneId: MainViewManager.ALL_PANES, fileList: list});
} | [
"function",
"removeListFromWorkingSet",
"(",
"list",
")",
"{",
"DeprecationWarning",
".",
"deprecationWarning",
"(",
"\"Use CommandManager.execute(Commands.FILE_CLOSE_LIST, {PaneId: MainViewManager.ALL_PANES, fileList: list}) instead of DocumentManager.removeListFromWorkingSet()\"",
",",
"true",
")",
";",
"CommandManager",
".",
"execute",
"(",
"Commands",
".",
"FILE_CLOSE_LIST",
",",
"{",
"PaneId",
":",
"MainViewManager",
".",
"ALL_PANES",
",",
"fileList",
":",
"list",
"}",
")",
";",
"}"
] | closes a list of files
@deprecated Use CommandManager.execute(Commands.FILE_CLOSE_LIST) instead
@param {!Array.<File>} list - list of File objectgs to close | [
"closes",
"a",
"list",
"of",
"files"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L228-L231 |
2,281 | adobe/brackets | src/document/DocumentManager.js | closeAll | function closeAll() {
DeprecationWarning.deprecationWarning("Use CommandManager.execute(Commands.FILE_CLOSE_ALL,{PaneId: MainViewManager.ALL_PANES}) instead of DocumentManager.closeAll()", true);
CommandManager.execute(Commands.FILE_CLOSE_ALL, {PaneId: MainViewManager.ALL_PANES});
} | javascript | function closeAll() {
DeprecationWarning.deprecationWarning("Use CommandManager.execute(Commands.FILE_CLOSE_ALL,{PaneId: MainViewManager.ALL_PANES}) instead of DocumentManager.closeAll()", true);
CommandManager.execute(Commands.FILE_CLOSE_ALL, {PaneId: MainViewManager.ALL_PANES});
} | [
"function",
"closeAll",
"(",
")",
"{",
"DeprecationWarning",
".",
"deprecationWarning",
"(",
"\"Use CommandManager.execute(Commands.FILE_CLOSE_ALL,{PaneId: MainViewManager.ALL_PANES}) instead of DocumentManager.closeAll()\"",
",",
"true",
")",
";",
"CommandManager",
".",
"execute",
"(",
"Commands",
".",
"FILE_CLOSE_ALL",
",",
"{",
"PaneId",
":",
"MainViewManager",
".",
"ALL_PANES",
"}",
")",
";",
"}"
] | closes all open files
@deprecated CommandManager.execute(Commands.FILE_CLOSE_ALL) instead | [
"closes",
"all",
"open",
"files"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L237-L240 |
2,282 | adobe/brackets | src/document/DocumentManager.js | closeFullEditor | function closeFullEditor(file) {
DeprecationWarning.deprecationWarning("Use CommandManager.execute(Commands.FILE_CLOSE, {File: file} instead of DocumentManager.closeFullEditor()", true);
CommandManager.execute(Commands.FILE_CLOSE, {File: file});
} | javascript | function closeFullEditor(file) {
DeprecationWarning.deprecationWarning("Use CommandManager.execute(Commands.FILE_CLOSE, {File: file} instead of DocumentManager.closeFullEditor()", true);
CommandManager.execute(Commands.FILE_CLOSE, {File: file});
} | [
"function",
"closeFullEditor",
"(",
"file",
")",
"{",
"DeprecationWarning",
".",
"deprecationWarning",
"(",
"\"Use CommandManager.execute(Commands.FILE_CLOSE, {File: file} instead of DocumentManager.closeFullEditor()\"",
",",
"true",
")",
";",
"CommandManager",
".",
"execute",
"(",
"Commands",
".",
"FILE_CLOSE",
",",
"{",
"File",
":",
"file",
"}",
")",
";",
"}"
] | closes the specified file file
@deprecated use CommandManager.execute(Commands.FILE_CLOSE, {File: file}) instead
@param {!File} file - the file to close | [
"closes",
"the",
"specified",
"file",
"file"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L247-L250 |
2,283 | adobe/brackets | src/document/DocumentManager.js | setCurrentDocument | function setCurrentDocument(doc) {
DeprecationWarning.deprecationWarning("Use CommandManager.execute(Commands.CMD_OPEN) instead of DocumentManager.setCurrentDocument()", true);
CommandManager.execute(Commands.CMD_OPEN, {fullPath: doc.file.fullPath});
} | javascript | function setCurrentDocument(doc) {
DeprecationWarning.deprecationWarning("Use CommandManager.execute(Commands.CMD_OPEN) instead of DocumentManager.setCurrentDocument()", true);
CommandManager.execute(Commands.CMD_OPEN, {fullPath: doc.file.fullPath});
} | [
"function",
"setCurrentDocument",
"(",
"doc",
")",
"{",
"DeprecationWarning",
".",
"deprecationWarning",
"(",
"\"Use CommandManager.execute(Commands.CMD_OPEN) instead of DocumentManager.setCurrentDocument()\"",
",",
"true",
")",
";",
"CommandManager",
".",
"execute",
"(",
"Commands",
".",
"CMD_OPEN",
",",
"{",
"fullPath",
":",
"doc",
".",
"file",
".",
"fullPath",
"}",
")",
";",
"}"
] | opens the specified document for editing in the currently active pane
@deprecated use CommandManager.execute(Commands.CMD_OPEN, {fullPath: doc.file.fullPath}) instead
@param {!Document} document The Document to make current. | [
"opens",
"the",
"specified",
"document",
"for",
"editing",
"in",
"the",
"currently",
"active",
"pane"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L257-L260 |
2,284 | adobe/brackets | src/document/DocumentManager.js | notifyPathDeleted | function notifyPathDeleted(fullPath) {
// FileSyncManager.syncOpenDocuments() does all the work prompting
// the user to save any unsaved changes and then calls us back
// via notifyFileDeleted
FileSyncManager.syncOpenDocuments(Strings.FILE_DELETED_TITLE);
var projectRoot = ProjectManager.getProjectRoot(),
context = {
location : {
scope: "user",
layer: "project",
layerID: projectRoot.fullPath
}
};
var encoding = PreferencesManager.getViewState("encoding", context);
delete encoding[fullPath];
PreferencesManager.setViewState("encoding", encoding, context);
if (!getOpenDocumentForPath(fullPath) &&
!MainViewManager.findInAllWorkingSets(fullPath).length) {
// For images not open in the workingset,
// FileSyncManager.syncOpenDocuments() will
// not tell us to close those views
exports.trigger("pathDeleted", fullPath);
}
} | javascript | function notifyPathDeleted(fullPath) {
// FileSyncManager.syncOpenDocuments() does all the work prompting
// the user to save any unsaved changes and then calls us back
// via notifyFileDeleted
FileSyncManager.syncOpenDocuments(Strings.FILE_DELETED_TITLE);
var projectRoot = ProjectManager.getProjectRoot(),
context = {
location : {
scope: "user",
layer: "project",
layerID: projectRoot.fullPath
}
};
var encoding = PreferencesManager.getViewState("encoding", context);
delete encoding[fullPath];
PreferencesManager.setViewState("encoding", encoding, context);
if (!getOpenDocumentForPath(fullPath) &&
!MainViewManager.findInAllWorkingSets(fullPath).length) {
// For images not open in the workingset,
// FileSyncManager.syncOpenDocuments() will
// not tell us to close those views
exports.trigger("pathDeleted", fullPath);
}
} | [
"function",
"notifyPathDeleted",
"(",
"fullPath",
")",
"{",
"// FileSyncManager.syncOpenDocuments() does all the work prompting",
"// the user to save any unsaved changes and then calls us back",
"// via notifyFileDeleted",
"FileSyncManager",
".",
"syncOpenDocuments",
"(",
"Strings",
".",
"FILE_DELETED_TITLE",
")",
";",
"var",
"projectRoot",
"=",
"ProjectManager",
".",
"getProjectRoot",
"(",
")",
",",
"context",
"=",
"{",
"location",
":",
"{",
"scope",
":",
"\"user\"",
",",
"layer",
":",
"\"project\"",
",",
"layerID",
":",
"projectRoot",
".",
"fullPath",
"}",
"}",
";",
"var",
"encoding",
"=",
"PreferencesManager",
".",
"getViewState",
"(",
"\"encoding\"",
",",
"context",
")",
";",
"delete",
"encoding",
"[",
"fullPath",
"]",
";",
"PreferencesManager",
".",
"setViewState",
"(",
"\"encoding\"",
",",
"encoding",
",",
"context",
")",
";",
"if",
"(",
"!",
"getOpenDocumentForPath",
"(",
"fullPath",
")",
"&&",
"!",
"MainViewManager",
".",
"findInAllWorkingSets",
"(",
"fullPath",
")",
".",
"length",
")",
"{",
"// For images not open in the workingset,",
"// FileSyncManager.syncOpenDocuments() will",
"// not tell us to close those views",
"exports",
".",
"trigger",
"(",
"\"pathDeleted\"",
",",
"fullPath",
")",
";",
"}",
"}"
] | Called after a file or folder has been deleted. This function is responsible
for updating underlying model data and notifying all views of the change.
@param {string} fullPath The path of the file/folder that has been deleted | [
"Called",
"after",
"a",
"file",
"or",
"folder",
"has",
"been",
"deleted",
".",
"This",
"function",
"is",
"responsible",
"for",
"updating",
"underlying",
"model",
"data",
"and",
"notifying",
"all",
"views",
"of",
"the",
"change",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L497-L522 |
2,285 | adobe/brackets | src/document/DocumentManager.js | notifyPathNameChanged | function notifyPathNameChanged(oldName, newName) {
// Notify all open documents
_.forEach(_openDocuments, function (doc) {
// TODO: Only notify affected documents? For now _notifyFilePathChange
// just updates the language if the extension changed, so it's fine
// to call for all open docs.
doc._notifyFilePathChanged();
});
// Send a "fileNameChange" event. This will trigger the views to update.
exports.trigger("fileNameChange", oldName, newName);
} | javascript | function notifyPathNameChanged(oldName, newName) {
// Notify all open documents
_.forEach(_openDocuments, function (doc) {
// TODO: Only notify affected documents? For now _notifyFilePathChange
// just updates the language if the extension changed, so it's fine
// to call for all open docs.
doc._notifyFilePathChanged();
});
// Send a "fileNameChange" event. This will trigger the views to update.
exports.trigger("fileNameChange", oldName, newName);
} | [
"function",
"notifyPathNameChanged",
"(",
"oldName",
",",
"newName",
")",
"{",
"// Notify all open documents",
"_",
".",
"forEach",
"(",
"_openDocuments",
",",
"function",
"(",
"doc",
")",
"{",
"// TODO: Only notify affected documents? For now _notifyFilePathChange",
"// just updates the language if the extension changed, so it's fine",
"// to call for all open docs.",
"doc",
".",
"_notifyFilePathChanged",
"(",
")",
";",
"}",
")",
";",
"// Send a \"fileNameChange\" event. This will trigger the views to update.",
"exports",
".",
"trigger",
"(",
"\"fileNameChange\"",
",",
"oldName",
",",
"newName",
")",
";",
"}"
] | Called after a file or folder name has changed. This function is responsible
for updating underlying model data and notifying all views of the change.
@param {string} oldName The old name of the file/folder
@param {string} newName The new name of the file/folder | [
"Called",
"after",
"a",
"file",
"or",
"folder",
"name",
"has",
"changed",
".",
"This",
"function",
"is",
"responsible",
"for",
"updating",
"underlying",
"model",
"data",
"and",
"notifying",
"all",
"views",
"of",
"the",
"change",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L531-L542 |
2,286 | adobe/brackets | src/document/DocumentManager.js | _proxyDeprecatedEvent | function _proxyDeprecatedEvent(eventName) {
DeprecationWarning.deprecateEvent(exports,
MainViewManager,
eventName,
eventName,
"DocumentManager." + eventName,
"MainViewManager." + eventName);
} | javascript | function _proxyDeprecatedEvent(eventName) {
DeprecationWarning.deprecateEvent(exports,
MainViewManager,
eventName,
eventName,
"DocumentManager." + eventName,
"MainViewManager." + eventName);
} | [
"function",
"_proxyDeprecatedEvent",
"(",
"eventName",
")",
"{",
"DeprecationWarning",
".",
"deprecateEvent",
"(",
"exports",
",",
"MainViewManager",
",",
"eventName",
",",
"eventName",
",",
"\"DocumentManager.\"",
"+",
"eventName",
",",
"\"MainViewManager.\"",
"+",
"eventName",
")",
";",
"}"
] | Listens for the given event on MainViewManager, and triggers a copy of the event on DocumentManager whenever it occurs | [
"Listens",
"for",
"the",
"given",
"event",
"on",
"MainViewManager",
"and",
"triggers",
"a",
"copy",
"of",
"the",
"event",
"on",
"DocumentManager",
"whenever",
"it",
"occurs"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L651-L658 |
2,287 | adobe/brackets | src/extensions/default/CodeFolding/foldhelpers/foldgutter.js | marker | function marker(spec) {
var elt = window.document.createElement("div");
elt.className = spec;
return elt;
} | javascript | function marker(spec) {
var elt = window.document.createElement("div");
elt.className = spec;
return elt;
} | [
"function",
"marker",
"(",
"spec",
")",
"{",
"var",
"elt",
"=",
"window",
".",
"document",
".",
"createElement",
"(",
"\"div\"",
")",
";",
"elt",
".",
"className",
"=",
"spec",
";",
"return",
"elt",
";",
"}"
] | Utility for creating fold markers in fold gutter
@param {string} spec the className for the marker
@return {HTMLElement} a htmlelement representing the fold marker | [
"Utility",
"for",
"creating",
"fold",
"markers",
"in",
"fold",
"gutter"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L29-L33 |
2,288 | adobe/brackets | src/extensions/default/CodeFolding/foldhelpers/foldgutter.js | updateFoldInfo | function updateFoldInfo(cm, from, to) {
var minFoldSize = prefs.getSetting("minFoldSize") || 2;
var opts = cm.state.foldGutter.options;
var fade = prefs.getSetting("hideUntilMouseover");
var $gutter = $(cm.getGutterElement());
var i = from;
function clear(m) {
return m.clear();
}
/**
* @private
* helper function to check if the given line is in a folded region in the editor.
* @param {number} line the
* @return {Object} the range that hides the specified line or undefine if the line is not hidden
*/
function _isCurrentlyFolded(line) {
var keys = Object.keys(cm._lineFolds), i = 0, range;
while (i < keys.length) {
range = cm._lineFolds[keys[i]];
if (range.from.line < line && range.to.line >= line) {
return range;
}
i++;
}
}
/**
This case is needed when unfolding a region that does not cause the viewport to change.
For instance in a file with about 15 lines, if some code regions are folded and unfolded, the
viewport change event isn't fired by CodeMirror. The setTimeout is a workaround to trigger the
gutter update after the viewport has been drawn.
*/
if (i === to) {
window.setTimeout(function () {
var vp = cm.getViewport();
updateFoldInfo(cm, vp.from, vp.to);
}, 200);
}
while (i < to) {
var sr = _isCurrentlyFolded(i), // surrounding range for the current line if one exists
range;
var mark = marker("CodeMirror-foldgutter-blank");
var pos = CodeMirror.Pos(i, 0),
func = opts.rangeFinder || CodeMirror.fold.auto;
// don't look inside collapsed ranges
if (sr) {
i = sr.to.line + 1;
} else {
range = cm._lineFolds[i] || (func && func(cm, pos));
if (!fade || (fade && $gutter.is(":hover"))) {
if (cm.isFolded(i)) {
// expand fold if invalid
if (range) {
mark = marker(opts.indicatorFolded);
} else {
cm.findMarksAt(pos).filter(isFold)
.forEach(clear);
}
} else {
if (range && range.to.line - range.from.line >= minFoldSize) {
mark = marker(opts.indicatorOpen);
}
}
}
cm.setGutterMarker(i, opts.gutter, mark);
i++;
}
}
} | javascript | function updateFoldInfo(cm, from, to) {
var minFoldSize = prefs.getSetting("minFoldSize") || 2;
var opts = cm.state.foldGutter.options;
var fade = prefs.getSetting("hideUntilMouseover");
var $gutter = $(cm.getGutterElement());
var i = from;
function clear(m) {
return m.clear();
}
/**
* @private
* helper function to check if the given line is in a folded region in the editor.
* @param {number} line the
* @return {Object} the range that hides the specified line or undefine if the line is not hidden
*/
function _isCurrentlyFolded(line) {
var keys = Object.keys(cm._lineFolds), i = 0, range;
while (i < keys.length) {
range = cm._lineFolds[keys[i]];
if (range.from.line < line && range.to.line >= line) {
return range;
}
i++;
}
}
/**
This case is needed when unfolding a region that does not cause the viewport to change.
For instance in a file with about 15 lines, if some code regions are folded and unfolded, the
viewport change event isn't fired by CodeMirror. The setTimeout is a workaround to trigger the
gutter update after the viewport has been drawn.
*/
if (i === to) {
window.setTimeout(function () {
var vp = cm.getViewport();
updateFoldInfo(cm, vp.from, vp.to);
}, 200);
}
while (i < to) {
var sr = _isCurrentlyFolded(i), // surrounding range for the current line if one exists
range;
var mark = marker("CodeMirror-foldgutter-blank");
var pos = CodeMirror.Pos(i, 0),
func = opts.rangeFinder || CodeMirror.fold.auto;
// don't look inside collapsed ranges
if (sr) {
i = sr.to.line + 1;
} else {
range = cm._lineFolds[i] || (func && func(cm, pos));
if (!fade || (fade && $gutter.is(":hover"))) {
if (cm.isFolded(i)) {
// expand fold if invalid
if (range) {
mark = marker(opts.indicatorFolded);
} else {
cm.findMarksAt(pos).filter(isFold)
.forEach(clear);
}
} else {
if (range && range.to.line - range.from.line >= minFoldSize) {
mark = marker(opts.indicatorOpen);
}
}
}
cm.setGutterMarker(i, opts.gutter, mark);
i++;
}
}
} | [
"function",
"updateFoldInfo",
"(",
"cm",
",",
"from",
",",
"to",
")",
"{",
"var",
"minFoldSize",
"=",
"prefs",
".",
"getSetting",
"(",
"\"minFoldSize\"",
")",
"||",
"2",
";",
"var",
"opts",
"=",
"cm",
".",
"state",
".",
"foldGutter",
".",
"options",
";",
"var",
"fade",
"=",
"prefs",
".",
"getSetting",
"(",
"\"hideUntilMouseover\"",
")",
";",
"var",
"$gutter",
"=",
"$",
"(",
"cm",
".",
"getGutterElement",
"(",
")",
")",
";",
"var",
"i",
"=",
"from",
";",
"function",
"clear",
"(",
"m",
")",
"{",
"return",
"m",
".",
"clear",
"(",
")",
";",
"}",
"/**\n * @private\n * helper function to check if the given line is in a folded region in the editor.\n * @param {number} line the\n * @return {Object} the range that hides the specified line or undefine if the line is not hidden\n */",
"function",
"_isCurrentlyFolded",
"(",
"line",
")",
"{",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"cm",
".",
"_lineFolds",
")",
",",
"i",
"=",
"0",
",",
"range",
";",
"while",
"(",
"i",
"<",
"keys",
".",
"length",
")",
"{",
"range",
"=",
"cm",
".",
"_lineFolds",
"[",
"keys",
"[",
"i",
"]",
"]",
";",
"if",
"(",
"range",
".",
"from",
".",
"line",
"<",
"line",
"&&",
"range",
".",
"to",
".",
"line",
">=",
"line",
")",
"{",
"return",
"range",
";",
"}",
"i",
"++",
";",
"}",
"}",
"/**\n This case is needed when unfolding a region that does not cause the viewport to change.\n For instance in a file with about 15 lines, if some code regions are folded and unfolded, the\n viewport change event isn't fired by CodeMirror. The setTimeout is a workaround to trigger the\n gutter update after the viewport has been drawn.\n */",
"if",
"(",
"i",
"===",
"to",
")",
"{",
"window",
".",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"var",
"vp",
"=",
"cm",
".",
"getViewport",
"(",
")",
";",
"updateFoldInfo",
"(",
"cm",
",",
"vp",
".",
"from",
",",
"vp",
".",
"to",
")",
";",
"}",
",",
"200",
")",
";",
"}",
"while",
"(",
"i",
"<",
"to",
")",
"{",
"var",
"sr",
"=",
"_isCurrentlyFolded",
"(",
"i",
")",
",",
"// surrounding range for the current line if one exists",
"range",
";",
"var",
"mark",
"=",
"marker",
"(",
"\"CodeMirror-foldgutter-blank\"",
")",
";",
"var",
"pos",
"=",
"CodeMirror",
".",
"Pos",
"(",
"i",
",",
"0",
")",
",",
"func",
"=",
"opts",
".",
"rangeFinder",
"||",
"CodeMirror",
".",
"fold",
".",
"auto",
";",
"// don't look inside collapsed ranges",
"if",
"(",
"sr",
")",
"{",
"i",
"=",
"sr",
".",
"to",
".",
"line",
"+",
"1",
";",
"}",
"else",
"{",
"range",
"=",
"cm",
".",
"_lineFolds",
"[",
"i",
"]",
"||",
"(",
"func",
"&&",
"func",
"(",
"cm",
",",
"pos",
")",
")",
";",
"if",
"(",
"!",
"fade",
"||",
"(",
"fade",
"&&",
"$gutter",
".",
"is",
"(",
"\":hover\"",
")",
")",
")",
"{",
"if",
"(",
"cm",
".",
"isFolded",
"(",
"i",
")",
")",
"{",
"// expand fold if invalid",
"if",
"(",
"range",
")",
"{",
"mark",
"=",
"marker",
"(",
"opts",
".",
"indicatorFolded",
")",
";",
"}",
"else",
"{",
"cm",
".",
"findMarksAt",
"(",
"pos",
")",
".",
"filter",
"(",
"isFold",
")",
".",
"forEach",
"(",
"clear",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"range",
"&&",
"range",
".",
"to",
".",
"line",
"-",
"range",
".",
"from",
".",
"line",
">=",
"minFoldSize",
")",
"{",
"mark",
"=",
"marker",
"(",
"opts",
".",
"indicatorOpen",
")",
";",
"}",
"}",
"}",
"cm",
".",
"setGutterMarker",
"(",
"i",
",",
"opts",
".",
"gutter",
",",
"mark",
")",
";",
"i",
"++",
";",
"}",
"}",
"}"
] | Updates the gutter markers for the specified range
@param {!CodeMirror} cm the CodeMirror instance for the active editor
@param {!number} from the starting line for the update
@param {!number} to the ending line for the update | [
"Updates",
"the",
"gutter",
"markers",
"for",
"the",
"specified",
"range"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L50-L122 |
2,289 | adobe/brackets | src/extensions/default/CodeFolding/foldhelpers/foldgutter.js | updateInViewport | function updateInViewport(cm, from, to) {
var vp = cm.getViewport(), state = cm.state.foldGutter;
from = isNaN(from) ? vp.from : from;
to = isNaN(to) ? vp.to : to;
if (!state) { return; }
cm.operation(function () {
updateFoldInfo(cm, from, to);
});
state.from = from;
state.to = to;
} | javascript | function updateInViewport(cm, from, to) {
var vp = cm.getViewport(), state = cm.state.foldGutter;
from = isNaN(from) ? vp.from : from;
to = isNaN(to) ? vp.to : to;
if (!state) { return; }
cm.operation(function () {
updateFoldInfo(cm, from, to);
});
state.from = from;
state.to = to;
} | [
"function",
"updateInViewport",
"(",
"cm",
",",
"from",
",",
"to",
")",
"{",
"var",
"vp",
"=",
"cm",
".",
"getViewport",
"(",
")",
",",
"state",
"=",
"cm",
".",
"state",
".",
"foldGutter",
";",
"from",
"=",
"isNaN",
"(",
"from",
")",
"?",
"vp",
".",
"from",
":",
"from",
";",
"to",
"=",
"isNaN",
"(",
"to",
")",
"?",
"vp",
".",
"to",
":",
"to",
";",
"if",
"(",
"!",
"state",
")",
"{",
"return",
";",
"}",
"cm",
".",
"operation",
"(",
"function",
"(",
")",
"{",
"updateFoldInfo",
"(",
"cm",
",",
"from",
",",
"to",
")",
";",
"}",
")",
";",
"state",
".",
"from",
"=",
"from",
";",
"state",
".",
"to",
"=",
"to",
";",
"}"
] | Updates the fold information in the viewport for the specified range
@param {CodeMirror} cm the instance of the CodeMirror object
@param {?number} from the starting line number for the update
@param {?number} to the end line number for the update | [
"Updates",
"the",
"fold",
"information",
"in",
"the",
"viewport",
"for",
"the",
"specified",
"range"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L130-L141 |
2,290 | adobe/brackets | src/extensions/default/CodeFolding/foldhelpers/foldgutter.js | getFoldOnLine | function getFoldOnLine(cm, line) {
var pos = CodeMirror.Pos(line, 0);
var folds = cm.findMarksAt(pos) || [];
folds = folds.filter(isFold);
return folds.length ? folds[0] : undefined;
} | javascript | function getFoldOnLine(cm, line) {
var pos = CodeMirror.Pos(line, 0);
var folds = cm.findMarksAt(pos) || [];
folds = folds.filter(isFold);
return folds.length ? folds[0] : undefined;
} | [
"function",
"getFoldOnLine",
"(",
"cm",
",",
"line",
")",
"{",
"var",
"pos",
"=",
"CodeMirror",
".",
"Pos",
"(",
"line",
",",
"0",
")",
";",
"var",
"folds",
"=",
"cm",
".",
"findMarksAt",
"(",
"pos",
")",
"||",
"[",
"]",
";",
"folds",
"=",
"folds",
".",
"filter",
"(",
"isFold",
")",
";",
"return",
"folds",
".",
"length",
"?",
"folds",
"[",
"0",
"]",
":",
"undefined",
";",
"}"
] | Helper function to return the fold text marker on a line in an editor
@param {CodeMirror} cm The CodeMirror instance for the active editor
@param {Number} line The line number representing the position of the fold marker
@returns {TextMarker} A CodeMirror TextMarker object | [
"Helper",
"function",
"to",
"return",
"the",
"fold",
"text",
"marker",
"on",
"a",
"line",
"in",
"an",
"editor"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L149-L154 |
2,291 | adobe/brackets | src/extensions/default/CodeFolding/foldhelpers/foldgutter.js | syncDocToFoldsCache | function syncDocToFoldsCache(cm, from, lineAdded) {
var minFoldSize = prefs.getSetting("minFoldSize") || 2;
var i, fold, range;
if (lineAdded <= 0) {
return;
}
for (i = from; i <= from + lineAdded; i = i + 1) {
fold = getFoldOnLine(cm, i);
if (fold) {
range = fold.find();
if (range && range.to.line - range.from.line >= minFoldSize) {
cm._lineFolds[i] = range;
i = range.to.line;
} else {
delete cm._lineFolds[i];
}
}
}
} | javascript | function syncDocToFoldsCache(cm, from, lineAdded) {
var minFoldSize = prefs.getSetting("minFoldSize") || 2;
var i, fold, range;
if (lineAdded <= 0) {
return;
}
for (i = from; i <= from + lineAdded; i = i + 1) {
fold = getFoldOnLine(cm, i);
if (fold) {
range = fold.find();
if (range && range.to.line - range.from.line >= minFoldSize) {
cm._lineFolds[i] = range;
i = range.to.line;
} else {
delete cm._lineFolds[i];
}
}
}
} | [
"function",
"syncDocToFoldsCache",
"(",
"cm",
",",
"from",
",",
"lineAdded",
")",
"{",
"var",
"minFoldSize",
"=",
"prefs",
".",
"getSetting",
"(",
"\"minFoldSize\"",
")",
"||",
"2",
";",
"var",
"i",
",",
"fold",
",",
"range",
";",
"if",
"(",
"lineAdded",
"<=",
"0",
")",
"{",
"return",
";",
"}",
"for",
"(",
"i",
"=",
"from",
";",
"i",
"<=",
"from",
"+",
"lineAdded",
";",
"i",
"=",
"i",
"+",
"1",
")",
"{",
"fold",
"=",
"getFoldOnLine",
"(",
"cm",
",",
"i",
")",
";",
"if",
"(",
"fold",
")",
"{",
"range",
"=",
"fold",
".",
"find",
"(",
")",
";",
"if",
"(",
"range",
"&&",
"range",
".",
"to",
".",
"line",
"-",
"range",
".",
"from",
".",
"line",
">=",
"minFoldSize",
")",
"{",
"cm",
".",
"_lineFolds",
"[",
"i",
"]",
"=",
"range",
";",
"i",
"=",
"range",
".",
"to",
".",
"line",
";",
"}",
"else",
"{",
"delete",
"cm",
".",
"_lineFolds",
"[",
"i",
"]",
";",
"}",
"}",
"}",
"}"
] | Synchronises the code folding states in the CM doc to cm._lineFolds cache.
When an undo operation is done, if folded code fragments are restored, then
we need to update cm._lineFolds with the fragments
@param {Object} cm cm the CodeMirror instance for the active editor
@param {Object} from starting position in the doc to sync the fold states from
@param {[[Type]]} lineAdded a number to show how many lines where added to the document | [
"Synchronises",
"the",
"code",
"folding",
"states",
"in",
"the",
"CM",
"doc",
"to",
"cm",
".",
"_lineFolds",
"cache",
".",
"When",
"an",
"undo",
"operation",
"is",
"done",
"if",
"folded",
"code",
"fragments",
"are",
"restored",
"then",
"we",
"need",
"to",
"update",
"cm",
".",
"_lineFolds",
"with",
"the",
"fragments"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L164-L183 |
2,292 | adobe/brackets | src/extensions/default/CodeFolding/foldhelpers/foldgutter.js | moveRange | function moveRange(range, numLines) {
return {from: CodeMirror.Pos(range.from.line + numLines, range.from.ch),
to: CodeMirror.Pos(range.to.line + numLines, range.to.ch)};
} | javascript | function moveRange(range, numLines) {
return {from: CodeMirror.Pos(range.from.line + numLines, range.from.ch),
to: CodeMirror.Pos(range.to.line + numLines, range.to.ch)};
} | [
"function",
"moveRange",
"(",
"range",
",",
"numLines",
")",
"{",
"return",
"{",
"from",
":",
"CodeMirror",
".",
"Pos",
"(",
"range",
".",
"from",
".",
"line",
"+",
"numLines",
",",
"range",
".",
"from",
".",
"ch",
")",
",",
"to",
":",
"CodeMirror",
".",
"Pos",
"(",
"range",
".",
"to",
".",
"line",
"+",
"numLines",
",",
"range",
".",
"to",
".",
"ch",
")",
"}",
";",
"}"
] | Helper function to move a fold range object by the specified number of lines
@param {Object} range An object specifying the fold range to move. It contains {from, to} which are CodeMirror.Pos objects.
@param {Number} numLines A positive or negative number representing the numbe of lines to move the range by | [
"Helper",
"function",
"to",
"move",
"a",
"fold",
"range",
"object",
"by",
"the",
"specified",
"number",
"of",
"lines"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L190-L193 |
2,293 | adobe/brackets | src/extensions/default/CodeFolding/foldhelpers/foldgutter.js | onCursorActivity | function onCursorActivity(cm) {
var state = cm.state.foldGutter;
var vp = cm.getViewport();
window.clearTimeout(state.changeUpdate);
state.changeUpdate = window.setTimeout(function () {
//need to render the entire visible viewport to remove fold marks rendered from previous selections if any
updateInViewport(cm, vp.from, vp.to);
}, 400);
} | javascript | function onCursorActivity(cm) {
var state = cm.state.foldGutter;
var vp = cm.getViewport();
window.clearTimeout(state.changeUpdate);
state.changeUpdate = window.setTimeout(function () {
//need to render the entire visible viewport to remove fold marks rendered from previous selections if any
updateInViewport(cm, vp.from, vp.to);
}, 400);
} | [
"function",
"onCursorActivity",
"(",
"cm",
")",
"{",
"var",
"state",
"=",
"cm",
".",
"state",
".",
"foldGutter",
";",
"var",
"vp",
"=",
"cm",
".",
"getViewport",
"(",
")",
";",
"window",
".",
"clearTimeout",
"(",
"state",
".",
"changeUpdate",
")",
";",
"state",
".",
"changeUpdate",
"=",
"window",
".",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"//need to render the entire visible viewport to remove fold marks rendered from previous selections if any",
"updateInViewport",
"(",
"cm",
",",
"vp",
".",
"from",
",",
"vp",
".",
"to",
")",
";",
"}",
",",
"400",
")",
";",
"}"
] | Triggered when the cursor moves in the editor and used to detect text selection changes
in the editor.
@param {!CodeMirror} cm the CodeMirror instance for the active editor | [
"Triggered",
"when",
"the",
"cursor",
"moves",
"in",
"the",
"editor",
"and",
"used",
"to",
"detect",
"text",
"selection",
"changes",
"in",
"the",
"editor",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L327-L335 |
2,294 | adobe/brackets | src/extensions/default/CodeFolding/foldhelpers/foldgutter.js | onFold | function onFold(cm, from, to) {
var state = cm.state.foldGutter;
updateFoldInfo(cm, from.line, from.line + 1);
} | javascript | function onFold(cm, from, to) {
var state = cm.state.foldGutter;
updateFoldInfo(cm, from.line, from.line + 1);
} | [
"function",
"onFold",
"(",
"cm",
",",
"from",
",",
"to",
")",
"{",
"var",
"state",
"=",
"cm",
".",
"state",
".",
"foldGutter",
";",
"updateFoldInfo",
"(",
"cm",
",",
"from",
".",
"line",
",",
"from",
".",
"line",
"+",
"1",
")",
";",
"}"
] | Triggered when a code segment is folded.
@param {!CodeMirror} cm the CodeMirror instance for the active editor
@param {!Object} from the ch and line position that designates the start of the region
@param {!Object} to the ch and line position that designates the end of the region | [
"Triggered",
"when",
"a",
"code",
"segment",
"is",
"folded",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L343-L346 |
2,295 | adobe/brackets | src/extensions/default/CodeFolding/foldhelpers/foldgutter.js | onUnFold | function onUnFold(cm, from, to) {
var state = cm.state.foldGutter;
var vp = cm.getViewport();
delete cm._lineFolds[from.line];
updateFoldInfo(cm, from.line, to.line || vp.to);
} | javascript | function onUnFold(cm, from, to) {
var state = cm.state.foldGutter;
var vp = cm.getViewport();
delete cm._lineFolds[from.line];
updateFoldInfo(cm, from.line, to.line || vp.to);
} | [
"function",
"onUnFold",
"(",
"cm",
",",
"from",
",",
"to",
")",
"{",
"var",
"state",
"=",
"cm",
".",
"state",
".",
"foldGutter",
";",
"var",
"vp",
"=",
"cm",
".",
"getViewport",
"(",
")",
";",
"delete",
"cm",
".",
"_lineFolds",
"[",
"from",
".",
"line",
"]",
";",
"updateFoldInfo",
"(",
"cm",
",",
"from",
".",
"line",
",",
"to",
".",
"line",
"||",
"vp",
".",
"to",
")",
";",
"}"
] | Triggered when a folded code segment is unfolded.
@param {!CodeMirror} cm the CodeMirror instance for the active editor
@param {!{line:number, ch:number}} from the ch and line position that designates the start of the region
@param {!{line:number, ch:number}} to the ch and line position that designates the end of the region | [
"Triggered",
"when",
"a",
"folded",
"code",
"segment",
"is",
"unfolded",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L354-L359 |
2,296 | adobe/brackets | src/extensions/default/CodeFolding/foldhelpers/foldgutter.js | init | function init() {
CodeMirror.defineOption("foldGutter", false, function (cm, val, old) {
if (old && old !== CodeMirror.Init) {
cm.clearGutter(cm.state.foldGutter.options.gutter);
cm.state.foldGutter = null;
cm.off("gutterClick", old.onGutterClick);
cm.off("change", onChange);
cm.off("viewportChange", onViewportChange);
cm.off("cursorActivity", onCursorActivity);
cm.off("fold", onFold);
cm.off("unfold", onUnFold);
cm.off("swapDoc", updateInViewport);
}
if (val) {
cm.state.foldGutter = new State(parseOptions(val));
updateInViewport(cm);
cm.on("gutterClick", val.onGutterClick);
cm.on("change", onChange);
cm.on("viewportChange", onViewportChange);
cm.on("cursorActivity", onCursorActivity);
cm.on("fold", onFold);
cm.on("unfold", onUnFold);
cm.on("swapDoc", updateInViewport);
}
});
} | javascript | function init() {
CodeMirror.defineOption("foldGutter", false, function (cm, val, old) {
if (old && old !== CodeMirror.Init) {
cm.clearGutter(cm.state.foldGutter.options.gutter);
cm.state.foldGutter = null;
cm.off("gutterClick", old.onGutterClick);
cm.off("change", onChange);
cm.off("viewportChange", onViewportChange);
cm.off("cursorActivity", onCursorActivity);
cm.off("fold", onFold);
cm.off("unfold", onUnFold);
cm.off("swapDoc", updateInViewport);
}
if (val) {
cm.state.foldGutter = new State(parseOptions(val));
updateInViewport(cm);
cm.on("gutterClick", val.onGutterClick);
cm.on("change", onChange);
cm.on("viewportChange", onViewportChange);
cm.on("cursorActivity", onCursorActivity);
cm.on("fold", onFold);
cm.on("unfold", onUnFold);
cm.on("swapDoc", updateInViewport);
}
});
} | [
"function",
"init",
"(",
")",
"{",
"CodeMirror",
".",
"defineOption",
"(",
"\"foldGutter\"",
",",
"false",
",",
"function",
"(",
"cm",
",",
"val",
",",
"old",
")",
"{",
"if",
"(",
"old",
"&&",
"old",
"!==",
"CodeMirror",
".",
"Init",
")",
"{",
"cm",
".",
"clearGutter",
"(",
"cm",
".",
"state",
".",
"foldGutter",
".",
"options",
".",
"gutter",
")",
";",
"cm",
".",
"state",
".",
"foldGutter",
"=",
"null",
";",
"cm",
".",
"off",
"(",
"\"gutterClick\"",
",",
"old",
".",
"onGutterClick",
")",
";",
"cm",
".",
"off",
"(",
"\"change\"",
",",
"onChange",
")",
";",
"cm",
".",
"off",
"(",
"\"viewportChange\"",
",",
"onViewportChange",
")",
";",
"cm",
".",
"off",
"(",
"\"cursorActivity\"",
",",
"onCursorActivity",
")",
";",
"cm",
".",
"off",
"(",
"\"fold\"",
",",
"onFold",
")",
";",
"cm",
".",
"off",
"(",
"\"unfold\"",
",",
"onUnFold",
")",
";",
"cm",
".",
"off",
"(",
"\"swapDoc\"",
",",
"updateInViewport",
")",
";",
"}",
"if",
"(",
"val",
")",
"{",
"cm",
".",
"state",
".",
"foldGutter",
"=",
"new",
"State",
"(",
"parseOptions",
"(",
"val",
")",
")",
";",
"updateInViewport",
"(",
"cm",
")",
";",
"cm",
".",
"on",
"(",
"\"gutterClick\"",
",",
"val",
".",
"onGutterClick",
")",
";",
"cm",
".",
"on",
"(",
"\"change\"",
",",
"onChange",
")",
";",
"cm",
".",
"on",
"(",
"\"viewportChange\"",
",",
"onViewportChange",
")",
";",
"cm",
".",
"on",
"(",
"\"cursorActivity\"",
",",
"onCursorActivity",
")",
";",
"cm",
".",
"on",
"(",
"\"fold\"",
",",
"onFold",
")",
";",
"cm",
".",
"on",
"(",
"\"unfold\"",
",",
"onUnFold",
")",
";",
"cm",
".",
"on",
"(",
"\"swapDoc\"",
",",
"updateInViewport",
")",
";",
"}",
"}",
")",
";",
"}"
] | Initialises the fold gutter and registers event handlers for changes to document, viewport
and user interactions. | [
"Initialises",
"the",
"fold",
"gutter",
"and",
"registers",
"event",
"handlers",
"for",
"changes",
"to",
"document",
"viewport",
"and",
"user",
"interactions",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L365-L391 |
2,297 | adobe/brackets | src/search/FileFilters.js | _getCondensedForm | function _getCondensedForm(filter) {
if (!_.isArray(filter)) {
return "";
}
// Format filter in condensed form
if (filter.length > 2) {
return filter.slice(0, 2).join(", ") + " " +
StringUtils.format(Strings.FILE_FILTER_CLIPPED_SUFFIX, filter.length - 2);
}
return filter.join(", ");
} | javascript | function _getCondensedForm(filter) {
if (!_.isArray(filter)) {
return "";
}
// Format filter in condensed form
if (filter.length > 2) {
return filter.slice(0, 2).join(", ") + " " +
StringUtils.format(Strings.FILE_FILTER_CLIPPED_SUFFIX, filter.length - 2);
}
return filter.join(", ");
} | [
"function",
"_getCondensedForm",
"(",
"filter",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isArray",
"(",
"filter",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"// Format filter in condensed form",
"if",
"(",
"filter",
".",
"length",
">",
"2",
")",
"{",
"return",
"filter",
".",
"slice",
"(",
"0",
",",
"2",
")",
".",
"join",
"(",
"\", \"",
")",
"+",
"\" \"",
"+",
"StringUtils",
".",
"format",
"(",
"Strings",
".",
"FILE_FILTER_CLIPPED_SUFFIX",
",",
"filter",
".",
"length",
"-",
"2",
")",
";",
"}",
"return",
"filter",
".",
"join",
"(",
"\", \"",
")",
";",
"}"
] | Get the condensed form of the filter set by joining the first two in the set with
a comma separator and appending a short message with the number of filters being clipped.
@param {Array.<string>} filter
@return {string} Condensed form of filter set if `filter` is a valid array.
Otherwise, return an empty string. | [
"Get",
"the",
"condensed",
"form",
"of",
"the",
"filter",
"set",
"by",
"joining",
"the",
"first",
"two",
"in",
"the",
"set",
"with",
"a",
"comma",
"separator",
"and",
"appending",
"a",
"short",
"message",
"with",
"the",
"number",
"of",
"filters",
"being",
"clipped",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L74-L85 |
2,298 | adobe/brackets | src/search/FileFilters.js | _doPopulate | function _doPopulate() {
var dropdownItems = [Strings.NEW_FILE_FILTER, Strings.CLEAR_FILE_FILTER],
filterSets = PreferencesManager.get("fileFilters") || [];
if (filterSets.length) {
dropdownItems.push("---");
// Remove all the empty exclusion sets before concatenating to the dropdownItems.
filterSets = filterSets.filter(function (filter) {
return (_getCondensedForm(filter.patterns) !== "");
});
// FIRST_FILTER_INDEX needs to stay in sync with the number of static items (plus separator)
// ie. the number of items populated so far before we concatenate with the actual filter sets.
dropdownItems = dropdownItems.concat(filterSets);
}
_picker.items = dropdownItems;
} | javascript | function _doPopulate() {
var dropdownItems = [Strings.NEW_FILE_FILTER, Strings.CLEAR_FILE_FILTER],
filterSets = PreferencesManager.get("fileFilters") || [];
if (filterSets.length) {
dropdownItems.push("---");
// Remove all the empty exclusion sets before concatenating to the dropdownItems.
filterSets = filterSets.filter(function (filter) {
return (_getCondensedForm(filter.patterns) !== "");
});
// FIRST_FILTER_INDEX needs to stay in sync with the number of static items (plus separator)
// ie. the number of items populated so far before we concatenate with the actual filter sets.
dropdownItems = dropdownItems.concat(filterSets);
}
_picker.items = dropdownItems;
} | [
"function",
"_doPopulate",
"(",
")",
"{",
"var",
"dropdownItems",
"=",
"[",
"Strings",
".",
"NEW_FILE_FILTER",
",",
"Strings",
".",
"CLEAR_FILE_FILTER",
"]",
",",
"filterSets",
"=",
"PreferencesManager",
".",
"get",
"(",
"\"fileFilters\"",
")",
"||",
"[",
"]",
";",
"if",
"(",
"filterSets",
".",
"length",
")",
"{",
"dropdownItems",
".",
"push",
"(",
"\"---\"",
")",
";",
"// Remove all the empty exclusion sets before concatenating to the dropdownItems.",
"filterSets",
"=",
"filterSets",
".",
"filter",
"(",
"function",
"(",
"filter",
")",
"{",
"return",
"(",
"_getCondensedForm",
"(",
"filter",
".",
"patterns",
")",
"!==",
"\"\"",
")",
";",
"}",
")",
";",
"// FIRST_FILTER_INDEX needs to stay in sync with the number of static items (plus separator)",
"// ie. the number of items populated so far before we concatenate with the actual filter sets.",
"dropdownItems",
"=",
"dropdownItems",
".",
"concat",
"(",
"filterSets",
")",
";",
"}",
"_picker",
".",
"items",
"=",
"dropdownItems",
";",
"}"
] | Populate the list of dropdown menu with two filter commands and
the list of saved filter sets. | [
"Populate",
"the",
"list",
"of",
"dropdown",
"menu",
"with",
"two",
"filter",
"commands",
"and",
"the",
"list",
"of",
"saved",
"filter",
"sets",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L91-L108 |
2,299 | adobe/brackets | src/search/FileFilters.js | _getFilterIndex | function _getFilterIndex(filterSets, filter) {
var index = -1;
if (!filter || !filterSets.length) {
return index;
}
return _.findIndex(filterSets, _.partial(_.isEqual, filter));
} | javascript | function _getFilterIndex(filterSets, filter) {
var index = -1;
if (!filter || !filterSets.length) {
return index;
}
return _.findIndex(filterSets, _.partial(_.isEqual, filter));
} | [
"function",
"_getFilterIndex",
"(",
"filterSets",
",",
"filter",
")",
"{",
"var",
"index",
"=",
"-",
"1",
";",
"if",
"(",
"!",
"filter",
"||",
"!",
"filterSets",
".",
"length",
")",
"{",
"return",
"index",
";",
"}",
"return",
"_",
".",
"findIndex",
"(",
"filterSets",
",",
"_",
".",
"partial",
"(",
"_",
".",
"isEqual",
",",
"filter",
")",
")",
";",
"}"
] | Find the index of a filter set in the list of saved filter sets.
@param {Array.<{name: string, patterns: Array.<string>}>} filterSets
@return {{name: string, patterns: Array.<string>}} filter | [
"Find",
"the",
"index",
"of",
"a",
"filter",
"set",
"in",
"the",
"list",
"of",
"saved",
"filter",
"sets",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L115-L123 |
Subsets and Splits