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,300 | adobe/brackets | src/search/FileFilters.js | filterFileList | function filterFileList(compiledFilter, files) {
if (!compiledFilter) {
return files;
}
var re = new RegExp(compiledFilter);
return files.filter(function (f) {
return !re.test(f.fullPath);
});
} | javascript | function filterFileList(compiledFilter, files) {
if (!compiledFilter) {
return files;
}
var re = new RegExp(compiledFilter);
return files.filter(function (f) {
return !re.test(f.fullPath);
});
} | [
"function",
"filterFileList",
"(",
"compiledFilter",
",",
"files",
")",
"{",
"if",
"(",
"!",
"compiledFilter",
")",
"{",
"return",
"files",
";",
"}",
"var",
"re",
"=",
"new",
"RegExp",
"(",
"compiledFilter",
")",
";",
"return",
"files",
".",
"filter",
"(",
"function",
"(",
"f",
")",
"{",
"return",
"!",
"re",
".",
"test",
"(",
"f",
".",
"fullPath",
")",
";",
"}",
")",
";",
"}"
] | Returns a copy of 'files' filtered to just those that don't match any of the exclusion globs in the filter.
@param {?string} compiledFilter 'Compiled' filter object as returned by compile(), or null to no-op
@param {!Array.<File>} files
@return {!Array.<File>} | [
"Returns",
"a",
"copy",
"of",
"files",
"filtered",
"to",
"just",
"those",
"that",
"don",
"t",
"match",
"any",
"of",
"the",
"exclusion",
"globs",
"in",
"the",
"filter",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L285-L294 |
2,301 | adobe/brackets | src/search/FileFilters.js | getPathsMatchingFilter | function getPathsMatchingFilter(compiledFilter, filePaths) {
if (!compiledFilter) {
return filePaths;
}
var re = new RegExp(compiledFilter);
return filePaths.filter(function (f) {
return f.match(re);
});
} | javascript | function getPathsMatchingFilter(compiledFilter, filePaths) {
if (!compiledFilter) {
return filePaths;
}
var re = new RegExp(compiledFilter);
return filePaths.filter(function (f) {
return f.match(re);
});
} | [
"function",
"getPathsMatchingFilter",
"(",
"compiledFilter",
",",
"filePaths",
")",
"{",
"if",
"(",
"!",
"compiledFilter",
")",
"{",
"return",
"filePaths",
";",
"}",
"var",
"re",
"=",
"new",
"RegExp",
"(",
"compiledFilter",
")",
";",
"return",
"filePaths",
".",
"filter",
"(",
"function",
"(",
"f",
")",
"{",
"return",
"f",
".",
"match",
"(",
"re",
")",
";",
"}",
")",
";",
"}"
] | Returns a copy of 'file path' strings that match any of the exclusion globs in the filter.
@param {?string} compiledFilter 'Compiled' filter object as returned by compile(), or null to no-op
@param {!Array.<string>} An array with a list of full file paths that matches atleast one of the filter.
@return {!Array.<string>} | [
"Returns",
"a",
"copy",
"of",
"file",
"path",
"strings",
"that",
"match",
"any",
"of",
"the",
"exclusion",
"globs",
"in",
"the",
"filter",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L303-L312 |
2,302 | adobe/brackets | src/search/FileFilters.js | _handleDeleteFilter | function _handleDeleteFilter(e) {
// Remove the filter set from the preferences and
// clear the active filter set index from view state.
var filterSets = PreferencesManager.get("fileFilters") || [],
activeFilterIndex = PreferencesManager.getViewState("activeFileFilter"),
filterIndex = $(e.target).parent().data("index") - FIRST_FILTER_INDEX;
// Don't let the click bubble upward.
e.stopPropagation();
filterSets.splice(filterIndex, 1);
PreferencesManager.set("fileFilters", filterSets);
if (activeFilterIndex === filterIndex) {
// Removing the active filter, so clear the active filter
// both in the view state.
setActiveFilter(null);
} else if (activeFilterIndex > filterIndex) {
// Adjust the active filter index after the removal of a filter set before it.
--activeFilterIndex;
setActiveFilter(filterSets[activeFilterIndex], activeFilterIndex);
}
_updatePicker();
_doPopulate();
_picker.refresh();
} | javascript | function _handleDeleteFilter(e) {
// Remove the filter set from the preferences and
// clear the active filter set index from view state.
var filterSets = PreferencesManager.get("fileFilters") || [],
activeFilterIndex = PreferencesManager.getViewState("activeFileFilter"),
filterIndex = $(e.target).parent().data("index") - FIRST_FILTER_INDEX;
// Don't let the click bubble upward.
e.stopPropagation();
filterSets.splice(filterIndex, 1);
PreferencesManager.set("fileFilters", filterSets);
if (activeFilterIndex === filterIndex) {
// Removing the active filter, so clear the active filter
// both in the view state.
setActiveFilter(null);
} else if (activeFilterIndex > filterIndex) {
// Adjust the active filter index after the removal of a filter set before it.
--activeFilterIndex;
setActiveFilter(filterSets[activeFilterIndex], activeFilterIndex);
}
_updatePicker();
_doPopulate();
_picker.refresh();
} | [
"function",
"_handleDeleteFilter",
"(",
"e",
")",
"{",
"// Remove the filter set from the preferences and",
"// clear the active filter set index from view state.",
"var",
"filterSets",
"=",
"PreferencesManager",
".",
"get",
"(",
"\"fileFilters\"",
")",
"||",
"[",
"]",
",",
"activeFilterIndex",
"=",
"PreferencesManager",
".",
"getViewState",
"(",
"\"activeFileFilter\"",
")",
",",
"filterIndex",
"=",
"$",
"(",
"e",
".",
"target",
")",
".",
"parent",
"(",
")",
".",
"data",
"(",
"\"index\"",
")",
"-",
"FIRST_FILTER_INDEX",
";",
"// Don't let the click bubble upward.",
"e",
".",
"stopPropagation",
"(",
")",
";",
"filterSets",
".",
"splice",
"(",
"filterIndex",
",",
"1",
")",
";",
"PreferencesManager",
".",
"set",
"(",
"\"fileFilters\"",
",",
"filterSets",
")",
";",
"if",
"(",
"activeFilterIndex",
"===",
"filterIndex",
")",
"{",
"// Removing the active filter, so clear the active filter",
"// both in the view state.",
"setActiveFilter",
"(",
"null",
")",
";",
"}",
"else",
"if",
"(",
"activeFilterIndex",
">",
"filterIndex",
")",
"{",
"// Adjust the active filter index after the removal of a filter set before it.",
"--",
"activeFilterIndex",
";",
"setActiveFilter",
"(",
"filterSets",
"[",
"activeFilterIndex",
"]",
",",
"activeFilterIndex",
")",
";",
"}",
"_updatePicker",
"(",
")",
";",
"_doPopulate",
"(",
")",
";",
"_picker",
".",
"refresh",
"(",
")",
";",
"}"
] | Remove the target item from the filter dropdown list and update dropdown button
and dropdown list UI.
@param {!Event} e Mouse events | [
"Remove",
"the",
"target",
"item",
"from",
"the",
"filter",
"dropdown",
"list",
"and",
"update",
"dropdown",
"button",
"and",
"dropdown",
"list",
"UI",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L434-L460 |
2,303 | adobe/brackets | src/search/FileFilters.js | _handleEditFilter | function _handleEditFilter(e) {
var filterSets = PreferencesManager.get("fileFilters") || [],
filterIndex = $(e.target).parent().data("index") - FIRST_FILTER_INDEX;
// Don't let the click bubble upward.
e.stopPropagation();
// Close the dropdown first before opening the edit filter dialog
// so that it will restore focus to the DOM element that has focus
// prior to opening it.
_picker.closeDropdown();
editFilter(filterSets[filterIndex], filterIndex);
} | javascript | function _handleEditFilter(e) {
var filterSets = PreferencesManager.get("fileFilters") || [],
filterIndex = $(e.target).parent().data("index") - FIRST_FILTER_INDEX;
// Don't let the click bubble upward.
e.stopPropagation();
// Close the dropdown first before opening the edit filter dialog
// so that it will restore focus to the DOM element that has focus
// prior to opening it.
_picker.closeDropdown();
editFilter(filterSets[filterIndex], filterIndex);
} | [
"function",
"_handleEditFilter",
"(",
"e",
")",
"{",
"var",
"filterSets",
"=",
"PreferencesManager",
".",
"get",
"(",
"\"fileFilters\"",
")",
"||",
"[",
"]",
",",
"filterIndex",
"=",
"$",
"(",
"e",
".",
"target",
")",
".",
"parent",
"(",
")",
".",
"data",
"(",
"\"index\"",
")",
"-",
"FIRST_FILTER_INDEX",
";",
"// Don't let the click bubble upward.",
"e",
".",
"stopPropagation",
"(",
")",
";",
"// Close the dropdown first before opening the edit filter dialog",
"// so that it will restore focus to the DOM element that has focus",
"// prior to opening it.",
"_picker",
".",
"closeDropdown",
"(",
")",
";",
"editFilter",
"(",
"filterSets",
"[",
"filterIndex",
"]",
",",
"filterIndex",
")",
";",
"}"
] | Close filter dropdwon list and launch edit filter dialog.
@param {!Event} e Mouse events | [
"Close",
"filter",
"dropdwon",
"list",
"and",
"launch",
"edit",
"filter",
"dialog",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L466-L479 |
2,304 | adobe/brackets | src/search/FileFilters.js | _handleListRendered | function _handleListRendered(event, $dropdown) {
var activeFilterIndex = PreferencesManager.getViewState("activeFileFilter"),
checkedItemIndex = (activeFilterIndex > -1) ? (activeFilterIndex + FIRST_FILTER_INDEX) : -1;
_picker.setChecked(checkedItemIndex, true);
$dropdown.find(".filter-trash-icon")
.on("click", _handleDeleteFilter);
$dropdown.find(".filter-edit-icon")
.on("click", _handleEditFilter);
} | javascript | function _handleListRendered(event, $dropdown) {
var activeFilterIndex = PreferencesManager.getViewState("activeFileFilter"),
checkedItemIndex = (activeFilterIndex > -1) ? (activeFilterIndex + FIRST_FILTER_INDEX) : -1;
_picker.setChecked(checkedItemIndex, true);
$dropdown.find(".filter-trash-icon")
.on("click", _handleDeleteFilter);
$dropdown.find(".filter-edit-icon")
.on("click", _handleEditFilter);
} | [
"function",
"_handleListRendered",
"(",
"event",
",",
"$dropdown",
")",
"{",
"var",
"activeFilterIndex",
"=",
"PreferencesManager",
".",
"getViewState",
"(",
"\"activeFileFilter\"",
")",
",",
"checkedItemIndex",
"=",
"(",
"activeFilterIndex",
">",
"-",
"1",
")",
"?",
"(",
"activeFilterIndex",
"+",
"FIRST_FILTER_INDEX",
")",
":",
"-",
"1",
";",
"_picker",
".",
"setChecked",
"(",
"checkedItemIndex",
",",
"true",
")",
";",
"$dropdown",
".",
"find",
"(",
"\".filter-trash-icon\"",
")",
".",
"on",
"(",
"\"click\"",
",",
"_handleDeleteFilter",
")",
";",
"$dropdown",
".",
"find",
"(",
"\".filter-edit-icon\"",
")",
".",
"on",
"(",
"\"click\"",
",",
"_handleEditFilter",
")",
";",
"}"
] | Set up mouse click event listeners for 'Delete' and 'Edit' buttons
when the dropdown is open. Also set check mark on the active filter.
@param {!Event>} event listRendered event triggered when the dropdown is open
@param {!jQueryObject} $dropdown the jQuery DOM node of the dropdown list | [
"Set",
"up",
"mouse",
"click",
"event",
"listeners",
"for",
"Delete",
"and",
"Edit",
"buttons",
"when",
"the",
"dropdown",
"is",
"open",
".",
"Also",
"set",
"check",
"mark",
"on",
"the",
"active",
"filter",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L487-L497 |
2,305 | adobe/brackets | src/search/FindInFilesUI.js | searchAndShowResults | function searchAndShowResults(queryInfo, scope, filter, replaceText, candidateFilesPromise) {
return FindInFiles.doSearchInScope(queryInfo, scope, filter, replaceText, candidateFilesPromise)
.done(function (zeroFilesToken) {
// Done searching all files: show results
if (FindInFiles.searchModel.hasResults()) {
_resultsView.open();
if (_findBar) {
_findBar.enable(true);
_findBar.focus();
}
} else {
_resultsView.close();
if (_findBar) {
var showMessage = false;
_findBar.enable(true);
if (zeroFilesToken === FindInFiles.ZERO_FILES_TO_SEARCH) {
_findBar.showError(StringUtils.format(Strings.FIND_IN_FILES_ZERO_FILES,
FindUtils.labelForScope(FindInFiles.searchModel.scope)), true);
} else {
showMessage = true;
}
_findBar.showNoResults(true, showMessage);
}
}
StatusBar.hideBusyIndicator();
})
.fail(function (err) {
console.log("find in files failed: ", err);
StatusBar.hideBusyIndicator();
});
} | javascript | function searchAndShowResults(queryInfo, scope, filter, replaceText, candidateFilesPromise) {
return FindInFiles.doSearchInScope(queryInfo, scope, filter, replaceText, candidateFilesPromise)
.done(function (zeroFilesToken) {
// Done searching all files: show results
if (FindInFiles.searchModel.hasResults()) {
_resultsView.open();
if (_findBar) {
_findBar.enable(true);
_findBar.focus();
}
} else {
_resultsView.close();
if (_findBar) {
var showMessage = false;
_findBar.enable(true);
if (zeroFilesToken === FindInFiles.ZERO_FILES_TO_SEARCH) {
_findBar.showError(StringUtils.format(Strings.FIND_IN_FILES_ZERO_FILES,
FindUtils.labelForScope(FindInFiles.searchModel.scope)), true);
} else {
showMessage = true;
}
_findBar.showNoResults(true, showMessage);
}
}
StatusBar.hideBusyIndicator();
})
.fail(function (err) {
console.log("find in files failed: ", err);
StatusBar.hideBusyIndicator();
});
} | [
"function",
"searchAndShowResults",
"(",
"queryInfo",
",",
"scope",
",",
"filter",
",",
"replaceText",
",",
"candidateFilesPromise",
")",
"{",
"return",
"FindInFiles",
".",
"doSearchInScope",
"(",
"queryInfo",
",",
"scope",
",",
"filter",
",",
"replaceText",
",",
"candidateFilesPromise",
")",
".",
"done",
"(",
"function",
"(",
"zeroFilesToken",
")",
"{",
"// Done searching all files: show results",
"if",
"(",
"FindInFiles",
".",
"searchModel",
".",
"hasResults",
"(",
")",
")",
"{",
"_resultsView",
".",
"open",
"(",
")",
";",
"if",
"(",
"_findBar",
")",
"{",
"_findBar",
".",
"enable",
"(",
"true",
")",
";",
"_findBar",
".",
"focus",
"(",
")",
";",
"}",
"}",
"else",
"{",
"_resultsView",
".",
"close",
"(",
")",
";",
"if",
"(",
"_findBar",
")",
"{",
"var",
"showMessage",
"=",
"false",
";",
"_findBar",
".",
"enable",
"(",
"true",
")",
";",
"if",
"(",
"zeroFilesToken",
"===",
"FindInFiles",
".",
"ZERO_FILES_TO_SEARCH",
")",
"{",
"_findBar",
".",
"showError",
"(",
"StringUtils",
".",
"format",
"(",
"Strings",
".",
"FIND_IN_FILES_ZERO_FILES",
",",
"FindUtils",
".",
"labelForScope",
"(",
"FindInFiles",
".",
"searchModel",
".",
"scope",
")",
")",
",",
"true",
")",
";",
"}",
"else",
"{",
"showMessage",
"=",
"true",
";",
"}",
"_findBar",
".",
"showNoResults",
"(",
"true",
",",
"showMessage",
")",
";",
"}",
"}",
"StatusBar",
".",
"hideBusyIndicator",
"(",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"\"find in files failed: \"",
",",
"err",
")",
";",
"StatusBar",
".",
"hideBusyIndicator",
"(",
")",
";",
"}",
")",
";",
"}"
] | Does a search in the given scope with the given filter. Shows the result list once the search is complete.
@param {{query: string, caseSensitive: boolean, isRegexp: boolean}} queryInfo Query info object
@param {?Entry} scope Project file/subfolder to search within; else searches whole project.
@param {?string} filter A "compiled" filter as returned by FileFilters.compile(), or null for no filter
@param {?string} replaceText If this is a replacement, the text to replace matches with.
@param {?$.Promise} candidateFilesPromise If specified, a promise that should resolve with the same set of files that
getCandidateFiles(scope) would return.
@return {$.Promise} A promise that's resolved with the search results or rejected when the find competes. | [
"Does",
"a",
"search",
"in",
"the",
"given",
"scope",
"with",
"the",
"given",
"filter",
".",
"Shows",
"the",
"result",
"list",
"once",
"the",
"search",
"is",
"complete",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindInFilesUI.js#L81-L115 |
2,306 | adobe/brackets | src/search/FindInFilesUI.js | searchAndReplaceResults | function searchAndReplaceResults(queryInfo, scope, filter, replaceText, candidateFilesPromise) {
return FindInFiles.doSearchInScope(queryInfo, scope, filter, replaceText, candidateFilesPromise)
.done(function (zeroFilesToken) {
// Done searching all files: replace all
if (FindInFiles.searchModel.hasResults()) {
_finishReplaceBatch(FindInFiles.searchModel);
if (_findBar) {
_findBar.enable(true);
_findBar.focus();
}
}
StatusBar.hideBusyIndicator();
})
.fail(function (err) {
console.log("replace all failed: ", err);
StatusBar.hideBusyIndicator();
});
} | javascript | function searchAndReplaceResults(queryInfo, scope, filter, replaceText, candidateFilesPromise) {
return FindInFiles.doSearchInScope(queryInfo, scope, filter, replaceText, candidateFilesPromise)
.done(function (zeroFilesToken) {
// Done searching all files: replace all
if (FindInFiles.searchModel.hasResults()) {
_finishReplaceBatch(FindInFiles.searchModel);
if (_findBar) {
_findBar.enable(true);
_findBar.focus();
}
}
StatusBar.hideBusyIndicator();
})
.fail(function (err) {
console.log("replace all failed: ", err);
StatusBar.hideBusyIndicator();
});
} | [
"function",
"searchAndReplaceResults",
"(",
"queryInfo",
",",
"scope",
",",
"filter",
",",
"replaceText",
",",
"candidateFilesPromise",
")",
"{",
"return",
"FindInFiles",
".",
"doSearchInScope",
"(",
"queryInfo",
",",
"scope",
",",
"filter",
",",
"replaceText",
",",
"candidateFilesPromise",
")",
".",
"done",
"(",
"function",
"(",
"zeroFilesToken",
")",
"{",
"// Done searching all files: replace all",
"if",
"(",
"FindInFiles",
".",
"searchModel",
".",
"hasResults",
"(",
")",
")",
"{",
"_finishReplaceBatch",
"(",
"FindInFiles",
".",
"searchModel",
")",
";",
"if",
"(",
"_findBar",
")",
"{",
"_findBar",
".",
"enable",
"(",
"true",
")",
";",
"_findBar",
".",
"focus",
"(",
")",
";",
"}",
"}",
"StatusBar",
".",
"hideBusyIndicator",
"(",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"\"replace all failed: \"",
",",
"err",
")",
";",
"StatusBar",
".",
"hideBusyIndicator",
"(",
")",
";",
"}",
")",
";",
"}"
] | Does a search in the given scope with the given filter. Replace the result list once the search is complete.
@param {{query: string, caseSensitive: boolean, isRegexp: boolean}} queryInfo Query info object
@param {?Entry} scope Project file/subfolder to search within; else searches whole project.
@param {?string} filter A "compiled" filter as returned by FileFilters.compile(), or null for no filter
@param {?string} replaceText If this is a replacement, the text to replace matches with.
@param {?$.Promise} candidateFilesPromise If specified, a promise that should resolve with the same set of files that
getCandidateFiles(scope) would return.
@return {$.Promise} A promise that's resolved with the search results or rejected when the find competes. | [
"Does",
"a",
"search",
"in",
"the",
"given",
"scope",
"with",
"the",
"given",
"filter",
".",
"Replace",
"the",
"result",
"list",
"once",
"the",
"search",
"is",
"complete",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindInFilesUI.js#L127-L146 |
2,307 | adobe/brackets | src/search/FindInFilesUI.js | _defferedSearch | function _defferedSearch() {
if (_findBar && _findBar._options.multifile && !_findBar._options.replace) {
_findBar.redoInstantSearch();
}
} | javascript | function _defferedSearch() {
if (_findBar && _findBar._options.multifile && !_findBar._options.replace) {
_findBar.redoInstantSearch();
}
} | [
"function",
"_defferedSearch",
"(",
")",
"{",
"if",
"(",
"_findBar",
"&&",
"_findBar",
".",
"_options",
".",
"multifile",
"&&",
"!",
"_findBar",
".",
"_options",
".",
"replace",
")",
"{",
"_findBar",
".",
"redoInstantSearch",
"(",
")",
";",
"}",
"}"
] | Issues a search if find bar is visible and is multi file search and not instant search | [
"Issues",
"a",
"search",
"if",
"find",
"bar",
"is",
"visible",
"and",
"is",
"multi",
"file",
"search",
"and",
"not",
"instant",
"search"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindInFilesUI.js#L437-L441 |
2,308 | adobe/brackets | src/widgets/ModalBar.js | ModalBar | function ModalBar(template, autoClose, animate) {
if (animate === undefined) {
animate = true;
}
this._handleKeydown = this._handleKeydown.bind(this);
this._handleFocusChange = this._handleFocusChange.bind(this);
this._$root = $("<div class='modal-bar'/>")
.html(template)
.insertBefore("#editor-holder");
if (animate) {
this._$root.addClass("popout offscreen");
// Forcing the renderer to do a layout, which will cause it to apply the transform for the "offscreen"
// class, so it will animate when you remove the class.
window.getComputedStyle(this._$root.get(0)).getPropertyValue("top");
this._$root.removeClass("popout offscreen");
}
// If something *other* than an editor (like another modal bar) has focus, set the focus
// to the editor here, before opening up the new modal bar. This ensures that the old
// focused item has time to react and close before the new modal bar is opened.
// See bugs #4287 and #3424
MainViewManager.focusActivePane();
if (autoClose) {
this._autoClose = true;
this._$root.on("keydown", this._handleKeydown);
window.document.body.addEventListener("focusin", this._handleFocusChange, true);
// Set focus to the first input field, or the first button if there is no input field.
// TODO: remove this logic?
var $firstInput = $("input[type='text']", this._$root).first();
if ($firstInput.length > 0) {
$firstInput.focus();
} else {
$("button", this._$root).first().focus();
}
}
// Preserve scroll position of the current full editor across the editor refresh, adjusting for the
// height of the modal bar so the code doesn't appear to shift if possible.
MainViewManager.cacheScrollState(MainViewManager.ALL_PANES);
WorkspaceManager.recomputeLayout(); // changes available ht for editor area
MainViewManager.restoreAdjustedScrollState(MainViewManager.ALL_PANES, this.height());
} | javascript | function ModalBar(template, autoClose, animate) {
if (animate === undefined) {
animate = true;
}
this._handleKeydown = this._handleKeydown.bind(this);
this._handleFocusChange = this._handleFocusChange.bind(this);
this._$root = $("<div class='modal-bar'/>")
.html(template)
.insertBefore("#editor-holder");
if (animate) {
this._$root.addClass("popout offscreen");
// Forcing the renderer to do a layout, which will cause it to apply the transform for the "offscreen"
// class, so it will animate when you remove the class.
window.getComputedStyle(this._$root.get(0)).getPropertyValue("top");
this._$root.removeClass("popout offscreen");
}
// If something *other* than an editor (like another modal bar) has focus, set the focus
// to the editor here, before opening up the new modal bar. This ensures that the old
// focused item has time to react and close before the new modal bar is opened.
// See bugs #4287 and #3424
MainViewManager.focusActivePane();
if (autoClose) {
this._autoClose = true;
this._$root.on("keydown", this._handleKeydown);
window.document.body.addEventListener("focusin", this._handleFocusChange, true);
// Set focus to the first input field, or the first button if there is no input field.
// TODO: remove this logic?
var $firstInput = $("input[type='text']", this._$root).first();
if ($firstInput.length > 0) {
$firstInput.focus();
} else {
$("button", this._$root).first().focus();
}
}
// Preserve scroll position of the current full editor across the editor refresh, adjusting for the
// height of the modal bar so the code doesn't appear to shift if possible.
MainViewManager.cacheScrollState(MainViewManager.ALL_PANES);
WorkspaceManager.recomputeLayout(); // changes available ht for editor area
MainViewManager.restoreAdjustedScrollState(MainViewManager.ALL_PANES, this.height());
} | [
"function",
"ModalBar",
"(",
"template",
",",
"autoClose",
",",
"animate",
")",
"{",
"if",
"(",
"animate",
"===",
"undefined",
")",
"{",
"animate",
"=",
"true",
";",
"}",
"this",
".",
"_handleKeydown",
"=",
"this",
".",
"_handleKeydown",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_handleFocusChange",
"=",
"this",
".",
"_handleFocusChange",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_$root",
"=",
"$",
"(",
"\"<div class='modal-bar'/>\"",
")",
".",
"html",
"(",
"template",
")",
".",
"insertBefore",
"(",
"\"#editor-holder\"",
")",
";",
"if",
"(",
"animate",
")",
"{",
"this",
".",
"_$root",
".",
"addClass",
"(",
"\"popout offscreen\"",
")",
";",
"// Forcing the renderer to do a layout, which will cause it to apply the transform for the \"offscreen\"",
"// class, so it will animate when you remove the class.",
"window",
".",
"getComputedStyle",
"(",
"this",
".",
"_$root",
".",
"get",
"(",
"0",
")",
")",
".",
"getPropertyValue",
"(",
"\"top\"",
")",
";",
"this",
".",
"_$root",
".",
"removeClass",
"(",
"\"popout offscreen\"",
")",
";",
"}",
"// If something *other* than an editor (like another modal bar) has focus, set the focus",
"// to the editor here, before opening up the new modal bar. This ensures that the old",
"// focused item has time to react and close before the new modal bar is opened.",
"// See bugs #4287 and #3424",
"MainViewManager",
".",
"focusActivePane",
"(",
")",
";",
"if",
"(",
"autoClose",
")",
"{",
"this",
".",
"_autoClose",
"=",
"true",
";",
"this",
".",
"_$root",
".",
"on",
"(",
"\"keydown\"",
",",
"this",
".",
"_handleKeydown",
")",
";",
"window",
".",
"document",
".",
"body",
".",
"addEventListener",
"(",
"\"focusin\"",
",",
"this",
".",
"_handleFocusChange",
",",
"true",
")",
";",
"// Set focus to the first input field, or the first button if there is no input field.",
"// TODO: remove this logic?",
"var",
"$firstInput",
"=",
"$",
"(",
"\"input[type='text']\"",
",",
"this",
".",
"_$root",
")",
".",
"first",
"(",
")",
";",
"if",
"(",
"$firstInput",
".",
"length",
">",
"0",
")",
"{",
"$firstInput",
".",
"focus",
"(",
")",
";",
"}",
"else",
"{",
"$",
"(",
"\"button\"",
",",
"this",
".",
"_$root",
")",
".",
"first",
"(",
")",
".",
"focus",
"(",
")",
";",
"}",
"}",
"// Preserve scroll position of the current full editor across the editor refresh, adjusting for the",
"// height of the modal bar so the code doesn't appear to shift if possible.",
"MainViewManager",
".",
"cacheScrollState",
"(",
"MainViewManager",
".",
"ALL_PANES",
")",
";",
"WorkspaceManager",
".",
"recomputeLayout",
"(",
")",
";",
"// changes available ht for editor area",
"MainViewManager",
".",
"restoreAdjustedScrollState",
"(",
"MainViewManager",
".",
"ALL_PANES",
",",
"this",
".",
"height",
"(",
")",
")",
";",
"}"
] | Creates a modal bar whose contents are the given template.
Dispatches one event:
- close - When the bar is closed, either via close() or via autoClose. After this event, the
bar may remain visible and in the DOM while its closing animation is playing. However,
by the time "close" is fired, the bar has been "popped out" of the layout and the
editor scroll position has already been restored.
Second argument is the reason for closing (one of ModalBar.CLOSE_*).
Third argument is the Promise that close() will be returning.
@constructor
@param {string} template The HTML contents of the modal bar.
@param {boolean} autoClose If true, then close the dialog if the user hits Esc
or if the bar loses focus.
@param {boolean} animate If true (the default), animate the dialog closed, otherwise
close it immediately. | [
"Creates",
"a",
"modal",
"bar",
"whose",
"contents",
"are",
"the",
"given",
"template",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/widgets/ModalBar.js#L56-L102 |
2,309 | adobe/brackets | src/extensions/default/CodeFolding/Prefs.js | simplify | function simplify(folds) {
if (!folds) {
return;
}
var res = {}, range;
Object.keys(folds).forEach(function (line) {
range = folds[line];
res[line] = Array.isArray(range) ? range : [[range.from.line, range.from.ch], [range.to.line, range.to.ch]];
});
return res;
} | javascript | function simplify(folds) {
if (!folds) {
return;
}
var res = {}, range;
Object.keys(folds).forEach(function (line) {
range = folds[line];
res[line] = Array.isArray(range) ? range : [[range.from.line, range.from.ch], [range.to.line, range.to.ch]];
});
return res;
} | [
"function",
"simplify",
"(",
"folds",
")",
"{",
"if",
"(",
"!",
"folds",
")",
"{",
"return",
";",
"}",
"var",
"res",
"=",
"{",
"}",
",",
"range",
";",
"Object",
".",
"keys",
"(",
"folds",
")",
".",
"forEach",
"(",
"function",
"(",
"line",
")",
"{",
"range",
"=",
"folds",
"[",
"line",
"]",
";",
"res",
"[",
"line",
"]",
"=",
"Array",
".",
"isArray",
"(",
"range",
")",
"?",
"range",
":",
"[",
"[",
"range",
".",
"from",
".",
"line",
",",
"range",
".",
"from",
".",
"ch",
"]",
",",
"[",
"range",
".",
"to",
".",
"line",
",",
"range",
".",
"to",
".",
"ch",
"]",
"]",
";",
"}",
")",
";",
"return",
"res",
";",
"}"
] | Simplifies the fold ranges into an array of pairs of numbers.
@param {!Object} folds the raw fold ranges indexed by line numbers
@return {Object} an object whose keys are line numbers and the values are array
of two 2-element arrays. First array contains [from.line, from.ch] and the second contains [to.line, to.ch] | [
"Simplifies",
"the",
"fold",
"ranges",
"into",
"an",
"array",
"of",
"pairs",
"of",
"numbers",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/Prefs.js#L49-L59 |
2,310 | adobe/brackets | src/extensions/default/CodeFolding/Prefs.js | getFolds | function getFolds(path) {
var context = getViewStateContext();
var folds = PreferencesManager.getViewState(FOLDS_PREF_KEY, context);
return inflate(folds[path]);
} | javascript | function getFolds(path) {
var context = getViewStateContext();
var folds = PreferencesManager.getViewState(FOLDS_PREF_KEY, context);
return inflate(folds[path]);
} | [
"function",
"getFolds",
"(",
"path",
")",
"{",
"var",
"context",
"=",
"getViewStateContext",
"(",
")",
";",
"var",
"folds",
"=",
"PreferencesManager",
".",
"getViewState",
"(",
"FOLDS_PREF_KEY",
",",
"context",
")",
";",
"return",
"inflate",
"(",
"folds",
"[",
"path",
"]",
")",
";",
"}"
] | Gets the line folds saved for the specified path.
@param {string} path the document path
@return {Object} the line folds for the document at the specified path | [
"Gets",
"the",
"line",
"folds",
"saved",
"for",
"the",
"specified",
"path",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/Prefs.js#L97-L101 |
2,311 | adobe/brackets | src/extensions/default/CodeFolding/Prefs.js | setFolds | function setFolds(path, folds) {
var context = getViewStateContext();
var allFolds = PreferencesManager.getViewState(FOLDS_PREF_KEY, context);
allFolds[path] = simplify(folds);
PreferencesManager.setViewState(FOLDS_PREF_KEY, allFolds, context);
} | javascript | function setFolds(path, folds) {
var context = getViewStateContext();
var allFolds = PreferencesManager.getViewState(FOLDS_PREF_KEY, context);
allFolds[path] = simplify(folds);
PreferencesManager.setViewState(FOLDS_PREF_KEY, allFolds, context);
} | [
"function",
"setFolds",
"(",
"path",
",",
"folds",
")",
"{",
"var",
"context",
"=",
"getViewStateContext",
"(",
")",
";",
"var",
"allFolds",
"=",
"PreferencesManager",
".",
"getViewState",
"(",
"FOLDS_PREF_KEY",
",",
"context",
")",
";",
"allFolds",
"[",
"path",
"]",
"=",
"simplify",
"(",
"folds",
")",
";",
"PreferencesManager",
".",
"setViewState",
"(",
"FOLDS_PREF_KEY",
",",
"allFolds",
",",
"context",
")",
";",
"}"
] | Saves the line folds for the specified path
@param {!string} path the path to the document
@param {Object} folds the fold ranges to save for the current document | [
"Saves",
"the",
"line",
"folds",
"for",
"the",
"specified",
"path"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/Prefs.js#L108-L113 |
2,312 | adobe/brackets | src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js | _convertToNumber | function _convertToNumber(str) {
if (typeof str !== "string") {
return { isNumber: false, value: null };
}
var val = parseFloat(+str, 10),
isNum = (typeof val === "number") && !isNaN(val) &&
(val !== Infinity) && (val !== -Infinity);
return {
isNumber: isNum,
value: val
};
} | javascript | function _convertToNumber(str) {
if (typeof str !== "string") {
return { isNumber: false, value: null };
}
var val = parseFloat(+str, 10),
isNum = (typeof val === "number") && !isNaN(val) &&
(val !== Infinity) && (val !== -Infinity);
return {
isNumber: isNum,
value: val
};
} | [
"function",
"_convertToNumber",
"(",
"str",
")",
"{",
"if",
"(",
"typeof",
"str",
"!==",
"\"string\"",
")",
"{",
"return",
"{",
"isNumber",
":",
"false",
",",
"value",
":",
"null",
"}",
";",
"}",
"var",
"val",
"=",
"parseFloat",
"(",
"+",
"str",
",",
"10",
")",
",",
"isNum",
"=",
"(",
"typeof",
"val",
"===",
"\"number\"",
")",
"&&",
"!",
"isNaN",
"(",
"val",
")",
"&&",
"(",
"val",
"!==",
"Infinity",
")",
"&&",
"(",
"val",
"!==",
"-",
"Infinity",
")",
";",
"return",
"{",
"isNumber",
":",
"isNum",
",",
"value",
":",
"val",
"}",
";",
"}"
] | If string is a number, then convert it.
@param {string} str value parsed from page.
@return { isNumber: boolean, value: ?number } | [
"If",
"string",
"is",
"a",
"number",
"then",
"convert",
"it",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js#L64-L77 |
2,313 | adobe/brackets | src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js | _getValidBezierParams | function _getValidBezierParams(match) {
var param,
// take ease-in-out as default value in case there are no params yet (or they are invalid)
def = [ ".42", "0", ".58", "1" ],
oldIndex = match.index, // we need to store the old match.index to re-set the index afterwards
originalString = match[0],
i;
if (match) {
match = match[1].split(",");
}
if (match) {
for (i = 0; i <= 3; i++) {
if (match[i]) {
match[i] = match[i].trim();
param = _convertToNumber(match[i]);
// Verify the param is a number
// If not, replace it with the default value
if (!param.isNumber) {
match[i] = undefined;
// Verify x coordinates are in 0-1 range
// If not, set them to the closest value in range
} else if (i === 0 || i === 2) {
if (param.value < 0) {
match[i] = "0";
} else if (param.value > 1) {
match[i] = "1";
}
}
}
if (!match[i]) {
match[i] = def[i];
}
}
} else {
match = def;
}
match = match.splice(0, 4); // make sure there are only 4 params
match = "cubic-bezier(" + match.join(", ") + ")";
match = match.match(BEZIER_CURVE_VALID_REGEX);
if (match) {
match.index = oldIndex; // re-set the index here to get the right context
match.originalString = originalString;
return match;
}
return null;
} | javascript | function _getValidBezierParams(match) {
var param,
// take ease-in-out as default value in case there are no params yet (or they are invalid)
def = [ ".42", "0", ".58", "1" ],
oldIndex = match.index, // we need to store the old match.index to re-set the index afterwards
originalString = match[0],
i;
if (match) {
match = match[1].split(",");
}
if (match) {
for (i = 0; i <= 3; i++) {
if (match[i]) {
match[i] = match[i].trim();
param = _convertToNumber(match[i]);
// Verify the param is a number
// If not, replace it with the default value
if (!param.isNumber) {
match[i] = undefined;
// Verify x coordinates are in 0-1 range
// If not, set them to the closest value in range
} else if (i === 0 || i === 2) {
if (param.value < 0) {
match[i] = "0";
} else if (param.value > 1) {
match[i] = "1";
}
}
}
if (!match[i]) {
match[i] = def[i];
}
}
} else {
match = def;
}
match = match.splice(0, 4); // make sure there are only 4 params
match = "cubic-bezier(" + match.join(", ") + ")";
match = match.match(BEZIER_CURVE_VALID_REGEX);
if (match) {
match.index = oldIndex; // re-set the index here to get the right context
match.originalString = originalString;
return match;
}
return null;
} | [
"function",
"_getValidBezierParams",
"(",
"match",
")",
"{",
"var",
"param",
",",
"// take ease-in-out as default value in case there are no params yet (or they are invalid)",
"def",
"=",
"[",
"\".42\"",
",",
"\"0\"",
",",
"\".58\"",
",",
"\"1\"",
"]",
",",
"oldIndex",
"=",
"match",
".",
"index",
",",
"// we need to store the old match.index to re-set the index afterwards",
"originalString",
"=",
"match",
"[",
"0",
"]",
",",
"i",
";",
"if",
"(",
"match",
")",
"{",
"match",
"=",
"match",
"[",
"1",
"]",
".",
"split",
"(",
"\",\"",
")",
";",
"}",
"if",
"(",
"match",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<=",
"3",
";",
"i",
"++",
")",
"{",
"if",
"(",
"match",
"[",
"i",
"]",
")",
"{",
"match",
"[",
"i",
"]",
"=",
"match",
"[",
"i",
"]",
".",
"trim",
"(",
")",
";",
"param",
"=",
"_convertToNumber",
"(",
"match",
"[",
"i",
"]",
")",
";",
"// Verify the param is a number",
"// If not, replace it with the default value",
"if",
"(",
"!",
"param",
".",
"isNumber",
")",
"{",
"match",
"[",
"i",
"]",
"=",
"undefined",
";",
"// Verify x coordinates are in 0-1 range",
"// If not, set them to the closest value in range",
"}",
"else",
"if",
"(",
"i",
"===",
"0",
"||",
"i",
"===",
"2",
")",
"{",
"if",
"(",
"param",
".",
"value",
"<",
"0",
")",
"{",
"match",
"[",
"i",
"]",
"=",
"\"0\"",
";",
"}",
"else",
"if",
"(",
"param",
".",
"value",
">",
"1",
")",
"{",
"match",
"[",
"i",
"]",
"=",
"\"1\"",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"match",
"[",
"i",
"]",
")",
"{",
"match",
"[",
"i",
"]",
"=",
"def",
"[",
"i",
"]",
";",
"}",
"}",
"}",
"else",
"{",
"match",
"=",
"def",
";",
"}",
"match",
"=",
"match",
".",
"splice",
"(",
"0",
",",
"4",
")",
";",
"// make sure there are only 4 params",
"match",
"=",
"\"cubic-bezier(\"",
"+",
"match",
".",
"join",
"(",
"\", \"",
")",
"+",
"\")\"",
";",
"match",
"=",
"match",
".",
"match",
"(",
"BEZIER_CURVE_VALID_REGEX",
")",
";",
"if",
"(",
"match",
")",
"{",
"match",
".",
"index",
"=",
"oldIndex",
";",
"// re-set the index here to get the right context",
"match",
".",
"originalString",
"=",
"originalString",
";",
"return",
"match",
";",
"}",
"return",
"null",
";",
"}"
] | Get valid params for an invalid cubic-bezier.
@param {RegExp.match} match (Invalid) matches from cubicBezierMatch()
@return {?RegExp.match} Valid match or null if the output is not valid | [
"Get",
"valid",
"params",
"for",
"an",
"invalid",
"cubic",
"-",
"bezier",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js#L85-L136 |
2,314 | adobe/brackets | src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js | _getValidStepsParams | function _getValidStepsParams(match) {
var param,
def = [ "5", "end" ],
params = def,
oldIndex = match.index, // we need to store the old match.index to re-set the index afterwards
originalString = match[0];
if (match) {
match = match[1].split(",");
}
if (match) {
if (match[0]) {
param = match[0].replace(/[\s\"']/g, ""); // replace possible trailing whitespace or leading quotes
param = _convertToNumber(param);
// Verify number_of_params is a number
// If not, replace it with the default value
if (!param.isNumber) {
param.value = def[0];
// Round number_of_params to an integer
} else if (param.value) {
param.value = Math.floor(param.value);
}
// Verify number_of_steps is >= 1
// If not, set them to the default value
if (param.value < 1) {
param.value = def[0];
}
params[0] = param.value;
}
if (match[1]) {
// little autocorrect feature: leading s gets 'start', everything else gets 'end'
param = match[1].replace(/[\s\"']/g, ""); // replace possible trailing whitespace or leading quotes
param = param.substr(0, 1);
if (param === "s") {
params[1] = "start";
} else {
params[1] = "end";
}
}
}
params = "steps(" + params.join(", ") + ")";
params = params.match(STEPS_VALID_REGEX);
if (params) {
params.index = oldIndex; // re-set the index here to get the right context
params.originalString = originalString;
return params;
}
return null;
} | javascript | function _getValidStepsParams(match) {
var param,
def = [ "5", "end" ],
params = def,
oldIndex = match.index, // we need to store the old match.index to re-set the index afterwards
originalString = match[0];
if (match) {
match = match[1].split(",");
}
if (match) {
if (match[0]) {
param = match[0].replace(/[\s\"']/g, ""); // replace possible trailing whitespace or leading quotes
param = _convertToNumber(param);
// Verify number_of_params is a number
// If not, replace it with the default value
if (!param.isNumber) {
param.value = def[0];
// Round number_of_params to an integer
} else if (param.value) {
param.value = Math.floor(param.value);
}
// Verify number_of_steps is >= 1
// If not, set them to the default value
if (param.value < 1) {
param.value = def[0];
}
params[0] = param.value;
}
if (match[1]) {
// little autocorrect feature: leading s gets 'start', everything else gets 'end'
param = match[1].replace(/[\s\"']/g, ""); // replace possible trailing whitespace or leading quotes
param = param.substr(0, 1);
if (param === "s") {
params[1] = "start";
} else {
params[1] = "end";
}
}
}
params = "steps(" + params.join(", ") + ")";
params = params.match(STEPS_VALID_REGEX);
if (params) {
params.index = oldIndex; // re-set the index here to get the right context
params.originalString = originalString;
return params;
}
return null;
} | [
"function",
"_getValidStepsParams",
"(",
"match",
")",
"{",
"var",
"param",
",",
"def",
"=",
"[",
"\"5\"",
",",
"\"end\"",
"]",
",",
"params",
"=",
"def",
",",
"oldIndex",
"=",
"match",
".",
"index",
",",
"// we need to store the old match.index to re-set the index afterwards",
"originalString",
"=",
"match",
"[",
"0",
"]",
";",
"if",
"(",
"match",
")",
"{",
"match",
"=",
"match",
"[",
"1",
"]",
".",
"split",
"(",
"\",\"",
")",
";",
"}",
"if",
"(",
"match",
")",
"{",
"if",
"(",
"match",
"[",
"0",
"]",
")",
"{",
"param",
"=",
"match",
"[",
"0",
"]",
".",
"replace",
"(",
"/",
"[\\s\\\"']",
"/",
"g",
",",
"\"\"",
")",
";",
"// replace possible trailing whitespace or leading quotes",
"param",
"=",
"_convertToNumber",
"(",
"param",
")",
";",
"// Verify number_of_params is a number",
"// If not, replace it with the default value",
"if",
"(",
"!",
"param",
".",
"isNumber",
")",
"{",
"param",
".",
"value",
"=",
"def",
"[",
"0",
"]",
";",
"// Round number_of_params to an integer",
"}",
"else",
"if",
"(",
"param",
".",
"value",
")",
"{",
"param",
".",
"value",
"=",
"Math",
".",
"floor",
"(",
"param",
".",
"value",
")",
";",
"}",
"// Verify number_of_steps is >= 1",
"// If not, set them to the default value",
"if",
"(",
"param",
".",
"value",
"<",
"1",
")",
"{",
"param",
".",
"value",
"=",
"def",
"[",
"0",
"]",
";",
"}",
"params",
"[",
"0",
"]",
"=",
"param",
".",
"value",
";",
"}",
"if",
"(",
"match",
"[",
"1",
"]",
")",
"{",
"// little autocorrect feature: leading s gets 'start', everything else gets 'end'",
"param",
"=",
"match",
"[",
"1",
"]",
".",
"replace",
"(",
"/",
"[\\s\\\"']",
"/",
"g",
",",
"\"\"",
")",
";",
"// replace possible trailing whitespace or leading quotes",
"param",
"=",
"param",
".",
"substr",
"(",
"0",
",",
"1",
")",
";",
"if",
"(",
"param",
"===",
"\"s\"",
")",
"{",
"params",
"[",
"1",
"]",
"=",
"\"start\"",
";",
"}",
"else",
"{",
"params",
"[",
"1",
"]",
"=",
"\"end\"",
";",
"}",
"}",
"}",
"params",
"=",
"\"steps(\"",
"+",
"params",
".",
"join",
"(",
"\", \"",
")",
"+",
"\")\"",
";",
"params",
"=",
"params",
".",
"match",
"(",
"STEPS_VALID_REGEX",
")",
";",
"if",
"(",
"params",
")",
"{",
"params",
".",
"index",
"=",
"oldIndex",
";",
"// re-set the index here to get the right context",
"params",
".",
"originalString",
"=",
"originalString",
";",
"return",
"params",
";",
"}",
"return",
"null",
";",
"}"
] | Get valid params for an invalid steps function.
@param {RegExp.match} match (Invalid) matches from stepsMatch()
@return {?RegExp.match} Valid match or null if the output is not valid | [
"Get",
"valid",
"params",
"for",
"an",
"invalid",
"steps",
"function",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js#L170-L223 |
2,315 | adobe/brackets | src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js | showHideHint | function showHideHint(hint, show, documentCode, editorCode) {
if (!hint || !hint.elem) {
return;
}
if (show) {
hint.shown = true;
hint.animationInProgress = false;
hint.elem.removeClass("fadeout");
hint.elem.html(StringUtils.format(Strings.INLINE_TIMING_EDITOR_INVALID, documentCode, editorCode));
hint.elem.css("display", "block");
} else if (hint.shown) {
hint.animationInProgress = true;
AnimationUtils.animateUsingClass(hint.elem[0], "fadeout", 750)
.done(function () {
if (hint.animationInProgress) { // do this only if the animation was not cancelled
hint.elem.hide();
}
hint.shown = false;
hint.animationInProgress = false;
});
} else {
hint.elem.hide();
}
} | javascript | function showHideHint(hint, show, documentCode, editorCode) {
if (!hint || !hint.elem) {
return;
}
if (show) {
hint.shown = true;
hint.animationInProgress = false;
hint.elem.removeClass("fadeout");
hint.elem.html(StringUtils.format(Strings.INLINE_TIMING_EDITOR_INVALID, documentCode, editorCode));
hint.elem.css("display", "block");
} else if (hint.shown) {
hint.animationInProgress = true;
AnimationUtils.animateUsingClass(hint.elem[0], "fadeout", 750)
.done(function () {
if (hint.animationInProgress) { // do this only if the animation was not cancelled
hint.elem.hide();
}
hint.shown = false;
hint.animationInProgress = false;
});
} else {
hint.elem.hide();
}
} | [
"function",
"showHideHint",
"(",
"hint",
",",
"show",
",",
"documentCode",
",",
"editorCode",
")",
"{",
"if",
"(",
"!",
"hint",
"||",
"!",
"hint",
".",
"elem",
")",
"{",
"return",
";",
"}",
"if",
"(",
"show",
")",
"{",
"hint",
".",
"shown",
"=",
"true",
";",
"hint",
".",
"animationInProgress",
"=",
"false",
";",
"hint",
".",
"elem",
".",
"removeClass",
"(",
"\"fadeout\"",
")",
";",
"hint",
".",
"elem",
".",
"html",
"(",
"StringUtils",
".",
"format",
"(",
"Strings",
".",
"INLINE_TIMING_EDITOR_INVALID",
",",
"documentCode",
",",
"editorCode",
")",
")",
";",
"hint",
".",
"elem",
".",
"css",
"(",
"\"display\"",
",",
"\"block\"",
")",
";",
"}",
"else",
"if",
"(",
"hint",
".",
"shown",
")",
"{",
"hint",
".",
"animationInProgress",
"=",
"true",
";",
"AnimationUtils",
".",
"animateUsingClass",
"(",
"hint",
".",
"elem",
"[",
"0",
"]",
",",
"\"fadeout\"",
",",
"750",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"hint",
".",
"animationInProgress",
")",
"{",
"// do this only if the animation was not cancelled",
"hint",
".",
"elem",
".",
"hide",
"(",
")",
";",
"}",
"hint",
".",
"shown",
"=",
"false",
";",
"hint",
".",
"animationInProgress",
"=",
"false",
";",
"}",
")",
";",
"}",
"else",
"{",
"hint",
".",
"elem",
".",
"hide",
"(",
")",
";",
"}",
"}"
] | Show, hide or update the hint text
@param {object} hint Editor.hint object of the current InlineTimingFunctionEditor
@param {boolean} show Whether the hint should be shown or hidden
@param {string=} documentCode The invalid code from the document (can be omitted when hiding)
@param {string=} editorCode The valid code that is shown in the Inline Editor (can be omitted when hiding) | [
"Show",
"hide",
"or",
"update",
"the",
"hint",
"text"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js#L254-L278 |
2,316 | adobe/brackets | src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js | _tagMatch | function _tagMatch(match, type) {
switch (type) {
case BEZIER:
match.isBezier = true;
break;
case STEP:
match.isStep = true;
break;
}
return match;
} | javascript | function _tagMatch(match, type) {
switch (type) {
case BEZIER:
match.isBezier = true;
break;
case STEP:
match.isStep = true;
break;
}
return match;
} | [
"function",
"_tagMatch",
"(",
"match",
",",
"type",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"BEZIER",
":",
"match",
".",
"isBezier",
"=",
"true",
";",
"break",
";",
"case",
"STEP",
":",
"match",
".",
"isStep",
"=",
"true",
";",
"break",
";",
"}",
"return",
"match",
";",
"}"
] | Tag this match with type and return it for chaining
@param {!RegExp.match} match RegExp Match object with steps function parameters
in array position 1 (and optionally 2).
@param {number} type Either BEZIER or STEP
@return {RegExp.match} Same object that was passed in. | [
"Tag",
"this",
"match",
"with",
"type",
"and",
"return",
"it",
"for",
"chaining"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js#L288-L299 |
2,317 | adobe/brackets | src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js | bezierCurveMatch | function bezierCurveMatch(str, lax) {
var match;
// First look for any cubic-bezier().
match = str.match(BEZIER_CURVE_VALID_REGEX);
if (match && _validateCubicBezierParams(match)) { // cubic-bezier() with valid params
return _tagMatch(match, BEZIER);
}
match = str.match(BEZIER_CURVE_GENERAL_REGEX);
if (match) {
match = _getValidBezierParams(match);
if (match && _validateCubicBezierParams(match)) {
return _tagMatch(match, BEZIER);
} else { // this should not happen!
window.console.log("brackets-cubic-bezier: TimingFunctionUtils._getValidBezierParams created invalid code");
}
}
// Next look for the ease functions (which are special cases of cubic-bezier())
if (lax) {
// For lax parsing, just look for the keywords
match = str.match(EASE_LAX_REGEX);
if (match) {
return _tagMatch(match, BEZIER);
}
} else {
// For strict parsing, start with a syntax verifying search
match = str.match(EASE_STRICT_REGEX);
if (match) {
// return exact match to keyword that we need for later replacement
return _tagMatch(str.match(EASE_LAX_REGEX), BEZIER);
}
}
// Final case is linear.
if (lax) {
// For lax parsing, just look for the keyword
match = str.match(LINEAR_LAX_REGEX);
if (match) {
return _tagMatch(match, BEZIER);
}
} else {
// The linear keyword can occur in other values, so for strict parsing we
// only detect when it's on same line as "transition" or "animation"
match = str.match(LINEAR_STRICT_REGEX);
if (match) {
// return exact match to keyword that we need for later replacement
return _tagMatch(str.match(LINEAR_LAX_REGEX), BEZIER);
}
}
return null;
} | javascript | function bezierCurveMatch(str, lax) {
var match;
// First look for any cubic-bezier().
match = str.match(BEZIER_CURVE_VALID_REGEX);
if (match && _validateCubicBezierParams(match)) { // cubic-bezier() with valid params
return _tagMatch(match, BEZIER);
}
match = str.match(BEZIER_CURVE_GENERAL_REGEX);
if (match) {
match = _getValidBezierParams(match);
if (match && _validateCubicBezierParams(match)) {
return _tagMatch(match, BEZIER);
} else { // this should not happen!
window.console.log("brackets-cubic-bezier: TimingFunctionUtils._getValidBezierParams created invalid code");
}
}
// Next look for the ease functions (which are special cases of cubic-bezier())
if (lax) {
// For lax parsing, just look for the keywords
match = str.match(EASE_LAX_REGEX);
if (match) {
return _tagMatch(match, BEZIER);
}
} else {
// For strict parsing, start with a syntax verifying search
match = str.match(EASE_STRICT_REGEX);
if (match) {
// return exact match to keyword that we need for later replacement
return _tagMatch(str.match(EASE_LAX_REGEX), BEZIER);
}
}
// Final case is linear.
if (lax) {
// For lax parsing, just look for the keyword
match = str.match(LINEAR_LAX_REGEX);
if (match) {
return _tagMatch(match, BEZIER);
}
} else {
// The linear keyword can occur in other values, so for strict parsing we
// only detect when it's on same line as "transition" or "animation"
match = str.match(LINEAR_STRICT_REGEX);
if (match) {
// return exact match to keyword that we need for later replacement
return _tagMatch(str.match(LINEAR_LAX_REGEX), BEZIER);
}
}
return null;
} | [
"function",
"bezierCurveMatch",
"(",
"str",
",",
"lax",
")",
"{",
"var",
"match",
";",
"// First look for any cubic-bezier().",
"match",
"=",
"str",
".",
"match",
"(",
"BEZIER_CURVE_VALID_REGEX",
")",
";",
"if",
"(",
"match",
"&&",
"_validateCubicBezierParams",
"(",
"match",
")",
")",
"{",
"// cubic-bezier() with valid params",
"return",
"_tagMatch",
"(",
"match",
",",
"BEZIER",
")",
";",
"}",
"match",
"=",
"str",
".",
"match",
"(",
"BEZIER_CURVE_GENERAL_REGEX",
")",
";",
"if",
"(",
"match",
")",
"{",
"match",
"=",
"_getValidBezierParams",
"(",
"match",
")",
";",
"if",
"(",
"match",
"&&",
"_validateCubicBezierParams",
"(",
"match",
")",
")",
"{",
"return",
"_tagMatch",
"(",
"match",
",",
"BEZIER",
")",
";",
"}",
"else",
"{",
"// this should not happen!",
"window",
".",
"console",
".",
"log",
"(",
"\"brackets-cubic-bezier: TimingFunctionUtils._getValidBezierParams created invalid code\"",
")",
";",
"}",
"}",
"// Next look for the ease functions (which are special cases of cubic-bezier())",
"if",
"(",
"lax",
")",
"{",
"// For lax parsing, just look for the keywords",
"match",
"=",
"str",
".",
"match",
"(",
"EASE_LAX_REGEX",
")",
";",
"if",
"(",
"match",
")",
"{",
"return",
"_tagMatch",
"(",
"match",
",",
"BEZIER",
")",
";",
"}",
"}",
"else",
"{",
"// For strict parsing, start with a syntax verifying search",
"match",
"=",
"str",
".",
"match",
"(",
"EASE_STRICT_REGEX",
")",
";",
"if",
"(",
"match",
")",
"{",
"// return exact match to keyword that we need for later replacement",
"return",
"_tagMatch",
"(",
"str",
".",
"match",
"(",
"EASE_LAX_REGEX",
")",
",",
"BEZIER",
")",
";",
"}",
"}",
"// Final case is linear.",
"if",
"(",
"lax",
")",
"{",
"// For lax parsing, just look for the keyword",
"match",
"=",
"str",
".",
"match",
"(",
"LINEAR_LAX_REGEX",
")",
";",
"if",
"(",
"match",
")",
"{",
"return",
"_tagMatch",
"(",
"match",
",",
"BEZIER",
")",
";",
"}",
"}",
"else",
"{",
"// The linear keyword can occur in other values, so for strict parsing we",
"// only detect when it's on same line as \"transition\" or \"animation\"",
"match",
"=",
"str",
".",
"match",
"(",
"LINEAR_STRICT_REGEX",
")",
";",
"if",
"(",
"match",
")",
"{",
"// return exact match to keyword that we need for later replacement",
"return",
"_tagMatch",
"(",
"str",
".",
"match",
"(",
"LINEAR_LAX_REGEX",
")",
",",
"BEZIER",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Match a bezier curve function value from a CSS Declaration or Value.
Matches returned from this function must be handled in
BezierCurveEditor._getCubicBezierCoords().
@param {string} str Input string.
@param {!boolean} lax Parsing mode where:
lax=false Input is a Full or partial line containing CSS Declaration.
This is the more strict search used for initial detection.
lax=true Input is a previously parsed value. This is the less strict search
used to convert previously parsed values to RegExp match format.
@return {!RegExpMatch} | [
"Match",
"a",
"bezier",
"curve",
"function",
"value",
"from",
"a",
"CSS",
"Declaration",
"or",
"Value",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js#L315-L368 |
2,318 | adobe/brackets | src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js | stepsMatch | function stepsMatch(str, lax) {
var match;
// First look for any steps().
match = str.match(STEPS_VALID_REGEX);
if (match && _validateStepsParams(match)) { // cubic-bezier() with valid params
return _tagMatch(match, STEP);
}
match = str.match(STEPS_GENERAL_REGEX);
if (match) {
match = _getValidStepsParams(match);
if (match && _validateStepsParams(match)) {
return _tagMatch(match, STEP);
} else { // this should not happen!
window.console.log("brackets-steps: TimingFunctionUtils._getValidStepsParams created invalid code");
}
}
// Next look for the step functions (which are special cases of steps())
if (lax) {
// For lax parsing, just look for the keywords
match = str.match(STEP_LAX_REGEX);
if (match) {
return _tagMatch(match, STEP);
}
} else {
// For strict parsing, start with a syntax verifying search
match = str.match(STEP_STRICT_REGEX);
if (match) {
// return exact match to keyword that we need for later replacement
return _tagMatch(str.match(STEP_LAX_REGEX), STEP);
}
}
return null;
} | javascript | function stepsMatch(str, lax) {
var match;
// First look for any steps().
match = str.match(STEPS_VALID_REGEX);
if (match && _validateStepsParams(match)) { // cubic-bezier() with valid params
return _tagMatch(match, STEP);
}
match = str.match(STEPS_GENERAL_REGEX);
if (match) {
match = _getValidStepsParams(match);
if (match && _validateStepsParams(match)) {
return _tagMatch(match, STEP);
} else { // this should not happen!
window.console.log("brackets-steps: TimingFunctionUtils._getValidStepsParams created invalid code");
}
}
// Next look for the step functions (which are special cases of steps())
if (lax) {
// For lax parsing, just look for the keywords
match = str.match(STEP_LAX_REGEX);
if (match) {
return _tagMatch(match, STEP);
}
} else {
// For strict parsing, start with a syntax verifying search
match = str.match(STEP_STRICT_REGEX);
if (match) {
// return exact match to keyword that we need for later replacement
return _tagMatch(str.match(STEP_LAX_REGEX), STEP);
}
}
return null;
} | [
"function",
"stepsMatch",
"(",
"str",
",",
"lax",
")",
"{",
"var",
"match",
";",
"// First look for any steps().",
"match",
"=",
"str",
".",
"match",
"(",
"STEPS_VALID_REGEX",
")",
";",
"if",
"(",
"match",
"&&",
"_validateStepsParams",
"(",
"match",
")",
")",
"{",
"// cubic-bezier() with valid params",
"return",
"_tagMatch",
"(",
"match",
",",
"STEP",
")",
";",
"}",
"match",
"=",
"str",
".",
"match",
"(",
"STEPS_GENERAL_REGEX",
")",
";",
"if",
"(",
"match",
")",
"{",
"match",
"=",
"_getValidStepsParams",
"(",
"match",
")",
";",
"if",
"(",
"match",
"&&",
"_validateStepsParams",
"(",
"match",
")",
")",
"{",
"return",
"_tagMatch",
"(",
"match",
",",
"STEP",
")",
";",
"}",
"else",
"{",
"// this should not happen!",
"window",
".",
"console",
".",
"log",
"(",
"\"brackets-steps: TimingFunctionUtils._getValidStepsParams created invalid code\"",
")",
";",
"}",
"}",
"// Next look for the step functions (which are special cases of steps())",
"if",
"(",
"lax",
")",
"{",
"// For lax parsing, just look for the keywords",
"match",
"=",
"str",
".",
"match",
"(",
"STEP_LAX_REGEX",
")",
";",
"if",
"(",
"match",
")",
"{",
"return",
"_tagMatch",
"(",
"match",
",",
"STEP",
")",
";",
"}",
"}",
"else",
"{",
"// For strict parsing, start with a syntax verifying search",
"match",
"=",
"str",
".",
"match",
"(",
"STEP_STRICT_REGEX",
")",
";",
"if",
"(",
"match",
")",
"{",
"// return exact match to keyword that we need for later replacement",
"return",
"_tagMatch",
"(",
"str",
".",
"match",
"(",
"STEP_LAX_REGEX",
")",
",",
"STEP",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Match a steps function value from a CSS Declaration or Value.
Matches returned from this function must be handled in
BezierCurveEditor._getCubicBezierCoords().
@param {string} str Input string.
@param {!boolean} lax Parsing mode where:
lax=false Input is a Full or partial line containing CSS Declaration.
This is the more strict search used for initial detection.
lax=true Input is a previously parsed value. This is the less strict search
used to convert previously parsed values to RegExp match format.
@return {!RegExpMatch} | [
"Match",
"a",
"steps",
"function",
"value",
"from",
"a",
"CSS",
"Declaration",
"or",
"Value",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js#L384-L420 |
2,319 | adobe/brackets | src/preferences/PreferencesDialogs.js | _validateBaseUrl | function _validateBaseUrl(url) {
var result = "";
// Empty url means "no server mapping; use file directly"
if (url === "") {
return result;
}
var obj = PathUtils.parseUrl(url);
if (!obj) {
result = Strings.BASEURL_ERROR_UNKNOWN_ERROR;
} else if (obj.href.search(/^(http|https):\/\//i) !== 0) {
result = StringUtils.format(Strings.BASEURL_ERROR_INVALID_PROTOCOL, obj.href.substring(0, obj.href.indexOf("//")));
} else if (obj.search !== "") {
result = StringUtils.format(Strings.BASEURL_ERROR_SEARCH_DISALLOWED, obj.search);
} else if (obj.hash !== "") {
result = StringUtils.format(Strings.BASEURL_ERROR_HASH_DISALLOWED, obj.hash);
} else {
var index = url.search(/[ \^\[\]\{\}<>\\"\?]+/);
if (index !== -1) {
result = StringUtils.format(Strings.BASEURL_ERROR_INVALID_CHAR, url[index]);
}
}
return result;
} | javascript | function _validateBaseUrl(url) {
var result = "";
// Empty url means "no server mapping; use file directly"
if (url === "") {
return result;
}
var obj = PathUtils.parseUrl(url);
if (!obj) {
result = Strings.BASEURL_ERROR_UNKNOWN_ERROR;
} else if (obj.href.search(/^(http|https):\/\//i) !== 0) {
result = StringUtils.format(Strings.BASEURL_ERROR_INVALID_PROTOCOL, obj.href.substring(0, obj.href.indexOf("//")));
} else if (obj.search !== "") {
result = StringUtils.format(Strings.BASEURL_ERROR_SEARCH_DISALLOWED, obj.search);
} else if (obj.hash !== "") {
result = StringUtils.format(Strings.BASEURL_ERROR_HASH_DISALLOWED, obj.hash);
} else {
var index = url.search(/[ \^\[\]\{\}<>\\"\?]+/);
if (index !== -1) {
result = StringUtils.format(Strings.BASEURL_ERROR_INVALID_CHAR, url[index]);
}
}
return result;
} | [
"function",
"_validateBaseUrl",
"(",
"url",
")",
"{",
"var",
"result",
"=",
"\"\"",
";",
"// Empty url means \"no server mapping; use file directly\"",
"if",
"(",
"url",
"===",
"\"\"",
")",
"{",
"return",
"result",
";",
"}",
"var",
"obj",
"=",
"PathUtils",
".",
"parseUrl",
"(",
"url",
")",
";",
"if",
"(",
"!",
"obj",
")",
"{",
"result",
"=",
"Strings",
".",
"BASEURL_ERROR_UNKNOWN_ERROR",
";",
"}",
"else",
"if",
"(",
"obj",
".",
"href",
".",
"search",
"(",
"/",
"^(http|https):\\/\\/",
"/",
"i",
")",
"!==",
"0",
")",
"{",
"result",
"=",
"StringUtils",
".",
"format",
"(",
"Strings",
".",
"BASEURL_ERROR_INVALID_PROTOCOL",
",",
"obj",
".",
"href",
".",
"substring",
"(",
"0",
",",
"obj",
".",
"href",
".",
"indexOf",
"(",
"\"//\"",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"obj",
".",
"search",
"!==",
"\"\"",
")",
"{",
"result",
"=",
"StringUtils",
".",
"format",
"(",
"Strings",
".",
"BASEURL_ERROR_SEARCH_DISALLOWED",
",",
"obj",
".",
"search",
")",
";",
"}",
"else",
"if",
"(",
"obj",
".",
"hash",
"!==",
"\"\"",
")",
"{",
"result",
"=",
"StringUtils",
".",
"format",
"(",
"Strings",
".",
"BASEURL_ERROR_HASH_DISALLOWED",
",",
"obj",
".",
"hash",
")",
";",
"}",
"else",
"{",
"var",
"index",
"=",
"url",
".",
"search",
"(",
"/",
"[ \\^\\[\\]\\{\\}<>\\\\\"\\?]+",
"/",
")",
";",
"if",
"(",
"index",
"!==",
"-",
"1",
")",
"{",
"result",
"=",
"StringUtils",
".",
"format",
"(",
"Strings",
".",
"BASEURL_ERROR_INVALID_CHAR",
",",
"url",
"[",
"index",
"]",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Validate that text string is a valid base url which should map to a server folder
@param {string} url
@return {string} Empty string if valid, otherwise error string | [
"Validate",
"that",
"text",
"string",
"is",
"a",
"valid",
"base",
"url",
"which",
"should",
"map",
"to",
"a",
"server",
"folder"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/preferences/PreferencesDialogs.js#L45-L69 |
2,320 | adobe/brackets | src/preferences/PreferencesDialogs.js | showProjectPreferencesDialog | function showProjectPreferencesDialog(baseUrl, errorMessage) {
var $baseUrlControl,
dialog;
// Title
var projectName = "",
projectRoot = ProjectManager.getProjectRoot(),
title;
if (projectRoot) {
projectName = projectRoot.name;
}
title = StringUtils.format(Strings.PROJECT_SETTINGS_TITLE, projectName);
var templateVars = {
title : title,
baseUrl : baseUrl,
errorMessage : errorMessage,
Strings : Strings
};
dialog = Dialogs.showModalDialogUsingTemplate(Mustache.render(SettingsDialogTemplate, templateVars));
dialog.done(function (id) {
if (id === Dialogs.DIALOG_BTN_OK) {
var baseUrlValue = $baseUrlControl.val();
var result = _validateBaseUrl(baseUrlValue);
if (result === "") {
// Send analytics data when url is set in project settings
HealthLogger.sendAnalyticsData(
"projectSettingsLivepreview",
"usage",
"projectSettings",
"use"
);
ProjectManager.setBaseUrl(baseUrlValue);
} else {
// Re-invoke dialog with result (error message)
showProjectPreferencesDialog(baseUrlValue, result);
}
}
});
// Give focus to first control
$baseUrlControl = dialog.getElement().find(".url");
$baseUrlControl.focus();
return dialog;
} | javascript | function showProjectPreferencesDialog(baseUrl, errorMessage) {
var $baseUrlControl,
dialog;
// Title
var projectName = "",
projectRoot = ProjectManager.getProjectRoot(),
title;
if (projectRoot) {
projectName = projectRoot.name;
}
title = StringUtils.format(Strings.PROJECT_SETTINGS_TITLE, projectName);
var templateVars = {
title : title,
baseUrl : baseUrl,
errorMessage : errorMessage,
Strings : Strings
};
dialog = Dialogs.showModalDialogUsingTemplate(Mustache.render(SettingsDialogTemplate, templateVars));
dialog.done(function (id) {
if (id === Dialogs.DIALOG_BTN_OK) {
var baseUrlValue = $baseUrlControl.val();
var result = _validateBaseUrl(baseUrlValue);
if (result === "") {
// Send analytics data when url is set in project settings
HealthLogger.sendAnalyticsData(
"projectSettingsLivepreview",
"usage",
"projectSettings",
"use"
);
ProjectManager.setBaseUrl(baseUrlValue);
} else {
// Re-invoke dialog with result (error message)
showProjectPreferencesDialog(baseUrlValue, result);
}
}
});
// Give focus to first control
$baseUrlControl = dialog.getElement().find(".url");
$baseUrlControl.focus();
return dialog;
} | [
"function",
"showProjectPreferencesDialog",
"(",
"baseUrl",
",",
"errorMessage",
")",
"{",
"var",
"$baseUrlControl",
",",
"dialog",
";",
"// Title",
"var",
"projectName",
"=",
"\"\"",
",",
"projectRoot",
"=",
"ProjectManager",
".",
"getProjectRoot",
"(",
")",
",",
"title",
";",
"if",
"(",
"projectRoot",
")",
"{",
"projectName",
"=",
"projectRoot",
".",
"name",
";",
"}",
"title",
"=",
"StringUtils",
".",
"format",
"(",
"Strings",
".",
"PROJECT_SETTINGS_TITLE",
",",
"projectName",
")",
";",
"var",
"templateVars",
"=",
"{",
"title",
":",
"title",
",",
"baseUrl",
":",
"baseUrl",
",",
"errorMessage",
":",
"errorMessage",
",",
"Strings",
":",
"Strings",
"}",
";",
"dialog",
"=",
"Dialogs",
".",
"showModalDialogUsingTemplate",
"(",
"Mustache",
".",
"render",
"(",
"SettingsDialogTemplate",
",",
"templateVars",
")",
")",
";",
"dialog",
".",
"done",
"(",
"function",
"(",
"id",
")",
"{",
"if",
"(",
"id",
"===",
"Dialogs",
".",
"DIALOG_BTN_OK",
")",
"{",
"var",
"baseUrlValue",
"=",
"$baseUrlControl",
".",
"val",
"(",
")",
";",
"var",
"result",
"=",
"_validateBaseUrl",
"(",
"baseUrlValue",
")",
";",
"if",
"(",
"result",
"===",
"\"\"",
")",
"{",
"// Send analytics data when url is set in project settings",
"HealthLogger",
".",
"sendAnalyticsData",
"(",
"\"projectSettingsLivepreview\"",
",",
"\"usage\"",
",",
"\"projectSettings\"",
",",
"\"use\"",
")",
";",
"ProjectManager",
".",
"setBaseUrl",
"(",
"baseUrlValue",
")",
";",
"}",
"else",
"{",
"// Re-invoke dialog with result (error message)",
"showProjectPreferencesDialog",
"(",
"baseUrlValue",
",",
"result",
")",
";",
"}",
"}",
"}",
")",
";",
"// Give focus to first control",
"$baseUrlControl",
"=",
"dialog",
".",
"getElement",
"(",
")",
".",
"find",
"(",
"\".url\"",
")",
";",
"$baseUrlControl",
".",
"focus",
"(",
")",
";",
"return",
"dialog",
";",
"}"
] | Show a dialog that shows the project preferences
@param {string} baseUrl Initial value
@param {string} errorMessage Error to display
@return {Dialog} A Dialog object with an internal promise that will be resolved with the ID
of the clicked button when the dialog is dismissed. Never rejected. | [
"Show",
"a",
"dialog",
"that",
"shows",
"the",
"project",
"preferences"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/preferences/PreferencesDialogs.js#L78-L125 |
2,321 | adobe/brackets | src/LiveDevelopment/Agents/RemoteFunctions.js | _validEvent | function _validEvent(event) {
if (window.navigator.platform.substr(0, 3) === "Mac") {
// Mac
return event.metaKey;
} else {
// Windows
return event.ctrlKey;
}
} | javascript | function _validEvent(event) {
if (window.navigator.platform.substr(0, 3) === "Mac") {
// Mac
return event.metaKey;
} else {
// Windows
return event.ctrlKey;
}
} | [
"function",
"_validEvent",
"(",
"event",
")",
"{",
"if",
"(",
"window",
".",
"navigator",
".",
"platform",
".",
"substr",
"(",
"0",
",",
"3",
")",
"===",
"\"Mac\"",
")",
"{",
"// Mac",
"return",
"event",
".",
"metaKey",
";",
"}",
"else",
"{",
"// Windows",
"return",
"event",
".",
"ctrlKey",
";",
"}",
"}"
] | Keep alive timeout value, in milliseconds determine whether an event should be processed for Live Development | [
"Keep",
"alive",
"timeout",
"value",
"in",
"milliseconds",
"determine",
"whether",
"an",
"event",
"should",
"be",
"processed",
"for",
"Live",
"Development"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/RemoteFunctions.js#L66-L74 |
2,322 | adobe/brackets | src/LiveDevelopment/Agents/RemoteFunctions.js | _screenOffset | function _screenOffset(element) {
var elemBounds = element.getBoundingClientRect(),
body = window.document.body,
offsetTop,
offsetLeft;
if (window.getComputedStyle(body).position === "static") {
offsetLeft = elemBounds.left + window.pageXOffset;
offsetTop = elemBounds.top + window.pageYOffset;
} else {
var bodyBounds = body.getBoundingClientRect();
offsetLeft = elemBounds.left - bodyBounds.left;
offsetTop = elemBounds.top - bodyBounds.top;
}
return { left: offsetLeft, top: offsetTop };
} | javascript | function _screenOffset(element) {
var elemBounds = element.getBoundingClientRect(),
body = window.document.body,
offsetTop,
offsetLeft;
if (window.getComputedStyle(body).position === "static") {
offsetLeft = elemBounds.left + window.pageXOffset;
offsetTop = elemBounds.top + window.pageYOffset;
} else {
var bodyBounds = body.getBoundingClientRect();
offsetLeft = elemBounds.left - bodyBounds.left;
offsetTop = elemBounds.top - bodyBounds.top;
}
return { left: offsetLeft, top: offsetTop };
} | [
"function",
"_screenOffset",
"(",
"element",
")",
"{",
"var",
"elemBounds",
"=",
"element",
".",
"getBoundingClientRect",
"(",
")",
",",
"body",
"=",
"window",
".",
"document",
".",
"body",
",",
"offsetTop",
",",
"offsetLeft",
";",
"if",
"(",
"window",
".",
"getComputedStyle",
"(",
"body",
")",
".",
"position",
"===",
"\"static\"",
")",
"{",
"offsetLeft",
"=",
"elemBounds",
".",
"left",
"+",
"window",
".",
"pageXOffset",
";",
"offsetTop",
"=",
"elemBounds",
".",
"top",
"+",
"window",
".",
"pageYOffset",
";",
"}",
"else",
"{",
"var",
"bodyBounds",
"=",
"body",
".",
"getBoundingClientRect",
"(",
")",
";",
"offsetLeft",
"=",
"elemBounds",
".",
"left",
"-",
"bodyBounds",
".",
"left",
";",
"offsetTop",
"=",
"elemBounds",
".",
"top",
"-",
"bodyBounds",
".",
"top",
";",
"}",
"return",
"{",
"left",
":",
"offsetLeft",
",",
"top",
":",
"offsetTop",
"}",
";",
"}"
] | compute the screen offset of an element | [
"compute",
"the",
"screen",
"offset",
"of",
"an",
"element"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/RemoteFunctions.js#L91-L106 |
2,323 | adobe/brackets | src/LiveDevelopment/Agents/RemoteFunctions.js | _trigger | function _trigger(element, name, value, autoRemove) {
var key = "data-ld-" + name;
if (value !== undefined && value !== null) {
element.setAttribute(key, value);
if (autoRemove) {
window.setTimeout(element.removeAttribute.bind(element, key));
}
} else {
element.removeAttribute(key);
}
} | javascript | function _trigger(element, name, value, autoRemove) {
var key = "data-ld-" + name;
if (value !== undefined && value !== null) {
element.setAttribute(key, value);
if (autoRemove) {
window.setTimeout(element.removeAttribute.bind(element, key));
}
} else {
element.removeAttribute(key);
}
} | [
"function",
"_trigger",
"(",
"element",
",",
"name",
",",
"value",
",",
"autoRemove",
")",
"{",
"var",
"key",
"=",
"\"data-ld-\"",
"+",
"name",
";",
"if",
"(",
"value",
"!==",
"undefined",
"&&",
"value",
"!==",
"null",
")",
"{",
"element",
".",
"setAttribute",
"(",
"key",
",",
"value",
")",
";",
"if",
"(",
"autoRemove",
")",
"{",
"window",
".",
"setTimeout",
"(",
"element",
".",
"removeAttribute",
".",
"bind",
"(",
"element",
",",
"key",
")",
")",
";",
"}",
"}",
"else",
"{",
"element",
".",
"removeAttribute",
"(",
"key",
")",
";",
"}",
"}"
] | set an event on a element | [
"set",
"an",
"event",
"on",
"a",
"element"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/RemoteFunctions.js#L109-L119 |
2,324 | adobe/brackets | src/LiveDevelopment/Agents/RemoteFunctions.js | isInViewport | function isInViewport(element) {
var rect = element.getBoundingClientRect();
var html = window.document.documentElement;
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || html.clientHeight) &&
rect.right <= (window.innerWidth || html.clientWidth)
);
} | javascript | function isInViewport(element) {
var rect = element.getBoundingClientRect();
var html = window.document.documentElement;
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || html.clientHeight) &&
rect.right <= (window.innerWidth || html.clientWidth)
);
} | [
"function",
"isInViewport",
"(",
"element",
")",
"{",
"var",
"rect",
"=",
"element",
".",
"getBoundingClientRect",
"(",
")",
";",
"var",
"html",
"=",
"window",
".",
"document",
".",
"documentElement",
";",
"return",
"(",
"rect",
".",
"top",
">=",
"0",
"&&",
"rect",
".",
"left",
">=",
"0",
"&&",
"rect",
".",
"bottom",
"<=",
"(",
"window",
".",
"innerHeight",
"||",
"html",
".",
"clientHeight",
")",
"&&",
"rect",
".",
"right",
"<=",
"(",
"window",
".",
"innerWidth",
"||",
"html",
".",
"clientWidth",
")",
")",
";",
"}"
] | Checks if the element is in Viewport in the client browser | [
"Checks",
"if",
"the",
"element",
"is",
"in",
"Viewport",
"in",
"the",
"client",
"browser"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/RemoteFunctions.js#L122-L131 |
2,325 | adobe/brackets | src/LiveDevelopment/Agents/RemoteFunctions.js | Menu | function Menu(element) {
this.element = element;
_trigger(this.element, "showgoto", 1, true);
window.setTimeout(window.remoteShowGoto);
this.remove = this.remove.bind(this);
} | javascript | function Menu(element) {
this.element = element;
_trigger(this.element, "showgoto", 1, true);
window.setTimeout(window.remoteShowGoto);
this.remove = this.remove.bind(this);
} | [
"function",
"Menu",
"(",
"element",
")",
"{",
"this",
".",
"element",
"=",
"element",
";",
"_trigger",
"(",
"this",
".",
"element",
",",
"\"showgoto\"",
",",
"1",
",",
"true",
")",
";",
"window",
".",
"setTimeout",
"(",
"window",
".",
"remoteShowGoto",
")",
";",
"this",
".",
"remove",
"=",
"this",
".",
"remove",
".",
"bind",
"(",
"this",
")",
";",
"}"
] | construct the info menu | [
"construct",
"the",
"info",
"menu"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/RemoteFunctions.js#L139-L144 |
2,326 | adobe/brackets | src/LiveDevelopment/Agents/RemoteFunctions.js | highlight | function highlight(node, clear) {
if (!_remoteHighlight) {
_remoteHighlight = new Highlight("#cfc");
}
if (clear) {
_remoteHighlight.clear();
}
_remoteHighlight.add(node, true);
} | javascript | function highlight(node, clear) {
if (!_remoteHighlight) {
_remoteHighlight = new Highlight("#cfc");
}
if (clear) {
_remoteHighlight.clear();
}
_remoteHighlight.add(node, true);
} | [
"function",
"highlight",
"(",
"node",
",",
"clear",
")",
"{",
"if",
"(",
"!",
"_remoteHighlight",
")",
"{",
"_remoteHighlight",
"=",
"new",
"Highlight",
"(",
"\"#cfc\"",
")",
";",
"}",
"if",
"(",
"clear",
")",
"{",
"_remoteHighlight",
".",
"clear",
"(",
")",
";",
"}",
"_remoteHighlight",
".",
"add",
"(",
"node",
",",
"true",
")",
";",
"}"
] | highlight a node | [
"highlight",
"a",
"node"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/RemoteFunctions.js#L664-L672 |
2,327 | adobe/brackets | src/LiveDevelopment/Agents/RemoteFunctions.js | highlightRule | function highlightRule(rule) {
hideHighlight();
var i, nodes = window.document.querySelectorAll(rule);
for (i = 0; i < nodes.length; i++) {
highlight(nodes[i]);
}
_remoteHighlight.selector = rule;
} | javascript | function highlightRule(rule) {
hideHighlight();
var i, nodes = window.document.querySelectorAll(rule);
for (i = 0; i < nodes.length; i++) {
highlight(nodes[i]);
}
_remoteHighlight.selector = rule;
} | [
"function",
"highlightRule",
"(",
"rule",
")",
"{",
"hideHighlight",
"(",
")",
";",
"var",
"i",
",",
"nodes",
"=",
"window",
".",
"document",
".",
"querySelectorAll",
"(",
"rule",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nodes",
".",
"length",
";",
"i",
"++",
")",
"{",
"highlight",
"(",
"nodes",
"[",
"i",
"]",
")",
";",
"}",
"_remoteHighlight",
".",
"selector",
"=",
"rule",
";",
"}"
] | highlight a rule | [
"highlight",
"a",
"rule"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/RemoteFunctions.js#L675-L682 |
2,328 | adobe/brackets | src/LiveDevelopment/Agents/RemoteFunctions.js | _scrollHandler | function _scrollHandler(e) {
// Document scrolls can be updated immediately. Any other scrolls
// need to be updated on a timer to ensure the layout is correct.
if (e.target === window.document) {
redrawHighlights();
} else {
if (_remoteHighlight || _localHighlight) {
window.setTimeout(redrawHighlights, 0);
}
}
} | javascript | function _scrollHandler(e) {
// Document scrolls can be updated immediately. Any other scrolls
// need to be updated on a timer to ensure the layout is correct.
if (e.target === window.document) {
redrawHighlights();
} else {
if (_remoteHighlight || _localHighlight) {
window.setTimeout(redrawHighlights, 0);
}
}
} | [
"function",
"_scrollHandler",
"(",
"e",
")",
"{",
"// Document scrolls can be updated immediately. Any other scrolls",
"// need to be updated on a timer to ensure the layout is correct.",
"if",
"(",
"e",
".",
"target",
"===",
"window",
".",
"document",
")",
"{",
"redrawHighlights",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"_remoteHighlight",
"||",
"_localHighlight",
")",
"{",
"window",
".",
"setTimeout",
"(",
"redrawHighlights",
",",
"0",
")",
";",
"}",
"}",
"}"
] | Add a capture-phase scroll listener to update highlights when any element scrolls. | [
"Add",
"a",
"capture",
"-",
"phase",
"scroll",
"listener",
"to",
"update",
"highlights",
"when",
"any",
"element",
"scrolls",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/RemoteFunctions.js#L695-L705 |
2,329 | adobe/brackets | src/utils/StringMatch.js | findMatchingSpecial | function findMatchingSpecial() {
// used to loop through the specials
var i;
for (i = specialsCounter; i < specials.length; i++) {
// short circuit this search when we know there are no matches following
if (specials[i] >= deadBranches[queryCounter]) {
break;
}
// First, ensure that we're not comparing specials that
// come earlier in the string than our current search position.
// This can happen when the string position changes elsewhere.
if (specials[i] < strCounter) {
specialsCounter = i;
} else if (query[queryCounter] === str[specials[i]]) {
// we have a match! do the required tracking
strCounter = specials[i];
// Upper case match check:
// If the query and original string matched, but the original string
// and the lower case version did not, that means that the original
// was upper case.
var upper = originalQuery[queryCounter] === originalStr[strCounter] && originalStr[strCounter] !== str[strCounter];
result.push(new SpecialMatch(strCounter, upper));
specialsCounter = i;
queryCounter++;
strCounter++;
return true;
}
}
return false;
} | javascript | function findMatchingSpecial() {
// used to loop through the specials
var i;
for (i = specialsCounter; i < specials.length; i++) {
// short circuit this search when we know there are no matches following
if (specials[i] >= deadBranches[queryCounter]) {
break;
}
// First, ensure that we're not comparing specials that
// come earlier in the string than our current search position.
// This can happen when the string position changes elsewhere.
if (specials[i] < strCounter) {
specialsCounter = i;
} else if (query[queryCounter] === str[specials[i]]) {
// we have a match! do the required tracking
strCounter = specials[i];
// Upper case match check:
// If the query and original string matched, but the original string
// and the lower case version did not, that means that the original
// was upper case.
var upper = originalQuery[queryCounter] === originalStr[strCounter] && originalStr[strCounter] !== str[strCounter];
result.push(new SpecialMatch(strCounter, upper));
specialsCounter = i;
queryCounter++;
strCounter++;
return true;
}
}
return false;
} | [
"function",
"findMatchingSpecial",
"(",
")",
"{",
"// used to loop through the specials",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"specialsCounter",
";",
"i",
"<",
"specials",
".",
"length",
";",
"i",
"++",
")",
"{",
"// short circuit this search when we know there are no matches following",
"if",
"(",
"specials",
"[",
"i",
"]",
">=",
"deadBranches",
"[",
"queryCounter",
"]",
")",
"{",
"break",
";",
"}",
"// First, ensure that we're not comparing specials that",
"// come earlier in the string than our current search position.",
"// This can happen when the string position changes elsewhere.",
"if",
"(",
"specials",
"[",
"i",
"]",
"<",
"strCounter",
")",
"{",
"specialsCounter",
"=",
"i",
";",
"}",
"else",
"if",
"(",
"query",
"[",
"queryCounter",
"]",
"===",
"str",
"[",
"specials",
"[",
"i",
"]",
"]",
")",
"{",
"// we have a match! do the required tracking",
"strCounter",
"=",
"specials",
"[",
"i",
"]",
";",
"// Upper case match check:",
"// If the query and original string matched, but the original string",
"// and the lower case version did not, that means that the original",
"// was upper case.",
"var",
"upper",
"=",
"originalQuery",
"[",
"queryCounter",
"]",
"===",
"originalStr",
"[",
"strCounter",
"]",
"&&",
"originalStr",
"[",
"strCounter",
"]",
"!==",
"str",
"[",
"strCounter",
"]",
";",
"result",
".",
"push",
"(",
"new",
"SpecialMatch",
"(",
"strCounter",
",",
"upper",
")",
")",
";",
"specialsCounter",
"=",
"i",
";",
"queryCounter",
"++",
";",
"strCounter",
"++",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Compares the current character from the query string against the special characters in str. Returns true if a match was found, false otherwise. | [
"Compares",
"the",
"current",
"character",
"from",
"the",
"query",
"string",
"against",
"the",
"special",
"characters",
"in",
"str",
".",
"Returns",
"true",
"if",
"a",
"match",
"was",
"found",
"false",
"otherwise",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/StringMatch.js#L255-L288 |
2,330 | adobe/brackets | src/utils/StringMatch.js | backtrack | function backtrack() {
// The idea is to pull matches off of our match list, rolling back
// characters from the query. We pay special attention to the special
// characters since they are searched first.
while (result.length > 0) {
var item = result.pop();
// nothing in the list? there's no possible match then.
if (!item) {
return false;
}
// we pulled off a match, which means that we need to put a character
// back into our query. strCounter is going to be set once we've pulled
// off the right special character and know where we're going to restart
// searching from.
queryCounter--;
if (item instanceof SpecialMatch) {
// pulled off a special, which means we need to make that special available
// for matching again
specialsCounter--;
// check to see if we've gone back as far as we need to
if (item.index < deadBranches[queryCounter]) {
// we now know that this part of the query does not match beyond this
// point
deadBranches[queryCounter] = item.index - 1;
// since we failed with the specials along this track, we're
// going to reset to looking for matches consecutively.
state = ANY_MATCH;
// we figure out where to start looking based on the new
// last item in the list. If there isn't anything else
// in the match list, we'll start over at the starting special
// (which is generally the beginning of the string, or the
// beginning of the last segment of the string)
item = result[result.length - 1];
if (!item) {
strCounter = specials[startingSpecial] + 1;
return true;
}
strCounter = item.index + 1;
return true;
}
}
}
return false;
} | javascript | function backtrack() {
// The idea is to pull matches off of our match list, rolling back
// characters from the query. We pay special attention to the special
// characters since they are searched first.
while (result.length > 0) {
var item = result.pop();
// nothing in the list? there's no possible match then.
if (!item) {
return false;
}
// we pulled off a match, which means that we need to put a character
// back into our query. strCounter is going to be set once we've pulled
// off the right special character and know where we're going to restart
// searching from.
queryCounter--;
if (item instanceof SpecialMatch) {
// pulled off a special, which means we need to make that special available
// for matching again
specialsCounter--;
// check to see if we've gone back as far as we need to
if (item.index < deadBranches[queryCounter]) {
// we now know that this part of the query does not match beyond this
// point
deadBranches[queryCounter] = item.index - 1;
// since we failed with the specials along this track, we're
// going to reset to looking for matches consecutively.
state = ANY_MATCH;
// we figure out where to start looking based on the new
// last item in the list. If there isn't anything else
// in the match list, we'll start over at the starting special
// (which is generally the beginning of the string, or the
// beginning of the last segment of the string)
item = result[result.length - 1];
if (!item) {
strCounter = specials[startingSpecial] + 1;
return true;
}
strCounter = item.index + 1;
return true;
}
}
}
return false;
} | [
"function",
"backtrack",
"(",
")",
"{",
"// The idea is to pull matches off of our match list, rolling back",
"// characters from the query. We pay special attention to the special",
"// characters since they are searched first.",
"while",
"(",
"result",
".",
"length",
">",
"0",
")",
"{",
"var",
"item",
"=",
"result",
".",
"pop",
"(",
")",
";",
"// nothing in the list? there's no possible match then.",
"if",
"(",
"!",
"item",
")",
"{",
"return",
"false",
";",
"}",
"// we pulled off a match, which means that we need to put a character",
"// back into our query. strCounter is going to be set once we've pulled",
"// off the right special character and know where we're going to restart",
"// searching from.",
"queryCounter",
"--",
";",
"if",
"(",
"item",
"instanceof",
"SpecialMatch",
")",
"{",
"// pulled off a special, which means we need to make that special available",
"// for matching again",
"specialsCounter",
"--",
";",
"// check to see if we've gone back as far as we need to",
"if",
"(",
"item",
".",
"index",
"<",
"deadBranches",
"[",
"queryCounter",
"]",
")",
"{",
"// we now know that this part of the query does not match beyond this",
"// point",
"deadBranches",
"[",
"queryCounter",
"]",
"=",
"item",
".",
"index",
"-",
"1",
";",
"// since we failed with the specials along this track, we're",
"// going to reset to looking for matches consecutively.",
"state",
"=",
"ANY_MATCH",
";",
"// we figure out where to start looking based on the new",
"// last item in the list. If there isn't anything else",
"// in the match list, we'll start over at the starting special",
"// (which is generally the beginning of the string, or the",
"// beginning of the last segment of the string)",
"item",
"=",
"result",
"[",
"result",
".",
"length",
"-",
"1",
"]",
";",
"if",
"(",
"!",
"item",
")",
"{",
"strCounter",
"=",
"specials",
"[",
"startingSpecial",
"]",
"+",
"1",
";",
"return",
"true",
";",
"}",
"strCounter",
"=",
"item",
".",
"index",
"+",
"1",
";",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | This function implements the backtracking that is done when we fail to find a match with the query using the "search for specials first" approach. returns false when it is not able to backtrack successfully | [
"This",
"function",
"implements",
"the",
"backtracking",
"that",
"is",
"done",
"when",
"we",
"fail",
"to",
"find",
"a",
"match",
"with",
"the",
"query",
"using",
"the",
"search",
"for",
"specials",
"first",
"approach",
".",
"returns",
"false",
"when",
"it",
"is",
"not",
"able",
"to",
"backtrack",
"successfully"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/StringMatch.js#L294-L344 |
2,331 | adobe/brackets | src/utils/StringMatch.js | closeRangeGap | function closeRangeGap(c) {
// Close the current range
if (currentRange) {
currentRange.includesLastSegment = lastMatchIndex >= lastSegmentStart;
if (currentRange.matched && currentRange.includesLastSegment) {
if (DEBUG_SCORES) {
scoreDebug.lastSegment += lastSegmentScore * LAST_SEGMENT_BOOST;
}
score += lastSegmentScore * LAST_SEGMENT_BOOST;
}
if (currentRange.matched && !currentRangeStartedOnSpecial) {
if (DEBUG_SCORES) {
scoreDebug.notStartingOnSpecial -= NOT_STARTING_ON_SPECIAL_PENALTY;
}
score -= NOT_STARTING_ON_SPECIAL_PENALTY;
}
ranges.push(currentRange);
}
// If there was space between the new range and the last,
// add a new unmatched range before the new range can be added.
if (lastMatchIndex + 1 < c) {
ranges.push({
text: str.substring(lastMatchIndex + 1, c),
matched: false,
includesLastSegment: c > lastSegmentStart
});
}
currentRange = null;
lastSegmentScore = 0;
} | javascript | function closeRangeGap(c) {
// Close the current range
if (currentRange) {
currentRange.includesLastSegment = lastMatchIndex >= lastSegmentStart;
if (currentRange.matched && currentRange.includesLastSegment) {
if (DEBUG_SCORES) {
scoreDebug.lastSegment += lastSegmentScore * LAST_SEGMENT_BOOST;
}
score += lastSegmentScore * LAST_SEGMENT_BOOST;
}
if (currentRange.matched && !currentRangeStartedOnSpecial) {
if (DEBUG_SCORES) {
scoreDebug.notStartingOnSpecial -= NOT_STARTING_ON_SPECIAL_PENALTY;
}
score -= NOT_STARTING_ON_SPECIAL_PENALTY;
}
ranges.push(currentRange);
}
// If there was space between the new range and the last,
// add a new unmatched range before the new range can be added.
if (lastMatchIndex + 1 < c) {
ranges.push({
text: str.substring(lastMatchIndex + 1, c),
matched: false,
includesLastSegment: c > lastSegmentStart
});
}
currentRange = null;
lastSegmentScore = 0;
} | [
"function",
"closeRangeGap",
"(",
"c",
")",
"{",
"// Close the current range",
"if",
"(",
"currentRange",
")",
"{",
"currentRange",
".",
"includesLastSegment",
"=",
"lastMatchIndex",
">=",
"lastSegmentStart",
";",
"if",
"(",
"currentRange",
".",
"matched",
"&&",
"currentRange",
".",
"includesLastSegment",
")",
"{",
"if",
"(",
"DEBUG_SCORES",
")",
"{",
"scoreDebug",
".",
"lastSegment",
"+=",
"lastSegmentScore",
"*",
"LAST_SEGMENT_BOOST",
";",
"}",
"score",
"+=",
"lastSegmentScore",
"*",
"LAST_SEGMENT_BOOST",
";",
"}",
"if",
"(",
"currentRange",
".",
"matched",
"&&",
"!",
"currentRangeStartedOnSpecial",
")",
"{",
"if",
"(",
"DEBUG_SCORES",
")",
"{",
"scoreDebug",
".",
"notStartingOnSpecial",
"-=",
"NOT_STARTING_ON_SPECIAL_PENALTY",
";",
"}",
"score",
"-=",
"NOT_STARTING_ON_SPECIAL_PENALTY",
";",
"}",
"ranges",
".",
"push",
"(",
"currentRange",
")",
";",
"}",
"// If there was space between the new range and the last,",
"// add a new unmatched range before the new range can be added.",
"if",
"(",
"lastMatchIndex",
"+",
"1",
"<",
"c",
")",
"{",
"ranges",
".",
"push",
"(",
"{",
"text",
":",
"str",
".",
"substring",
"(",
"lastMatchIndex",
"+",
"1",
",",
"c",
")",
",",
"matched",
":",
"false",
",",
"includesLastSegment",
":",
"c",
">",
"lastSegmentStart",
"}",
")",
";",
"}",
"currentRange",
"=",
"null",
";",
"lastSegmentScore",
"=",
"0",
";",
"}"
] | Records the current range and adds any additional ranges required to get to character index c. This function is called before starting a new range or returning from the function. | [
"Records",
"the",
"current",
"range",
"and",
"adds",
"any",
"additional",
"ranges",
"required",
"to",
"get",
"to",
"character",
"index",
"c",
".",
"This",
"function",
"is",
"called",
"before",
"starting",
"a",
"new",
"range",
"or",
"returning",
"from",
"the",
"function",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/StringMatch.js#L534-L565 |
2,332 | adobe/brackets | src/utils/StringMatch.js | addMatch | function addMatch(match) {
// Pull off the character index
var c = match.index;
var newPoints = 0;
// A match means that we need to do some scoring bookkeeping.
// Start with points added for any match
if (DEBUG_SCORES) {
scoreDebug.match += MATCH_POINTS;
}
newPoints += MATCH_POINTS;
if (match.upper) {
if (DEBUG_SCORES) {
scoreDebug.upper += UPPER_CASE_MATCH;
}
newPoints += UPPER_CASE_MATCH;
}
// A bonus is given for characters that match at the beginning
// of the filename
if (c === lastSegmentStart) {
if (DEBUG_SCORES) {
scoreDebug.beginning += BEGINNING_OF_NAME_POINTS;
}
newPoints += BEGINNING_OF_NAME_POINTS;
}
// If the new character immediately follows the last matched character,
// we award the consecutive matches bonus. The check for score > 0
// handles the initial value of lastMatchIndex which is used for
// constructing ranges but we don't yet have a true match.
if (score > 0 && lastMatchIndex + 1 === c) {
// Continue boosting for each additional match at the beginning
// of the name
if (c - numConsecutive === lastSegmentStart) {
if (DEBUG_SCORES) {
scoreDebug.beginning += BEGINNING_OF_NAME_POINTS;
}
newPoints += BEGINNING_OF_NAME_POINTS;
}
numConsecutive++;
var boost = CONSECUTIVE_MATCHES_POINTS * numConsecutive;
// Consecutive matches that started on a special are a
// good indicator of intent, so we award an added bonus there.
if (currentRangeStartedOnSpecial) {
boost = boost * 2;
}
if (DEBUG_SCORES) {
scoreDebug.consecutive += boost;
}
newPoints += boost;
} else {
numConsecutive = 1;
}
// add points for "special" character matches
if (match instanceof SpecialMatch) {
if (DEBUG_SCORES) {
scoreDebug.special += SPECIAL_POINTS;
}
newPoints += SPECIAL_POINTS;
}
score += newPoints;
// points accumulated in the last segment get an extra bonus
if (c >= lastSegmentStart) {
lastSegmentScore += newPoints;
}
// if the last range wasn't a match or there's a gap, we need to close off
// the range to start a new one.
if ((currentRange && !currentRange.matched) || c > lastMatchIndex + 1) {
closeRangeGap(c);
}
lastMatchIndex = c;
// set up a new match range or add to the current one
if (!currentRange) {
currentRange = {
text: str[c],
matched: true
};
// Check to see if this new matched range is starting on a special
// character. We penalize those ranges that don't, because most
// people will search on the logical boundaries of the name
currentRangeStartedOnSpecial = match instanceof SpecialMatch;
} else {
currentRange.text += str[c];
}
} | javascript | function addMatch(match) {
// Pull off the character index
var c = match.index;
var newPoints = 0;
// A match means that we need to do some scoring bookkeeping.
// Start with points added for any match
if (DEBUG_SCORES) {
scoreDebug.match += MATCH_POINTS;
}
newPoints += MATCH_POINTS;
if (match.upper) {
if (DEBUG_SCORES) {
scoreDebug.upper += UPPER_CASE_MATCH;
}
newPoints += UPPER_CASE_MATCH;
}
// A bonus is given for characters that match at the beginning
// of the filename
if (c === lastSegmentStart) {
if (DEBUG_SCORES) {
scoreDebug.beginning += BEGINNING_OF_NAME_POINTS;
}
newPoints += BEGINNING_OF_NAME_POINTS;
}
// If the new character immediately follows the last matched character,
// we award the consecutive matches bonus. The check for score > 0
// handles the initial value of lastMatchIndex which is used for
// constructing ranges but we don't yet have a true match.
if (score > 0 && lastMatchIndex + 1 === c) {
// Continue boosting for each additional match at the beginning
// of the name
if (c - numConsecutive === lastSegmentStart) {
if (DEBUG_SCORES) {
scoreDebug.beginning += BEGINNING_OF_NAME_POINTS;
}
newPoints += BEGINNING_OF_NAME_POINTS;
}
numConsecutive++;
var boost = CONSECUTIVE_MATCHES_POINTS * numConsecutive;
// Consecutive matches that started on a special are a
// good indicator of intent, so we award an added bonus there.
if (currentRangeStartedOnSpecial) {
boost = boost * 2;
}
if (DEBUG_SCORES) {
scoreDebug.consecutive += boost;
}
newPoints += boost;
} else {
numConsecutive = 1;
}
// add points for "special" character matches
if (match instanceof SpecialMatch) {
if (DEBUG_SCORES) {
scoreDebug.special += SPECIAL_POINTS;
}
newPoints += SPECIAL_POINTS;
}
score += newPoints;
// points accumulated in the last segment get an extra bonus
if (c >= lastSegmentStart) {
lastSegmentScore += newPoints;
}
// if the last range wasn't a match or there's a gap, we need to close off
// the range to start a new one.
if ((currentRange && !currentRange.matched) || c > lastMatchIndex + 1) {
closeRangeGap(c);
}
lastMatchIndex = c;
// set up a new match range or add to the current one
if (!currentRange) {
currentRange = {
text: str[c],
matched: true
};
// Check to see if this new matched range is starting on a special
// character. We penalize those ranges that don't, because most
// people will search on the logical boundaries of the name
currentRangeStartedOnSpecial = match instanceof SpecialMatch;
} else {
currentRange.text += str[c];
}
} | [
"function",
"addMatch",
"(",
"match",
")",
"{",
"// Pull off the character index",
"var",
"c",
"=",
"match",
".",
"index",
";",
"var",
"newPoints",
"=",
"0",
";",
"// A match means that we need to do some scoring bookkeeping.",
"// Start with points added for any match",
"if",
"(",
"DEBUG_SCORES",
")",
"{",
"scoreDebug",
".",
"match",
"+=",
"MATCH_POINTS",
";",
"}",
"newPoints",
"+=",
"MATCH_POINTS",
";",
"if",
"(",
"match",
".",
"upper",
")",
"{",
"if",
"(",
"DEBUG_SCORES",
")",
"{",
"scoreDebug",
".",
"upper",
"+=",
"UPPER_CASE_MATCH",
";",
"}",
"newPoints",
"+=",
"UPPER_CASE_MATCH",
";",
"}",
"// A bonus is given for characters that match at the beginning",
"// of the filename",
"if",
"(",
"c",
"===",
"lastSegmentStart",
")",
"{",
"if",
"(",
"DEBUG_SCORES",
")",
"{",
"scoreDebug",
".",
"beginning",
"+=",
"BEGINNING_OF_NAME_POINTS",
";",
"}",
"newPoints",
"+=",
"BEGINNING_OF_NAME_POINTS",
";",
"}",
"// If the new character immediately follows the last matched character,",
"// we award the consecutive matches bonus. The check for score > 0",
"// handles the initial value of lastMatchIndex which is used for",
"// constructing ranges but we don't yet have a true match.",
"if",
"(",
"score",
">",
"0",
"&&",
"lastMatchIndex",
"+",
"1",
"===",
"c",
")",
"{",
"// Continue boosting for each additional match at the beginning",
"// of the name",
"if",
"(",
"c",
"-",
"numConsecutive",
"===",
"lastSegmentStart",
")",
"{",
"if",
"(",
"DEBUG_SCORES",
")",
"{",
"scoreDebug",
".",
"beginning",
"+=",
"BEGINNING_OF_NAME_POINTS",
";",
"}",
"newPoints",
"+=",
"BEGINNING_OF_NAME_POINTS",
";",
"}",
"numConsecutive",
"++",
";",
"var",
"boost",
"=",
"CONSECUTIVE_MATCHES_POINTS",
"*",
"numConsecutive",
";",
"// Consecutive matches that started on a special are a",
"// good indicator of intent, so we award an added bonus there.",
"if",
"(",
"currentRangeStartedOnSpecial",
")",
"{",
"boost",
"=",
"boost",
"*",
"2",
";",
"}",
"if",
"(",
"DEBUG_SCORES",
")",
"{",
"scoreDebug",
".",
"consecutive",
"+=",
"boost",
";",
"}",
"newPoints",
"+=",
"boost",
";",
"}",
"else",
"{",
"numConsecutive",
"=",
"1",
";",
"}",
"// add points for \"special\" character matches",
"if",
"(",
"match",
"instanceof",
"SpecialMatch",
")",
"{",
"if",
"(",
"DEBUG_SCORES",
")",
"{",
"scoreDebug",
".",
"special",
"+=",
"SPECIAL_POINTS",
";",
"}",
"newPoints",
"+=",
"SPECIAL_POINTS",
";",
"}",
"score",
"+=",
"newPoints",
";",
"// points accumulated in the last segment get an extra bonus",
"if",
"(",
"c",
">=",
"lastSegmentStart",
")",
"{",
"lastSegmentScore",
"+=",
"newPoints",
";",
"}",
"// if the last range wasn't a match or there's a gap, we need to close off",
"// the range to start a new one.",
"if",
"(",
"(",
"currentRange",
"&&",
"!",
"currentRange",
".",
"matched",
")",
"||",
"c",
">",
"lastMatchIndex",
"+",
"1",
")",
"{",
"closeRangeGap",
"(",
"c",
")",
";",
"}",
"lastMatchIndex",
"=",
"c",
";",
"// set up a new match range or add to the current one",
"if",
"(",
"!",
"currentRange",
")",
"{",
"currentRange",
"=",
"{",
"text",
":",
"str",
"[",
"c",
"]",
",",
"matched",
":",
"true",
"}",
";",
"// Check to see if this new matched range is starting on a special",
"// character. We penalize those ranges that don't, because most",
"// people will search on the logical boundaries of the name",
"currentRangeStartedOnSpecial",
"=",
"match",
"instanceof",
"SpecialMatch",
";",
"}",
"else",
"{",
"currentRange",
".",
"text",
"+=",
"str",
"[",
"c",
"]",
";",
"}",
"}"
] | Adds a matched character to the appropriate range | [
"Adds",
"a",
"matched",
"character",
"to",
"the",
"appropriate",
"range"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/StringMatch.js#L572-L668 |
2,333 | adobe/brackets | src/editor/InlineTextEditor.js | _syncGutterWidths | function _syncGutterWidths(hostEditor) {
var allHostedEditors = EditorManager.getInlineEditors(hostEditor);
// add the host itself to the list too
allHostedEditors.push(hostEditor);
var maxWidth = 0;
allHostedEditors.forEach(function (editor) {
var $gutter = $(editor._codeMirror.getGutterElement()).find(".CodeMirror-linenumbers");
$gutter.css("min-width", "");
var curWidth = $gutter.width();
if (curWidth > maxWidth) {
maxWidth = curWidth;
}
});
if (allHostedEditors.length === 1) {
//There's only the host, just refresh the gutter
allHostedEditors[0]._codeMirror.setOption("gutters", allHostedEditors[0]._codeMirror.getOption("gutters"));
return;
}
maxWidth = maxWidth + "px";
allHostedEditors.forEach(function (editor) {
$(editor._codeMirror.getGutterElement()).find(".CodeMirror-linenumbers").css("min-width", maxWidth);
// Force CodeMirror to refresh the gutter
editor._codeMirror.setOption("gutters", editor._codeMirror.getOption("gutters"));
});
} | javascript | function _syncGutterWidths(hostEditor) {
var allHostedEditors = EditorManager.getInlineEditors(hostEditor);
// add the host itself to the list too
allHostedEditors.push(hostEditor);
var maxWidth = 0;
allHostedEditors.forEach(function (editor) {
var $gutter = $(editor._codeMirror.getGutterElement()).find(".CodeMirror-linenumbers");
$gutter.css("min-width", "");
var curWidth = $gutter.width();
if (curWidth > maxWidth) {
maxWidth = curWidth;
}
});
if (allHostedEditors.length === 1) {
//There's only the host, just refresh the gutter
allHostedEditors[0]._codeMirror.setOption("gutters", allHostedEditors[0]._codeMirror.getOption("gutters"));
return;
}
maxWidth = maxWidth + "px";
allHostedEditors.forEach(function (editor) {
$(editor._codeMirror.getGutterElement()).find(".CodeMirror-linenumbers").css("min-width", maxWidth);
// Force CodeMirror to refresh the gutter
editor._codeMirror.setOption("gutters", editor._codeMirror.getOption("gutters"));
});
} | [
"function",
"_syncGutterWidths",
"(",
"hostEditor",
")",
"{",
"var",
"allHostedEditors",
"=",
"EditorManager",
".",
"getInlineEditors",
"(",
"hostEditor",
")",
";",
"// add the host itself to the list too",
"allHostedEditors",
".",
"push",
"(",
"hostEditor",
")",
";",
"var",
"maxWidth",
"=",
"0",
";",
"allHostedEditors",
".",
"forEach",
"(",
"function",
"(",
"editor",
")",
"{",
"var",
"$gutter",
"=",
"$",
"(",
"editor",
".",
"_codeMirror",
".",
"getGutterElement",
"(",
")",
")",
".",
"find",
"(",
"\".CodeMirror-linenumbers\"",
")",
";",
"$gutter",
".",
"css",
"(",
"\"min-width\"",
",",
"\"\"",
")",
";",
"var",
"curWidth",
"=",
"$gutter",
".",
"width",
"(",
")",
";",
"if",
"(",
"curWidth",
">",
"maxWidth",
")",
"{",
"maxWidth",
"=",
"curWidth",
";",
"}",
"}",
")",
";",
"if",
"(",
"allHostedEditors",
".",
"length",
"===",
"1",
")",
"{",
"//There's only the host, just refresh the gutter",
"allHostedEditors",
"[",
"0",
"]",
".",
"_codeMirror",
".",
"setOption",
"(",
"\"gutters\"",
",",
"allHostedEditors",
"[",
"0",
"]",
".",
"_codeMirror",
".",
"getOption",
"(",
"\"gutters\"",
")",
")",
";",
"return",
";",
"}",
"maxWidth",
"=",
"maxWidth",
"+",
"\"px\"",
";",
"allHostedEditors",
".",
"forEach",
"(",
"function",
"(",
"editor",
")",
"{",
"$",
"(",
"editor",
".",
"_codeMirror",
".",
"getGutterElement",
"(",
")",
")",
".",
"find",
"(",
"\".CodeMirror-linenumbers\"",
")",
".",
"css",
"(",
"\"min-width\"",
",",
"maxWidth",
")",
";",
"// Force CodeMirror to refresh the gutter",
"editor",
".",
"_codeMirror",
".",
"setOption",
"(",
"\"gutters\"",
",",
"editor",
".",
"_codeMirror",
".",
"getOption",
"(",
"\"gutters\"",
")",
")",
";",
"}",
")",
";",
"}"
] | Given a host editor and its inline editors, find the widest gutter and make all the others match
@param {!Editor} hostEditor Host editor containing all the inline editors to sync
@private | [
"Given",
"a",
"host",
"editor",
"and",
"its",
"inline",
"editors",
"find",
"the",
"widest",
"gutter",
"and",
"make",
"all",
"the",
"others",
"match"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/InlineTextEditor.js#L96-L125 |
2,334 | adobe/brackets | src/extensions/default/StaticServer/node/StaticServerDomain.js | init | function init(domainManager) {
_domainManager = domainManager;
if (!domainManager.hasDomain("staticServer")) {
domainManager.registerDomain("staticServer", {major: 0, minor: 1});
}
_domainManager.registerCommand(
"staticServer",
"_setRequestFilterTimeout",
_cmdSetRequestFilterTimeout,
false,
"Unit tests only. Set timeout value for filtered requests.",
[{
name: "timeout",
type: "number",
description: "Duration to wait before passing a filtered request to the static file server."
}],
[]
);
_domainManager.registerCommand(
"staticServer",
"getServer",
_cmdGetServer,
true,
"Starts or returns an existing server for the given path.",
[
{
name: "path",
type: "string",
description: "Absolute filesystem path for root of server."
},
{
name: "port",
type: "number",
description: "Port number to use for HTTP server. Pass zero to assign a random port."
}
],
[{
name: "address",
type: "{address: string, family: string, port: number}",
description: "hostname (stored in 'address' parameter), port, and socket type (stored in 'family' parameter) for the server. Currently, 'family' will always be 'IPv4'."
}]
);
_domainManager.registerCommand(
"staticServer",
"closeServer",
_cmdCloseServer,
false,
"Closes the server for the given path.",
[{
name: "path",
type: "string",
description: "absolute filesystem path for root of server"
}],
[{
name: "result",
type: "boolean",
description: "indicates whether a server was found for the specific path then closed"
}]
);
_domainManager.registerCommand(
"staticServer",
"setRequestFilterPaths",
_cmdSetRequestFilterPaths,
false,
"Defines a set of paths from a server's root path to watch and fire 'requestFilter' events for.",
[
{
name: "root",
type: "string",
description: "absolute filesystem path for root of server"
},
{
name: "paths",
type: "Array",
description: "path to notify"
}
],
[]
);
_domainManager.registerCommand(
"staticServer",
"writeFilteredResponse",
_cmdWriteFilteredResponse,
false,
"Overrides the server response from static middleware with the provided response data. This should be called only in response to a filtered request.",
[
{
name: "root",
type: "string",
description: "absolute filesystem path for root of server"
},
{
name: "path",
type: "string",
description: "path to rewrite"
},
{
name: "resData",
type: "{body: string, headers: Array}",
description: "TODO"
}
],
[]
);
_domainManager.registerEvent(
"staticServer",
"requestFilter",
[{
name: "location",
type: "{hostname: string, pathname: string, port: number, root: string: id: number}",
description: "request path"
}]
);
} | javascript | function init(domainManager) {
_domainManager = domainManager;
if (!domainManager.hasDomain("staticServer")) {
domainManager.registerDomain("staticServer", {major: 0, minor: 1});
}
_domainManager.registerCommand(
"staticServer",
"_setRequestFilterTimeout",
_cmdSetRequestFilterTimeout,
false,
"Unit tests only. Set timeout value for filtered requests.",
[{
name: "timeout",
type: "number",
description: "Duration to wait before passing a filtered request to the static file server."
}],
[]
);
_domainManager.registerCommand(
"staticServer",
"getServer",
_cmdGetServer,
true,
"Starts or returns an existing server for the given path.",
[
{
name: "path",
type: "string",
description: "Absolute filesystem path for root of server."
},
{
name: "port",
type: "number",
description: "Port number to use for HTTP server. Pass zero to assign a random port."
}
],
[{
name: "address",
type: "{address: string, family: string, port: number}",
description: "hostname (stored in 'address' parameter), port, and socket type (stored in 'family' parameter) for the server. Currently, 'family' will always be 'IPv4'."
}]
);
_domainManager.registerCommand(
"staticServer",
"closeServer",
_cmdCloseServer,
false,
"Closes the server for the given path.",
[{
name: "path",
type: "string",
description: "absolute filesystem path for root of server"
}],
[{
name: "result",
type: "boolean",
description: "indicates whether a server was found for the specific path then closed"
}]
);
_domainManager.registerCommand(
"staticServer",
"setRequestFilterPaths",
_cmdSetRequestFilterPaths,
false,
"Defines a set of paths from a server's root path to watch and fire 'requestFilter' events for.",
[
{
name: "root",
type: "string",
description: "absolute filesystem path for root of server"
},
{
name: "paths",
type: "Array",
description: "path to notify"
}
],
[]
);
_domainManager.registerCommand(
"staticServer",
"writeFilteredResponse",
_cmdWriteFilteredResponse,
false,
"Overrides the server response from static middleware with the provided response data. This should be called only in response to a filtered request.",
[
{
name: "root",
type: "string",
description: "absolute filesystem path for root of server"
},
{
name: "path",
type: "string",
description: "path to rewrite"
},
{
name: "resData",
type: "{body: string, headers: Array}",
description: "TODO"
}
],
[]
);
_domainManager.registerEvent(
"staticServer",
"requestFilter",
[{
name: "location",
type: "{hostname: string, pathname: string, port: number, root: string: id: number}",
description: "request path"
}]
);
} | [
"function",
"init",
"(",
"domainManager",
")",
"{",
"_domainManager",
"=",
"domainManager",
";",
"if",
"(",
"!",
"domainManager",
".",
"hasDomain",
"(",
"\"staticServer\"",
")",
")",
"{",
"domainManager",
".",
"registerDomain",
"(",
"\"staticServer\"",
",",
"{",
"major",
":",
"0",
",",
"minor",
":",
"1",
"}",
")",
";",
"}",
"_domainManager",
".",
"registerCommand",
"(",
"\"staticServer\"",
",",
"\"_setRequestFilterTimeout\"",
",",
"_cmdSetRequestFilterTimeout",
",",
"false",
",",
"\"Unit tests only. Set timeout value for filtered requests.\"",
",",
"[",
"{",
"name",
":",
"\"timeout\"",
",",
"type",
":",
"\"number\"",
",",
"description",
":",
"\"Duration to wait before passing a filtered request to the static file server.\"",
"}",
"]",
",",
"[",
"]",
")",
";",
"_domainManager",
".",
"registerCommand",
"(",
"\"staticServer\"",
",",
"\"getServer\"",
",",
"_cmdGetServer",
",",
"true",
",",
"\"Starts or returns an existing server for the given path.\"",
",",
"[",
"{",
"name",
":",
"\"path\"",
",",
"type",
":",
"\"string\"",
",",
"description",
":",
"\"Absolute filesystem path for root of server.\"",
"}",
",",
"{",
"name",
":",
"\"port\"",
",",
"type",
":",
"\"number\"",
",",
"description",
":",
"\"Port number to use for HTTP server. Pass zero to assign a random port.\"",
"}",
"]",
",",
"[",
"{",
"name",
":",
"\"address\"",
",",
"type",
":",
"\"{address: string, family: string, port: number}\"",
",",
"description",
":",
"\"hostname (stored in 'address' parameter), port, and socket type (stored in 'family' parameter) for the server. Currently, 'family' will always be 'IPv4'.\"",
"}",
"]",
")",
";",
"_domainManager",
".",
"registerCommand",
"(",
"\"staticServer\"",
",",
"\"closeServer\"",
",",
"_cmdCloseServer",
",",
"false",
",",
"\"Closes the server for the given path.\"",
",",
"[",
"{",
"name",
":",
"\"path\"",
",",
"type",
":",
"\"string\"",
",",
"description",
":",
"\"absolute filesystem path for root of server\"",
"}",
"]",
",",
"[",
"{",
"name",
":",
"\"result\"",
",",
"type",
":",
"\"boolean\"",
",",
"description",
":",
"\"indicates whether a server was found for the specific path then closed\"",
"}",
"]",
")",
";",
"_domainManager",
".",
"registerCommand",
"(",
"\"staticServer\"",
",",
"\"setRequestFilterPaths\"",
",",
"_cmdSetRequestFilterPaths",
",",
"false",
",",
"\"Defines a set of paths from a server's root path to watch and fire 'requestFilter' events for.\"",
",",
"[",
"{",
"name",
":",
"\"root\"",
",",
"type",
":",
"\"string\"",
",",
"description",
":",
"\"absolute filesystem path for root of server\"",
"}",
",",
"{",
"name",
":",
"\"paths\"",
",",
"type",
":",
"\"Array\"",
",",
"description",
":",
"\"path to notify\"",
"}",
"]",
",",
"[",
"]",
")",
";",
"_domainManager",
".",
"registerCommand",
"(",
"\"staticServer\"",
",",
"\"writeFilteredResponse\"",
",",
"_cmdWriteFilteredResponse",
",",
"false",
",",
"\"Overrides the server response from static middleware with the provided response data. This should be called only in response to a filtered request.\"",
",",
"[",
"{",
"name",
":",
"\"root\"",
",",
"type",
":",
"\"string\"",
",",
"description",
":",
"\"absolute filesystem path for root of server\"",
"}",
",",
"{",
"name",
":",
"\"path\"",
",",
"type",
":",
"\"string\"",
",",
"description",
":",
"\"path to rewrite\"",
"}",
",",
"{",
"name",
":",
"\"resData\"",
",",
"type",
":",
"\"{body: string, headers: Array}\"",
",",
"description",
":",
"\"TODO\"",
"}",
"]",
",",
"[",
"]",
")",
";",
"_domainManager",
".",
"registerEvent",
"(",
"\"staticServer\"",
",",
"\"requestFilter\"",
",",
"[",
"{",
"name",
":",
"\"location\"",
",",
"type",
":",
"\"{hostname: string, pathname: string, port: number, root: string: id: number}\"",
",",
"description",
":",
"\"request path\"",
"}",
"]",
")",
";",
"}"
] | Initializes the StaticServer domain with its commands.
@param {DomainManager} domainManager The DomainManager for the server | [
"Initializes",
"the",
"StaticServer",
"domain",
"with",
"its",
"commands",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/StaticServer/node/StaticServerDomain.js#L361-L475 |
2,335 | adobe/brackets | src/search/FindUtils.js | _doReplaceInDocument | function _doReplaceInDocument(doc, matchInfo, replaceText, isRegexp) {
// Double-check that the open document's timestamp matches the one we recorded. This
// should normally never go out of sync, because if it did we wouldn't start the
// replace in the first place (due to the fact that we immediately close the search
// results panel whenever we detect a filesystem change that affects the results),
// but we want to double-check in case we don't happen to get the change in time.
// This will *not* handle cases where the document has been edited in memory since
// the matchInfo was generated.
if (doc.diskTimestamp.getTime() !== matchInfo.timestamp.getTime()) {
return new $.Deferred().reject(exports.ERROR_FILE_CHANGED).promise();
}
// Do the replacements in reverse document order so the offsets continue to be correct.
doc.batchOperation(function () {
matchInfo.matches.reverse().forEach(function (match) {
if (match.isChecked) {
doc.replaceRange(isRegexp ? parseDollars(replaceText, match.result) : replaceText, match.start, match.end);
}
});
});
return new $.Deferred().resolve().promise();
} | javascript | function _doReplaceInDocument(doc, matchInfo, replaceText, isRegexp) {
// Double-check that the open document's timestamp matches the one we recorded. This
// should normally never go out of sync, because if it did we wouldn't start the
// replace in the first place (due to the fact that we immediately close the search
// results panel whenever we detect a filesystem change that affects the results),
// but we want to double-check in case we don't happen to get the change in time.
// This will *not* handle cases where the document has been edited in memory since
// the matchInfo was generated.
if (doc.diskTimestamp.getTime() !== matchInfo.timestamp.getTime()) {
return new $.Deferred().reject(exports.ERROR_FILE_CHANGED).promise();
}
// Do the replacements in reverse document order so the offsets continue to be correct.
doc.batchOperation(function () {
matchInfo.matches.reverse().forEach(function (match) {
if (match.isChecked) {
doc.replaceRange(isRegexp ? parseDollars(replaceText, match.result) : replaceText, match.start, match.end);
}
});
});
return new $.Deferred().resolve().promise();
} | [
"function",
"_doReplaceInDocument",
"(",
"doc",
",",
"matchInfo",
",",
"replaceText",
",",
"isRegexp",
")",
"{",
"// Double-check that the open document's timestamp matches the one we recorded. This",
"// should normally never go out of sync, because if it did we wouldn't start the",
"// replace in the first place (due to the fact that we immediately close the search",
"// results panel whenever we detect a filesystem change that affects the results),",
"// but we want to double-check in case we don't happen to get the change in time.",
"// This will *not* handle cases where the document has been edited in memory since",
"// the matchInfo was generated.",
"if",
"(",
"doc",
".",
"diskTimestamp",
".",
"getTime",
"(",
")",
"!==",
"matchInfo",
".",
"timestamp",
".",
"getTime",
"(",
")",
")",
"{",
"return",
"new",
"$",
".",
"Deferred",
"(",
")",
".",
"reject",
"(",
"exports",
".",
"ERROR_FILE_CHANGED",
")",
".",
"promise",
"(",
")",
";",
"}",
"// Do the replacements in reverse document order so the offsets continue to be correct.",
"doc",
".",
"batchOperation",
"(",
"function",
"(",
")",
"{",
"matchInfo",
".",
"matches",
".",
"reverse",
"(",
")",
".",
"forEach",
"(",
"function",
"(",
"match",
")",
"{",
"if",
"(",
"match",
".",
"isChecked",
")",
"{",
"doc",
".",
"replaceRange",
"(",
"isRegexp",
"?",
"parseDollars",
"(",
"replaceText",
",",
"match",
".",
"result",
")",
":",
"replaceText",
",",
"match",
".",
"start",
",",
"match",
".",
"end",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"return",
"new",
"$",
".",
"Deferred",
"(",
")",
".",
"resolve",
"(",
")",
".",
"promise",
"(",
")",
";",
"}"
] | Does a set of replacements in a single document in memory.
@param {!Document} doc The document to do the replacements in.
@param {Object} matchInfo The match info for this file, as returned by `_addSearchMatches()`. Might be mutated.
@param {string} replaceText The text to replace each result with.
@param {boolean=} isRegexp Whether the original query was a regexp.
@return {$.Promise} A promise that's resolved when the replacement is finished or rejected with an error if there were one or more errors. | [
"Does",
"a",
"set",
"of",
"replacements",
"in",
"a",
"single",
"document",
"in",
"memory",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindUtils.js#L113-L135 |
2,336 | adobe/brackets | src/search/FindUtils.js | _doReplaceOnDisk | function _doReplaceOnDisk(fullPath, matchInfo, replaceText, isRegexp) {
var file = FileSystem.getFileForPath(fullPath);
return DocumentManager.getDocumentText(file, true).then(function (contents, timestamp, lineEndings) {
if (timestamp.getTime() !== matchInfo.timestamp.getTime()) {
// Return a promise that we'll reject immediately. (We can't just return the
// error since this is the success handler.)
return new $.Deferred().reject(exports.ERROR_FILE_CHANGED).promise();
}
// Note that this assumes that the matches are sorted.
// TODO: is there a more efficient way to do this in a large string?
var result = [],
lastIndex = 0;
matchInfo.matches.forEach(function (match) {
if (match.isChecked) {
result.push(contents.slice(lastIndex, match.startOffset));
result.push(isRegexp ? parseDollars(replaceText, match.result) : replaceText);
lastIndex = match.endOffset;
}
});
result.push(contents.slice(lastIndex));
var newContents = result.join("");
// TODO: duplicated logic from Document - should refactor this?
if (lineEndings === FileUtils.LINE_ENDINGS_CRLF) {
newContents = newContents.replace(/\n/g, "\r\n");
}
return Async.promisify(file, "write", newContents);
});
} | javascript | function _doReplaceOnDisk(fullPath, matchInfo, replaceText, isRegexp) {
var file = FileSystem.getFileForPath(fullPath);
return DocumentManager.getDocumentText(file, true).then(function (contents, timestamp, lineEndings) {
if (timestamp.getTime() !== matchInfo.timestamp.getTime()) {
// Return a promise that we'll reject immediately. (We can't just return the
// error since this is the success handler.)
return new $.Deferred().reject(exports.ERROR_FILE_CHANGED).promise();
}
// Note that this assumes that the matches are sorted.
// TODO: is there a more efficient way to do this in a large string?
var result = [],
lastIndex = 0;
matchInfo.matches.forEach(function (match) {
if (match.isChecked) {
result.push(contents.slice(lastIndex, match.startOffset));
result.push(isRegexp ? parseDollars(replaceText, match.result) : replaceText);
lastIndex = match.endOffset;
}
});
result.push(contents.slice(lastIndex));
var newContents = result.join("");
// TODO: duplicated logic from Document - should refactor this?
if (lineEndings === FileUtils.LINE_ENDINGS_CRLF) {
newContents = newContents.replace(/\n/g, "\r\n");
}
return Async.promisify(file, "write", newContents);
});
} | [
"function",
"_doReplaceOnDisk",
"(",
"fullPath",
",",
"matchInfo",
",",
"replaceText",
",",
"isRegexp",
")",
"{",
"var",
"file",
"=",
"FileSystem",
".",
"getFileForPath",
"(",
"fullPath",
")",
";",
"return",
"DocumentManager",
".",
"getDocumentText",
"(",
"file",
",",
"true",
")",
".",
"then",
"(",
"function",
"(",
"contents",
",",
"timestamp",
",",
"lineEndings",
")",
"{",
"if",
"(",
"timestamp",
".",
"getTime",
"(",
")",
"!==",
"matchInfo",
".",
"timestamp",
".",
"getTime",
"(",
")",
")",
"{",
"// Return a promise that we'll reject immediately. (We can't just return the",
"// error since this is the success handler.)",
"return",
"new",
"$",
".",
"Deferred",
"(",
")",
".",
"reject",
"(",
"exports",
".",
"ERROR_FILE_CHANGED",
")",
".",
"promise",
"(",
")",
";",
"}",
"// Note that this assumes that the matches are sorted.",
"// TODO: is there a more efficient way to do this in a large string?",
"var",
"result",
"=",
"[",
"]",
",",
"lastIndex",
"=",
"0",
";",
"matchInfo",
".",
"matches",
".",
"forEach",
"(",
"function",
"(",
"match",
")",
"{",
"if",
"(",
"match",
".",
"isChecked",
")",
"{",
"result",
".",
"push",
"(",
"contents",
".",
"slice",
"(",
"lastIndex",
",",
"match",
".",
"startOffset",
")",
")",
";",
"result",
".",
"push",
"(",
"isRegexp",
"?",
"parseDollars",
"(",
"replaceText",
",",
"match",
".",
"result",
")",
":",
"replaceText",
")",
";",
"lastIndex",
"=",
"match",
".",
"endOffset",
";",
"}",
"}",
")",
";",
"result",
".",
"push",
"(",
"contents",
".",
"slice",
"(",
"lastIndex",
")",
")",
";",
"var",
"newContents",
"=",
"result",
".",
"join",
"(",
"\"\"",
")",
";",
"// TODO: duplicated logic from Document - should refactor this?",
"if",
"(",
"lineEndings",
"===",
"FileUtils",
".",
"LINE_ENDINGS_CRLF",
")",
"{",
"newContents",
"=",
"newContents",
".",
"replace",
"(",
"/",
"\\n",
"/",
"g",
",",
"\"\\r\\n\"",
")",
";",
"}",
"return",
"Async",
".",
"promisify",
"(",
"file",
",",
"\"write\"",
",",
"newContents",
")",
";",
"}",
")",
";",
"}"
] | Does a set of replacements in a single file on disk.
@param {string} fullPath The full path to the file.
@param {Object} matchInfo The match info for this file, as returned by `_addSearchMatches()`.
@param {string} replaceText The text to replace each result with.
@param {boolean=} isRegexp Whether the original query was a regexp.
@return {$.Promise} A promise that's resolved when the replacement is finished or rejected with an error if there were one or more errors. | [
"Does",
"a",
"set",
"of",
"replacements",
"in",
"a",
"single",
"file",
"on",
"disk",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindUtils.js#L145-L175 |
2,337 | adobe/brackets | src/search/FindUtils.js | _doReplaceInOneFile | function _doReplaceInOneFile(fullPath, matchInfo, replaceText, options) {
var doc = DocumentManager.getOpenDocumentForPath(fullPath);
options = options || {};
// If we're forcing files open, or if the document is in the working set but not actually open
// yet, we want to open the file and do the replacement in memory.
if (!doc && (options.forceFilesOpen || MainViewManager.findInWorkingSet(MainViewManager.ALL_PANES, fullPath) !== -1)) {
return DocumentManager.getDocumentForPath(fullPath).then(function (newDoc) {
return _doReplaceInDocument(newDoc, matchInfo, replaceText, options.isRegexp);
});
} else if (doc) {
return _doReplaceInDocument(doc, matchInfo, replaceText, options.isRegexp);
} else {
return _doReplaceOnDisk(fullPath, matchInfo, replaceText, options.isRegexp);
}
} | javascript | function _doReplaceInOneFile(fullPath, matchInfo, replaceText, options) {
var doc = DocumentManager.getOpenDocumentForPath(fullPath);
options = options || {};
// If we're forcing files open, or if the document is in the working set but not actually open
// yet, we want to open the file and do the replacement in memory.
if (!doc && (options.forceFilesOpen || MainViewManager.findInWorkingSet(MainViewManager.ALL_PANES, fullPath) !== -1)) {
return DocumentManager.getDocumentForPath(fullPath).then(function (newDoc) {
return _doReplaceInDocument(newDoc, matchInfo, replaceText, options.isRegexp);
});
} else if (doc) {
return _doReplaceInDocument(doc, matchInfo, replaceText, options.isRegexp);
} else {
return _doReplaceOnDisk(fullPath, matchInfo, replaceText, options.isRegexp);
}
} | [
"function",
"_doReplaceInOneFile",
"(",
"fullPath",
",",
"matchInfo",
",",
"replaceText",
",",
"options",
")",
"{",
"var",
"doc",
"=",
"DocumentManager",
".",
"getOpenDocumentForPath",
"(",
"fullPath",
")",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"// If we're forcing files open, or if the document is in the working set but not actually open",
"// yet, we want to open the file and do the replacement in memory.",
"if",
"(",
"!",
"doc",
"&&",
"(",
"options",
".",
"forceFilesOpen",
"||",
"MainViewManager",
".",
"findInWorkingSet",
"(",
"MainViewManager",
".",
"ALL_PANES",
",",
"fullPath",
")",
"!==",
"-",
"1",
")",
")",
"{",
"return",
"DocumentManager",
".",
"getDocumentForPath",
"(",
"fullPath",
")",
".",
"then",
"(",
"function",
"(",
"newDoc",
")",
"{",
"return",
"_doReplaceInDocument",
"(",
"newDoc",
",",
"matchInfo",
",",
"replaceText",
",",
"options",
".",
"isRegexp",
")",
";",
"}",
")",
";",
"}",
"else",
"if",
"(",
"doc",
")",
"{",
"return",
"_doReplaceInDocument",
"(",
"doc",
",",
"matchInfo",
",",
"replaceText",
",",
"options",
".",
"isRegexp",
")",
";",
"}",
"else",
"{",
"return",
"_doReplaceOnDisk",
"(",
"fullPath",
",",
"matchInfo",
",",
"replaceText",
",",
"options",
".",
"isRegexp",
")",
";",
"}",
"}"
] | Does a set of replacements in a single file. If the file is already open in a Document in memory,
will do the replacement there, otherwise does it directly on disk.
@param {string} fullPath The full path to the file.
@param {Object} matchInfo The match info for this file, as returned by `_addSearchMatches()`.
@param {string} replaceText The text to replace each result with.
@param {Object=} options An options object:
forceFilesOpen: boolean - Whether to open the file in an editor and do replacements there rather than doing the
replacements on disk. Note that even if this is false, files that are already open in editors will have replacements
done in memory.
isRegexp: boolean - Whether the original query was a regexp. If true, $-substitution is performed on the replaceText.
@return {$.Promise} A promise that's resolved when the replacement is finished or rejected with an error if there were one or more errors. | [
"Does",
"a",
"set",
"of",
"replacements",
"in",
"a",
"single",
"file",
".",
"If",
"the",
"file",
"is",
"already",
"open",
"in",
"a",
"Document",
"in",
"memory",
"will",
"do",
"the",
"replacement",
"there",
"otherwise",
"does",
"it",
"directly",
"on",
"disk",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindUtils.js#L190-L204 |
2,338 | adobe/brackets | src/search/FindUtils.js | labelForScope | function labelForScope(scope) {
if (scope) {
return StringUtils.format(
Strings.FIND_IN_FILES_SCOPED,
StringUtils.breakableUrl(
ProjectManager.makeProjectRelativeIfPossible(scope.fullPath)
)
);
} else {
return Strings.FIND_IN_FILES_NO_SCOPE;
}
} | javascript | function labelForScope(scope) {
if (scope) {
return StringUtils.format(
Strings.FIND_IN_FILES_SCOPED,
StringUtils.breakableUrl(
ProjectManager.makeProjectRelativeIfPossible(scope.fullPath)
)
);
} else {
return Strings.FIND_IN_FILES_NO_SCOPE;
}
} | [
"function",
"labelForScope",
"(",
"scope",
")",
"{",
"if",
"(",
"scope",
")",
"{",
"return",
"StringUtils",
".",
"format",
"(",
"Strings",
".",
"FIND_IN_FILES_SCOPED",
",",
"StringUtils",
".",
"breakableUrl",
"(",
"ProjectManager",
".",
"makeProjectRelativeIfPossible",
"(",
"scope",
".",
"fullPath",
")",
")",
")",
";",
"}",
"else",
"{",
"return",
"Strings",
".",
"FIND_IN_FILES_NO_SCOPE",
";",
"}",
"}"
] | Returns label text to indicate the search scope. Already HTML-escaped.
@param {?Entry} scope
@return {string} | [
"Returns",
"label",
"text",
"to",
"indicate",
"the",
"search",
"scope",
".",
"Already",
"HTML",
"-",
"escaped",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindUtils.js#L286-L297 |
2,339 | adobe/brackets | src/search/FindUtils.js | parseQueryInfo | function parseQueryInfo(queryInfo) {
var queryExpr;
if (!queryInfo || !queryInfo.query) {
return {empty: true};
}
// For now, treat all matches as multiline (i.e. ^/$ match on every line, not the whole
// document). This is consistent with how single-file find works. Eventually we should add
// an option for this.
var flags = "gm";
if (!queryInfo.isCaseSensitive) {
flags += "i";
}
// Is it a (non-blank) regex?
if (queryInfo.isRegexp) {
try {
queryExpr = new RegExp(queryInfo.query, flags);
} catch (e) {
return {valid: false, error: e.message};
}
} else {
// Query is a plain string. Turn it into a regexp
queryExpr = new RegExp(StringUtils.regexEscape(queryInfo.query), flags);
}
return {valid: true, queryExpr: queryExpr};
} | javascript | function parseQueryInfo(queryInfo) {
var queryExpr;
if (!queryInfo || !queryInfo.query) {
return {empty: true};
}
// For now, treat all matches as multiline (i.e. ^/$ match on every line, not the whole
// document). This is consistent with how single-file find works. Eventually we should add
// an option for this.
var flags = "gm";
if (!queryInfo.isCaseSensitive) {
flags += "i";
}
// Is it a (non-blank) regex?
if (queryInfo.isRegexp) {
try {
queryExpr = new RegExp(queryInfo.query, flags);
} catch (e) {
return {valid: false, error: e.message};
}
} else {
// Query is a plain string. Turn it into a regexp
queryExpr = new RegExp(StringUtils.regexEscape(queryInfo.query), flags);
}
return {valid: true, queryExpr: queryExpr};
} | [
"function",
"parseQueryInfo",
"(",
"queryInfo",
")",
"{",
"var",
"queryExpr",
";",
"if",
"(",
"!",
"queryInfo",
"||",
"!",
"queryInfo",
".",
"query",
")",
"{",
"return",
"{",
"empty",
":",
"true",
"}",
";",
"}",
"// For now, treat all matches as multiline (i.e. ^/$ match on every line, not the whole",
"// document). This is consistent with how single-file find works. Eventually we should add",
"// an option for this.",
"var",
"flags",
"=",
"\"gm\"",
";",
"if",
"(",
"!",
"queryInfo",
".",
"isCaseSensitive",
")",
"{",
"flags",
"+=",
"\"i\"",
";",
"}",
"// Is it a (non-blank) regex?",
"if",
"(",
"queryInfo",
".",
"isRegexp",
")",
"{",
"try",
"{",
"queryExpr",
"=",
"new",
"RegExp",
"(",
"queryInfo",
".",
"query",
",",
"flags",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"return",
"{",
"valid",
":",
"false",
",",
"error",
":",
"e",
".",
"message",
"}",
";",
"}",
"}",
"else",
"{",
"// Query is a plain string. Turn it into a regexp",
"queryExpr",
"=",
"new",
"RegExp",
"(",
"StringUtils",
".",
"regexEscape",
"(",
"queryInfo",
".",
"query",
")",
",",
"flags",
")",
";",
"}",
"return",
"{",
"valid",
":",
"true",
",",
"queryExpr",
":",
"queryExpr",
"}",
";",
"}"
] | Parses the given query into a regexp, and returns whether it was valid or not.
@param {{query: string, caseSensitive: boolean, isRegexp: boolean}} queryInfo
@return {{queryExpr: RegExp, valid: boolean, empty: boolean, error: string}}
queryExpr - the regexp representing the query
valid - set to true if query is a nonempty string or a valid regexp.
empty - set to true if query was empty.
error - set to an error string if valid is false and query is nonempty. | [
"Parses",
"the",
"given",
"query",
"into",
"a",
"regexp",
"and",
"returns",
"whether",
"it",
"was",
"valid",
"or",
"not",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindUtils.js#L308-L335 |
2,340 | adobe/brackets | src/search/FindUtils.js | prioritizeOpenFile | function prioritizeOpenFile(files, firstFile) {
var workingSetFiles = MainViewManager.getWorkingSet(MainViewManager.ALL_PANES),
workingSetFileFound = {},
fileSetWithoutWorkingSet = [],
startingWorkingFileSet = [],
propertyName = "",
i = 0;
firstFile = firstFile || "";
// Create a working set path map which indicates if a file in working set is found in file list
for (i = 0; i < workingSetFiles.length; i++) {
workingSetFileFound[workingSetFiles[i].fullPath] = false;
}
// Remove all the working set files from the filtration list
fileSetWithoutWorkingSet = files.filter(function (key) {
if (workingSetFileFound[key] !== undefined) {
workingSetFileFound[key] = true;
return false;
}
return true;
});
//push in the first file
if (workingSetFileFound[firstFile] === true) {
startingWorkingFileSet.push(firstFile);
workingSetFileFound[firstFile] = false;
}
//push in the rest of working set files already present in file list
for (propertyName in workingSetFileFound) {
if (workingSetFileFound.hasOwnProperty(propertyName) && workingSetFileFound[propertyName]) {
startingWorkingFileSet.push(propertyName);
}
}
return startingWorkingFileSet.concat(fileSetWithoutWorkingSet);
} | javascript | function prioritizeOpenFile(files, firstFile) {
var workingSetFiles = MainViewManager.getWorkingSet(MainViewManager.ALL_PANES),
workingSetFileFound = {},
fileSetWithoutWorkingSet = [],
startingWorkingFileSet = [],
propertyName = "",
i = 0;
firstFile = firstFile || "";
// Create a working set path map which indicates if a file in working set is found in file list
for (i = 0; i < workingSetFiles.length; i++) {
workingSetFileFound[workingSetFiles[i].fullPath] = false;
}
// Remove all the working set files from the filtration list
fileSetWithoutWorkingSet = files.filter(function (key) {
if (workingSetFileFound[key] !== undefined) {
workingSetFileFound[key] = true;
return false;
}
return true;
});
//push in the first file
if (workingSetFileFound[firstFile] === true) {
startingWorkingFileSet.push(firstFile);
workingSetFileFound[firstFile] = false;
}
//push in the rest of working set files already present in file list
for (propertyName in workingSetFileFound) {
if (workingSetFileFound.hasOwnProperty(propertyName) && workingSetFileFound[propertyName]) {
startingWorkingFileSet.push(propertyName);
}
}
return startingWorkingFileSet.concat(fileSetWithoutWorkingSet);
} | [
"function",
"prioritizeOpenFile",
"(",
"files",
",",
"firstFile",
")",
"{",
"var",
"workingSetFiles",
"=",
"MainViewManager",
".",
"getWorkingSet",
"(",
"MainViewManager",
".",
"ALL_PANES",
")",
",",
"workingSetFileFound",
"=",
"{",
"}",
",",
"fileSetWithoutWorkingSet",
"=",
"[",
"]",
",",
"startingWorkingFileSet",
"=",
"[",
"]",
",",
"propertyName",
"=",
"\"\"",
",",
"i",
"=",
"0",
";",
"firstFile",
"=",
"firstFile",
"||",
"\"\"",
";",
"// Create a working set path map which indicates if a file in working set is found in file list",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"workingSetFiles",
".",
"length",
";",
"i",
"++",
")",
"{",
"workingSetFileFound",
"[",
"workingSetFiles",
"[",
"i",
"]",
".",
"fullPath",
"]",
"=",
"false",
";",
"}",
"// Remove all the working set files from the filtration list",
"fileSetWithoutWorkingSet",
"=",
"files",
".",
"filter",
"(",
"function",
"(",
"key",
")",
"{",
"if",
"(",
"workingSetFileFound",
"[",
"key",
"]",
"!==",
"undefined",
")",
"{",
"workingSetFileFound",
"[",
"key",
"]",
"=",
"true",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
")",
";",
"//push in the first file",
"if",
"(",
"workingSetFileFound",
"[",
"firstFile",
"]",
"===",
"true",
")",
"{",
"startingWorkingFileSet",
".",
"push",
"(",
"firstFile",
")",
";",
"workingSetFileFound",
"[",
"firstFile",
"]",
"=",
"false",
";",
"}",
"//push in the rest of working set files already present in file list",
"for",
"(",
"propertyName",
"in",
"workingSetFileFound",
")",
"{",
"if",
"(",
"workingSetFileFound",
".",
"hasOwnProperty",
"(",
"propertyName",
")",
"&&",
"workingSetFileFound",
"[",
"propertyName",
"]",
")",
"{",
"startingWorkingFileSet",
".",
"push",
"(",
"propertyName",
")",
";",
"}",
"}",
"return",
"startingWorkingFileSet",
".",
"concat",
"(",
"fileSetWithoutWorkingSet",
")",
";",
"}"
] | Prioritizes the open file and then the working set files to the starting of the list of files
@param {Array.<*>} files An array of file paths or file objects to sort
@param {?string} firstFile If specified, the path to the file that should be sorted to the top.
@return {Array.<*>} | [
"Prioritizes",
"the",
"open",
"file",
"and",
"then",
"the",
"working",
"set",
"files",
"to",
"the",
"starting",
"of",
"the",
"list",
"of",
"files"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindUtils.js#L343-L378 |
2,341 | adobe/brackets | src/utils/DeprecationWarning.js | _trimStack | function _trimStack(stack) {
var indexOfFirstRequireJSline;
// Remove everything in the stack up to the end of the line that shows this module file path
stack = stack.substr(stack.indexOf(")\n") + 2);
// Find the very first line of require.js in the stack if the call is from an extension.
// Remove all those lines from the call stack.
indexOfFirstRequireJSline = stack.indexOf("requirejs/require.js");
if (indexOfFirstRequireJSline !== -1) {
indexOfFirstRequireJSline = stack.lastIndexOf(")", indexOfFirstRequireJSline) + 1;
stack = stack.substr(0, indexOfFirstRequireJSline);
}
return stack;
} | javascript | function _trimStack(stack) {
var indexOfFirstRequireJSline;
// Remove everything in the stack up to the end of the line that shows this module file path
stack = stack.substr(stack.indexOf(")\n") + 2);
// Find the very first line of require.js in the stack if the call is from an extension.
// Remove all those lines from the call stack.
indexOfFirstRequireJSline = stack.indexOf("requirejs/require.js");
if (indexOfFirstRequireJSline !== -1) {
indexOfFirstRequireJSline = stack.lastIndexOf(")", indexOfFirstRequireJSline) + 1;
stack = stack.substr(0, indexOfFirstRequireJSline);
}
return stack;
} | [
"function",
"_trimStack",
"(",
"stack",
")",
"{",
"var",
"indexOfFirstRequireJSline",
";",
"// Remove everything in the stack up to the end of the line that shows this module file path",
"stack",
"=",
"stack",
".",
"substr",
"(",
"stack",
".",
"indexOf",
"(",
"\")\\n\"",
")",
"+",
"2",
")",
";",
"// Find the very first line of require.js in the stack if the call is from an extension.",
"// Remove all those lines from the call stack.",
"indexOfFirstRequireJSline",
"=",
"stack",
".",
"indexOf",
"(",
"\"requirejs/require.js\"",
")",
";",
"if",
"(",
"indexOfFirstRequireJSline",
"!==",
"-",
"1",
")",
"{",
"indexOfFirstRequireJSline",
"=",
"stack",
".",
"lastIndexOf",
"(",
"\")\"",
",",
"indexOfFirstRequireJSline",
")",
"+",
"1",
";",
"stack",
"=",
"stack",
".",
"substr",
"(",
"0",
",",
"indexOfFirstRequireJSline",
")",
";",
"}",
"return",
"stack",
";",
"}"
] | Trim the stack so that it does not have the call to this module,
and all the calls to require.js to load the extension that shows
this deprecation warning. | [
"Trim",
"the",
"stack",
"so",
"that",
"it",
"does",
"not",
"have",
"the",
"call",
"to",
"this",
"module",
"and",
"all",
"the",
"calls",
"to",
"require",
".",
"js",
"to",
"load",
"the",
"extension",
"that",
"shows",
"this",
"deprecation",
"warning",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/DeprecationWarning.js#L41-L56 |
2,342 | adobe/brackets | src/utils/DeprecationWarning.js | deprecationWarning | function deprecationWarning(message, oncePerCaller, callerStackPos) {
// If oncePerCaller isn't set, then only show the message once no matter who calls it.
if (!message || (!oncePerCaller && displayedWarnings[message])) {
return;
}
// Don't show the warning again if we've already gotten it from the current caller.
// The true caller location is the fourth line in the stack trace:
// * 0 is the word "Error"
// * 1 is this function
// * 2 is the caller of this function (the one throwing the deprecation warning)
// * 3 is the actual caller of the deprecated function.
var stack = new Error().stack,
callerLocation = stack.split("\n")[callerStackPos || 3];
if (oncePerCaller && displayedWarnings[message] && displayedWarnings[message][callerLocation]) {
return;
}
console.warn(message + "\n" + _trimStack(stack));
if (!displayedWarnings[message]) {
displayedWarnings[message] = {};
}
displayedWarnings[message][callerLocation] = true;
} | javascript | function deprecationWarning(message, oncePerCaller, callerStackPos) {
// If oncePerCaller isn't set, then only show the message once no matter who calls it.
if (!message || (!oncePerCaller && displayedWarnings[message])) {
return;
}
// Don't show the warning again if we've already gotten it from the current caller.
// The true caller location is the fourth line in the stack trace:
// * 0 is the word "Error"
// * 1 is this function
// * 2 is the caller of this function (the one throwing the deprecation warning)
// * 3 is the actual caller of the deprecated function.
var stack = new Error().stack,
callerLocation = stack.split("\n")[callerStackPos || 3];
if (oncePerCaller && displayedWarnings[message] && displayedWarnings[message][callerLocation]) {
return;
}
console.warn(message + "\n" + _trimStack(stack));
if (!displayedWarnings[message]) {
displayedWarnings[message] = {};
}
displayedWarnings[message][callerLocation] = true;
} | [
"function",
"deprecationWarning",
"(",
"message",
",",
"oncePerCaller",
",",
"callerStackPos",
")",
"{",
"// If oncePerCaller isn't set, then only show the message once no matter who calls it.",
"if",
"(",
"!",
"message",
"||",
"(",
"!",
"oncePerCaller",
"&&",
"displayedWarnings",
"[",
"message",
"]",
")",
")",
"{",
"return",
";",
"}",
"// Don't show the warning again if we've already gotten it from the current caller.",
"// The true caller location is the fourth line in the stack trace:",
"// * 0 is the word \"Error\"",
"// * 1 is this function",
"// * 2 is the caller of this function (the one throwing the deprecation warning)",
"// * 3 is the actual caller of the deprecated function.",
"var",
"stack",
"=",
"new",
"Error",
"(",
")",
".",
"stack",
",",
"callerLocation",
"=",
"stack",
".",
"split",
"(",
"\"\\n\"",
")",
"[",
"callerStackPos",
"||",
"3",
"]",
";",
"if",
"(",
"oncePerCaller",
"&&",
"displayedWarnings",
"[",
"message",
"]",
"&&",
"displayedWarnings",
"[",
"message",
"]",
"[",
"callerLocation",
"]",
")",
"{",
"return",
";",
"}",
"console",
".",
"warn",
"(",
"message",
"+",
"\"\\n\"",
"+",
"_trimStack",
"(",
"stack",
")",
")",
";",
"if",
"(",
"!",
"displayedWarnings",
"[",
"message",
"]",
")",
"{",
"displayedWarnings",
"[",
"message",
"]",
"=",
"{",
"}",
";",
"}",
"displayedWarnings",
"[",
"message",
"]",
"[",
"callerLocation",
"]",
"=",
"true",
";",
"}"
] | Show deprecation warning with the call stack if it
has never been displayed before.
@param {!string} message The deprecation message to be displayed.
@param {boolean=} oncePerCaller If true, displays the message once for each unique call location.
If false (the default), only displays the message once no matter where it's called from.
Note that setting this to true can cause a slight performance hit (because it has to generate
a stack trace), so don't set this for functions that you expect to be called from performance-
sensitive code (e.g. tight loops).
@param {number=} callerStackPos Only used if oncePerCaller=true. Overrides the `Error().stack` depth
where the client-code caller can be found. Only needed if extra shim layers are involved. | [
"Show",
"deprecation",
"warning",
"with",
"the",
"call",
"stack",
"if",
"it",
"has",
"never",
"been",
"displayed",
"before",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/DeprecationWarning.js#L70-L93 |
2,343 | adobe/brackets | src/utils/DeprecationWarning.js | deprecateEvent | function deprecateEvent(outbound, inbound, oldEventName, newEventName, canonicalOutboundName, canonicalInboundName) {
// Mark deprecated so EventDispatcher.on() will emit warnings
EventDispatcher.markDeprecated(outbound, oldEventName, canonicalInboundName);
// create an event handler for the new event to listen for
inbound.on(newEventName, function () {
// Dispatch the event in case anyone is still listening
EventDispatcher.triggerWithArray(outbound, oldEventName, Array.prototype.slice.call(arguments, 1));
});
} | javascript | function deprecateEvent(outbound, inbound, oldEventName, newEventName, canonicalOutboundName, canonicalInboundName) {
// Mark deprecated so EventDispatcher.on() will emit warnings
EventDispatcher.markDeprecated(outbound, oldEventName, canonicalInboundName);
// create an event handler for the new event to listen for
inbound.on(newEventName, function () {
// Dispatch the event in case anyone is still listening
EventDispatcher.triggerWithArray(outbound, oldEventName, Array.prototype.slice.call(arguments, 1));
});
} | [
"function",
"deprecateEvent",
"(",
"outbound",
",",
"inbound",
",",
"oldEventName",
",",
"newEventName",
",",
"canonicalOutboundName",
",",
"canonicalInboundName",
")",
"{",
"// Mark deprecated so EventDispatcher.on() will emit warnings",
"EventDispatcher",
".",
"markDeprecated",
"(",
"outbound",
",",
"oldEventName",
",",
"canonicalInboundName",
")",
";",
"// create an event handler for the new event to listen for",
"inbound",
".",
"on",
"(",
"newEventName",
",",
"function",
"(",
")",
"{",
"// Dispatch the event in case anyone is still listening",
"EventDispatcher",
".",
"triggerWithArray",
"(",
"outbound",
",",
"oldEventName",
",",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
")",
";",
"}",
")",
";",
"}"
] | Show a deprecation warning if there are listeners for the event
```
DeprecationWarning.deprecateEvent(exports,
MainViewManager,
"workingSetAdd",
"workingSetAdd",
"DocumentManager.workingSetAdd",
"MainViewManager.workingSetAdd");
```
@param {Object} outbound - the object with the old event to dispatch
@param {Object} inbound - the object with the new event to map to the old event
@param {string} oldEventName - the name of the old event
@param {string} newEventName - the name of the new event
@param {string=} canonicalOutboundName - the canonical name of the old event
@param {string=} canonicalInboundName - the canonical name of the new event | [
"Show",
"a",
"deprecation",
"warning",
"if",
"there",
"are",
"listeners",
"for",
"the",
"event"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/DeprecationWarning.js#L115-L124 |
2,344 | adobe/brackets | src/utils/DeprecationWarning.js | deprecateConstant | function deprecateConstant(obj, oldId, newId) {
var warning = "Use Menus." + newId + " instead of Menus." + oldId,
newValue = obj[newId];
Object.defineProperty(obj, oldId, {
get: function () {
deprecationWarning(warning, true);
return newValue;
}
});
} | javascript | function deprecateConstant(obj, oldId, newId) {
var warning = "Use Menus." + newId + " instead of Menus." + oldId,
newValue = obj[newId];
Object.defineProperty(obj, oldId, {
get: function () {
deprecationWarning(warning, true);
return newValue;
}
});
} | [
"function",
"deprecateConstant",
"(",
"obj",
",",
"oldId",
",",
"newId",
")",
"{",
"var",
"warning",
"=",
"\"Use Menus.\"",
"+",
"newId",
"+",
"\" instead of Menus.\"",
"+",
"oldId",
",",
"newValue",
"=",
"obj",
"[",
"newId",
"]",
";",
"Object",
".",
"defineProperty",
"(",
"obj",
",",
"oldId",
",",
"{",
"get",
":",
"function",
"(",
")",
"{",
"deprecationWarning",
"(",
"warning",
",",
"true",
")",
";",
"return",
"newValue",
";",
"}",
"}",
")",
";",
"}"
] | Create a deprecation warning and action for updated constants
@param {!string} old Menu Id
@param {!string} new Menu Id | [
"Create",
"a",
"deprecation",
"warning",
"and",
"action",
"for",
"updated",
"constants"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/DeprecationWarning.js#L132-L142 |
2,345 | adobe/brackets | src/preferences/PreferencesManager.js | setViewState | function setViewState(id, value, context, doNotSave) {
PreferencesImpl.stateManager.set(id, value, context);
if (!doNotSave) {
PreferencesImpl.stateManager.save();
}
} | javascript | function setViewState(id, value, context, doNotSave) {
PreferencesImpl.stateManager.set(id, value, context);
if (!doNotSave) {
PreferencesImpl.stateManager.save();
}
} | [
"function",
"setViewState",
"(",
"id",
",",
"value",
",",
"context",
",",
"doNotSave",
")",
"{",
"PreferencesImpl",
".",
"stateManager",
".",
"set",
"(",
"id",
",",
"value",
",",
"context",
")",
";",
"if",
"(",
"!",
"doNotSave",
")",
"{",
"PreferencesImpl",
".",
"stateManager",
".",
"save",
"(",
")",
";",
"}",
"}"
] | Convenience function that sets a view state and then saves the file
@param {string} id preference to set
@param {*} value new value for the preference
@param {?Object} context Optional additional information about the request
@param {boolean=} doNotSave If it is undefined or false, then save the
view state immediately. | [
"Convenience",
"function",
"that",
"sets",
"a",
"view",
"state",
"and",
"then",
"saves",
"the",
"file"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/preferences/PreferencesManager.js#L307-L314 |
2,346 | adobe/brackets | src/utils/TokenUtils.js | movePrevToken | function movePrevToken(ctx, precise) {
if (precise === undefined) {
precise = true;
}
if (ctx.pos.ch <= 0 || ctx.token.start <= 0) {
//move up a line
if (ctx.pos.line <= 0) {
return false; //at the top already
}
ctx.pos.line--;
ctx.pos.ch = ctx.editor.getLine(ctx.pos.line).length;
} else {
ctx.pos.ch = ctx.token.start;
}
ctx.token = getTokenAt(ctx.editor, ctx.pos, precise);
return true;
} | javascript | function movePrevToken(ctx, precise) {
if (precise === undefined) {
precise = true;
}
if (ctx.pos.ch <= 0 || ctx.token.start <= 0) {
//move up a line
if (ctx.pos.line <= 0) {
return false; //at the top already
}
ctx.pos.line--;
ctx.pos.ch = ctx.editor.getLine(ctx.pos.line).length;
} else {
ctx.pos.ch = ctx.token.start;
}
ctx.token = getTokenAt(ctx.editor, ctx.pos, precise);
return true;
} | [
"function",
"movePrevToken",
"(",
"ctx",
",",
"precise",
")",
"{",
"if",
"(",
"precise",
"===",
"undefined",
")",
"{",
"precise",
"=",
"true",
";",
"}",
"if",
"(",
"ctx",
".",
"pos",
".",
"ch",
"<=",
"0",
"||",
"ctx",
".",
"token",
".",
"start",
"<=",
"0",
")",
"{",
"//move up a line",
"if",
"(",
"ctx",
".",
"pos",
".",
"line",
"<=",
"0",
")",
"{",
"return",
"false",
";",
"//at the top already",
"}",
"ctx",
".",
"pos",
".",
"line",
"--",
";",
"ctx",
".",
"pos",
".",
"ch",
"=",
"ctx",
".",
"editor",
".",
"getLine",
"(",
"ctx",
".",
"pos",
".",
"line",
")",
".",
"length",
";",
"}",
"else",
"{",
"ctx",
".",
"pos",
".",
"ch",
"=",
"ctx",
".",
"token",
".",
"start",
";",
"}",
"ctx",
".",
"token",
"=",
"getTokenAt",
"(",
"ctx",
".",
"editor",
",",
"ctx",
".",
"pos",
",",
"precise",
")",
";",
"return",
"true",
";",
"}"
] | Moves the given context backwards by one token.
@param {!{editor:!CodeMirror, pos:!{ch:number, line:number}, token:Object}} ctx
@param {boolean=} precise If code is being edited, use true (default) for accuracy.
If parsing unchanging code, use false to use cache for performance.
@return {boolean} whether the context changed | [
"Moves",
"the",
"given",
"context",
"backwards",
"by",
"one",
"token",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/TokenUtils.js#L109-L126 |
2,347 | adobe/brackets | src/utils/TokenUtils.js | moveNextToken | function moveNextToken(ctx, precise) {
var eol = ctx.editor.getLine(ctx.pos.line).length;
if (precise === undefined) {
precise = true;
}
if (ctx.pos.ch >= eol || ctx.token.end >= eol) {
//move down a line
if (ctx.pos.line >= ctx.editor.lineCount() - 1) {
return false; //at the bottom
}
ctx.pos.line++;
ctx.pos.ch = 0;
} else {
ctx.pos.ch = ctx.token.end + 1;
}
ctx.token = getTokenAt(ctx.editor, ctx.pos, precise);
return true;
} | javascript | function moveNextToken(ctx, precise) {
var eol = ctx.editor.getLine(ctx.pos.line).length;
if (precise === undefined) {
precise = true;
}
if (ctx.pos.ch >= eol || ctx.token.end >= eol) {
//move down a line
if (ctx.pos.line >= ctx.editor.lineCount() - 1) {
return false; //at the bottom
}
ctx.pos.line++;
ctx.pos.ch = 0;
} else {
ctx.pos.ch = ctx.token.end + 1;
}
ctx.token = getTokenAt(ctx.editor, ctx.pos, precise);
return true;
} | [
"function",
"moveNextToken",
"(",
"ctx",
",",
"precise",
")",
"{",
"var",
"eol",
"=",
"ctx",
".",
"editor",
".",
"getLine",
"(",
"ctx",
".",
"pos",
".",
"line",
")",
".",
"length",
";",
"if",
"(",
"precise",
"===",
"undefined",
")",
"{",
"precise",
"=",
"true",
";",
"}",
"if",
"(",
"ctx",
".",
"pos",
".",
"ch",
">=",
"eol",
"||",
"ctx",
".",
"token",
".",
"end",
">=",
"eol",
")",
"{",
"//move down a line",
"if",
"(",
"ctx",
".",
"pos",
".",
"line",
">=",
"ctx",
".",
"editor",
".",
"lineCount",
"(",
")",
"-",
"1",
")",
"{",
"return",
"false",
";",
"//at the bottom",
"}",
"ctx",
".",
"pos",
".",
"line",
"++",
";",
"ctx",
".",
"pos",
".",
"ch",
"=",
"0",
";",
"}",
"else",
"{",
"ctx",
".",
"pos",
".",
"ch",
"=",
"ctx",
".",
"token",
".",
"end",
"+",
"1",
";",
"}",
"ctx",
".",
"token",
"=",
"getTokenAt",
"(",
"ctx",
".",
"editor",
",",
"ctx",
".",
"pos",
",",
"precise",
")",
";",
"return",
"true",
";",
"}"
] | Moves the given context forward by one token.
@param {!{editor:!CodeMirror, pos:!{ch:number, line:number}, token:Object}} ctx
@param {boolean=} precise If code is being edited, use true (default) for accuracy.
If parsing unchanging code, use false to use cache for performance.
@return {boolean} whether the context changed | [
"Moves",
"the",
"given",
"context",
"forward",
"by",
"one",
"token",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/TokenUtils.js#L143-L161 |
2,348 | adobe/brackets | src/utils/TokenUtils.js | moveSkippingWhitespace | function moveSkippingWhitespace(moveFxn, ctx) {
if (!moveFxn(ctx)) {
return false;
}
while (!ctx.token.type && !/\S/.test(ctx.token.string)) {
if (!moveFxn(ctx)) {
return false;
}
}
return true;
} | javascript | function moveSkippingWhitespace(moveFxn, ctx) {
if (!moveFxn(ctx)) {
return false;
}
while (!ctx.token.type && !/\S/.test(ctx.token.string)) {
if (!moveFxn(ctx)) {
return false;
}
}
return true;
} | [
"function",
"moveSkippingWhitespace",
"(",
"moveFxn",
",",
"ctx",
")",
"{",
"if",
"(",
"!",
"moveFxn",
"(",
"ctx",
")",
")",
"{",
"return",
"false",
";",
"}",
"while",
"(",
"!",
"ctx",
".",
"token",
".",
"type",
"&&",
"!",
"/",
"\\S",
"/",
".",
"test",
"(",
"ctx",
".",
"token",
".",
"string",
")",
")",
"{",
"if",
"(",
"!",
"moveFxn",
"(",
"ctx",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Moves the given context in the given direction, skipping any whitespace it hits.
@param {function} moveFxn the function to move the context
@param {!{editor:!CodeMirror, pos:!{ch:number, line:number}, token:Object}} ctx
@return {boolean} whether the context changed | [
"Moves",
"the",
"given",
"context",
"in",
"the",
"given",
"direction",
"skipping",
"any",
"whitespace",
"it",
"hits",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/TokenUtils.js#L178-L188 |
2,349 | adobe/brackets | src/utils/TokenUtils.js | offsetInToken | function offsetInToken(ctx) {
var offset = ctx.pos.ch - ctx.token.start;
if (offset < 0) {
console.log("CodeHintUtils: _offsetInToken - Invalid context: pos not in the current token!");
}
return offset;
} | javascript | function offsetInToken(ctx) {
var offset = ctx.pos.ch - ctx.token.start;
if (offset < 0) {
console.log("CodeHintUtils: _offsetInToken - Invalid context: pos not in the current token!");
}
return offset;
} | [
"function",
"offsetInToken",
"(",
"ctx",
")",
"{",
"var",
"offset",
"=",
"ctx",
".",
"pos",
".",
"ch",
"-",
"ctx",
".",
"token",
".",
"start",
";",
"if",
"(",
"offset",
"<",
"0",
")",
"{",
"console",
".",
"log",
"(",
"\"CodeHintUtils: _offsetInToken - Invalid context: pos not in the current token!\"",
")",
";",
"}",
"return",
"offset",
";",
"}"
] | In the given context, get the character offset of pos from the start of the token.
@param {!{editor:!CodeMirror, pos:!{ch:number, line:number}, token:Object}} context
@return {number} | [
"In",
"the",
"given",
"context",
"get",
"the",
"character",
"offset",
"of",
"pos",
"from",
"the",
"start",
"of",
"the",
"token",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/TokenUtils.js#L195-L201 |
2,350 | adobe/brackets | src/utils/TokenUtils.js | getModeAt | function getModeAt(cm, pos, precise) {
precise = precise || true;
var modeData = cm.getMode(),
name;
if (modeData.innerMode) {
modeData = CodeMirror.innerMode(modeData, getTokenAt(cm, pos, precise).state).mode;
}
name = (modeData.name === "xml") ?
modeData.configuration : modeData.name;
return {mode: modeData, name: name};
} | javascript | function getModeAt(cm, pos, precise) {
precise = precise || true;
var modeData = cm.getMode(),
name;
if (modeData.innerMode) {
modeData = CodeMirror.innerMode(modeData, getTokenAt(cm, pos, precise).state).mode;
}
name = (modeData.name === "xml") ?
modeData.configuration : modeData.name;
return {mode: modeData, name: name};
} | [
"function",
"getModeAt",
"(",
"cm",
",",
"pos",
",",
"precise",
")",
"{",
"precise",
"=",
"precise",
"||",
"true",
";",
"var",
"modeData",
"=",
"cm",
".",
"getMode",
"(",
")",
",",
"name",
";",
"if",
"(",
"modeData",
".",
"innerMode",
")",
"{",
"modeData",
"=",
"CodeMirror",
".",
"innerMode",
"(",
"modeData",
",",
"getTokenAt",
"(",
"cm",
",",
"pos",
",",
"precise",
")",
".",
"state",
")",
".",
"mode",
";",
"}",
"name",
"=",
"(",
"modeData",
".",
"name",
"===",
"\"xml\"",
")",
"?",
"modeData",
".",
"configuration",
":",
"modeData",
".",
"name",
";",
"return",
"{",
"mode",
":",
"modeData",
",",
"name",
":",
"name",
"}",
";",
"}"
] | Returns the mode object and mode name string at a given position
@param {!CodeMirror} cm CodeMirror instance
@param {!{line:number, ch:number}} pos Position to query for mode
@param {boolean} precise If given, results in more current results. Suppresses caching.
@return {mode:{Object}, name:string} | [
"Returns",
"the",
"mode",
"object",
"and",
"mode",
"name",
"string",
"at",
"a",
"given",
"position"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/TokenUtils.js#L210-L223 |
2,351 | adobe/brackets | src/LiveDevelopment/Agents/HighlightAgent.js | node | function node(n) {
if (!LiveDevelopment.config.experimental) {
return;
}
if (!Inspector.config.highlight) {
return;
}
// go to the parent of a text node
if (n && n.type === 3) {
n = n.parent;
}
// node cannot be highlighted
if (!n || !n.nodeId || n.type !== 1) {
return hide();
}
// node is already highlighted
if (_highlight.type === "node" && _highlight.ref === n.nodeId) {
return;
}
// highlight the node
_highlight = {type: "node", ref: n.nodeId};
Inspector.DOM.highlightNode(n.nodeId, Inspector.config.highlightConfig);
} | javascript | function node(n) {
if (!LiveDevelopment.config.experimental) {
return;
}
if (!Inspector.config.highlight) {
return;
}
// go to the parent of a text node
if (n && n.type === 3) {
n = n.parent;
}
// node cannot be highlighted
if (!n || !n.nodeId || n.type !== 1) {
return hide();
}
// node is already highlighted
if (_highlight.type === "node" && _highlight.ref === n.nodeId) {
return;
}
// highlight the node
_highlight = {type: "node", ref: n.nodeId};
Inspector.DOM.highlightNode(n.nodeId, Inspector.config.highlightConfig);
} | [
"function",
"node",
"(",
"n",
")",
"{",
"if",
"(",
"!",
"LiveDevelopment",
".",
"config",
".",
"experimental",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"Inspector",
".",
"config",
".",
"highlight",
")",
"{",
"return",
";",
"}",
"// go to the parent of a text node",
"if",
"(",
"n",
"&&",
"n",
".",
"type",
"===",
"3",
")",
"{",
"n",
"=",
"n",
".",
"parent",
";",
"}",
"// node cannot be highlighted",
"if",
"(",
"!",
"n",
"||",
"!",
"n",
".",
"nodeId",
"||",
"n",
".",
"type",
"!==",
"1",
")",
"{",
"return",
"hide",
"(",
")",
";",
"}",
"// node is already highlighted",
"if",
"(",
"_highlight",
".",
"type",
"===",
"\"node\"",
"&&",
"_highlight",
".",
"ref",
"===",
"n",
".",
"nodeId",
")",
"{",
"return",
";",
"}",
"// highlight the node",
"_highlight",
"=",
"{",
"type",
":",
"\"node\"",
",",
"ref",
":",
"n",
".",
"nodeId",
"}",
";",
"Inspector",
".",
"DOM",
".",
"highlightNode",
"(",
"n",
".",
"nodeId",
",",
"Inspector",
".",
"config",
".",
"highlightConfig",
")",
";",
"}"
] | Highlight a single node using DOM.highlightNode
@param {DOMNode} node | [
"Highlight",
"a",
"single",
"node",
"using",
"DOM",
".",
"highlightNode"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/HighlightAgent.js#L67-L94 |
2,352 | adobe/brackets | src/LiveDevelopment/Agents/HighlightAgent.js | rule | function rule(name) {
if (_highlight.ref === name) {
return;
}
hide();
_highlight = {type: "css", ref: name};
RemoteAgent.call("highlightRule", name);
} | javascript | function rule(name) {
if (_highlight.ref === name) {
return;
}
hide();
_highlight = {type: "css", ref: name};
RemoteAgent.call("highlightRule", name);
} | [
"function",
"rule",
"(",
"name",
")",
"{",
"if",
"(",
"_highlight",
".",
"ref",
"===",
"name",
")",
"{",
"return",
";",
"}",
"hide",
"(",
")",
";",
"_highlight",
"=",
"{",
"type",
":",
"\"css\"",
",",
"ref",
":",
"name",
"}",
";",
"RemoteAgent",
".",
"call",
"(",
"\"highlightRule\"",
",",
"name",
")",
";",
"}"
] | Highlight all nodes affected by a CSS rule
@param {string} rule selector | [
"Highlight",
"all",
"nodes",
"affected",
"by",
"a",
"CSS",
"rule"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/HighlightAgent.js#L99-L106 |
2,353 | adobe/brackets | src/LiveDevelopment/Agents/HighlightAgent.js | domElement | function domElement(ids) {
var selector = "";
if (!Array.isArray(ids)) {
ids = [ids];
}
_.each(ids, function (id) {
if (selector !== "") {
selector += ",";
}
selector += "[data-brackets-id='" + id + "']";
});
rule(selector);
} | javascript | function domElement(ids) {
var selector = "";
if (!Array.isArray(ids)) {
ids = [ids];
}
_.each(ids, function (id) {
if (selector !== "") {
selector += ",";
}
selector += "[data-brackets-id='" + id + "']";
});
rule(selector);
} | [
"function",
"domElement",
"(",
"ids",
")",
"{",
"var",
"selector",
"=",
"\"\"",
";",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"ids",
")",
")",
"{",
"ids",
"=",
"[",
"ids",
"]",
";",
"}",
"_",
".",
"each",
"(",
"ids",
",",
"function",
"(",
"id",
")",
"{",
"if",
"(",
"selector",
"!==",
"\"\"",
")",
"{",
"selector",
"+=",
"\",\"",
";",
"}",
"selector",
"+=",
"\"[data-brackets-id='\"",
"+",
"id",
"+",
"\"']\"",
";",
"}",
")",
";",
"rule",
"(",
"selector",
")",
";",
"}"
] | Highlight all nodes with 'data-brackets-id' value
that matches id, or if id is an array, matches any of the given ids.
@param {string|Array<string>} value of the 'data-brackets-id' to match,
or an array of such. | [
"Highlight",
"all",
"nodes",
"with",
"data",
"-",
"brackets",
"-",
"id",
"value",
"that",
"matches",
"id",
"or",
"if",
"id",
"is",
"an",
"array",
"matches",
"any",
"of",
"the",
"given",
"ids",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/HighlightAgent.js#L113-L125 |
2,354 | adobe/brackets | src/project/FileViewController.js | openAndSelectDocument | function openAndSelectDocument(fullPath, fileSelectionFocus, paneId) {
var result,
curDocChangedDueToMe = _curDocChangedDueToMe;
function _getDerivedPaneContext() {
function _secondPaneContext() {
return (window.event.ctrlKey || window.event.metaKey) && window.event.altKey ? MainViewManager.SECOND_PANE : null;
}
function _firstPaneContext() {
return (window.event.ctrlKey || window.event.metaKey) ? MainViewManager.FIRST_PANE : null;
}
return window.event && (_secondPaneContext() || _firstPaneContext());
}
if (fileSelectionFocus !== PROJECT_MANAGER && fileSelectionFocus !== WORKING_SET_VIEW) {
console.error("Bad parameter passed to FileViewController.openAndSelectDocument");
return;
}
// Opening files are asynchronous and we want to know when this function caused a file
// to open so that _fileSelectionFocus is set appropriatly. _curDocChangedDueToMe is set here
// and checked in the currentFileChange handler
_curDocChangedDueToMe = true;
_fileSelectionFocus = fileSelectionFocus;
paneId = (paneId || _getDerivedPaneContext() || MainViewManager.ACTIVE_PANE);
// If fullPath corresonds to the current doc being viewed then opening the file won't
// trigger a currentFileChange event, so we need to trigger a documentSelectionFocusChange
// in this case to signify the selection focus has changed even though the current document has not.
var currentPath = MainViewManager.getCurrentlyViewedPath(paneId);
if (currentPath === fullPath) {
_activatePane(paneId);
result = (new $.Deferred()).resolve().promise();
} else {
result = CommandManager.execute(Commands.FILE_OPEN, {fullPath: fullPath,
paneId: paneId});
}
// clear after notification is done
result.always(function () {
_curDocChangedDueToMe = curDocChangedDueToMe;
});
return result;
} | javascript | function openAndSelectDocument(fullPath, fileSelectionFocus, paneId) {
var result,
curDocChangedDueToMe = _curDocChangedDueToMe;
function _getDerivedPaneContext() {
function _secondPaneContext() {
return (window.event.ctrlKey || window.event.metaKey) && window.event.altKey ? MainViewManager.SECOND_PANE : null;
}
function _firstPaneContext() {
return (window.event.ctrlKey || window.event.metaKey) ? MainViewManager.FIRST_PANE : null;
}
return window.event && (_secondPaneContext() || _firstPaneContext());
}
if (fileSelectionFocus !== PROJECT_MANAGER && fileSelectionFocus !== WORKING_SET_VIEW) {
console.error("Bad parameter passed to FileViewController.openAndSelectDocument");
return;
}
// Opening files are asynchronous and we want to know when this function caused a file
// to open so that _fileSelectionFocus is set appropriatly. _curDocChangedDueToMe is set here
// and checked in the currentFileChange handler
_curDocChangedDueToMe = true;
_fileSelectionFocus = fileSelectionFocus;
paneId = (paneId || _getDerivedPaneContext() || MainViewManager.ACTIVE_PANE);
// If fullPath corresonds to the current doc being viewed then opening the file won't
// trigger a currentFileChange event, so we need to trigger a documentSelectionFocusChange
// in this case to signify the selection focus has changed even though the current document has not.
var currentPath = MainViewManager.getCurrentlyViewedPath(paneId);
if (currentPath === fullPath) {
_activatePane(paneId);
result = (new $.Deferred()).resolve().promise();
} else {
result = CommandManager.execute(Commands.FILE_OPEN, {fullPath: fullPath,
paneId: paneId});
}
// clear after notification is done
result.always(function () {
_curDocChangedDueToMe = curDocChangedDueToMe;
});
return result;
} | [
"function",
"openAndSelectDocument",
"(",
"fullPath",
",",
"fileSelectionFocus",
",",
"paneId",
")",
"{",
"var",
"result",
",",
"curDocChangedDueToMe",
"=",
"_curDocChangedDueToMe",
";",
"function",
"_getDerivedPaneContext",
"(",
")",
"{",
"function",
"_secondPaneContext",
"(",
")",
"{",
"return",
"(",
"window",
".",
"event",
".",
"ctrlKey",
"||",
"window",
".",
"event",
".",
"metaKey",
")",
"&&",
"window",
".",
"event",
".",
"altKey",
"?",
"MainViewManager",
".",
"SECOND_PANE",
":",
"null",
";",
"}",
"function",
"_firstPaneContext",
"(",
")",
"{",
"return",
"(",
"window",
".",
"event",
".",
"ctrlKey",
"||",
"window",
".",
"event",
".",
"metaKey",
")",
"?",
"MainViewManager",
".",
"FIRST_PANE",
":",
"null",
";",
"}",
"return",
"window",
".",
"event",
"&&",
"(",
"_secondPaneContext",
"(",
")",
"||",
"_firstPaneContext",
"(",
")",
")",
";",
"}",
"if",
"(",
"fileSelectionFocus",
"!==",
"PROJECT_MANAGER",
"&&",
"fileSelectionFocus",
"!==",
"WORKING_SET_VIEW",
")",
"{",
"console",
".",
"error",
"(",
"\"Bad parameter passed to FileViewController.openAndSelectDocument\"",
")",
";",
"return",
";",
"}",
"// Opening files are asynchronous and we want to know when this function caused a file",
"// to open so that _fileSelectionFocus is set appropriatly. _curDocChangedDueToMe is set here",
"// and checked in the currentFileChange handler",
"_curDocChangedDueToMe",
"=",
"true",
";",
"_fileSelectionFocus",
"=",
"fileSelectionFocus",
";",
"paneId",
"=",
"(",
"paneId",
"||",
"_getDerivedPaneContext",
"(",
")",
"||",
"MainViewManager",
".",
"ACTIVE_PANE",
")",
";",
"// If fullPath corresonds to the current doc being viewed then opening the file won't",
"// trigger a currentFileChange event, so we need to trigger a documentSelectionFocusChange",
"// in this case to signify the selection focus has changed even though the current document has not.",
"var",
"currentPath",
"=",
"MainViewManager",
".",
"getCurrentlyViewedPath",
"(",
"paneId",
")",
";",
"if",
"(",
"currentPath",
"===",
"fullPath",
")",
"{",
"_activatePane",
"(",
"paneId",
")",
";",
"result",
"=",
"(",
"new",
"$",
".",
"Deferred",
"(",
")",
")",
".",
"resolve",
"(",
")",
".",
"promise",
"(",
")",
";",
"}",
"else",
"{",
"result",
"=",
"CommandManager",
".",
"execute",
"(",
"Commands",
".",
"FILE_OPEN",
",",
"{",
"fullPath",
":",
"fullPath",
",",
"paneId",
":",
"paneId",
"}",
")",
";",
"}",
"// clear after notification is done",
"result",
".",
"always",
"(",
"function",
"(",
")",
"{",
"_curDocChangedDueToMe",
"=",
"curDocChangedDueToMe",
";",
"}",
")",
";",
"return",
"result",
";",
"}"
] | Opens a document if it's not open and selects the file in the UI corresponding to
fileSelectionFocus
@param {!fullPath} fullPath - full path of the document to open
@param {string} fileSelectionFocus - (WORKING_SET_VIEW || PROJECT_MANAGER)
@param {string} paneId - pane in which to open the document
@return {$.Promise} | [
"Opens",
"a",
"document",
"if",
"it",
"s",
"not",
"open",
"and",
"selects",
"the",
"file",
"in",
"the",
"UI",
"corresponding",
"to",
"fileSelectionFocus"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileViewController.js#L145-L195 |
2,355 | adobe/brackets | src/extensions/default/AutoUpdate/UpdateInfoBar.js | generateJsonForMustache | function generateJsonForMustache(msgObj) {
var msgJsonObj = {};
if (msgObj.type) {
msgJsonObj.type = "'" + msgObj.type + "'";
}
msgJsonObj.title = msgObj.title;
msgJsonObj.description = msgObj.description;
if (msgObj.needButtons) {
msgJsonObj.buttons = [{
"id": "restart",
"value": Strings.RESTART_BUTTON,
"tIndex": "'0'"
}, {
"id": "later",
"value": Strings.LATER_BUTTON,
"tIndex": "'0'"
}];
msgJsonObj.needButtons = msgObj.needButtons;
}
return msgJsonObj;
} | javascript | function generateJsonForMustache(msgObj) {
var msgJsonObj = {};
if (msgObj.type) {
msgJsonObj.type = "'" + msgObj.type + "'";
}
msgJsonObj.title = msgObj.title;
msgJsonObj.description = msgObj.description;
if (msgObj.needButtons) {
msgJsonObj.buttons = [{
"id": "restart",
"value": Strings.RESTART_BUTTON,
"tIndex": "'0'"
}, {
"id": "later",
"value": Strings.LATER_BUTTON,
"tIndex": "'0'"
}];
msgJsonObj.needButtons = msgObj.needButtons;
}
return msgJsonObj;
} | [
"function",
"generateJsonForMustache",
"(",
"msgObj",
")",
"{",
"var",
"msgJsonObj",
"=",
"{",
"}",
";",
"if",
"(",
"msgObj",
".",
"type",
")",
"{",
"msgJsonObj",
".",
"type",
"=",
"\"'\"",
"+",
"msgObj",
".",
"type",
"+",
"\"'\"",
";",
"}",
"msgJsonObj",
".",
"title",
"=",
"msgObj",
".",
"title",
";",
"msgJsonObj",
".",
"description",
"=",
"msgObj",
".",
"description",
";",
"if",
"(",
"msgObj",
".",
"needButtons",
")",
"{",
"msgJsonObj",
".",
"buttons",
"=",
"[",
"{",
"\"id\"",
":",
"\"restart\"",
",",
"\"value\"",
":",
"Strings",
".",
"RESTART_BUTTON",
",",
"\"tIndex\"",
":",
"\"'0'\"",
"}",
",",
"{",
"\"id\"",
":",
"\"later\"",
",",
"\"value\"",
":",
"Strings",
".",
"LATER_BUTTON",
",",
"\"tIndex\"",
":",
"\"'0'\"",
"}",
"]",
";",
"msgJsonObj",
".",
"needButtons",
"=",
"msgObj",
".",
"needButtons",
";",
"}",
"return",
"msgJsonObj",
";",
"}"
] | keycode for escape key
Generates the json to be used by Mustache for rendering
@param {object} msgObj - json object containing message information to be displayed
@returns {object} - the generated json object | [
"keycode",
"for",
"escape",
"key",
"Generates",
"the",
"json",
"to",
"be",
"used",
"by",
"Mustache",
"for",
"rendering"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/UpdateInfoBar.js#L53-L73 |
2,356 | adobe/brackets | src/extensions/default/AutoUpdate/UpdateInfoBar.js | function () {
if($updateContent.length > 0 && $contentContainer.length > 0 && $updateBar.length > 0) {
var newWidth = $updateBar.outerWidth() - 38;
if($buttonContainer.length > 0) {
newWidth = newWidth- $buttonContainer.outerWidth();
}
if($iconContainer.length > 0) {
newWidth = newWidth - $iconContainer.outerWidth();
}
if($closeIconContainer.length > 0) {
newWidth = newWidth - $closeIconContainer.outerWidth();
}
$contentContainer.css({
"maxWidth": newWidth
});
}
} | javascript | function () {
if($updateContent.length > 0 && $contentContainer.length > 0 && $updateBar.length > 0) {
var newWidth = $updateBar.outerWidth() - 38;
if($buttonContainer.length > 0) {
newWidth = newWidth- $buttonContainer.outerWidth();
}
if($iconContainer.length > 0) {
newWidth = newWidth - $iconContainer.outerWidth();
}
if($closeIconContainer.length > 0) {
newWidth = newWidth - $closeIconContainer.outerWidth();
}
$contentContainer.css({
"maxWidth": newWidth
});
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"$updateContent",
".",
"length",
">",
"0",
"&&",
"$contentContainer",
".",
"length",
">",
"0",
"&&",
"$updateBar",
".",
"length",
">",
"0",
")",
"{",
"var",
"newWidth",
"=",
"$updateBar",
".",
"outerWidth",
"(",
")",
"-",
"38",
";",
"if",
"(",
"$buttonContainer",
".",
"length",
">",
"0",
")",
"{",
"newWidth",
"=",
"newWidth",
"-",
"$buttonContainer",
".",
"outerWidth",
"(",
")",
";",
"}",
"if",
"(",
"$iconContainer",
".",
"length",
">",
"0",
")",
"{",
"newWidth",
"=",
"newWidth",
"-",
"$iconContainer",
".",
"outerWidth",
"(",
")",
";",
"}",
"if",
"(",
"$closeIconContainer",
".",
"length",
">",
"0",
")",
"{",
"newWidth",
"=",
"newWidth",
"-",
"$closeIconContainer",
".",
"outerWidth",
"(",
")",
";",
"}",
"$contentContainer",
".",
"css",
"(",
"{",
"\"maxWidth\"",
":",
"newWidth",
"}",
")",
";",
"}",
"}"
] | Content Container Width between Icon Container and Button Container or Close Icon Container will be assigned when window will be rezied. | [
"Content",
"Container",
"Width",
"between",
"Icon",
"Container",
"and",
"Button",
"Container",
"or",
"Close",
"Icon",
"Container",
"will",
"be",
"assigned",
"when",
"window",
"will",
"be",
"rezied",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/UpdateInfoBar.js#L123-L140 |
|
2,357 | adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/remote/DocumentObserver.js | function (href) {
var self = this;
// Inspect CSSRules for @imports:
// styleSheet obejct is required to scan CSSImportRules but
// browsers differ on the implementation of MutationObserver interface.
// Webkit triggers notifications before stylesheets are loaded,
// Firefox does it after loading.
// There are also differences on when 'load' event is triggered for
// the 'link' nodes. Webkit triggers it before stylesheet is loaded.
// Some references to check:
// http://www.phpied.com/when-is-a-stylesheet-really-loaded/
// http://stackoverflow.com/questions/17747616/webkit-dynamically-created-stylesheet-when-does-it-really-load
// http://stackoverflow.com/questions/11425209/are-dom-mutation-observers-slower-than-dom-mutation-events
//
// TODO: This is just a temporary 'cross-browser' solution, it needs optimization.
var loadInterval = setInterval(function () {
var i;
for (i = 0; i < window.document.styleSheets.length; i++) {
if (window.document.styleSheets[i].href === href) {
//clear interval
clearInterval(loadInterval);
// notify stylesheets added
self.notifyStylesheetAdded(href);
break;
}
}
}, 50);
} | javascript | function (href) {
var self = this;
// Inspect CSSRules for @imports:
// styleSheet obejct is required to scan CSSImportRules but
// browsers differ on the implementation of MutationObserver interface.
// Webkit triggers notifications before stylesheets are loaded,
// Firefox does it after loading.
// There are also differences on when 'load' event is triggered for
// the 'link' nodes. Webkit triggers it before stylesheet is loaded.
// Some references to check:
// http://www.phpied.com/when-is-a-stylesheet-really-loaded/
// http://stackoverflow.com/questions/17747616/webkit-dynamically-created-stylesheet-when-does-it-really-load
// http://stackoverflow.com/questions/11425209/are-dom-mutation-observers-slower-than-dom-mutation-events
//
// TODO: This is just a temporary 'cross-browser' solution, it needs optimization.
var loadInterval = setInterval(function () {
var i;
for (i = 0; i < window.document.styleSheets.length; i++) {
if (window.document.styleSheets[i].href === href) {
//clear interval
clearInterval(loadInterval);
// notify stylesheets added
self.notifyStylesheetAdded(href);
break;
}
}
}, 50);
} | [
"function",
"(",
"href",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// Inspect CSSRules for @imports:",
"// styleSheet obejct is required to scan CSSImportRules but",
"// browsers differ on the implementation of MutationObserver interface.",
"// Webkit triggers notifications before stylesheets are loaded,",
"// Firefox does it after loading.",
"// There are also differences on when 'load' event is triggered for",
"// the 'link' nodes. Webkit triggers it before stylesheet is loaded.",
"// Some references to check:",
"// http://www.phpied.com/when-is-a-stylesheet-really-loaded/",
"// http://stackoverflow.com/questions/17747616/webkit-dynamically-created-stylesheet-when-does-it-really-load",
"// http://stackoverflow.com/questions/11425209/are-dom-mutation-observers-slower-than-dom-mutation-events",
"//",
"// TODO: This is just a temporary 'cross-browser' solution, it needs optimization.",
"var",
"loadInterval",
"=",
"setInterval",
"(",
"function",
"(",
")",
"{",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"window",
".",
"document",
".",
"styleSheets",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"window",
".",
"document",
".",
"styleSheets",
"[",
"i",
"]",
".",
"href",
"===",
"href",
")",
"{",
"//clear interval",
"clearInterval",
"(",
"loadInterval",
")",
";",
"// notify stylesheets added",
"self",
".",
"notifyStylesheetAdded",
"(",
"href",
")",
";",
"break",
";",
"}",
"}",
"}",
",",
"50",
")",
";",
"}"
] | Check the stylesheet that was just added be really loaded
to be able to extract potential import-ed stylesheets.
It invokes notifyStylesheetAdded once the sheet is loaded.
@param {string} href Absolute URL of the stylesheet. | [
"Check",
"the",
"stylesheet",
"that",
"was",
"just",
"added",
"be",
"really",
"loaded",
"to",
"be",
"able",
"to",
"extract",
"potential",
"import",
"-",
"ed",
"stylesheets",
".",
"It",
"invokes",
"notifyStylesheetAdded",
"once",
"the",
"sheet",
"is",
"loaded",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/remote/DocumentObserver.js#L124-L153 |
|
2,358 | adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/remote/DocumentObserver.js | function () {
var added = {},
current,
newStatus;
current = this.stylesheets;
newStatus = related().stylesheets;
Object.keys(newStatus).forEach(function (v, i) {
if (!current[v]) {
added[v] = newStatus[v];
}
});
Object.keys(added).forEach(function (v, i) {
_transport.send(JSON.stringify({
method: "StylesheetAdded",
href: v,
roots: [added[v]]
}));
});
this.stylesheets = newStatus;
} | javascript | function () {
var added = {},
current,
newStatus;
current = this.stylesheets;
newStatus = related().stylesheets;
Object.keys(newStatus).forEach(function (v, i) {
if (!current[v]) {
added[v] = newStatus[v];
}
});
Object.keys(added).forEach(function (v, i) {
_transport.send(JSON.stringify({
method: "StylesheetAdded",
href: v,
roots: [added[v]]
}));
});
this.stylesheets = newStatus;
} | [
"function",
"(",
")",
"{",
"var",
"added",
"=",
"{",
"}",
",",
"current",
",",
"newStatus",
";",
"current",
"=",
"this",
".",
"stylesheets",
";",
"newStatus",
"=",
"related",
"(",
")",
".",
"stylesheets",
";",
"Object",
".",
"keys",
"(",
"newStatus",
")",
".",
"forEach",
"(",
"function",
"(",
"v",
",",
"i",
")",
"{",
"if",
"(",
"!",
"current",
"[",
"v",
"]",
")",
"{",
"added",
"[",
"v",
"]",
"=",
"newStatus",
"[",
"v",
"]",
";",
"}",
"}",
")",
";",
"Object",
".",
"keys",
"(",
"added",
")",
".",
"forEach",
"(",
"function",
"(",
"v",
",",
"i",
")",
"{",
"_transport",
".",
"send",
"(",
"JSON",
".",
"stringify",
"(",
"{",
"method",
":",
"\"StylesheetAdded\"",
",",
"href",
":",
"v",
",",
"roots",
":",
"[",
"added",
"[",
"v",
"]",
"]",
"}",
")",
")",
";",
"}",
")",
";",
"this",
".",
"stylesheets",
"=",
"newStatus",
";",
"}"
] | Send a notification for the stylesheet added and
its import-ed styleshets based on document.stylesheets diff
from previous status. It also updates stylesheets status. | [
"Send",
"a",
"notification",
"for",
"the",
"stylesheet",
"added",
"and",
"its",
"import",
"-",
"ed",
"styleshets",
"based",
"on",
"document",
".",
"stylesheets",
"diff",
"from",
"previous",
"status",
".",
"It",
"also",
"updates",
"stylesheets",
"status",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/remote/DocumentObserver.js#L169-L192 |
|
2,359 | adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/remote/DocumentObserver.js | function () {
var self = this;
var removed = {},
newStatus,
current;
current = self.stylesheets;
newStatus = related().stylesheets;
Object.keys(current).forEach(function (v, i) {
if (!newStatus[v]) {
removed[v] = current[v];
// remove node created by setStylesheetText if any
self.onStylesheetRemoved(current[v]);
}
});
Object.keys(removed).forEach(function (v, i) {
_transport.send(JSON.stringify({
method: "StylesheetRemoved",
href: v,
roots: [removed[v]]
}));
});
self.stylesheets = newStatus;
} | javascript | function () {
var self = this;
var removed = {},
newStatus,
current;
current = self.stylesheets;
newStatus = related().stylesheets;
Object.keys(current).forEach(function (v, i) {
if (!newStatus[v]) {
removed[v] = current[v];
// remove node created by setStylesheetText if any
self.onStylesheetRemoved(current[v]);
}
});
Object.keys(removed).forEach(function (v, i) {
_transport.send(JSON.stringify({
method: "StylesheetRemoved",
href: v,
roots: [removed[v]]
}));
});
self.stylesheets = newStatus;
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"removed",
"=",
"{",
"}",
",",
"newStatus",
",",
"current",
";",
"current",
"=",
"self",
".",
"stylesheets",
";",
"newStatus",
"=",
"related",
"(",
")",
".",
"stylesheets",
";",
"Object",
".",
"keys",
"(",
"current",
")",
".",
"forEach",
"(",
"function",
"(",
"v",
",",
"i",
")",
"{",
"if",
"(",
"!",
"newStatus",
"[",
"v",
"]",
")",
"{",
"removed",
"[",
"v",
"]",
"=",
"current",
"[",
"v",
"]",
";",
"// remove node created by setStylesheetText if any",
"self",
".",
"onStylesheetRemoved",
"(",
"current",
"[",
"v",
"]",
")",
";",
"}",
"}",
")",
";",
"Object",
".",
"keys",
"(",
"removed",
")",
".",
"forEach",
"(",
"function",
"(",
"v",
",",
"i",
")",
"{",
"_transport",
".",
"send",
"(",
"JSON",
".",
"stringify",
"(",
"{",
"method",
":",
"\"StylesheetRemoved\"",
",",
"href",
":",
"v",
",",
"roots",
":",
"[",
"removed",
"[",
"v",
"]",
"]",
"}",
")",
")",
";",
"}",
")",
";",
"self",
".",
"stylesheets",
"=",
"newStatus",
";",
"}"
] | Send a notification for the removed stylesheet and
its import-ed styleshets based on document.stylesheets diff
from previous status. It also updates stylesheets status. | [
"Send",
"a",
"notification",
"for",
"the",
"removed",
"stylesheet",
"and",
"its",
"import",
"-",
"ed",
"styleshets",
"based",
"on",
"document",
".",
"stylesheets",
"diff",
"from",
"previous",
"status",
".",
"It",
"also",
"updates",
"stylesheets",
"status",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/remote/DocumentObserver.js#L199-L226 |
|
2,360 | adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/remote/DocumentObserver.js | start | function start(document, transport) {
_transport = transport;
_document = document;
// start listening to node changes
_enableListeners();
var rel = related();
// send the current status of related docs.
_transport.send(JSON.stringify({
method: "DocumentRelated",
related: rel
}));
// initialize stylesheets with current status for further notifications.
CSS.stylesheets = rel.stylesheets;
} | javascript | function start(document, transport) {
_transport = transport;
_document = document;
// start listening to node changes
_enableListeners();
var rel = related();
// send the current status of related docs.
_transport.send(JSON.stringify({
method: "DocumentRelated",
related: rel
}));
// initialize stylesheets with current status for further notifications.
CSS.stylesheets = rel.stylesheets;
} | [
"function",
"start",
"(",
"document",
",",
"transport",
")",
"{",
"_transport",
"=",
"transport",
";",
"_document",
"=",
"document",
";",
"// start listening to node changes",
"_enableListeners",
"(",
")",
";",
"var",
"rel",
"=",
"related",
"(",
")",
";",
"// send the current status of related docs.",
"_transport",
".",
"send",
"(",
"JSON",
".",
"stringify",
"(",
"{",
"method",
":",
"\"DocumentRelated\"",
",",
"related",
":",
"rel",
"}",
")",
")",
";",
"// initialize stylesheets with current status for further notifications.",
"CSS",
".",
"stylesheets",
"=",
"rel",
".",
"stylesheets",
";",
"}"
] | Start listening for events and send initial related documents message.
@param {HTMLDocument} document
@param {object} transport Live development transport connection | [
"Start",
"listening",
"for",
"events",
"and",
"send",
"initial",
"related",
"documents",
"message",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/remote/DocumentObserver.js#L303-L318 |
2,361 | adobe/brackets | src/utils/NativeApp.js | openLiveBrowser | function openLiveBrowser(url, enableRemoteDebugging) {
var result = new $.Deferred();
brackets.app.openLiveBrowser(url, !!enableRemoteDebugging, function onRun(err, pid) {
if (!err) {
// Undefined ids never get removed from list, so don't push them on
if (pid !== undefined) {
liveBrowserOpenedPIDs.push(pid);
}
result.resolve(pid);
} else {
result.reject(_browserErrToFileError(err));
}
});
return result.promise();
} | javascript | function openLiveBrowser(url, enableRemoteDebugging) {
var result = new $.Deferred();
brackets.app.openLiveBrowser(url, !!enableRemoteDebugging, function onRun(err, pid) {
if (!err) {
// Undefined ids never get removed from list, so don't push them on
if (pid !== undefined) {
liveBrowserOpenedPIDs.push(pid);
}
result.resolve(pid);
} else {
result.reject(_browserErrToFileError(err));
}
});
return result.promise();
} | [
"function",
"openLiveBrowser",
"(",
"url",
",",
"enableRemoteDebugging",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"brackets",
".",
"app",
".",
"openLiveBrowser",
"(",
"url",
",",
"!",
"!",
"enableRemoteDebugging",
",",
"function",
"onRun",
"(",
"err",
",",
"pid",
")",
"{",
"if",
"(",
"!",
"err",
")",
"{",
"// Undefined ids never get removed from list, so don't push them on",
"if",
"(",
"pid",
"!==",
"undefined",
")",
"{",
"liveBrowserOpenedPIDs",
".",
"push",
"(",
"pid",
")",
";",
"}",
"result",
".",
"resolve",
"(",
"pid",
")",
";",
"}",
"else",
"{",
"result",
".",
"reject",
"(",
"_browserErrToFileError",
"(",
"err",
")",
")",
";",
"}",
"}",
")",
";",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] | openLiveBrowser
Open the given URL in the user's system browser, optionally enabling debugging.
@param {string} url The URL to open.
@param {boolean=} enableRemoteDebugging Whether to turn on remote debugging. Default false.
@return {$.Promise} | [
"openLiveBrowser",
"Open",
"the",
"given",
"URL",
"in",
"the",
"user",
"s",
"system",
"browser",
"optionally",
"enabling",
"debugging",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/NativeApp.js#L51-L67 |
2,362 | adobe/brackets | src/LiveDevelopment/Servers/BaseServer.js | BaseServer | function BaseServer(config) {
this._baseUrl = config.baseUrl;
this._root = config.root; // ProjectManager.getProjectRoot().fullPath
this._pathResolver = config.pathResolver; // ProjectManager.makeProjectRelativeIfPossible(doc.file.fullPath)
this._liveDocuments = {};
} | javascript | function BaseServer(config) {
this._baseUrl = config.baseUrl;
this._root = config.root; // ProjectManager.getProjectRoot().fullPath
this._pathResolver = config.pathResolver; // ProjectManager.makeProjectRelativeIfPossible(doc.file.fullPath)
this._liveDocuments = {};
} | [
"function",
"BaseServer",
"(",
"config",
")",
"{",
"this",
".",
"_baseUrl",
"=",
"config",
".",
"baseUrl",
";",
"this",
".",
"_root",
"=",
"config",
".",
"root",
";",
"// ProjectManager.getProjectRoot().fullPath",
"this",
".",
"_pathResolver",
"=",
"config",
".",
"pathResolver",
";",
"// ProjectManager.makeProjectRelativeIfPossible(doc.file.fullPath)",
"this",
".",
"_liveDocuments",
"=",
"{",
"}",
";",
"}"
] | Base class for live preview servers
Configuration parameters for this server:
- baseUrl - Optional base URL (populated by the current project)
- pathResolver - Function to covert absolute native paths to project relative paths
- root - Native path to the project root (and base URL)
@constructor
@param {!{baseUrl: string, root: string, pathResolver: function(string): string}} config | [
"Base",
"class",
"for",
"live",
"preview",
"servers"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Servers/BaseServer.js#L40-L45 |
2,363 | adobe/brackets | src/extensions/default/HealthData/HealthDataUtils.js | getUserInstalledExtensions | function getUserInstalledExtensions() {
var result = new $.Deferred();
if (!ExtensionManager.hasDownloadedRegistry) {
ExtensionManager.downloadRegistry().done(function () {
result.resolve(getUserExtensionsPresentInRegistry(ExtensionManager.extensions));
})
.fail(function () {
result.resolve([]);
});
} else {
result.resolve(getUserExtensionsPresentInRegistry(ExtensionManager.extensions));
}
return result.promise();
} | javascript | function getUserInstalledExtensions() {
var result = new $.Deferred();
if (!ExtensionManager.hasDownloadedRegistry) {
ExtensionManager.downloadRegistry().done(function () {
result.resolve(getUserExtensionsPresentInRegistry(ExtensionManager.extensions));
})
.fail(function () {
result.resolve([]);
});
} else {
result.resolve(getUserExtensionsPresentInRegistry(ExtensionManager.extensions));
}
return result.promise();
} | [
"function",
"getUserInstalledExtensions",
"(",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"if",
"(",
"!",
"ExtensionManager",
".",
"hasDownloadedRegistry",
")",
"{",
"ExtensionManager",
".",
"downloadRegistry",
"(",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"result",
".",
"resolve",
"(",
"getUserExtensionsPresentInRegistry",
"(",
"ExtensionManager",
".",
"extensions",
")",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"result",
".",
"resolve",
"(",
"[",
"]",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"result",
".",
"resolve",
"(",
"getUserExtensionsPresentInRegistry",
"(",
"ExtensionManager",
".",
"extensions",
")",
")",
";",
"}",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] | Utility function to get the user installed extension which are present in the registry | [
"Utility",
"function",
"to",
"get",
"the",
"user",
"installed",
"extension",
"which",
"are",
"present",
"in",
"the",
"registry"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/HealthData/HealthDataUtils.js#L53-L68 |
2,364 | adobe/brackets | src/extensions/default/HealthData/HealthDataUtils.js | getUserInstalledTheme | function getUserInstalledTheme() {
var result = new $.Deferred();
var installedTheme = themesPref.get("theme"),
bracketsTheme;
if (installedTheme === "light-theme" || installedTheme === "dark-theme") {
return result.resolve(installedTheme);
}
if (!ExtensionManager.hasDownloadedRegistry) {
ExtensionManager.downloadRegistry().done(function () {
bracketsTheme = ExtensionManager.extensions[installedTheme];
if (bracketsTheme && bracketsTheme.installInfo && bracketsTheme.installInfo.locationType === ExtensionManager.LOCATION_USER && bracketsTheme.registryInfo) {
result.resolve(installedTheme);
} else {
result.reject();
}
})
.fail(function () {
result.reject();
});
} else {
bracketsTheme = ExtensionManager.extensions[installedTheme];
if (bracketsTheme && bracketsTheme.installInfo && bracketsTheme.installInfo.locationType === ExtensionManager.LOCATION_USER && bracketsTheme.registryInfo) {
result.resolve(installedTheme);
} else {
result.reject();
}
}
return result.promise();
} | javascript | function getUserInstalledTheme() {
var result = new $.Deferred();
var installedTheme = themesPref.get("theme"),
bracketsTheme;
if (installedTheme === "light-theme" || installedTheme === "dark-theme") {
return result.resolve(installedTheme);
}
if (!ExtensionManager.hasDownloadedRegistry) {
ExtensionManager.downloadRegistry().done(function () {
bracketsTheme = ExtensionManager.extensions[installedTheme];
if (bracketsTheme && bracketsTheme.installInfo && bracketsTheme.installInfo.locationType === ExtensionManager.LOCATION_USER && bracketsTheme.registryInfo) {
result.resolve(installedTheme);
} else {
result.reject();
}
})
.fail(function () {
result.reject();
});
} else {
bracketsTheme = ExtensionManager.extensions[installedTheme];
if (bracketsTheme && bracketsTheme.installInfo && bracketsTheme.installInfo.locationType === ExtensionManager.LOCATION_USER && bracketsTheme.registryInfo) {
result.resolve(installedTheme);
} else {
result.reject();
}
}
return result.promise();
} | [
"function",
"getUserInstalledTheme",
"(",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"var",
"installedTheme",
"=",
"themesPref",
".",
"get",
"(",
"\"theme\"",
")",
",",
"bracketsTheme",
";",
"if",
"(",
"installedTheme",
"===",
"\"light-theme\"",
"||",
"installedTheme",
"===",
"\"dark-theme\"",
")",
"{",
"return",
"result",
".",
"resolve",
"(",
"installedTheme",
")",
";",
"}",
"if",
"(",
"!",
"ExtensionManager",
".",
"hasDownloadedRegistry",
")",
"{",
"ExtensionManager",
".",
"downloadRegistry",
"(",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"bracketsTheme",
"=",
"ExtensionManager",
".",
"extensions",
"[",
"installedTheme",
"]",
";",
"if",
"(",
"bracketsTheme",
"&&",
"bracketsTheme",
".",
"installInfo",
"&&",
"bracketsTheme",
".",
"installInfo",
".",
"locationType",
"===",
"ExtensionManager",
".",
"LOCATION_USER",
"&&",
"bracketsTheme",
".",
"registryInfo",
")",
"{",
"result",
".",
"resolve",
"(",
"installedTheme",
")",
";",
"}",
"else",
"{",
"result",
".",
"reject",
"(",
")",
";",
"}",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"result",
".",
"reject",
"(",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"bracketsTheme",
"=",
"ExtensionManager",
".",
"extensions",
"[",
"installedTheme",
"]",
";",
"if",
"(",
"bracketsTheme",
"&&",
"bracketsTheme",
".",
"installInfo",
"&&",
"bracketsTheme",
".",
"installInfo",
".",
"locationType",
"===",
"ExtensionManager",
".",
"LOCATION_USER",
"&&",
"bracketsTheme",
".",
"registryInfo",
")",
"{",
"result",
".",
"resolve",
"(",
"installedTheme",
")",
";",
"}",
"else",
"{",
"result",
".",
"reject",
"(",
")",
";",
"}",
"}",
"return",
"result",
".",
"promise",
"(",
")",
";",
"}"
] | Utility function to get the user installed theme which are present in the registry | [
"Utility",
"function",
"to",
"get",
"the",
"user",
"installed",
"theme",
"which",
"are",
"present",
"in",
"the",
"registry"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/HealthData/HealthDataUtils.js#L73-L105 |
2,365 | adobe/brackets | src/command/KeyBindingManager.js | normalizeKeyDescriptorString | function normalizeKeyDescriptorString(origDescriptor) {
var hasMacCtrl = false,
hasCtrl = false,
hasAlt = false,
hasShift = false,
key = "",
error = false;
function _compareModifierString(left, right) {
if (!left || !right) {
return false;
}
left = left.trim().toLowerCase();
right = right.trim().toLowerCase();
return (left.length > 0 && left === right);
}
origDescriptor.split("-").forEach(function parseDescriptor(ele, i, arr) {
if (_compareModifierString("ctrl", ele)) {
if (brackets.platform === "mac") {
hasMacCtrl = true;
} else {
hasCtrl = true;
}
} else if (_compareModifierString("cmd", ele)) {
if (brackets.platform === "mac") {
hasCtrl = true;
} else {
error = true;
}
} else if (_compareModifierString("alt", ele)) {
hasAlt = true;
} else if (_compareModifierString("opt", ele)) {
if (brackets.platform === "mac") {
hasAlt = true;
} else {
error = true;
}
} else if (_compareModifierString("shift", ele)) {
hasShift = true;
} else if (key.length > 0) {
console.log("KeyBindingManager normalizeKeyDescriptorString() - Multiple keys defined. Using key: " + key + " from: " + origDescriptor);
error = true;
} else {
key = ele;
}
});
if (error) {
return null;
}
// Check to see if the binding is for "-".
if (key === "" && origDescriptor.search(/^.+--$/) !== -1) {
key = "-";
}
// '+' char is valid if it's the only key. Keyboard shortcut strings should use
// unicode characters (unescaped). Keyboard shortcut display strings may use
// unicode escape sequences (e.g. \u20AC euro sign)
if ((key.indexOf("+")) >= 0 && (key.length > 1)) {
return null;
}
// Ensure that the first letter of the key name is in upper case and the rest are
// in lower case. i.e. 'a' => 'A' and 'up' => 'Up'
if (/^[a-z]/i.test(key)) {
key = _.capitalize(key.toLowerCase());
}
// Also make sure that the second word of PageUp/PageDown has the first letter in upper case.
if (/^Page/.test(key)) {
key = key.replace(/(up|down)$/, function (match, p1) {
return _.capitalize(p1);
});
}
// No restriction on single character key yet, but other key names are restricted to either
// Function keys or those listed in _keyNames array.
if (key.length > 1 && !/F\d+/.test(key) &&
_keyNames.indexOf(key) === -1) {
return null;
}
return _buildKeyDescriptor(hasMacCtrl, hasCtrl, hasAlt, hasShift, key);
} | javascript | function normalizeKeyDescriptorString(origDescriptor) {
var hasMacCtrl = false,
hasCtrl = false,
hasAlt = false,
hasShift = false,
key = "",
error = false;
function _compareModifierString(left, right) {
if (!left || !right) {
return false;
}
left = left.trim().toLowerCase();
right = right.trim().toLowerCase();
return (left.length > 0 && left === right);
}
origDescriptor.split("-").forEach(function parseDescriptor(ele, i, arr) {
if (_compareModifierString("ctrl", ele)) {
if (brackets.platform === "mac") {
hasMacCtrl = true;
} else {
hasCtrl = true;
}
} else if (_compareModifierString("cmd", ele)) {
if (brackets.platform === "mac") {
hasCtrl = true;
} else {
error = true;
}
} else if (_compareModifierString("alt", ele)) {
hasAlt = true;
} else if (_compareModifierString("opt", ele)) {
if (brackets.platform === "mac") {
hasAlt = true;
} else {
error = true;
}
} else if (_compareModifierString("shift", ele)) {
hasShift = true;
} else if (key.length > 0) {
console.log("KeyBindingManager normalizeKeyDescriptorString() - Multiple keys defined. Using key: " + key + " from: " + origDescriptor);
error = true;
} else {
key = ele;
}
});
if (error) {
return null;
}
// Check to see if the binding is for "-".
if (key === "" && origDescriptor.search(/^.+--$/) !== -1) {
key = "-";
}
// '+' char is valid if it's the only key. Keyboard shortcut strings should use
// unicode characters (unescaped). Keyboard shortcut display strings may use
// unicode escape sequences (e.g. \u20AC euro sign)
if ((key.indexOf("+")) >= 0 && (key.length > 1)) {
return null;
}
// Ensure that the first letter of the key name is in upper case and the rest are
// in lower case. i.e. 'a' => 'A' and 'up' => 'Up'
if (/^[a-z]/i.test(key)) {
key = _.capitalize(key.toLowerCase());
}
// Also make sure that the second word of PageUp/PageDown has the first letter in upper case.
if (/^Page/.test(key)) {
key = key.replace(/(up|down)$/, function (match, p1) {
return _.capitalize(p1);
});
}
// No restriction on single character key yet, but other key names are restricted to either
// Function keys or those listed in _keyNames array.
if (key.length > 1 && !/F\d+/.test(key) &&
_keyNames.indexOf(key) === -1) {
return null;
}
return _buildKeyDescriptor(hasMacCtrl, hasCtrl, hasAlt, hasShift, key);
} | [
"function",
"normalizeKeyDescriptorString",
"(",
"origDescriptor",
")",
"{",
"var",
"hasMacCtrl",
"=",
"false",
",",
"hasCtrl",
"=",
"false",
",",
"hasAlt",
"=",
"false",
",",
"hasShift",
"=",
"false",
",",
"key",
"=",
"\"\"",
",",
"error",
"=",
"false",
";",
"function",
"_compareModifierString",
"(",
"left",
",",
"right",
")",
"{",
"if",
"(",
"!",
"left",
"||",
"!",
"right",
")",
"{",
"return",
"false",
";",
"}",
"left",
"=",
"left",
".",
"trim",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"right",
"=",
"right",
".",
"trim",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"return",
"(",
"left",
".",
"length",
">",
"0",
"&&",
"left",
"===",
"right",
")",
";",
"}",
"origDescriptor",
".",
"split",
"(",
"\"-\"",
")",
".",
"forEach",
"(",
"function",
"parseDescriptor",
"(",
"ele",
",",
"i",
",",
"arr",
")",
"{",
"if",
"(",
"_compareModifierString",
"(",
"\"ctrl\"",
",",
"ele",
")",
")",
"{",
"if",
"(",
"brackets",
".",
"platform",
"===",
"\"mac\"",
")",
"{",
"hasMacCtrl",
"=",
"true",
";",
"}",
"else",
"{",
"hasCtrl",
"=",
"true",
";",
"}",
"}",
"else",
"if",
"(",
"_compareModifierString",
"(",
"\"cmd\"",
",",
"ele",
")",
")",
"{",
"if",
"(",
"brackets",
".",
"platform",
"===",
"\"mac\"",
")",
"{",
"hasCtrl",
"=",
"true",
";",
"}",
"else",
"{",
"error",
"=",
"true",
";",
"}",
"}",
"else",
"if",
"(",
"_compareModifierString",
"(",
"\"alt\"",
",",
"ele",
")",
")",
"{",
"hasAlt",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"_compareModifierString",
"(",
"\"opt\"",
",",
"ele",
")",
")",
"{",
"if",
"(",
"brackets",
".",
"platform",
"===",
"\"mac\"",
")",
"{",
"hasAlt",
"=",
"true",
";",
"}",
"else",
"{",
"error",
"=",
"true",
";",
"}",
"}",
"else",
"if",
"(",
"_compareModifierString",
"(",
"\"shift\"",
",",
"ele",
")",
")",
"{",
"hasShift",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"key",
".",
"length",
">",
"0",
")",
"{",
"console",
".",
"log",
"(",
"\"KeyBindingManager normalizeKeyDescriptorString() - Multiple keys defined. Using key: \"",
"+",
"key",
"+",
"\" from: \"",
"+",
"origDescriptor",
")",
";",
"error",
"=",
"true",
";",
"}",
"else",
"{",
"key",
"=",
"ele",
";",
"}",
"}",
")",
";",
"if",
"(",
"error",
")",
"{",
"return",
"null",
";",
"}",
"// Check to see if the binding is for \"-\".",
"if",
"(",
"key",
"===",
"\"\"",
"&&",
"origDescriptor",
".",
"search",
"(",
"/",
"^.+--$",
"/",
")",
"!==",
"-",
"1",
")",
"{",
"key",
"=",
"\"-\"",
";",
"}",
"// '+' char is valid if it's the only key. Keyboard shortcut strings should use",
"// unicode characters (unescaped). Keyboard shortcut display strings may use",
"// unicode escape sequences (e.g. \\u20AC euro sign)",
"if",
"(",
"(",
"key",
".",
"indexOf",
"(",
"\"+\"",
")",
")",
">=",
"0",
"&&",
"(",
"key",
".",
"length",
">",
"1",
")",
")",
"{",
"return",
"null",
";",
"}",
"// Ensure that the first letter of the key name is in upper case and the rest are",
"// in lower case. i.e. 'a' => 'A' and 'up' => 'Up'",
"if",
"(",
"/",
"^[a-z]",
"/",
"i",
".",
"test",
"(",
"key",
")",
")",
"{",
"key",
"=",
"_",
".",
"capitalize",
"(",
"key",
".",
"toLowerCase",
"(",
")",
")",
";",
"}",
"// Also make sure that the second word of PageUp/PageDown has the first letter in upper case.",
"if",
"(",
"/",
"^Page",
"/",
".",
"test",
"(",
"key",
")",
")",
"{",
"key",
"=",
"key",
".",
"replace",
"(",
"/",
"(up|down)$",
"/",
",",
"function",
"(",
"match",
",",
"p1",
")",
"{",
"return",
"_",
".",
"capitalize",
"(",
"p1",
")",
";",
"}",
")",
";",
"}",
"// No restriction on single character key yet, but other key names are restricted to either",
"// Function keys or those listed in _keyNames array.",
"if",
"(",
"key",
".",
"length",
">",
"1",
"&&",
"!",
"/",
"F\\d+",
"/",
".",
"test",
"(",
"key",
")",
"&&",
"_keyNames",
".",
"indexOf",
"(",
"key",
")",
"===",
"-",
"1",
")",
"{",
"return",
"null",
";",
"}",
"return",
"_buildKeyDescriptor",
"(",
"hasMacCtrl",
",",
"hasCtrl",
",",
"hasAlt",
",",
"hasShift",
",",
"key",
")",
";",
"}"
] | normalizes the incoming key descriptor so the modifier keys are always specified in the correct order
@param {string} The string for a key descriptor, can be in any order, the result will be Ctrl-Alt-Shift-<Key>
@return {string} The normalized key descriptor or null if the descriptor invalid | [
"normalizes",
"the",
"incoming",
"key",
"descriptor",
"so",
"the",
"modifier",
"keys",
"are",
"always",
"specified",
"in",
"the",
"correct",
"order"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/KeyBindingManager.js#L339-L425 |
2,366 | adobe/brackets | src/command/KeyBindingManager.js | _translateKeyboardEvent | function _translateKeyboardEvent(event) {
var hasMacCtrl = (brackets.platform === "mac") ? (event.ctrlKey) : false,
hasCtrl = (brackets.platform !== "mac") ? (event.ctrlKey) : (event.metaKey),
hasAlt = (event.altKey),
hasShift = (event.shiftKey),
key = String.fromCharCode(event.keyCode);
//From the W3C, if we can get the KeyboardEvent.keyIdentifier then look here
//As that will let us use keys like then function keys "F5" for commands. The
//full set of values we can use is here
//http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/keyset.html#KeySet-Set
var ident = event.keyIdentifier;
if (ident) {
if (ident.charAt(0) === "U" && ident.charAt(1) === "+") {
//This is a unicode code point like "U+002A", get the 002A and use that
key = String.fromCharCode(parseInt(ident.substring(2), 16));
} else {
//This is some non-character key, just use the raw identifier
key = ident;
}
}
// Translate some keys to their common names
if (key === "\t") {
key = "Tab";
} else if (key === " ") {
key = "Space";
} else if (key === "\b") {
key = "Backspace";
} else if (key === "Help") {
key = "Insert";
} else if (event.keyCode === KeyEvent.DOM_VK_DELETE) {
key = "Delete";
} else {
key = _mapKeycodeToKey(event.keyCode, key);
}
return _buildKeyDescriptor(hasMacCtrl, hasCtrl, hasAlt, hasShift, key);
} | javascript | function _translateKeyboardEvent(event) {
var hasMacCtrl = (brackets.platform === "mac") ? (event.ctrlKey) : false,
hasCtrl = (brackets.platform !== "mac") ? (event.ctrlKey) : (event.metaKey),
hasAlt = (event.altKey),
hasShift = (event.shiftKey),
key = String.fromCharCode(event.keyCode);
//From the W3C, if we can get the KeyboardEvent.keyIdentifier then look here
//As that will let us use keys like then function keys "F5" for commands. The
//full set of values we can use is here
//http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/keyset.html#KeySet-Set
var ident = event.keyIdentifier;
if (ident) {
if (ident.charAt(0) === "U" && ident.charAt(1) === "+") {
//This is a unicode code point like "U+002A", get the 002A and use that
key = String.fromCharCode(parseInt(ident.substring(2), 16));
} else {
//This is some non-character key, just use the raw identifier
key = ident;
}
}
// Translate some keys to their common names
if (key === "\t") {
key = "Tab";
} else if (key === " ") {
key = "Space";
} else if (key === "\b") {
key = "Backspace";
} else if (key === "Help") {
key = "Insert";
} else if (event.keyCode === KeyEvent.DOM_VK_DELETE) {
key = "Delete";
} else {
key = _mapKeycodeToKey(event.keyCode, key);
}
return _buildKeyDescriptor(hasMacCtrl, hasCtrl, hasAlt, hasShift, key);
} | [
"function",
"_translateKeyboardEvent",
"(",
"event",
")",
"{",
"var",
"hasMacCtrl",
"=",
"(",
"brackets",
".",
"platform",
"===",
"\"mac\"",
")",
"?",
"(",
"event",
".",
"ctrlKey",
")",
":",
"false",
",",
"hasCtrl",
"=",
"(",
"brackets",
".",
"platform",
"!==",
"\"mac\"",
")",
"?",
"(",
"event",
".",
"ctrlKey",
")",
":",
"(",
"event",
".",
"metaKey",
")",
",",
"hasAlt",
"=",
"(",
"event",
".",
"altKey",
")",
",",
"hasShift",
"=",
"(",
"event",
".",
"shiftKey",
")",
",",
"key",
"=",
"String",
".",
"fromCharCode",
"(",
"event",
".",
"keyCode",
")",
";",
"//From the W3C, if we can get the KeyboardEvent.keyIdentifier then look here",
"//As that will let us use keys like then function keys \"F5\" for commands. The",
"//full set of values we can use is here",
"//http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/keyset.html#KeySet-Set",
"var",
"ident",
"=",
"event",
".",
"keyIdentifier",
";",
"if",
"(",
"ident",
")",
"{",
"if",
"(",
"ident",
".",
"charAt",
"(",
"0",
")",
"===",
"\"U\"",
"&&",
"ident",
".",
"charAt",
"(",
"1",
")",
"===",
"\"+\"",
")",
"{",
"//This is a unicode code point like \"U+002A\", get the 002A and use that",
"key",
"=",
"String",
".",
"fromCharCode",
"(",
"parseInt",
"(",
"ident",
".",
"substring",
"(",
"2",
")",
",",
"16",
")",
")",
";",
"}",
"else",
"{",
"//This is some non-character key, just use the raw identifier",
"key",
"=",
"ident",
";",
"}",
"}",
"// Translate some keys to their common names",
"if",
"(",
"key",
"===",
"\"\\t\"",
")",
"{",
"key",
"=",
"\"Tab\"",
";",
"}",
"else",
"if",
"(",
"key",
"===",
"\" \"",
")",
"{",
"key",
"=",
"\"Space\"",
";",
"}",
"else",
"if",
"(",
"key",
"===",
"\"\\b\"",
")",
"{",
"key",
"=",
"\"Backspace\"",
";",
"}",
"else",
"if",
"(",
"key",
"===",
"\"Help\"",
")",
"{",
"key",
"=",
"\"Insert\"",
";",
"}",
"else",
"if",
"(",
"event",
".",
"keyCode",
"===",
"KeyEvent",
".",
"DOM_VK_DELETE",
")",
"{",
"key",
"=",
"\"Delete\"",
";",
"}",
"else",
"{",
"key",
"=",
"_mapKeycodeToKey",
"(",
"event",
".",
"keyCode",
",",
"key",
")",
";",
"}",
"return",
"_buildKeyDescriptor",
"(",
"hasMacCtrl",
",",
"hasCtrl",
",",
"hasAlt",
",",
"hasShift",
",",
"key",
")",
";",
"}"
] | Takes a keyboard event and translates it into a key in a key map | [
"Takes",
"a",
"keyboard",
"event",
"and",
"translates",
"it",
"into",
"a",
"key",
"in",
"a",
"key",
"map"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/KeyBindingManager.js#L482-L520 |
2,367 | adobe/brackets | src/command/KeyBindingManager.js | formatKeyDescriptor | function formatKeyDescriptor(descriptor) {
var displayStr;
if (brackets.platform === "mac") {
displayStr = descriptor.replace(/-(?!$)/g, ""); // remove dashes
displayStr = displayStr.replace("Ctrl", "\u2303"); // Ctrl > control symbol
displayStr = displayStr.replace("Cmd", "\u2318"); // Cmd > command symbol
displayStr = displayStr.replace("Shift", "\u21E7"); // Shift > shift symbol
displayStr = displayStr.replace("Alt", "\u2325"); // Alt > option symbol
} else {
displayStr = descriptor.replace("Ctrl", Strings.KEYBOARD_CTRL);
displayStr = displayStr.replace("Shift", Strings.KEYBOARD_SHIFT);
displayStr = displayStr.replace(/-(?!$)/g, "+");
}
displayStr = displayStr.replace("Space", Strings.KEYBOARD_SPACE);
displayStr = displayStr.replace("PageUp", Strings.KEYBOARD_PAGE_UP);
displayStr = displayStr.replace("PageDown", Strings.KEYBOARD_PAGE_DOWN);
displayStr = displayStr.replace("Home", Strings.KEYBOARD_HOME);
displayStr = displayStr.replace("End", Strings.KEYBOARD_END);
displayStr = displayStr.replace("Ins", Strings.KEYBOARD_INSERT);
displayStr = displayStr.replace("Del", Strings.KEYBOARD_DELETE);
return displayStr;
} | javascript | function formatKeyDescriptor(descriptor) {
var displayStr;
if (brackets.platform === "mac") {
displayStr = descriptor.replace(/-(?!$)/g, ""); // remove dashes
displayStr = displayStr.replace("Ctrl", "\u2303"); // Ctrl > control symbol
displayStr = displayStr.replace("Cmd", "\u2318"); // Cmd > command symbol
displayStr = displayStr.replace("Shift", "\u21E7"); // Shift > shift symbol
displayStr = displayStr.replace("Alt", "\u2325"); // Alt > option symbol
} else {
displayStr = descriptor.replace("Ctrl", Strings.KEYBOARD_CTRL);
displayStr = displayStr.replace("Shift", Strings.KEYBOARD_SHIFT);
displayStr = displayStr.replace(/-(?!$)/g, "+");
}
displayStr = displayStr.replace("Space", Strings.KEYBOARD_SPACE);
displayStr = displayStr.replace("PageUp", Strings.KEYBOARD_PAGE_UP);
displayStr = displayStr.replace("PageDown", Strings.KEYBOARD_PAGE_DOWN);
displayStr = displayStr.replace("Home", Strings.KEYBOARD_HOME);
displayStr = displayStr.replace("End", Strings.KEYBOARD_END);
displayStr = displayStr.replace("Ins", Strings.KEYBOARD_INSERT);
displayStr = displayStr.replace("Del", Strings.KEYBOARD_DELETE);
return displayStr;
} | [
"function",
"formatKeyDescriptor",
"(",
"descriptor",
")",
"{",
"var",
"displayStr",
";",
"if",
"(",
"brackets",
".",
"platform",
"===",
"\"mac\"",
")",
"{",
"displayStr",
"=",
"descriptor",
".",
"replace",
"(",
"/",
"-(?!$)",
"/",
"g",
",",
"\"\"",
")",
";",
"// remove dashes",
"displayStr",
"=",
"displayStr",
".",
"replace",
"(",
"\"Ctrl\"",
",",
"\"\\u2303\"",
")",
";",
"// Ctrl > control symbol",
"displayStr",
"=",
"displayStr",
".",
"replace",
"(",
"\"Cmd\"",
",",
"\"\\u2318\"",
")",
";",
"// Cmd > command symbol",
"displayStr",
"=",
"displayStr",
".",
"replace",
"(",
"\"Shift\"",
",",
"\"\\u21E7\"",
")",
";",
"// Shift > shift symbol",
"displayStr",
"=",
"displayStr",
".",
"replace",
"(",
"\"Alt\"",
",",
"\"\\u2325\"",
")",
";",
"// Alt > option symbol",
"}",
"else",
"{",
"displayStr",
"=",
"descriptor",
".",
"replace",
"(",
"\"Ctrl\"",
",",
"Strings",
".",
"KEYBOARD_CTRL",
")",
";",
"displayStr",
"=",
"displayStr",
".",
"replace",
"(",
"\"Shift\"",
",",
"Strings",
".",
"KEYBOARD_SHIFT",
")",
";",
"displayStr",
"=",
"displayStr",
".",
"replace",
"(",
"/",
"-(?!$)",
"/",
"g",
",",
"\"+\"",
")",
";",
"}",
"displayStr",
"=",
"displayStr",
".",
"replace",
"(",
"\"Space\"",
",",
"Strings",
".",
"KEYBOARD_SPACE",
")",
";",
"displayStr",
"=",
"displayStr",
".",
"replace",
"(",
"\"PageUp\"",
",",
"Strings",
".",
"KEYBOARD_PAGE_UP",
")",
";",
"displayStr",
"=",
"displayStr",
".",
"replace",
"(",
"\"PageDown\"",
",",
"Strings",
".",
"KEYBOARD_PAGE_DOWN",
")",
";",
"displayStr",
"=",
"displayStr",
".",
"replace",
"(",
"\"Home\"",
",",
"Strings",
".",
"KEYBOARD_HOME",
")",
";",
"displayStr",
"=",
"displayStr",
".",
"replace",
"(",
"\"End\"",
",",
"Strings",
".",
"KEYBOARD_END",
")",
";",
"displayStr",
"=",
"displayStr",
".",
"replace",
"(",
"\"Ins\"",
",",
"Strings",
".",
"KEYBOARD_INSERT",
")",
";",
"displayStr",
"=",
"displayStr",
".",
"replace",
"(",
"\"Del\"",
",",
"Strings",
".",
"KEYBOARD_DELETE",
")",
";",
"return",
"displayStr",
";",
"}"
] | Convert normalized key representation to display appropriate for platform.
@param {!string} descriptor Normalized key descriptor.
@return {!string} Display/Operating system appropriate string | [
"Convert",
"normalized",
"key",
"representation",
"to",
"display",
"appropriate",
"for",
"platform",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/KeyBindingManager.js#L527-L553 |
2,368 | adobe/brackets | src/command/KeyBindingManager.js | removeBinding | function removeBinding(key, platform) {
if (!key || ((platform !== null) && (platform !== undefined) && (platform !== brackets.platform))) {
return;
}
var normalizedKey = normalizeKeyDescriptorString(key);
if (!normalizedKey) {
console.log("Failed to normalize " + key);
} else if (_isKeyAssigned(normalizedKey)) {
var binding = _keyMap[normalizedKey],
command = CommandManager.get(binding.commandID),
bindings = _commandMap[binding.commandID];
// delete key binding record
delete _keyMap[normalizedKey];
if (bindings) {
// delete mapping from command to key binding
_commandMap[binding.commandID] = bindings.filter(function (b) {
return (b.key !== normalizedKey);
});
if (command) {
command.trigger("keyBindingRemoved", {key: normalizedKey, displayKey: binding.displayKey});
}
}
}
} | javascript | function removeBinding(key, platform) {
if (!key || ((platform !== null) && (platform !== undefined) && (platform !== brackets.platform))) {
return;
}
var normalizedKey = normalizeKeyDescriptorString(key);
if (!normalizedKey) {
console.log("Failed to normalize " + key);
} else if (_isKeyAssigned(normalizedKey)) {
var binding = _keyMap[normalizedKey],
command = CommandManager.get(binding.commandID),
bindings = _commandMap[binding.commandID];
// delete key binding record
delete _keyMap[normalizedKey];
if (bindings) {
// delete mapping from command to key binding
_commandMap[binding.commandID] = bindings.filter(function (b) {
return (b.key !== normalizedKey);
});
if (command) {
command.trigger("keyBindingRemoved", {key: normalizedKey, displayKey: binding.displayKey});
}
}
}
} | [
"function",
"removeBinding",
"(",
"key",
",",
"platform",
")",
"{",
"if",
"(",
"!",
"key",
"||",
"(",
"(",
"platform",
"!==",
"null",
")",
"&&",
"(",
"platform",
"!==",
"undefined",
")",
"&&",
"(",
"platform",
"!==",
"brackets",
".",
"platform",
")",
")",
")",
"{",
"return",
";",
"}",
"var",
"normalizedKey",
"=",
"normalizeKeyDescriptorString",
"(",
"key",
")",
";",
"if",
"(",
"!",
"normalizedKey",
")",
"{",
"console",
".",
"log",
"(",
"\"Failed to normalize \"",
"+",
"key",
")",
";",
"}",
"else",
"if",
"(",
"_isKeyAssigned",
"(",
"normalizedKey",
")",
")",
"{",
"var",
"binding",
"=",
"_keyMap",
"[",
"normalizedKey",
"]",
",",
"command",
"=",
"CommandManager",
".",
"get",
"(",
"binding",
".",
"commandID",
")",
",",
"bindings",
"=",
"_commandMap",
"[",
"binding",
".",
"commandID",
"]",
";",
"// delete key binding record",
"delete",
"_keyMap",
"[",
"normalizedKey",
"]",
";",
"if",
"(",
"bindings",
")",
"{",
"// delete mapping from command to key binding",
"_commandMap",
"[",
"binding",
".",
"commandID",
"]",
"=",
"bindings",
".",
"filter",
"(",
"function",
"(",
"b",
")",
"{",
"return",
"(",
"b",
".",
"key",
"!==",
"normalizedKey",
")",
";",
"}",
")",
";",
"if",
"(",
"command",
")",
"{",
"command",
".",
"trigger",
"(",
"\"keyBindingRemoved\"",
",",
"{",
"key",
":",
"normalizedKey",
",",
"displayKey",
":",
"binding",
".",
"displayKey",
"}",
")",
";",
"}",
"}",
"}",
"}"
] | Remove a key binding from _keymap
@param {!string} key - a key-description string that may or may not be normalized.
@param {?string} platform - OS from which to remove the binding (all platforms if unspecified) | [
"Remove",
"a",
"key",
"binding",
"from",
"_keymap"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/KeyBindingManager.js#L570-L598 |
2,369 | adobe/brackets | src/command/KeyBindingManager.js | _handleKey | function _handleKey(key) {
if (_enabled && _keyMap[key]) {
// The execute() function returns a promise because some commands are async.
// Generally, commands decide whether they can run or not synchronously,
// and reject immediately, so we can test for that synchronously.
var promise = CommandManager.execute(_keyMap[key].commandID);
return (promise.state() !== "rejected");
}
return false;
} | javascript | function _handleKey(key) {
if (_enabled && _keyMap[key]) {
// The execute() function returns a promise because some commands are async.
// Generally, commands decide whether they can run or not synchronously,
// and reject immediately, so we can test for that synchronously.
var promise = CommandManager.execute(_keyMap[key].commandID);
return (promise.state() !== "rejected");
}
return false;
} | [
"function",
"_handleKey",
"(",
"key",
")",
"{",
"if",
"(",
"_enabled",
"&&",
"_keyMap",
"[",
"key",
"]",
")",
"{",
"// The execute() function returns a promise because some commands are async.",
"// Generally, commands decide whether they can run or not synchronously,",
"// and reject immediately, so we can test for that synchronously.",
"var",
"promise",
"=",
"CommandManager",
".",
"execute",
"(",
"_keyMap",
"[",
"key",
"]",
".",
"commandID",
")",
";",
"return",
"(",
"promise",
".",
"state",
"(",
")",
"!==",
"\"rejected\"",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Process the keybinding for the current key.
@param {string} A key-description string.
@return {boolean} true if the key was processed, false otherwise | [
"Process",
"the",
"keybinding",
"for",
"the",
"current",
"key",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/KeyBindingManager.js#L811-L820 |
2,370 | adobe/brackets | src/command/KeyBindingManager.js | addBinding | function addBinding(command, keyBindings, platform) {
var commandID = "",
results;
if (!command) {
console.error("addBinding(): missing required parameter: command");
return;
}
if (!keyBindings) { return; }
if (typeof (command) === "string") {
commandID = command;
} else {
commandID = command.getID();
}
if (Array.isArray(keyBindings)) {
var keyBinding;
results = [];
// process platform-specific bindings first
keyBindings.sort(_sortByPlatform);
keyBindings.forEach(function addSingleBinding(keyBindingRequest) {
// attempt to add keybinding
keyBinding = _addBinding(commandID, keyBindingRequest, keyBindingRequest.platform);
if (keyBinding) {
results.push(keyBinding);
}
});
} else {
results = _addBinding(commandID, keyBindings, platform);
}
return results;
} | javascript | function addBinding(command, keyBindings, platform) {
var commandID = "",
results;
if (!command) {
console.error("addBinding(): missing required parameter: command");
return;
}
if (!keyBindings) { return; }
if (typeof (command) === "string") {
commandID = command;
} else {
commandID = command.getID();
}
if (Array.isArray(keyBindings)) {
var keyBinding;
results = [];
// process platform-specific bindings first
keyBindings.sort(_sortByPlatform);
keyBindings.forEach(function addSingleBinding(keyBindingRequest) {
// attempt to add keybinding
keyBinding = _addBinding(commandID, keyBindingRequest, keyBindingRequest.platform);
if (keyBinding) {
results.push(keyBinding);
}
});
} else {
results = _addBinding(commandID, keyBindings, platform);
}
return results;
} | [
"function",
"addBinding",
"(",
"command",
",",
"keyBindings",
",",
"platform",
")",
"{",
"var",
"commandID",
"=",
"\"\"",
",",
"results",
";",
"if",
"(",
"!",
"command",
")",
"{",
"console",
".",
"error",
"(",
"\"addBinding(): missing required parameter: command\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"keyBindings",
")",
"{",
"return",
";",
"}",
"if",
"(",
"typeof",
"(",
"command",
")",
"===",
"\"string\"",
")",
"{",
"commandID",
"=",
"command",
";",
"}",
"else",
"{",
"commandID",
"=",
"command",
".",
"getID",
"(",
")",
";",
"}",
"if",
"(",
"Array",
".",
"isArray",
"(",
"keyBindings",
")",
")",
"{",
"var",
"keyBinding",
";",
"results",
"=",
"[",
"]",
";",
"// process platform-specific bindings first",
"keyBindings",
".",
"sort",
"(",
"_sortByPlatform",
")",
";",
"keyBindings",
".",
"forEach",
"(",
"function",
"addSingleBinding",
"(",
"keyBindingRequest",
")",
"{",
"// attempt to add keybinding",
"keyBinding",
"=",
"_addBinding",
"(",
"commandID",
",",
"keyBindingRequest",
",",
"keyBindingRequest",
".",
"platform",
")",
";",
"if",
"(",
"keyBinding",
")",
"{",
"results",
".",
"push",
"(",
"keyBinding",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"results",
"=",
"_addBinding",
"(",
"commandID",
",",
"keyBindings",
",",
"platform",
")",
";",
"}",
"return",
"results",
";",
"}"
] | Add one or more key bindings to a particular Command.
@param {!string | Command} command - A command ID or command object
@param {?({key: string, displayKey: string}|Array.<{key: string, displayKey: string, platform: string}>)} keyBindings
A single key binding or an array of keybindings. Example:
"Shift-Cmd-F". Mac and Win key equivalents are automatically
mapped to each other. Use displayKey property to display a different
string (e.g. "CMD+" instead of "CMD=").
@param {?string} platform The target OS of the keyBindings either
"mac", "win" or "linux". If undefined, all platforms not explicitly
defined will use the key binding.
NOTE: If platform is not specified, Ctrl will be replaced by Cmd for "mac" platform
@return {{key: string, displayKey:String}|Array.<{key: string, displayKey:String}>}
Returns record(s) for valid key binding(s) | [
"Add",
"one",
"or",
"more",
"key",
"bindings",
"to",
"a",
"particular",
"Command",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/KeyBindingManager.js#L850-L887 |
2,371 | adobe/brackets | src/command/KeyBindingManager.js | getKeyBindings | function getKeyBindings(command) {
var bindings = [],
commandID = "";
if (!command) {
console.error("getKeyBindings(): missing required parameter: command");
return [];
}
if (typeof (command) === "string") {
commandID = command;
} else {
commandID = command.getID();
}
bindings = _commandMap[commandID];
return bindings || [];
} | javascript | function getKeyBindings(command) {
var bindings = [],
commandID = "";
if (!command) {
console.error("getKeyBindings(): missing required parameter: command");
return [];
}
if (typeof (command) === "string") {
commandID = command;
} else {
commandID = command.getID();
}
bindings = _commandMap[commandID];
return bindings || [];
} | [
"function",
"getKeyBindings",
"(",
"command",
")",
"{",
"var",
"bindings",
"=",
"[",
"]",
",",
"commandID",
"=",
"\"\"",
";",
"if",
"(",
"!",
"command",
")",
"{",
"console",
".",
"error",
"(",
"\"getKeyBindings(): missing required parameter: command\"",
")",
";",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"typeof",
"(",
"command",
")",
"===",
"\"string\"",
")",
"{",
"commandID",
"=",
"command",
";",
"}",
"else",
"{",
"commandID",
"=",
"command",
".",
"getID",
"(",
")",
";",
"}",
"bindings",
"=",
"_commandMap",
"[",
"commandID",
"]",
";",
"return",
"bindings",
"||",
"[",
"]",
";",
"}"
] | Retrieve key bindings currently associated with a command
@param {!string | Command} command - A command ID or command object
@return {!Array.<{{key: string, displayKey: string}}>} An array of associated key bindings. | [
"Retrieve",
"key",
"bindings",
"currently",
"associated",
"with",
"a",
"command"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/KeyBindingManager.js#L895-L912 |
2,372 | adobe/brackets | src/command/KeyBindingManager.js | _handleCommandRegistered | function _handleCommandRegistered(event, command) {
var commandId = command.getID(),
defaults = KeyboardPrefs[commandId];
if (defaults) {
addBinding(commandId, defaults);
}
} | javascript | function _handleCommandRegistered(event, command) {
var commandId = command.getID(),
defaults = KeyboardPrefs[commandId];
if (defaults) {
addBinding(commandId, defaults);
}
} | [
"function",
"_handleCommandRegistered",
"(",
"event",
",",
"command",
")",
"{",
"var",
"commandId",
"=",
"command",
".",
"getID",
"(",
")",
",",
"defaults",
"=",
"KeyboardPrefs",
"[",
"commandId",
"]",
";",
"if",
"(",
"defaults",
")",
"{",
"addBinding",
"(",
"commandId",
",",
"defaults",
")",
";",
"}",
"}"
] | Adds default key bindings when commands are registered to CommandManager
@param {$.Event} event jQuery event
@param {Command} command Newly registered command | [
"Adds",
"default",
"key",
"bindings",
"when",
"commands",
"are",
"registered",
"to",
"CommandManager"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/KeyBindingManager.js#L919-L926 |
2,373 | adobe/brackets | src/command/KeyBindingManager.js | removeGlobalKeydownHook | function removeGlobalKeydownHook(hook) {
var index = _globalKeydownHooks.indexOf(hook);
if (index !== -1) {
_globalKeydownHooks.splice(index, 1);
}
} | javascript | function removeGlobalKeydownHook(hook) {
var index = _globalKeydownHooks.indexOf(hook);
if (index !== -1) {
_globalKeydownHooks.splice(index, 1);
}
} | [
"function",
"removeGlobalKeydownHook",
"(",
"hook",
")",
"{",
"var",
"index",
"=",
"_globalKeydownHooks",
".",
"indexOf",
"(",
"hook",
")",
";",
"if",
"(",
"index",
"!==",
"-",
"1",
")",
"{",
"_globalKeydownHooks",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"}",
"}"
] | Removes a global keydown hook added by `addGlobalKeydownHook`.
Does not need to be the most recently added hook.
@param {function(Event): boolean} hook The global hook to remove. | [
"Removes",
"a",
"global",
"keydown",
"hook",
"added",
"by",
"addGlobalKeydownHook",
".",
"Does",
"not",
"need",
"to",
"be",
"the",
"most",
"recently",
"added",
"hook",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/KeyBindingManager.js#L964-L969 |
2,374 | adobe/brackets | src/command/KeyBindingManager.js | _handleKeyEvent | function _handleKeyEvent(event) {
var i, handled = false;
for (i = _globalKeydownHooks.length - 1; i >= 0; i--) {
if (_globalKeydownHooks[i](event)) {
handled = true;
break;
}
}
_detectAltGrKeyDown(event);
if (!handled && _handleKey(_translateKeyboardEvent(event))) {
event.stopPropagation();
event.preventDefault();
}
} | javascript | function _handleKeyEvent(event) {
var i, handled = false;
for (i = _globalKeydownHooks.length - 1; i >= 0; i--) {
if (_globalKeydownHooks[i](event)) {
handled = true;
break;
}
}
_detectAltGrKeyDown(event);
if (!handled && _handleKey(_translateKeyboardEvent(event))) {
event.stopPropagation();
event.preventDefault();
}
} | [
"function",
"_handleKeyEvent",
"(",
"event",
")",
"{",
"var",
"i",
",",
"handled",
"=",
"false",
";",
"for",
"(",
"i",
"=",
"_globalKeydownHooks",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"_globalKeydownHooks",
"[",
"i",
"]",
"(",
"event",
")",
")",
"{",
"handled",
"=",
"true",
";",
"break",
";",
"}",
"}",
"_detectAltGrKeyDown",
"(",
"event",
")",
";",
"if",
"(",
"!",
"handled",
"&&",
"_handleKey",
"(",
"_translateKeyboardEvent",
"(",
"event",
")",
")",
")",
"{",
"event",
".",
"stopPropagation",
"(",
")",
";",
"event",
".",
"preventDefault",
"(",
")",
";",
"}",
"}"
] | Handles a given keydown event, checking global hooks first before
deciding to handle it ourselves.
@param {Event} The keydown event to handle. | [
"Handles",
"a",
"given",
"keydown",
"event",
"checking",
"global",
"hooks",
"first",
"before",
"deciding",
"to",
"handle",
"it",
"ourselves",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/KeyBindingManager.js#L976-L989 |
2,375 | adobe/brackets | src/command/CommandManager.js | register | function register(name, id, commandFn) {
if (_commands[id]) {
console.log("Attempting to register an already-registered command: " + id);
return null;
}
if (!name || !id || !commandFn) {
console.error("Attempting to register a command with a missing name, id, or command function:" + name + " " + id);
return null;
}
var command = new Command(name, id, commandFn);
_commands[id] = command;
exports.trigger("commandRegistered", command);
return command;
} | javascript | function register(name, id, commandFn) {
if (_commands[id]) {
console.log("Attempting to register an already-registered command: " + id);
return null;
}
if (!name || !id || !commandFn) {
console.error("Attempting to register a command with a missing name, id, or command function:" + name + " " + id);
return null;
}
var command = new Command(name, id, commandFn);
_commands[id] = command;
exports.trigger("commandRegistered", command);
return command;
} | [
"function",
"register",
"(",
"name",
",",
"id",
",",
"commandFn",
")",
"{",
"if",
"(",
"_commands",
"[",
"id",
"]",
")",
"{",
"console",
".",
"log",
"(",
"\"Attempting to register an already-registered command: \"",
"+",
"id",
")",
";",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"name",
"||",
"!",
"id",
"||",
"!",
"commandFn",
")",
"{",
"console",
".",
"error",
"(",
"\"Attempting to register a command with a missing name, id, or command function:\"",
"+",
"name",
"+",
"\" \"",
"+",
"id",
")",
";",
"return",
"null",
";",
"}",
"var",
"command",
"=",
"new",
"Command",
"(",
"name",
",",
"id",
",",
"commandFn",
")",
";",
"_commands",
"[",
"id",
"]",
"=",
"command",
";",
"exports",
".",
"trigger",
"(",
"\"commandRegistered\"",
",",
"command",
")",
";",
"return",
"command",
";",
"}"
] | Registers a global command.
@param {string} name - text that will be displayed in the UI to represent command
@param {string} id - unique identifier for command.
Core commands in Brackets use a simple command title as an id, for example "open.file".
Extensions should use the following format: "author.myextension.mycommandname".
For example, "lschmitt.csswizard.format.css".
@param {function(...)} commandFn - the function to call when the command is executed. Any arguments passed to
execute() (after the id) are passed as arguments to the function. If the function is asynchronous,
it must return a jQuery promise that is resolved when the command completes. Otherwise, the
CommandManager will assume it is synchronous, and return a promise that is already resolved.
@return {?Command} | [
"Registers",
"a",
"global",
"command",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/CommandManager.js#L189-L205 |
2,376 | adobe/brackets | src/command/CommandManager.js | registerInternal | function registerInternal(id, commandFn) {
if (_commands[id]) {
console.log("Attempting to register an already-registered command: " + id);
return null;
}
if (!id || !commandFn) {
console.error("Attempting to register an internal command with a missing id, or command function: " + id);
return null;
}
var command = new Command(null, id, commandFn);
_commands[id] = command;
exports.trigger("commandRegistered", command);
return command;
} | javascript | function registerInternal(id, commandFn) {
if (_commands[id]) {
console.log("Attempting to register an already-registered command: " + id);
return null;
}
if (!id || !commandFn) {
console.error("Attempting to register an internal command with a missing id, or command function: " + id);
return null;
}
var command = new Command(null, id, commandFn);
_commands[id] = command;
exports.trigger("commandRegistered", command);
return command;
} | [
"function",
"registerInternal",
"(",
"id",
",",
"commandFn",
")",
"{",
"if",
"(",
"_commands",
"[",
"id",
"]",
")",
"{",
"console",
".",
"log",
"(",
"\"Attempting to register an already-registered command: \"",
"+",
"id",
")",
";",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"id",
"||",
"!",
"commandFn",
")",
"{",
"console",
".",
"error",
"(",
"\"Attempting to register an internal command with a missing id, or command function: \"",
"+",
"id",
")",
";",
"return",
"null",
";",
"}",
"var",
"command",
"=",
"new",
"Command",
"(",
"null",
",",
"id",
",",
"commandFn",
")",
";",
"_commands",
"[",
"id",
"]",
"=",
"command",
";",
"exports",
".",
"trigger",
"(",
"\"commandRegistered\"",
",",
"command",
")",
";",
"return",
"command",
";",
"}"
] | Registers a global internal only command.
@param {string} id - unique identifier for command.
Core commands in Brackets use a simple command title as an id, for example "app.abort_quit".
Extensions should use the following format: "author.myextension.mycommandname".
For example, "lschmitt.csswizard.format.css".
@param {function(...)} commandFn - the function to call when the command is executed. Any arguments passed to
execute() (after the id) are passed as arguments to the function. If the function is asynchronous,
it must return a jQuery promise that is resolved when the command completes. Otherwise, the
CommandManager will assume it is synchronous, and return a promise that is already resolved.
@return {?Command} | [
"Registers",
"a",
"global",
"internal",
"only",
"command",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/CommandManager.js#L219-L235 |
2,377 | adobe/brackets | src/command/CommandManager.js | execute | function execute(id) {
var command = _commands[id];
if (command) {
try {
exports.trigger("beforeExecuteCommand", id);
} catch (err) {
console.error(err);
}
return command.execute.apply(command, Array.prototype.slice.call(arguments, 1));
} else {
return (new $.Deferred()).reject().promise();
}
} | javascript | function execute(id) {
var command = _commands[id];
if (command) {
try {
exports.trigger("beforeExecuteCommand", id);
} catch (err) {
console.error(err);
}
return command.execute.apply(command, Array.prototype.slice.call(arguments, 1));
} else {
return (new $.Deferred()).reject().promise();
}
} | [
"function",
"execute",
"(",
"id",
")",
"{",
"var",
"command",
"=",
"_commands",
"[",
"id",
"]",
";",
"if",
"(",
"command",
")",
"{",
"try",
"{",
"exports",
".",
"trigger",
"(",
"\"beforeExecuteCommand\"",
",",
"id",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"console",
".",
"error",
"(",
"err",
")",
";",
"}",
"return",
"command",
".",
"execute",
".",
"apply",
"(",
"command",
",",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
")",
";",
"}",
"else",
"{",
"return",
"(",
"new",
"$",
".",
"Deferred",
"(",
")",
")",
".",
"reject",
"(",
")",
".",
"promise",
"(",
")",
";",
"}",
"}"
] | Looks up and runs a global command. Additional arguments are passed to the command.
@param {string} id The ID of the command to run.
@return {$.Promise} a jQuery promise that will be resolved when the command completes. | [
"Looks",
"up",
"and",
"runs",
"a",
"global",
"command",
".",
"Additional",
"arguments",
"are",
"passed",
"to",
"the",
"command",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/CommandManager.js#L277-L291 |
2,378 | adobe/brackets | src/utils/PerfUtils.js | addMeasurement | function addMeasurement(id) {
if (!enabled) {
return;
}
if (!(id instanceof PerfMeasurement)) {
id = new PerfMeasurement(id, id);
}
var elapsedTime = brackets.app.getElapsedMilliseconds();
if (activeTests[id.id]) {
elapsedTime -= activeTests[id.id].startTime;
delete activeTests[id.id];
}
if (perfData[id]) {
// We have existing data, add to it
if (Array.isArray(perfData[id])) {
perfData[id].push(elapsedTime);
} else {
// Current data is a number, convert to Array
perfData[id] = [perfData[id], elapsedTime];
}
} else {
perfData[id] = elapsedTime;
}
if (id.reent !== undefined) {
if (_reentTests[id] === 0) {
delete _reentTests[id];
} else {
_reentTests[id]--;
}
}
} | javascript | function addMeasurement(id) {
if (!enabled) {
return;
}
if (!(id instanceof PerfMeasurement)) {
id = new PerfMeasurement(id, id);
}
var elapsedTime = brackets.app.getElapsedMilliseconds();
if (activeTests[id.id]) {
elapsedTime -= activeTests[id.id].startTime;
delete activeTests[id.id];
}
if (perfData[id]) {
// We have existing data, add to it
if (Array.isArray(perfData[id])) {
perfData[id].push(elapsedTime);
} else {
// Current data is a number, convert to Array
perfData[id] = [perfData[id], elapsedTime];
}
} else {
perfData[id] = elapsedTime;
}
if (id.reent !== undefined) {
if (_reentTests[id] === 0) {
delete _reentTests[id];
} else {
_reentTests[id]--;
}
}
} | [
"function",
"addMeasurement",
"(",
"id",
")",
"{",
"if",
"(",
"!",
"enabled",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"(",
"id",
"instanceof",
"PerfMeasurement",
")",
")",
"{",
"id",
"=",
"new",
"PerfMeasurement",
"(",
"id",
",",
"id",
")",
";",
"}",
"var",
"elapsedTime",
"=",
"brackets",
".",
"app",
".",
"getElapsedMilliseconds",
"(",
")",
";",
"if",
"(",
"activeTests",
"[",
"id",
".",
"id",
"]",
")",
"{",
"elapsedTime",
"-=",
"activeTests",
"[",
"id",
".",
"id",
"]",
".",
"startTime",
";",
"delete",
"activeTests",
"[",
"id",
".",
"id",
"]",
";",
"}",
"if",
"(",
"perfData",
"[",
"id",
"]",
")",
"{",
"// We have existing data, add to it",
"if",
"(",
"Array",
".",
"isArray",
"(",
"perfData",
"[",
"id",
"]",
")",
")",
"{",
"perfData",
"[",
"id",
"]",
".",
"push",
"(",
"elapsedTime",
")",
";",
"}",
"else",
"{",
"// Current data is a number, convert to Array",
"perfData",
"[",
"id",
"]",
"=",
"[",
"perfData",
"[",
"id",
"]",
",",
"elapsedTime",
"]",
";",
"}",
"}",
"else",
"{",
"perfData",
"[",
"id",
"]",
"=",
"elapsedTime",
";",
"}",
"if",
"(",
"id",
".",
"reent",
"!==",
"undefined",
")",
"{",
"if",
"(",
"_reentTests",
"[",
"id",
"]",
"===",
"0",
")",
"{",
"delete",
"_reentTests",
"[",
"id",
"]",
";",
"}",
"else",
"{",
"_reentTests",
"[",
"id",
"]",
"--",
";",
"}",
"}",
"}"
] | Stop a timer and add its measurements to the performance data.
Multiple measurements can be stored for any given name. If there are
multiple values for a name, they are stored in an Array.
If markStart() was not called for the specified timer, the
measured time is relative to app startup.
@param {Object} id Timer id. | [
"Stop",
"a",
"timer",
"and",
"add",
"its",
"measurements",
"to",
"the",
"performance",
"data",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/PerfUtils.js#L187-L223 |
2,379 | adobe/brackets | src/utils/PerfUtils.js | finalizeMeasurement | function finalizeMeasurement(id) {
if (activeTests[id.id]) {
delete activeTests[id.id];
}
if (updatableTests[id.id]) {
delete updatableTests[id.id];
}
} | javascript | function finalizeMeasurement(id) {
if (activeTests[id.id]) {
delete activeTests[id.id];
}
if (updatableTests[id.id]) {
delete updatableTests[id.id];
}
} | [
"function",
"finalizeMeasurement",
"(",
"id",
")",
"{",
"if",
"(",
"activeTests",
"[",
"id",
".",
"id",
"]",
")",
"{",
"delete",
"activeTests",
"[",
"id",
".",
"id",
"]",
";",
"}",
"if",
"(",
"updatableTests",
"[",
"id",
".",
"id",
"]",
")",
"{",
"delete",
"updatableTests",
"[",
"id",
".",
"id",
"]",
";",
"}",
"}"
] | Remove timer from lists so next action starts a new measurement
updateMeasurement may not have been called, so timer may be
in either or neither list, but should never be in both.
@param {Object} id Timer id. | [
"Remove",
"timer",
"from",
"lists",
"so",
"next",
"action",
"starts",
"a",
"new",
"measurement"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/PerfUtils.js#L281-L289 |
2,380 | adobe/brackets | src/utils/PerfUtils.js | getDelimitedPerfData | function getDelimitedPerfData() {
var result = "";
_.forEach(perfData, function (entry, testName) {
result += getValueAsString(entry) + "\t" + testName + "\n";
});
return result;
} | javascript | function getDelimitedPerfData() {
var result = "";
_.forEach(perfData, function (entry, testName) {
result += getValueAsString(entry) + "\t" + testName + "\n";
});
return result;
} | [
"function",
"getDelimitedPerfData",
"(",
")",
"{",
"var",
"result",
"=",
"\"\"",
";",
"_",
".",
"forEach",
"(",
"perfData",
",",
"function",
"(",
"entry",
",",
"testName",
")",
"{",
"result",
"+=",
"getValueAsString",
"(",
"entry",
")",
"+",
"\"\\t\"",
"+",
"testName",
"+",
"\"\\n\"",
";",
"}",
")",
";",
"return",
"result",
";",
"}"
] | Returns the performance data as a tab delimited string
@return {string} | [
"Returns",
"the",
"performance",
"data",
"as",
"a",
"tab",
"delimited",
"string"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/PerfUtils.js#L343-L350 |
2,381 | adobe/brackets | src/utils/PerfUtils.js | getHealthReport | function getHealthReport() {
var healthReport = {
projectLoadTimes : "",
fileOpenTimes : ""
};
_.forEach(perfData, function (entry, testName) {
if (StringUtils.startsWith(testName, "Application Startup")) {
healthReport.AppStartupTime = getValueAsString(entry);
} else if (StringUtils.startsWith(testName, "brackets module dependencies resolved")) {
healthReport.ModuleDepsResolved = getValueAsString(entry);
} else if (StringUtils.startsWith(testName, "Load Project")) {
healthReport.projectLoadTimes += ":" + getValueAsString(entry, true);
} else if (StringUtils.startsWith(testName, "Open File")) {
healthReport.fileOpenTimes += ":" + getValueAsString(entry, true);
}
});
return healthReport;
} | javascript | function getHealthReport() {
var healthReport = {
projectLoadTimes : "",
fileOpenTimes : ""
};
_.forEach(perfData, function (entry, testName) {
if (StringUtils.startsWith(testName, "Application Startup")) {
healthReport.AppStartupTime = getValueAsString(entry);
} else if (StringUtils.startsWith(testName, "brackets module dependencies resolved")) {
healthReport.ModuleDepsResolved = getValueAsString(entry);
} else if (StringUtils.startsWith(testName, "Load Project")) {
healthReport.projectLoadTimes += ":" + getValueAsString(entry, true);
} else if (StringUtils.startsWith(testName, "Open File")) {
healthReport.fileOpenTimes += ":" + getValueAsString(entry, true);
}
});
return healthReport;
} | [
"function",
"getHealthReport",
"(",
")",
"{",
"var",
"healthReport",
"=",
"{",
"projectLoadTimes",
":",
"\"\"",
",",
"fileOpenTimes",
":",
"\"\"",
"}",
";",
"_",
".",
"forEach",
"(",
"perfData",
",",
"function",
"(",
"entry",
",",
"testName",
")",
"{",
"if",
"(",
"StringUtils",
".",
"startsWith",
"(",
"testName",
",",
"\"Application Startup\"",
")",
")",
"{",
"healthReport",
".",
"AppStartupTime",
"=",
"getValueAsString",
"(",
"entry",
")",
";",
"}",
"else",
"if",
"(",
"StringUtils",
".",
"startsWith",
"(",
"testName",
",",
"\"brackets module dependencies resolved\"",
")",
")",
"{",
"healthReport",
".",
"ModuleDepsResolved",
"=",
"getValueAsString",
"(",
"entry",
")",
";",
"}",
"else",
"if",
"(",
"StringUtils",
".",
"startsWith",
"(",
"testName",
",",
"\"Load Project\"",
")",
")",
"{",
"healthReport",
".",
"projectLoadTimes",
"+=",
"\":\"",
"+",
"getValueAsString",
"(",
"entry",
",",
"true",
")",
";",
"}",
"else",
"if",
"(",
"StringUtils",
".",
"startsWith",
"(",
"testName",
",",
"\"Open File\"",
")",
")",
"{",
"healthReport",
".",
"fileOpenTimes",
"+=",
"\":\"",
"+",
"getValueAsString",
"(",
"entry",
",",
"true",
")",
";",
"}",
"}",
")",
";",
"return",
"healthReport",
";",
"}"
] | Returns the Performance metrics to be logged for health report
@return {Object} An object with the health data logs to be sent | [
"Returns",
"the",
"Performance",
"metrics",
"to",
"be",
"logged",
"for",
"health",
"report"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/PerfUtils.js#L368-L387 |
2,382 | adobe/brackets | src/language/HTMLUtils.js | getTagAttributes | function getTagAttributes(editor, pos) {
var attrs = [],
backwardCtx = TokenUtils.getInitialContext(editor._codeMirror, pos),
forwardCtx = $.extend({}, backwardCtx);
if (editor.getModeForSelection() === "html") {
if (backwardCtx.token && !tagPrefixedRegExp.test(backwardCtx.token.type)) {
while (TokenUtils.movePrevToken(backwardCtx) && !tagPrefixedRegExp.test(backwardCtx.token.type)) {
if (backwardCtx.token.type === "error" && backwardCtx.token.string.indexOf("<") === 0) {
break;
}
if (backwardCtx.token.type === "attribute") {
attrs.push(backwardCtx.token.string);
}
}
while (TokenUtils.moveNextToken(forwardCtx) && !tagPrefixedRegExp.test(forwardCtx.token.type)) {
if (forwardCtx.token.type === "attribute") {
// If the current tag is not closed, codemirror may return the next opening
// tag as an attribute. Stop the search loop in that case.
if (forwardCtx.token.string.indexOf("<") === 0) {
break;
}
attrs.push(forwardCtx.token.string);
} else if (forwardCtx.token.type === "error") {
if (forwardCtx.token.string.indexOf("<") === 0 || forwardCtx.token.string.indexOf(">") === 0) {
break;
}
// If we type the first letter of the next attribute, it comes as an error
// token. We need to double check for possible invalidated attributes.
if (/\S/.test(forwardCtx.token.string) &&
forwardCtx.token.string.indexOf("\"") === -1 &&
forwardCtx.token.string.indexOf("'") === -1 &&
forwardCtx.token.string.indexOf("=") === -1) {
attrs.push(forwardCtx.token.string);
}
}
}
}
}
return attrs;
} | javascript | function getTagAttributes(editor, pos) {
var attrs = [],
backwardCtx = TokenUtils.getInitialContext(editor._codeMirror, pos),
forwardCtx = $.extend({}, backwardCtx);
if (editor.getModeForSelection() === "html") {
if (backwardCtx.token && !tagPrefixedRegExp.test(backwardCtx.token.type)) {
while (TokenUtils.movePrevToken(backwardCtx) && !tagPrefixedRegExp.test(backwardCtx.token.type)) {
if (backwardCtx.token.type === "error" && backwardCtx.token.string.indexOf("<") === 0) {
break;
}
if (backwardCtx.token.type === "attribute") {
attrs.push(backwardCtx.token.string);
}
}
while (TokenUtils.moveNextToken(forwardCtx) && !tagPrefixedRegExp.test(forwardCtx.token.type)) {
if (forwardCtx.token.type === "attribute") {
// If the current tag is not closed, codemirror may return the next opening
// tag as an attribute. Stop the search loop in that case.
if (forwardCtx.token.string.indexOf("<") === 0) {
break;
}
attrs.push(forwardCtx.token.string);
} else if (forwardCtx.token.type === "error") {
if (forwardCtx.token.string.indexOf("<") === 0 || forwardCtx.token.string.indexOf(">") === 0) {
break;
}
// If we type the first letter of the next attribute, it comes as an error
// token. We need to double check for possible invalidated attributes.
if (/\S/.test(forwardCtx.token.string) &&
forwardCtx.token.string.indexOf("\"") === -1 &&
forwardCtx.token.string.indexOf("'") === -1 &&
forwardCtx.token.string.indexOf("=") === -1) {
attrs.push(forwardCtx.token.string);
}
}
}
}
}
return attrs;
} | [
"function",
"getTagAttributes",
"(",
"editor",
",",
"pos",
")",
"{",
"var",
"attrs",
"=",
"[",
"]",
",",
"backwardCtx",
"=",
"TokenUtils",
".",
"getInitialContext",
"(",
"editor",
".",
"_codeMirror",
",",
"pos",
")",
",",
"forwardCtx",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"backwardCtx",
")",
";",
"if",
"(",
"editor",
".",
"getModeForSelection",
"(",
")",
"===",
"\"html\"",
")",
"{",
"if",
"(",
"backwardCtx",
".",
"token",
"&&",
"!",
"tagPrefixedRegExp",
".",
"test",
"(",
"backwardCtx",
".",
"token",
".",
"type",
")",
")",
"{",
"while",
"(",
"TokenUtils",
".",
"movePrevToken",
"(",
"backwardCtx",
")",
"&&",
"!",
"tagPrefixedRegExp",
".",
"test",
"(",
"backwardCtx",
".",
"token",
".",
"type",
")",
")",
"{",
"if",
"(",
"backwardCtx",
".",
"token",
".",
"type",
"===",
"\"error\"",
"&&",
"backwardCtx",
".",
"token",
".",
"string",
".",
"indexOf",
"(",
"\"<\"",
")",
"===",
"0",
")",
"{",
"break",
";",
"}",
"if",
"(",
"backwardCtx",
".",
"token",
".",
"type",
"===",
"\"attribute\"",
")",
"{",
"attrs",
".",
"push",
"(",
"backwardCtx",
".",
"token",
".",
"string",
")",
";",
"}",
"}",
"while",
"(",
"TokenUtils",
".",
"moveNextToken",
"(",
"forwardCtx",
")",
"&&",
"!",
"tagPrefixedRegExp",
".",
"test",
"(",
"forwardCtx",
".",
"token",
".",
"type",
")",
")",
"{",
"if",
"(",
"forwardCtx",
".",
"token",
".",
"type",
"===",
"\"attribute\"",
")",
"{",
"// If the current tag is not closed, codemirror may return the next opening",
"// tag as an attribute. Stop the search loop in that case.",
"if",
"(",
"forwardCtx",
".",
"token",
".",
"string",
".",
"indexOf",
"(",
"\"<\"",
")",
"===",
"0",
")",
"{",
"break",
";",
"}",
"attrs",
".",
"push",
"(",
"forwardCtx",
".",
"token",
".",
"string",
")",
";",
"}",
"else",
"if",
"(",
"forwardCtx",
".",
"token",
".",
"type",
"===",
"\"error\"",
")",
"{",
"if",
"(",
"forwardCtx",
".",
"token",
".",
"string",
".",
"indexOf",
"(",
"\"<\"",
")",
"===",
"0",
"||",
"forwardCtx",
".",
"token",
".",
"string",
".",
"indexOf",
"(",
"\">\"",
")",
"===",
"0",
")",
"{",
"break",
";",
"}",
"// If we type the first letter of the next attribute, it comes as an error",
"// token. We need to double check for possible invalidated attributes.",
"if",
"(",
"/",
"\\S",
"/",
".",
"test",
"(",
"forwardCtx",
".",
"token",
".",
"string",
")",
"&&",
"forwardCtx",
".",
"token",
".",
"string",
".",
"indexOf",
"(",
"\"\\\"\"",
")",
"===",
"-",
"1",
"&&",
"forwardCtx",
".",
"token",
".",
"string",
".",
"indexOf",
"(",
"\"'\"",
")",
"===",
"-",
"1",
"&&",
"forwardCtx",
".",
"token",
".",
"string",
".",
"indexOf",
"(",
"\"=\"",
")",
"===",
"-",
"1",
")",
"{",
"attrs",
".",
"push",
"(",
"forwardCtx",
".",
"token",
".",
"string",
")",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"attrs",
";",
"}"
] | Compiles a list of used attributes for a given tag
@param {CodeMirror} editor An instance of a CodeMirror editor
@param {ch:{string}, line:{number}} pos A CodeMirror position
@return {Array.<string>} A list of the used attributes inside the current tag | [
"Compiles",
"a",
"list",
"of",
"used",
"attributes",
"for",
"a",
"given",
"tag"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/HTMLUtils.js#L131-L173 |
2,383 | adobe/brackets | src/language/HTMLUtils.js | createTagInfo | function createTagInfo(tokenType, offset, tagName, attrName, attrValue, valueAssigned, quoteChar, hasEndQuote) {
return { tagName: tagName || "",
attr:
{ name: attrName || "",
value: attrValue || "",
valueAssigned: valueAssigned || false,
quoteChar: quoteChar || "",
hasEndQuote: hasEndQuote || false },
position:
{ tokenType: tokenType || "",
offset: offset || 0 } };
} | javascript | function createTagInfo(tokenType, offset, tagName, attrName, attrValue, valueAssigned, quoteChar, hasEndQuote) {
return { tagName: tagName || "",
attr:
{ name: attrName || "",
value: attrValue || "",
valueAssigned: valueAssigned || false,
quoteChar: quoteChar || "",
hasEndQuote: hasEndQuote || false },
position:
{ tokenType: tokenType || "",
offset: offset || 0 } };
} | [
"function",
"createTagInfo",
"(",
"tokenType",
",",
"offset",
",",
"tagName",
",",
"attrName",
",",
"attrValue",
",",
"valueAssigned",
",",
"quoteChar",
",",
"hasEndQuote",
")",
"{",
"return",
"{",
"tagName",
":",
"tagName",
"||",
"\"\"",
",",
"attr",
":",
"{",
"name",
":",
"attrName",
"||",
"\"\"",
",",
"value",
":",
"attrValue",
"||",
"\"\"",
",",
"valueAssigned",
":",
"valueAssigned",
"||",
"false",
",",
"quoteChar",
":",
"quoteChar",
"||",
"\"\"",
",",
"hasEndQuote",
":",
"hasEndQuote",
"||",
"false",
"}",
",",
"position",
":",
"{",
"tokenType",
":",
"tokenType",
"||",
"\"\"",
",",
"offset",
":",
"offset",
"||",
"0",
"}",
"}",
";",
"}"
] | Creates a tagInfo object and assures all the values are entered or are empty strings
@param {string=} tokenType what is getting edited and should be hinted
@param {number=} offset where the cursor is for the part getting hinted
@param {string=} tagName The name of the tag
@param {string=} attrName The name of the attribute
@param {string=} attrValue The value of the attribute
@return {{tagName:string,
attr:{name:string, value:string, valueAssigned:boolean, quoteChar:string, hasEndQuote:boolean},
position:{tokenType:string, offset:number}
}}
A tagInfo object with some context about the current tag hint. | [
"Creates",
"a",
"tagInfo",
"object",
"and",
"assures",
"all",
"the",
"values",
"are",
"entered",
"or",
"are",
"empty",
"strings"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/HTMLUtils.js#L188-L199 |
2,384 | adobe/brackets | src/extensions/default/CodeFolding/foldhelpers/handlebarsFold.js | scanTextUntil | function scanTextUntil(cm, startCh, startLine, condition) {
var line = cm.getLine(startLine),
seen = "",
characterIndex = startCh,
currentLine = startLine,
range;
while (currentLine <= cm.lastLine()) {
if (line.length === 0) {
characterIndex = 0;
line = cm.getLine(++currentLine);
} else {
seen = seen.concat(line[characterIndex] || "");
if (condition(seen)) {
range = {
from: {ch: startCh, line: startLine},
to: {ch: characterIndex, line: currentLine},
string: seen
};
return range;
} else if (characterIndex >= line.length) {
seen = seen.concat(cm.lineSeparator());
if (condition(seen)) {
range = {
from: {ch: startCh, line: startLine},
to: {ch: characterIndex, line: currentLine},
string: seen
};
return range;
}
characterIndex = 0;
line = cm.getLine(++currentLine);
} else {
++characterIndex;
}
}
}
} | javascript | function scanTextUntil(cm, startCh, startLine, condition) {
var line = cm.getLine(startLine),
seen = "",
characterIndex = startCh,
currentLine = startLine,
range;
while (currentLine <= cm.lastLine()) {
if (line.length === 0) {
characterIndex = 0;
line = cm.getLine(++currentLine);
} else {
seen = seen.concat(line[characterIndex] || "");
if (condition(seen)) {
range = {
from: {ch: startCh, line: startLine},
to: {ch: characterIndex, line: currentLine},
string: seen
};
return range;
} else if (characterIndex >= line.length) {
seen = seen.concat(cm.lineSeparator());
if (condition(seen)) {
range = {
from: {ch: startCh, line: startLine},
to: {ch: characterIndex, line: currentLine},
string: seen
};
return range;
}
characterIndex = 0;
line = cm.getLine(++currentLine);
} else {
++characterIndex;
}
}
}
} | [
"function",
"scanTextUntil",
"(",
"cm",
",",
"startCh",
",",
"startLine",
",",
"condition",
")",
"{",
"var",
"line",
"=",
"cm",
".",
"getLine",
"(",
"startLine",
")",
",",
"seen",
"=",
"\"\"",
",",
"characterIndex",
"=",
"startCh",
",",
"currentLine",
"=",
"startLine",
",",
"range",
";",
"while",
"(",
"currentLine",
"<=",
"cm",
".",
"lastLine",
"(",
")",
")",
"{",
"if",
"(",
"line",
".",
"length",
"===",
"0",
")",
"{",
"characterIndex",
"=",
"0",
";",
"line",
"=",
"cm",
".",
"getLine",
"(",
"++",
"currentLine",
")",
";",
"}",
"else",
"{",
"seen",
"=",
"seen",
".",
"concat",
"(",
"line",
"[",
"characterIndex",
"]",
"||",
"\"\"",
")",
";",
"if",
"(",
"condition",
"(",
"seen",
")",
")",
"{",
"range",
"=",
"{",
"from",
":",
"{",
"ch",
":",
"startCh",
",",
"line",
":",
"startLine",
"}",
",",
"to",
":",
"{",
"ch",
":",
"characterIndex",
",",
"line",
":",
"currentLine",
"}",
",",
"string",
":",
"seen",
"}",
";",
"return",
"range",
";",
"}",
"else",
"if",
"(",
"characterIndex",
">=",
"line",
".",
"length",
")",
"{",
"seen",
"=",
"seen",
".",
"concat",
"(",
"cm",
".",
"lineSeparator",
"(",
")",
")",
";",
"if",
"(",
"condition",
"(",
"seen",
")",
")",
"{",
"range",
"=",
"{",
"from",
":",
"{",
"ch",
":",
"startCh",
",",
"line",
":",
"startLine",
"}",
",",
"to",
":",
"{",
"ch",
":",
"characterIndex",
",",
"line",
":",
"currentLine",
"}",
",",
"string",
":",
"seen",
"}",
";",
"return",
"range",
";",
"}",
"characterIndex",
"=",
"0",
";",
"line",
"=",
"cm",
".",
"getLine",
"(",
"++",
"currentLine",
")",
";",
"}",
"else",
"{",
"++",
"characterIndex",
";",
"}",
"}",
"}",
"}"
] | Utility function for scanning the text in a document until a certain condition is met
@param {object} cm The code mirror object representing the document
@param {string} startCh The start character position for the scan operation
@param {number} startLine The start line position for the scan operation
@param {function (string): boolean} condition A predicate function that takes in the text seen so far and returns true if the scanning process should be halted
@returns {{from:CodeMirror.Pos, to: CodeMirror.Pos, string: string}} An object representing the range of text scanned. | [
"Utility",
"function",
"for",
"scanning",
"the",
"text",
"in",
"a",
"document",
"until",
"a",
"certain",
"condition",
"is",
"met"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/handlebarsFold.js#L44-L80 |
2,385 | adobe/brackets | src/LiveDevelopment/Agents/CSSAgent.js | styleForURL | function styleForURL(url) {
var styleSheetId, styles = {};
url = _canonicalize(url);
for (styleSheetId in _styleSheetDetails) {
if (_styleSheetDetails[styleSheetId].canonicalizedURL === url) {
styles[styleSheetId] = _styleSheetDetails[styleSheetId];
}
}
return styles;
} | javascript | function styleForURL(url) {
var styleSheetId, styles = {};
url = _canonicalize(url);
for (styleSheetId in _styleSheetDetails) {
if (_styleSheetDetails[styleSheetId].canonicalizedURL === url) {
styles[styleSheetId] = _styleSheetDetails[styleSheetId];
}
}
return styles;
} | [
"function",
"styleForURL",
"(",
"url",
")",
"{",
"var",
"styleSheetId",
",",
"styles",
"=",
"{",
"}",
";",
"url",
"=",
"_canonicalize",
"(",
"url",
")",
";",
"for",
"(",
"styleSheetId",
"in",
"_styleSheetDetails",
")",
"{",
"if",
"(",
"_styleSheetDetails",
"[",
"styleSheetId",
"]",
".",
"canonicalizedURL",
"===",
"url",
")",
"{",
"styles",
"[",
"styleSheetId",
"]",
"=",
"_styleSheetDetails",
"[",
"styleSheetId",
"]",
";",
"}",
"}",
"return",
"styles",
";",
"}"
] | Get the style sheets for a url
@param {string} url
@return {Object.<string, CSSStyleSheetHeader>} | [
"Get",
"the",
"style",
"sheets",
"for",
"a",
"url"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/CSSAgent.js#L81-L90 |
2,386 | adobe/brackets | src/LiveDevelopment/Agents/CSSAgent.js | reloadCSSForDocument | function reloadCSSForDocument(doc, newContent) {
var styles = styleForURL(doc.url),
styleSheetId,
deferreds = [];
if (newContent === undefined) {
newContent = doc.getText();
}
for (styleSheetId in styles) {
deferreds.push(Inspector.CSS.setStyleSheetText(styles[styleSheetId].styleSheetId, newContent));
}
if (!deferreds.length) {
console.error("Style Sheet for document not loaded: " + doc.url);
return new $.Deferred().reject().promise();
}
// return master deferred
return $.when.apply($, deferreds);
} | javascript | function reloadCSSForDocument(doc, newContent) {
var styles = styleForURL(doc.url),
styleSheetId,
deferreds = [];
if (newContent === undefined) {
newContent = doc.getText();
}
for (styleSheetId in styles) {
deferreds.push(Inspector.CSS.setStyleSheetText(styles[styleSheetId].styleSheetId, newContent));
}
if (!deferreds.length) {
console.error("Style Sheet for document not loaded: " + doc.url);
return new $.Deferred().reject().promise();
}
// return master deferred
return $.when.apply($, deferreds);
} | [
"function",
"reloadCSSForDocument",
"(",
"doc",
",",
"newContent",
")",
"{",
"var",
"styles",
"=",
"styleForURL",
"(",
"doc",
".",
"url",
")",
",",
"styleSheetId",
",",
"deferreds",
"=",
"[",
"]",
";",
"if",
"(",
"newContent",
"===",
"undefined",
")",
"{",
"newContent",
"=",
"doc",
".",
"getText",
"(",
")",
";",
"}",
"for",
"(",
"styleSheetId",
"in",
"styles",
")",
"{",
"deferreds",
".",
"push",
"(",
"Inspector",
".",
"CSS",
".",
"setStyleSheetText",
"(",
"styles",
"[",
"styleSheetId",
"]",
".",
"styleSheetId",
",",
"newContent",
")",
")",
";",
"}",
"if",
"(",
"!",
"deferreds",
".",
"length",
")",
"{",
"console",
".",
"error",
"(",
"\"Style Sheet for document not loaded: \"",
"+",
"doc",
".",
"url",
")",
";",
"return",
"new",
"$",
".",
"Deferred",
"(",
")",
".",
"reject",
"(",
")",
".",
"promise",
"(",
")",
";",
"}",
"// return master deferred",
"return",
"$",
".",
"when",
".",
"apply",
"(",
"$",
",",
"deferreds",
")",
";",
"}"
] | Reload a CSS style sheet from a document
@param {Document} document
@param {string=} newContent new content of every stylesheet. Defaults to doc.getText() if omitted
@return {jQuery.Promise} | [
"Reload",
"a",
"CSS",
"style",
"sheet",
"from",
"a",
"document"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/CSSAgent.js#L98-L115 |
2,387 | adobe/brackets | src/search/FindInFiles.js | _removeListeners | function _removeListeners() {
DocumentModule.off("documentChange", _documentChangeHandler);
FileSystem.off("change", _debouncedFileSystemChangeHandler);
DocumentManager.off("fileNameChange", _fileNameChangeHandler);
} | javascript | function _removeListeners() {
DocumentModule.off("documentChange", _documentChangeHandler);
FileSystem.off("change", _debouncedFileSystemChangeHandler);
DocumentManager.off("fileNameChange", _fileNameChangeHandler);
} | [
"function",
"_removeListeners",
"(",
")",
"{",
"DocumentModule",
".",
"off",
"(",
"\"documentChange\"",
",",
"_documentChangeHandler",
")",
";",
"FileSystem",
".",
"off",
"(",
"\"change\"",
",",
"_debouncedFileSystemChangeHandler",
")",
";",
"DocumentManager",
".",
"off",
"(",
"\"fileNameChange\"",
",",
"_fileNameChangeHandler",
")",
";",
"}"
] | Remove the listeners that were tracking potential search result changes | [
"Remove",
"the",
"listeners",
"that",
"were",
"tracking",
"potential",
"search",
"result",
"changes"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindInFiles.js#L91-L95 |
2,388 | adobe/brackets | src/search/FindInFiles.js | _addListeners | function _addListeners() {
// Avoid adding duplicate listeners - e.g. if a 2nd search is run without closing the old results panel first
_removeListeners();
DocumentModule.on("documentChange", _documentChangeHandler);
FileSystem.on("change", _debouncedFileSystemChangeHandler);
DocumentManager.on("fileNameChange", _fileNameChangeHandler);
} | javascript | function _addListeners() {
// Avoid adding duplicate listeners - e.g. if a 2nd search is run without closing the old results panel first
_removeListeners();
DocumentModule.on("documentChange", _documentChangeHandler);
FileSystem.on("change", _debouncedFileSystemChangeHandler);
DocumentManager.on("fileNameChange", _fileNameChangeHandler);
} | [
"function",
"_addListeners",
"(",
")",
"{",
"// Avoid adding duplicate listeners - e.g. if a 2nd search is run without closing the old results panel first",
"_removeListeners",
"(",
")",
";",
"DocumentModule",
".",
"on",
"(",
"\"documentChange\"",
",",
"_documentChangeHandler",
")",
";",
"FileSystem",
".",
"on",
"(",
"\"change\"",
",",
"_debouncedFileSystemChangeHandler",
")",
";",
"DocumentManager",
".",
"on",
"(",
"\"fileNameChange\"",
",",
"_fileNameChangeHandler",
")",
";",
"}"
] | Add listeners to track events that might change the search result set | [
"Add",
"listeners",
"to",
"track",
"events",
"that",
"might",
"change",
"the",
"search",
"result",
"set"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindInFiles.js#L98-L105 |
2,389 | adobe/brackets | src/search/FindInFiles.js | getCandidateFiles | function getCandidateFiles(scope) {
function filter(file) {
return _subtreeFilter(file, scope) && _isReadableText(file.fullPath);
}
// If the scope is a single file, just check if the file passes the filter directly rather than
// trying to use ProjectManager.getAllFiles(), both for performance and because an individual
// in-memory file might be an untitled document that doesn't show up in getAllFiles().
if (scope && scope.isFile) {
return new $.Deferred().resolve(filter(scope) ? [scope] : []).promise();
} else {
return ProjectManager.getAllFiles(filter, true, true);
}
} | javascript | function getCandidateFiles(scope) {
function filter(file) {
return _subtreeFilter(file, scope) && _isReadableText(file.fullPath);
}
// If the scope is a single file, just check if the file passes the filter directly rather than
// trying to use ProjectManager.getAllFiles(), both for performance and because an individual
// in-memory file might be an untitled document that doesn't show up in getAllFiles().
if (scope && scope.isFile) {
return new $.Deferred().resolve(filter(scope) ? [scope] : []).promise();
} else {
return ProjectManager.getAllFiles(filter, true, true);
}
} | [
"function",
"getCandidateFiles",
"(",
"scope",
")",
"{",
"function",
"filter",
"(",
"file",
")",
"{",
"return",
"_subtreeFilter",
"(",
"file",
",",
"scope",
")",
"&&",
"_isReadableText",
"(",
"file",
".",
"fullPath",
")",
";",
"}",
"// If the scope is a single file, just check if the file passes the filter directly rather than",
"// trying to use ProjectManager.getAllFiles(), both for performance and because an individual",
"// in-memory file might be an untitled document that doesn't show up in getAllFiles().",
"if",
"(",
"scope",
"&&",
"scope",
".",
"isFile",
")",
"{",
"return",
"new",
"$",
".",
"Deferred",
"(",
")",
".",
"resolve",
"(",
"filter",
"(",
"scope",
")",
"?",
"[",
"scope",
"]",
":",
"[",
"]",
")",
".",
"promise",
"(",
")",
";",
"}",
"else",
"{",
"return",
"ProjectManager",
".",
"getAllFiles",
"(",
"filter",
",",
"true",
",",
"true",
")",
";",
"}",
"}"
] | Finds all candidate files to search in the given scope's subtree that are not binary content. Does NOT apply
the current filter yet.
@param {?FileSystemEntry} scope Search scope, or null if whole project
@return {$.Promise} A promise that will be resolved with the list of files in the scope. Never rejected. | [
"Finds",
"all",
"candidate",
"files",
"to",
"search",
"in",
"the",
"given",
"scope",
"s",
"subtree",
"that",
"are",
"not",
"binary",
"content",
".",
"Does",
"NOT",
"apply",
"the",
"current",
"filter",
"yet",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindInFiles.js#L350-L363 |
2,390 | adobe/brackets | src/search/FindInFiles.js | doSearchInScope | function doSearchInScope(queryInfo, scope, filter, replaceText, candidateFilesPromise) {
clearSearch();
searchModel.scope = scope;
if (replaceText !== undefined) {
searchModel.isReplace = true;
searchModel.replaceText = replaceText;
}
candidateFilesPromise = candidateFilesPromise || getCandidateFiles(scope);
return _doSearch(queryInfo, candidateFilesPromise, filter);
} | javascript | function doSearchInScope(queryInfo, scope, filter, replaceText, candidateFilesPromise) {
clearSearch();
searchModel.scope = scope;
if (replaceText !== undefined) {
searchModel.isReplace = true;
searchModel.replaceText = replaceText;
}
candidateFilesPromise = candidateFilesPromise || getCandidateFiles(scope);
return _doSearch(queryInfo, candidateFilesPromise, filter);
} | [
"function",
"doSearchInScope",
"(",
"queryInfo",
",",
"scope",
",",
"filter",
",",
"replaceText",
",",
"candidateFilesPromise",
")",
"{",
"clearSearch",
"(",
")",
";",
"searchModel",
".",
"scope",
"=",
"scope",
";",
"if",
"(",
"replaceText",
"!==",
"undefined",
")",
"{",
"searchModel",
".",
"isReplace",
"=",
"true",
";",
"searchModel",
".",
"replaceText",
"=",
"replaceText",
";",
"}",
"candidateFilesPromise",
"=",
"candidateFilesPromise",
"||",
"getCandidateFiles",
"(",
"scope",
")",
";",
"return",
"_doSearch",
"(",
"queryInfo",
",",
"candidateFilesPromise",
",",
"filter",
")",
";",
"}"
] | Does a search in the given scope with the given filter. Used when you want to start a search
programmatically.
@param {{query: string, caseSensitive: boolean, isRegexp: boolean}} queryInfo Query info object
@param {?Entry} scope Project file/subfolder to search within; else searches whole project.
@param {?string} filter A "compiled" filter as returned by FileFilters.compile(), or null for no filter
@param {?string} replaceText If this is a replacement, the text to replace matches with. This is just
stored in the model for later use - the replacement is not actually performed right now.
@param {?$.Promise} candidateFilesPromise If specified, a promise that should resolve with the same set of files that
getCandidateFiles(scope) would return.
@return {$.Promise} A promise that's resolved with the search results or rejected when the find competes. | [
"Does",
"a",
"search",
"in",
"the",
"given",
"scope",
"with",
"the",
"given",
"filter",
".",
"Used",
"when",
"you",
"want",
"to",
"start",
"a",
"search",
"programmatically",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindInFiles.js#L619-L628 |
2,391 | adobe/brackets | src/search/FindInFiles.js | doReplace | function doReplace(results, replaceText, options) {
return FindUtils.performReplacements(results, replaceText, options).always(function () {
// For UI integration testing only
exports._replaceDone = true;
});
} | javascript | function doReplace(results, replaceText, options) {
return FindUtils.performReplacements(results, replaceText, options).always(function () {
// For UI integration testing only
exports._replaceDone = true;
});
} | [
"function",
"doReplace",
"(",
"results",
",",
"replaceText",
",",
"options",
")",
"{",
"return",
"FindUtils",
".",
"performReplacements",
"(",
"results",
",",
"replaceText",
",",
"options",
")",
".",
"always",
"(",
"function",
"(",
")",
"{",
"// For UI integration testing only",
"exports",
".",
"_replaceDone",
"=",
"true",
";",
"}",
")",
";",
"}"
] | Given a set of search results, replaces them with the given replaceText, either on disk or in memory.
@param {Object.<fullPath: string, {matches: Array.<{start: {line:number,ch:number}, end: {line:number,ch:number}, startOffset: number, endOffset: number, line: string}>, collapsed: boolean}>} results
The list of results to replace, as returned from _doSearch..
@param {string} replaceText The text to replace each result with.
@param {?Object} options An options object:
forceFilesOpen: boolean - Whether to open all files in editors and do replacements there rather than doing the
replacements on disk. Note that even if this is false, files that are already open in editors will have replacements
done in memory.
isRegexp: boolean - Whether the original query was a regexp. If true, $-substitution is performed on the replaceText.
@return {$.Promise} A promise that's resolved when the replacement is finished or rejected with an array of errors
if there were one or more errors. Each individual item in the array will be a {item: string, error: string} object,
where item is the full path to the file that could not be updated, and error is either a FileSystem error or one
of the `FindInFiles.ERROR_*` constants. | [
"Given",
"a",
"set",
"of",
"search",
"results",
"replaces",
"them",
"with",
"the",
"given",
"replaceText",
"either",
"on",
"disk",
"or",
"in",
"memory",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindInFiles.js#L645-L650 |
2,392 | adobe/brackets | src/search/FindInFiles.js | filesChanged | function filesChanged(fileList) {
if (FindUtils.isNodeSearchDisabled() || !fileList || fileList.length === 0) {
return;
}
var updateObject = {
"fileList": fileList
};
if (searchModel.filter) {
updateObject.filesInSearchScope = FileFilters.getPathsMatchingFilter(searchModel.filter, fileList);
_searchScopeChanged();
}
searchDomain.exec("filesChanged", updateObject);
} | javascript | function filesChanged(fileList) {
if (FindUtils.isNodeSearchDisabled() || !fileList || fileList.length === 0) {
return;
}
var updateObject = {
"fileList": fileList
};
if (searchModel.filter) {
updateObject.filesInSearchScope = FileFilters.getPathsMatchingFilter(searchModel.filter, fileList);
_searchScopeChanged();
}
searchDomain.exec("filesChanged", updateObject);
} | [
"function",
"filesChanged",
"(",
"fileList",
")",
"{",
"if",
"(",
"FindUtils",
".",
"isNodeSearchDisabled",
"(",
")",
"||",
"!",
"fileList",
"||",
"fileList",
".",
"length",
"===",
"0",
")",
"{",
"return",
";",
"}",
"var",
"updateObject",
"=",
"{",
"\"fileList\"",
":",
"fileList",
"}",
";",
"if",
"(",
"searchModel",
".",
"filter",
")",
"{",
"updateObject",
".",
"filesInSearchScope",
"=",
"FileFilters",
".",
"getPathsMatchingFilter",
"(",
"searchModel",
".",
"filter",
",",
"fileList",
")",
";",
"_searchScopeChanged",
"(",
")",
";",
"}",
"searchDomain",
".",
"exec",
"(",
"\"filesChanged\"",
",",
"updateObject",
")",
";",
"}"
] | Inform node that the list of files has changed.
@param {array} fileList The list of files that changed. | [
"Inform",
"node",
"that",
"the",
"list",
"of",
"files",
"has",
"changed",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindInFiles.js#L674-L686 |
2,393 | adobe/brackets | src/search/FindInFiles.js | function (child) {
// Replicate filtering that getAllFiles() does
if (ProjectManager.shouldShow(child)) {
if (child.isFile && _isReadableText(child.name)) {
// Re-check the filtering that the initial search applied
if (_inSearchScope(child)) {
addedFiles.push(child);
addedFilePaths.push(child.fullPath);
}
}
return true;
}
return false;
} | javascript | function (child) {
// Replicate filtering that getAllFiles() does
if (ProjectManager.shouldShow(child)) {
if (child.isFile && _isReadableText(child.name)) {
// Re-check the filtering that the initial search applied
if (_inSearchScope(child)) {
addedFiles.push(child);
addedFilePaths.push(child.fullPath);
}
}
return true;
}
return false;
} | [
"function",
"(",
"child",
")",
"{",
"// Replicate filtering that getAllFiles() does",
"if",
"(",
"ProjectManager",
".",
"shouldShow",
"(",
"child",
")",
")",
"{",
"if",
"(",
"child",
".",
"isFile",
"&&",
"_isReadableText",
"(",
"child",
".",
"name",
")",
")",
"{",
"// Re-check the filtering that the initial search applied",
"if",
"(",
"_inSearchScope",
"(",
"child",
")",
")",
"{",
"addedFiles",
".",
"push",
"(",
"child",
")",
";",
"addedFilePaths",
".",
"push",
"(",
"child",
".",
"fullPath",
")",
";",
"}",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | gather up added files | [
"gather",
"up",
"added",
"files"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindInFiles.js#L783-L796 |
|
2,394 | adobe/brackets | src/search/FindInFiles.js | function () {
function filter(file) {
return _subtreeFilter(file, null) && _isReadableText(file.fullPath);
}
FindUtils.setInstantSearchDisabled(true);
//we always listen for filesytem changes.
_addListeners();
if (!PreferencesManager.get("findInFiles.nodeSearch")) {
return;
}
ProjectManager.getAllFiles(filter, true, true)
.done(function (fileListResult) {
var files = fileListResult,
filter = FileFilters.getActiveFilter();
if (filter && filter.patterns.length > 0) {
files = FileFilters.filterFileList(FileFilters.compile(filter.patterns), files);
}
files = files.filter(function (entry) {
return entry.isFile && _isReadableText(entry.fullPath);
}).map(function (entry) {
return entry.fullPath;
});
FindUtils.notifyIndexingStarted();
searchDomain.exec("initCache", files);
});
_searchScopeChanged();
} | javascript | function () {
function filter(file) {
return _subtreeFilter(file, null) && _isReadableText(file.fullPath);
}
FindUtils.setInstantSearchDisabled(true);
//we always listen for filesytem changes.
_addListeners();
if (!PreferencesManager.get("findInFiles.nodeSearch")) {
return;
}
ProjectManager.getAllFiles(filter, true, true)
.done(function (fileListResult) {
var files = fileListResult,
filter = FileFilters.getActiveFilter();
if (filter && filter.patterns.length > 0) {
files = FileFilters.filterFileList(FileFilters.compile(filter.patterns), files);
}
files = files.filter(function (entry) {
return entry.isFile && _isReadableText(entry.fullPath);
}).map(function (entry) {
return entry.fullPath;
});
FindUtils.notifyIndexingStarted();
searchDomain.exec("initCache", files);
});
_searchScopeChanged();
} | [
"function",
"(",
")",
"{",
"function",
"filter",
"(",
"file",
")",
"{",
"return",
"_subtreeFilter",
"(",
"file",
",",
"null",
")",
"&&",
"_isReadableText",
"(",
"file",
".",
"fullPath",
")",
";",
"}",
"FindUtils",
".",
"setInstantSearchDisabled",
"(",
"true",
")",
";",
"//we always listen for filesytem changes.",
"_addListeners",
"(",
")",
";",
"if",
"(",
"!",
"PreferencesManager",
".",
"get",
"(",
"\"findInFiles.nodeSearch\"",
")",
")",
"{",
"return",
";",
"}",
"ProjectManager",
".",
"getAllFiles",
"(",
"filter",
",",
"true",
",",
"true",
")",
".",
"done",
"(",
"function",
"(",
"fileListResult",
")",
"{",
"var",
"files",
"=",
"fileListResult",
",",
"filter",
"=",
"FileFilters",
".",
"getActiveFilter",
"(",
")",
";",
"if",
"(",
"filter",
"&&",
"filter",
".",
"patterns",
".",
"length",
">",
"0",
")",
"{",
"files",
"=",
"FileFilters",
".",
"filterFileList",
"(",
"FileFilters",
".",
"compile",
"(",
"filter",
".",
"patterns",
")",
",",
"files",
")",
";",
"}",
"files",
"=",
"files",
".",
"filter",
"(",
"function",
"(",
"entry",
")",
"{",
"return",
"entry",
".",
"isFile",
"&&",
"_isReadableText",
"(",
"entry",
".",
"fullPath",
")",
";",
"}",
")",
".",
"map",
"(",
"function",
"(",
"entry",
")",
"{",
"return",
"entry",
".",
"fullPath",
";",
"}",
")",
";",
"FindUtils",
".",
"notifyIndexingStarted",
"(",
")",
";",
"searchDomain",
".",
"exec",
"(",
"\"initCache\"",
",",
"files",
")",
";",
"}",
")",
";",
"_searchScopeChanged",
"(",
")",
";",
"}"
] | On project change, inform node about the new list of files that needs to be crawled.
Instant search is also disabled for the time being till the crawl is complete in node. | [
"On",
"project",
"change",
"inform",
"node",
"about",
"the",
"new",
"list",
"of",
"files",
"that",
"needs",
"to",
"be",
"crawled",
".",
"Instant",
"search",
"is",
"also",
"disabled",
"for",
"the",
"time",
"being",
"till",
"the",
"crawl",
"is",
"complete",
"in",
"node",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindInFiles.js#L916-L944 |
|
2,395 | adobe/brackets | src/search/FindInFiles.js | getNextPageofSearchResults | function getNextPageofSearchResults() {
var searchDeferred = $.Deferred();
if (searchModel.allResultsAvailable) {
return searchDeferred.resolve().promise();
}
_updateChangedDocs();
FindUtils.notifyNodeSearchStarted();
searchDomain.exec("nextPage")
.done(function (rcvd_object) {
FindUtils.notifyNodeSearchFinished();
if (searchModel.results) {
var resultEntry;
for (resultEntry in rcvd_object.results ) {
if (rcvd_object.results.hasOwnProperty(resultEntry)) {
searchModel.results[resultEntry.toString()] = rcvd_object.results[resultEntry];
}
}
} else {
searchModel.results = rcvd_object.results;
}
searchModel.fireChanged();
searchDeferred.resolve();
})
.fail(function () {
FindUtils.notifyNodeSearchFinished();
console.log('node fails');
FindUtils.setNodeSearchDisabled(true);
searchDeferred.reject();
});
return searchDeferred.promise();
} | javascript | function getNextPageofSearchResults() {
var searchDeferred = $.Deferred();
if (searchModel.allResultsAvailable) {
return searchDeferred.resolve().promise();
}
_updateChangedDocs();
FindUtils.notifyNodeSearchStarted();
searchDomain.exec("nextPage")
.done(function (rcvd_object) {
FindUtils.notifyNodeSearchFinished();
if (searchModel.results) {
var resultEntry;
for (resultEntry in rcvd_object.results ) {
if (rcvd_object.results.hasOwnProperty(resultEntry)) {
searchModel.results[resultEntry.toString()] = rcvd_object.results[resultEntry];
}
}
} else {
searchModel.results = rcvd_object.results;
}
searchModel.fireChanged();
searchDeferred.resolve();
})
.fail(function () {
FindUtils.notifyNodeSearchFinished();
console.log('node fails');
FindUtils.setNodeSearchDisabled(true);
searchDeferred.reject();
});
return searchDeferred.promise();
} | [
"function",
"getNextPageofSearchResults",
"(",
")",
"{",
"var",
"searchDeferred",
"=",
"$",
".",
"Deferred",
"(",
")",
";",
"if",
"(",
"searchModel",
".",
"allResultsAvailable",
")",
"{",
"return",
"searchDeferred",
".",
"resolve",
"(",
")",
".",
"promise",
"(",
")",
";",
"}",
"_updateChangedDocs",
"(",
")",
";",
"FindUtils",
".",
"notifyNodeSearchStarted",
"(",
")",
";",
"searchDomain",
".",
"exec",
"(",
"\"nextPage\"",
")",
".",
"done",
"(",
"function",
"(",
"rcvd_object",
")",
"{",
"FindUtils",
".",
"notifyNodeSearchFinished",
"(",
")",
";",
"if",
"(",
"searchModel",
".",
"results",
")",
"{",
"var",
"resultEntry",
";",
"for",
"(",
"resultEntry",
"in",
"rcvd_object",
".",
"results",
")",
"{",
"if",
"(",
"rcvd_object",
".",
"results",
".",
"hasOwnProperty",
"(",
"resultEntry",
")",
")",
"{",
"searchModel",
".",
"results",
"[",
"resultEntry",
".",
"toString",
"(",
")",
"]",
"=",
"rcvd_object",
".",
"results",
"[",
"resultEntry",
"]",
";",
"}",
"}",
"}",
"else",
"{",
"searchModel",
".",
"results",
"=",
"rcvd_object",
".",
"results",
";",
"}",
"searchModel",
".",
"fireChanged",
"(",
")",
";",
"searchDeferred",
".",
"resolve",
"(",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"FindUtils",
".",
"notifyNodeSearchFinished",
"(",
")",
";",
"console",
".",
"log",
"(",
"'node fails'",
")",
";",
"FindUtils",
".",
"setNodeSearchDisabled",
"(",
"true",
")",
";",
"searchDeferred",
".",
"reject",
"(",
")",
";",
"}",
")",
";",
"return",
"searchDeferred",
".",
"promise",
"(",
")",
";",
"}"
] | Gets the next page of search results to append to the result set.
@return {object} A promise that's resolved with the search results or rejected when the find competes. | [
"Gets",
"the",
"next",
"page",
"of",
"search",
"results",
"to",
"append",
"to",
"the",
"result",
"set",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindInFiles.js#L951-L981 |
2,396 | adobe/brackets | src/language/HTMLDOMDiff.js | function (beforeID, isBeingDeleted) {
newEdits.forEach(function (edit) {
// elementDeletes don't need any positioning information
if (edit.type !== "elementDelete") {
edit.beforeID = beforeID;
}
});
edits.push.apply(edits, newEdits);
newEdits = [];
// If the item we made this set of edits relative to
// is being deleted, we can't use it as the afterID for future
// edits. It's okay to just keep the previous afterID, since
// this node will no longer be in the tree by the time we get
// to any future edit that needs an afterID.
if (!isBeingDeleted) {
textAfterID = beforeID;
}
} | javascript | function (beforeID, isBeingDeleted) {
newEdits.forEach(function (edit) {
// elementDeletes don't need any positioning information
if (edit.type !== "elementDelete") {
edit.beforeID = beforeID;
}
});
edits.push.apply(edits, newEdits);
newEdits = [];
// If the item we made this set of edits relative to
// is being deleted, we can't use it as the afterID for future
// edits. It's okay to just keep the previous afterID, since
// this node will no longer be in the tree by the time we get
// to any future edit that needs an afterID.
if (!isBeingDeleted) {
textAfterID = beforeID;
}
} | [
"function",
"(",
"beforeID",
",",
"isBeingDeleted",
")",
"{",
"newEdits",
".",
"forEach",
"(",
"function",
"(",
"edit",
")",
"{",
"// elementDeletes don't need any positioning information",
"if",
"(",
"edit",
".",
"type",
"!==",
"\"elementDelete\"",
")",
"{",
"edit",
".",
"beforeID",
"=",
"beforeID",
";",
"}",
"}",
")",
";",
"edits",
".",
"push",
".",
"apply",
"(",
"edits",
",",
"newEdits",
")",
";",
"newEdits",
"=",
"[",
"]",
";",
"// If the item we made this set of edits relative to",
"// is being deleted, we can't use it as the afterID for future",
"// edits. It's okay to just keep the previous afterID, since",
"// this node will no longer be in the tree by the time we get",
"// to any future edit that needs an afterID.",
"if",
"(",
"!",
"isBeingDeleted",
")",
"{",
"textAfterID",
"=",
"beforeID",
";",
"}",
"}"
] | We initially put new edit objects into the `newEdits` array so that we
can fix them up with proper positioning information. This function is
responsible for doing that fixup.
The `beforeID` that appears in many edits tells the browser to make the
change before the element with the given ID. In other words, an
elementInsert with a `beforeID` of 32 would result in something like
`parentElement.insertBefore(newChildElement, _queryBracketsID(32))`
Many new edits are captured in the `newEdits` array so that a suitable
`beforeID` can be added to them before they are added to the main edits
list. This function sets the `beforeID` on any pending edits and adds
them to the main list.
If this item is not being deleted, then it will be used as the `afterID`
for text edits that follow.
@param {int} beforeID ID to set on the pending edits
@param {boolean} isBeingDeleted true if the given item is being deleted. If so,
we can't use it as the `afterID` for future edits--whatever previous item
was set as the `textAfterID` is still okay. | [
"We",
"initially",
"put",
"new",
"edit",
"objects",
"into",
"the",
"newEdits",
"array",
"so",
"that",
"we",
"can",
"fix",
"them",
"up",
"with",
"proper",
"positioning",
"information",
".",
"This",
"function",
"is",
"responsible",
"for",
"doing",
"that",
"fixup",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/HTMLDOMDiff.js#L131-L149 |
|
2,397 | adobe/brackets | src/language/HTMLDOMDiff.js | function () {
if (!oldNodeMap[newChild.tagID]) {
newEdit = {
type: "elementInsert",
tag: newChild.tag,
tagID: newChild.tagID,
parentID: newChild.parent.tagID,
attributes: newChild.attributes
};
newEdits.push(newEdit);
// This newly inserted node needs to have edits generated for its
// children, so we add it to the queue.
newElements.push(newChild);
// A textInsert edit that follows this elementInsert should use
// this element's ID.
textAfterID = newChild.tagID;
// new element means we need to move on to compare the next
// of the current tree with the one from the old tree that we
// just compared
newIndex++;
return true;
}
return false;
} | javascript | function () {
if (!oldNodeMap[newChild.tagID]) {
newEdit = {
type: "elementInsert",
tag: newChild.tag,
tagID: newChild.tagID,
parentID: newChild.parent.tagID,
attributes: newChild.attributes
};
newEdits.push(newEdit);
// This newly inserted node needs to have edits generated for its
// children, so we add it to the queue.
newElements.push(newChild);
// A textInsert edit that follows this elementInsert should use
// this element's ID.
textAfterID = newChild.tagID;
// new element means we need to move on to compare the next
// of the current tree with the one from the old tree that we
// just compared
newIndex++;
return true;
}
return false;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"oldNodeMap",
"[",
"newChild",
".",
"tagID",
"]",
")",
"{",
"newEdit",
"=",
"{",
"type",
":",
"\"elementInsert\"",
",",
"tag",
":",
"newChild",
".",
"tag",
",",
"tagID",
":",
"newChild",
".",
"tagID",
",",
"parentID",
":",
"newChild",
".",
"parent",
".",
"tagID",
",",
"attributes",
":",
"newChild",
".",
"attributes",
"}",
";",
"newEdits",
".",
"push",
"(",
"newEdit",
")",
";",
"// This newly inserted node needs to have edits generated for its",
"// children, so we add it to the queue.",
"newElements",
".",
"push",
"(",
"newChild",
")",
";",
"// A textInsert edit that follows this elementInsert should use",
"// this element's ID.",
"textAfterID",
"=",
"newChild",
".",
"tagID",
";",
"// new element means we need to move on to compare the next",
"// of the current tree with the one from the old tree that we",
"// just compared",
"newIndex",
"++",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | If the current element was not in the old DOM, then we will create
an elementInsert edit for it.
If the element was in the old DOM, this will return false and the
main loop will either spot this element later in the child list
or the element has been moved.
@return {boolean} true if an elementInsert was created | [
"If",
"the",
"current",
"element",
"was",
"not",
"in",
"the",
"old",
"DOM",
"then",
"we",
"will",
"create",
"an",
"elementInsert",
"edit",
"for",
"it",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/HTMLDOMDiff.js#L161-L188 |
|
2,398 | adobe/brackets | src/language/HTMLDOMDiff.js | function () {
if (!newNodeMap[oldChild.tagID]) {
// We can finalize existing edits relative to this node *before* it's
// deleted.
finalizeNewEdits(oldChild.tagID, true);
newEdit = {
type: "elementDelete",
tagID: oldChild.tagID
};
newEdits.push(newEdit);
// deleted element means we need to move on to compare the next
// of the old tree with the one from the current tree that we
// just compared
oldIndex++;
return true;
}
return false;
} | javascript | function () {
if (!newNodeMap[oldChild.tagID]) {
// We can finalize existing edits relative to this node *before* it's
// deleted.
finalizeNewEdits(oldChild.tagID, true);
newEdit = {
type: "elementDelete",
tagID: oldChild.tagID
};
newEdits.push(newEdit);
// deleted element means we need to move on to compare the next
// of the old tree with the one from the current tree that we
// just compared
oldIndex++;
return true;
}
return false;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"newNodeMap",
"[",
"oldChild",
".",
"tagID",
"]",
")",
"{",
"// We can finalize existing edits relative to this node *before* it's",
"// deleted.",
"finalizeNewEdits",
"(",
"oldChild",
".",
"tagID",
",",
"true",
")",
";",
"newEdit",
"=",
"{",
"type",
":",
"\"elementDelete\"",
",",
"tagID",
":",
"oldChild",
".",
"tagID",
"}",
";",
"newEdits",
".",
"push",
"(",
"newEdit",
")",
";",
"// deleted element means we need to move on to compare the next",
"// of the old tree with the one from the current tree that we",
"// just compared",
"oldIndex",
"++",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | If the old element that we're looking at does not appear in the new
DOM, that means it was deleted and we'll create an elementDelete edit.
If the element is in the new DOM, then this will return false and
the main loop with either spot this node later on or the element
has been moved.
@return {boolean} true if elementDelete was generated | [
"If",
"the",
"old",
"element",
"that",
"we",
"re",
"looking",
"at",
"does",
"not",
"appear",
"in",
"the",
"new",
"DOM",
"that",
"means",
"it",
"was",
"deleted",
"and",
"we",
"ll",
"create",
"an",
"elementDelete",
"edit",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/HTMLDOMDiff.js#L200-L219 |
|
2,399 | adobe/brackets | src/language/HTMLDOMDiff.js | function () {
newEdit = {
type: "textInsert",
content: newChild.content,
parentID: newChild.parent.tagID
};
// text changes will generally have afterID and beforeID, but we make
// special note if it's the first child.
if (textAfterID) {
newEdit.afterID = textAfterID;
} else {
newEdit.firstChild = true;
}
newEdits.push(newEdit);
// The text node is in the new tree, so we move to the next new tree item
newIndex++;
} | javascript | function () {
newEdit = {
type: "textInsert",
content: newChild.content,
parentID: newChild.parent.tagID
};
// text changes will generally have afterID and beforeID, but we make
// special note if it's the first child.
if (textAfterID) {
newEdit.afterID = textAfterID;
} else {
newEdit.firstChild = true;
}
newEdits.push(newEdit);
// The text node is in the new tree, so we move to the next new tree item
newIndex++;
} | [
"function",
"(",
")",
"{",
"newEdit",
"=",
"{",
"type",
":",
"\"textInsert\"",
",",
"content",
":",
"newChild",
".",
"content",
",",
"parentID",
":",
"newChild",
".",
"parent",
".",
"tagID",
"}",
";",
"// text changes will generally have afterID and beforeID, but we make",
"// special note if it's the first child.",
"if",
"(",
"textAfterID",
")",
"{",
"newEdit",
".",
"afterID",
"=",
"textAfterID",
";",
"}",
"else",
"{",
"newEdit",
".",
"firstChild",
"=",
"true",
";",
"}",
"newEdits",
".",
"push",
"(",
"newEdit",
")",
";",
"// The text node is in the new tree, so we move to the next new tree item",
"newIndex",
"++",
";",
"}"
] | Adds a textInsert edit for a newly created text node. | [
"Adds",
"a",
"textInsert",
"edit",
"for",
"a",
"newly",
"created",
"text",
"node",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/HTMLDOMDiff.js#L224-L242 |
Subsets and Splits