id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
sequence
docstring
stringlengths
4
11.8k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
86
226
1,800
adobe/brackets
src/language/CodeInspection.js
getProvidersForLanguageId
function getProvidersForLanguageId(languageId) { var result = []; if (_providers[languageId]) { result = result.concat(_providers[languageId]); } if (_providers['*']) { result = result.concat(_providers['*']); } return result; }
javascript
function getProvidersForLanguageId(languageId) { var result = []; if (_providers[languageId]) { result = result.concat(_providers[languageId]); } if (_providers['*']) { result = result.concat(_providers['*']); } return result; }
[ "function", "getProvidersForLanguageId", "(", "languageId", ")", "{", "var", "result", "=", "[", "]", ";", "if", "(", "_providers", "[", "languageId", "]", ")", "{", "result", "=", "result", ".", "concat", "(", "_providers", "[", "languageId", "]", ")", ";", "}", "if", "(", "_providers", "[", "'*'", "]", ")", "{", "result", "=", "result", ".", "concat", "(", "_providers", "[", "'*'", "]", ")", ";", "}", "return", "result", ";", "}" ]
Returns a list of providers registered for given languageId through register function
[ "Returns", "a", "list", "of", "providers", "registered", "for", "given", "languageId", "through", "register", "function" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CodeInspection.js#L519-L528
1,801
adobe/brackets
src/language/CodeInspection.js
updateListeners
function updateListeners() { if (_enabled) { // register our event listeners MainViewManager .on("currentFileChange.codeInspection", function () { run(); }); DocumentManager .on("currentDocumentLanguageChanged.codeInspection", function () { run(); }) .on("documentSaved.codeInspection documentRefreshed.codeInspection", function (event, document) { if (document === DocumentManager.getCurrentDocument()) { run(); } }); } else { DocumentManager.off(".codeInspection"); MainViewManager.off(".codeInspection"); } }
javascript
function updateListeners() { if (_enabled) { // register our event listeners MainViewManager .on("currentFileChange.codeInspection", function () { run(); }); DocumentManager .on("currentDocumentLanguageChanged.codeInspection", function () { run(); }) .on("documentSaved.codeInspection documentRefreshed.codeInspection", function (event, document) { if (document === DocumentManager.getCurrentDocument()) { run(); } }); } else { DocumentManager.off(".codeInspection"); MainViewManager.off(".codeInspection"); } }
[ "function", "updateListeners", "(", ")", "{", "if", "(", "_enabled", ")", "{", "// register our event listeners", "MainViewManager", ".", "on", "(", "\"currentFileChange.codeInspection\"", ",", "function", "(", ")", "{", "run", "(", ")", ";", "}", ")", ";", "DocumentManager", ".", "on", "(", "\"currentDocumentLanguageChanged.codeInspection\"", ",", "function", "(", ")", "{", "run", "(", ")", ";", "}", ")", ".", "on", "(", "\"documentSaved.codeInspection documentRefreshed.codeInspection\"", ",", "function", "(", "event", ",", "document", ")", "{", "if", "(", "document", "===", "DocumentManager", ".", "getCurrentDocument", "(", ")", ")", "{", "run", "(", ")", ";", "}", "}", ")", ";", "}", "else", "{", "DocumentManager", ".", "off", "(", "\".codeInspection\"", ")", ";", "MainViewManager", ".", "off", "(", "\".codeInspection\"", ")", ";", "}", "}" ]
Update DocumentManager listeners.
[ "Update", "DocumentManager", "listeners", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CodeInspection.js#L533-L553
1,802
adobe/brackets
src/language/CodeInspection.js
toggleEnabled
function toggleEnabled(enabled, doNotSave) { if (enabled === undefined) { enabled = !_enabled; } // Take no action when there is no change. if (enabled === _enabled) { return; } _enabled = enabled; CommandManager.get(Commands.VIEW_TOGGLE_INSPECTION).setChecked(_enabled); updateListeners(); if (!doNotSave) { prefs.set(PREF_ENABLED, _enabled); prefs.save(); } // run immediately run(); }
javascript
function toggleEnabled(enabled, doNotSave) { if (enabled === undefined) { enabled = !_enabled; } // Take no action when there is no change. if (enabled === _enabled) { return; } _enabled = enabled; CommandManager.get(Commands.VIEW_TOGGLE_INSPECTION).setChecked(_enabled); updateListeners(); if (!doNotSave) { prefs.set(PREF_ENABLED, _enabled); prefs.save(); } // run immediately run(); }
[ "function", "toggleEnabled", "(", "enabled", ",", "doNotSave", ")", "{", "if", "(", "enabled", "===", "undefined", ")", "{", "enabled", "=", "!", "_enabled", ";", "}", "// Take no action when there is no change.", "if", "(", "enabled", "===", "_enabled", ")", "{", "return", ";", "}", "_enabled", "=", "enabled", ";", "CommandManager", ".", "get", "(", "Commands", ".", "VIEW_TOGGLE_INSPECTION", ")", ".", "setChecked", "(", "_enabled", ")", ";", "updateListeners", "(", ")", ";", "if", "(", "!", "doNotSave", ")", "{", "prefs", ".", "set", "(", "PREF_ENABLED", ",", "_enabled", ")", ";", "prefs", ".", "save", "(", ")", ";", "}", "// run immediately", "run", "(", ")", ";", "}" ]
Enable or disable all inspection. @param {?boolean} enabled Enabled state. If omitted, the state is toggled. @param {?boolean} doNotSave true if the preference should not be saved to user settings. This is generally for events triggered by project-level settings.
[ "Enable", "or", "disable", "all", "inspection", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CodeInspection.js#L560-L581
1,803
adobe/brackets
src/editor/EditorCommandHandlers.js
_firstNotWs
function _firstNotWs(doc, lineNum) { var text = doc.getLine(lineNum); if (text === null || text === undefined) { return 0; } return text.search(/\S|$/); }
javascript
function _firstNotWs(doc, lineNum) { var text = doc.getLine(lineNum); if (text === null || text === undefined) { return 0; } return text.search(/\S|$/); }
[ "function", "_firstNotWs", "(", "doc", ",", "lineNum", ")", "{", "var", "text", "=", "doc", ".", "getLine", "(", "lineNum", ")", ";", "if", "(", "text", "===", "null", "||", "text", "===", "undefined", ")", "{", "return", "0", ";", "}", "return", "text", ".", "search", "(", "/", "\\S|$", "/", ")", ";", "}" ]
Return the column of the first non whitespace char in the given line. @private @param {!Document} doc @param {number} lineNum @returns {number} the column index or null
[ "Return", "the", "column", "of", "the", "first", "non", "whitespace", "char", "in", "the", "given", "line", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/EditorCommandHandlers.js#L308-L315
1,804
adobe/brackets
src/extensions/default/InlineTimingFunctionEditor/main.js
prepareEditorForProvider
function prepareEditorForProvider(hostEditor, pos) { var cursorLine, sel, startPos, endPos, startBookmark, endBookmark, currentMatch, cm = hostEditor._codeMirror; sel = hostEditor.getSelection(); if (sel.start.line !== sel.end.line) { return {timingFunction: null, reason: null}; } cursorLine = hostEditor.document.getLine(pos.line); // code runs several matches complicated patterns, multiple times, so // first do a quick, simple check to see make sure we may have a match if (!cursorLine.match(/cubic-bezier|linear|ease|step/)) { return {timingFunction: null, reason: null}; } currentMatch = TimingFunctionUtils.timingFunctionMatch(cursorLine, false); if (!currentMatch) { return {timingFunction: null, reason: Strings.ERROR_TIMINGQUICKEDIT_INVALIDSYNTAX}; } // check for subsequent matches, and use first match after pos var lineOffset = 0, matchLength = ((currentMatch.originalString && currentMatch.originalString.length) || currentMatch[0].length); while (pos.ch > (currentMatch.index + matchLength + lineOffset)) { var restOfLine = cursorLine.substring(currentMatch.index + matchLength + lineOffset), newMatch = TimingFunctionUtils.timingFunctionMatch(restOfLine, false); if (newMatch) { lineOffset += (currentMatch.index + matchLength); currentMatch = $.extend(true, [], newMatch); } else { break; } } currentMatch.lineOffset = lineOffset; startPos = {line: pos.line, ch: lineOffset + currentMatch.index}; endPos = {line: pos.line, ch: lineOffset + currentMatch.index + matchLength}; startBookmark = cm.setBookmark(startPos); endBookmark = cm.setBookmark(endPos); // Adjust selection to the match so that the inline editor won't // get dismissed while we're updating the timing function. hostEditor.setSelection(startPos, endPos); return { timingFunction: currentMatch, start: startBookmark, end: endBookmark }; }
javascript
function prepareEditorForProvider(hostEditor, pos) { var cursorLine, sel, startPos, endPos, startBookmark, endBookmark, currentMatch, cm = hostEditor._codeMirror; sel = hostEditor.getSelection(); if (sel.start.line !== sel.end.line) { return {timingFunction: null, reason: null}; } cursorLine = hostEditor.document.getLine(pos.line); // code runs several matches complicated patterns, multiple times, so // first do a quick, simple check to see make sure we may have a match if (!cursorLine.match(/cubic-bezier|linear|ease|step/)) { return {timingFunction: null, reason: null}; } currentMatch = TimingFunctionUtils.timingFunctionMatch(cursorLine, false); if (!currentMatch) { return {timingFunction: null, reason: Strings.ERROR_TIMINGQUICKEDIT_INVALIDSYNTAX}; } // check for subsequent matches, and use first match after pos var lineOffset = 0, matchLength = ((currentMatch.originalString && currentMatch.originalString.length) || currentMatch[0].length); while (pos.ch > (currentMatch.index + matchLength + lineOffset)) { var restOfLine = cursorLine.substring(currentMatch.index + matchLength + lineOffset), newMatch = TimingFunctionUtils.timingFunctionMatch(restOfLine, false); if (newMatch) { lineOffset += (currentMatch.index + matchLength); currentMatch = $.extend(true, [], newMatch); } else { break; } } currentMatch.lineOffset = lineOffset; startPos = {line: pos.line, ch: lineOffset + currentMatch.index}; endPos = {line: pos.line, ch: lineOffset + currentMatch.index + matchLength}; startBookmark = cm.setBookmark(startPos); endBookmark = cm.setBookmark(endPos); // Adjust selection to the match so that the inline editor won't // get dismissed while we're updating the timing function. hostEditor.setSelection(startPos, endPos); return { timingFunction: currentMatch, start: startBookmark, end: endBookmark }; }
[ "function", "prepareEditorForProvider", "(", "hostEditor", ",", "pos", ")", "{", "var", "cursorLine", ",", "sel", ",", "startPos", ",", "endPos", ",", "startBookmark", ",", "endBookmark", ",", "currentMatch", ",", "cm", "=", "hostEditor", ".", "_codeMirror", ";", "sel", "=", "hostEditor", ".", "getSelection", "(", ")", ";", "if", "(", "sel", ".", "start", ".", "line", "!==", "sel", ".", "end", ".", "line", ")", "{", "return", "{", "timingFunction", ":", "null", ",", "reason", ":", "null", "}", ";", "}", "cursorLine", "=", "hostEditor", ".", "document", ".", "getLine", "(", "pos", ".", "line", ")", ";", "// code runs several matches complicated patterns, multiple times, so", "// first do a quick, simple check to see make sure we may have a match", "if", "(", "!", "cursorLine", ".", "match", "(", "/", "cubic-bezier|linear|ease|step", "/", ")", ")", "{", "return", "{", "timingFunction", ":", "null", ",", "reason", ":", "null", "}", ";", "}", "currentMatch", "=", "TimingFunctionUtils", ".", "timingFunctionMatch", "(", "cursorLine", ",", "false", ")", ";", "if", "(", "!", "currentMatch", ")", "{", "return", "{", "timingFunction", ":", "null", ",", "reason", ":", "Strings", ".", "ERROR_TIMINGQUICKEDIT_INVALIDSYNTAX", "}", ";", "}", "// check for subsequent matches, and use first match after pos", "var", "lineOffset", "=", "0", ",", "matchLength", "=", "(", "(", "currentMatch", ".", "originalString", "&&", "currentMatch", ".", "originalString", ".", "length", ")", "||", "currentMatch", "[", "0", "]", ".", "length", ")", ";", "while", "(", "pos", ".", "ch", ">", "(", "currentMatch", ".", "index", "+", "matchLength", "+", "lineOffset", ")", ")", "{", "var", "restOfLine", "=", "cursorLine", ".", "substring", "(", "currentMatch", ".", "index", "+", "matchLength", "+", "lineOffset", ")", ",", "newMatch", "=", "TimingFunctionUtils", ".", "timingFunctionMatch", "(", "restOfLine", ",", "false", ")", ";", "if", "(", "newMatch", ")", "{", "lineOffset", "+=", "(", "currentMatch", ".", "index", "+", "matchLength", ")", ";", "currentMatch", "=", "$", ".", "extend", "(", "true", ",", "[", "]", ",", "newMatch", ")", ";", "}", "else", "{", "break", ";", "}", "}", "currentMatch", ".", "lineOffset", "=", "lineOffset", ";", "startPos", "=", "{", "line", ":", "pos", ".", "line", ",", "ch", ":", "lineOffset", "+", "currentMatch", ".", "index", "}", ";", "endPos", "=", "{", "line", ":", "pos", ".", "line", ",", "ch", ":", "lineOffset", "+", "currentMatch", ".", "index", "+", "matchLength", "}", ";", "startBookmark", "=", "cm", ".", "setBookmark", "(", "startPos", ")", ";", "endBookmark", "=", "cm", ".", "setBookmark", "(", "endPos", ")", ";", "// Adjust selection to the match so that the inline editor won't", "// get dismissed while we're updating the timing function.", "hostEditor", ".", "setSelection", "(", "startPos", ",", "endPos", ")", ";", "return", "{", "timingFunction", ":", "currentMatch", ",", "start", ":", "startBookmark", ",", "end", ":", "endBookmark", "}", ";", "}" ]
Functions Prepare hostEditor for an InlineTimingFunctionEditor at pos if possible. Return editor context if so; otherwise null. @param {Editor} hostEditor @param {{line:Number, ch:Number}} pos @return {timingFunction:{?string}, reason:{?string}, start:{?TextMarker}, end:{?TextMarker}}
[ "Functions", "Prepare", "hostEditor", "for", "an", "InlineTimingFunctionEditor", "at", "pos", "if", "possible", ".", "Return", "editor", "context", "if", "so", ";", "otherwise", "null", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/main.js#L68-L122
1,805
adobe/brackets
src/project/WorkingSetView.js
refresh
function refresh(rebuild) { _.forEach(_views, function (view) { var top = view.$openFilesContainer.scrollTop(); if (rebuild) { view._rebuildViewList(true); } else { view._redraw(); } view.$openFilesContainer.scrollTop(top); }); }
javascript
function refresh(rebuild) { _.forEach(_views, function (view) { var top = view.$openFilesContainer.scrollTop(); if (rebuild) { view._rebuildViewList(true); } else { view._redraw(); } view.$openFilesContainer.scrollTop(top); }); }
[ "function", "refresh", "(", "rebuild", ")", "{", "_", ".", "forEach", "(", "_views", ",", "function", "(", "view", ")", "{", "var", "top", "=", "view", ".", "$openFilesContainer", ".", "scrollTop", "(", ")", ";", "if", "(", "rebuild", ")", "{", "view", ".", "_rebuildViewList", "(", "true", ")", ";", "}", "else", "{", "view", ".", "_redraw", "(", ")", ";", "}", "view", ".", "$openFilesContainer", ".", "scrollTop", "(", "top", ")", ";", "}", ")", ";", "}" ]
Refreshes all Pane View List Views
[ "Refreshes", "all", "Pane", "View", "List", "Views" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetView.js#L120-L130
1,806
adobe/brackets
src/project/WorkingSetView.js
_updateListItemSelection
function _updateListItemSelection(listItem, selectedFile) { var shouldBeSelected = (selectedFile && $(listItem).data(_FILE_KEY).fullPath === selectedFile.fullPath); ViewUtils.toggleClass($(listItem), "selected", shouldBeSelected); }
javascript
function _updateListItemSelection(listItem, selectedFile) { var shouldBeSelected = (selectedFile && $(listItem).data(_FILE_KEY).fullPath === selectedFile.fullPath); ViewUtils.toggleClass($(listItem), "selected", shouldBeSelected); }
[ "function", "_updateListItemSelection", "(", "listItem", ",", "selectedFile", ")", "{", "var", "shouldBeSelected", "=", "(", "selectedFile", "&&", "$", "(", "listItem", ")", ".", "data", "(", "_FILE_KEY", ")", ".", "fullPath", "===", "selectedFile", ".", "fullPath", ")", ";", "ViewUtils", ".", "toggleClass", "(", "$", "(", "listItem", ")", ",", "\"selected\"", ",", "shouldBeSelected", ")", ";", "}" ]
Updates the appearance of the list element based on the parameters provided. @private @param {!HTMLLIElement} listElement @param {?File} selectedFile
[ "Updates", "the", "appearance", "of", "the", "list", "element", "based", "on", "the", "parameters", "provided", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetView.js#L147-L150
1,807
adobe/brackets
src/project/WorkingSetView.js
_isOpenAndDirty
function _isOpenAndDirty(file) { // working set item might never have been opened; if so, then it's definitely not dirty var docIfOpen = DocumentManager.getOpenDocumentForPath(file.fullPath); return (docIfOpen && docIfOpen.isDirty); }
javascript
function _isOpenAndDirty(file) { // working set item might never have been opened; if so, then it's definitely not dirty var docIfOpen = DocumentManager.getOpenDocumentForPath(file.fullPath); return (docIfOpen && docIfOpen.isDirty); }
[ "function", "_isOpenAndDirty", "(", "file", ")", "{", "// working set item might never have been opened; if so, then it's definitely not dirty", "var", "docIfOpen", "=", "DocumentManager", ".", "getOpenDocumentForPath", "(", "file", ".", "fullPath", ")", ";", "return", "(", "docIfOpen", "&&", "docIfOpen", ".", "isDirty", ")", ";", "}" ]
Determines if a file is dirty @private @param {!File} file - file to test @return {boolean} true if the file is dirty, false otherwise
[ "Determines", "if", "a", "file", "is", "dirty" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetView.js#L158-L162
1,808
adobe/brackets
src/project/WorkingSetView.js
_suppressScrollShadowsOnAllViews
function _suppressScrollShadowsOnAllViews(disable) { _.forEach(_views, function (view) { if (disable) { ViewUtils.removeScrollerShadow(view.$openFilesContainer[0], null); } else if (view.$openFilesContainer[0].scrollHeight > view.$openFilesContainer[0].clientHeight) { ViewUtils.addScrollerShadow(view.$openFilesContainer[0], null, true); } }); }
javascript
function _suppressScrollShadowsOnAllViews(disable) { _.forEach(_views, function (view) { if (disable) { ViewUtils.removeScrollerShadow(view.$openFilesContainer[0], null); } else if (view.$openFilesContainer[0].scrollHeight > view.$openFilesContainer[0].clientHeight) { ViewUtils.addScrollerShadow(view.$openFilesContainer[0], null, true); } }); }
[ "function", "_suppressScrollShadowsOnAllViews", "(", "disable", ")", "{", "_", ".", "forEach", "(", "_views", ",", "function", "(", "view", ")", "{", "if", "(", "disable", ")", "{", "ViewUtils", ".", "removeScrollerShadow", "(", "view", ".", "$openFilesContainer", "[", "0", "]", ",", "null", ")", ";", "}", "else", "if", "(", "view", ".", "$openFilesContainer", "[", "0", "]", ".", "scrollHeight", ">", "view", ".", "$openFilesContainer", "[", "0", "]", ".", "clientHeight", ")", "{", "ViewUtils", ".", "addScrollerShadow", "(", "view", ".", "$openFilesContainer", "[", "0", "]", ",", "null", ",", "true", ")", ";", "}", "}", ")", ";", "}" ]
turns off the scroll shadow on view containers so they don't interfere with dragging @private @param {Boolean} disable - true to disable, false to enable
[ "turns", "off", "the", "scroll", "shadow", "on", "view", "containers", "so", "they", "don", "t", "interfere", "with", "dragging" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetView.js#L188-L196
1,809
adobe/brackets
src/project/WorkingSetView.js
_deactivateAllViews
function _deactivateAllViews(deactivate) { _.forEach(_views, function (view) { if (deactivate) { if (view.$el.hasClass("active")) { view.$el.removeClass("active").addClass("reactivate"); view.$openFilesList.trigger("selectionHide"); } } else { if (view.$el.hasClass("reactivate")) { view.$el.removeClass("reactivate").addClass("active"); } // don't update the scroll pos view._fireSelectionChanged(false); } }); }
javascript
function _deactivateAllViews(deactivate) { _.forEach(_views, function (view) { if (deactivate) { if (view.$el.hasClass("active")) { view.$el.removeClass("active").addClass("reactivate"); view.$openFilesList.trigger("selectionHide"); } } else { if (view.$el.hasClass("reactivate")) { view.$el.removeClass("reactivate").addClass("active"); } // don't update the scroll pos view._fireSelectionChanged(false); } }); }
[ "function", "_deactivateAllViews", "(", "deactivate", ")", "{", "_", ".", "forEach", "(", "_views", ",", "function", "(", "view", ")", "{", "if", "(", "deactivate", ")", "{", "if", "(", "view", ".", "$el", ".", "hasClass", "(", "\"active\"", ")", ")", "{", "view", ".", "$el", ".", "removeClass", "(", "\"active\"", ")", ".", "addClass", "(", "\"reactivate\"", ")", ";", "view", ".", "$openFilesList", ".", "trigger", "(", "\"selectionHide\"", ")", ";", "}", "}", "else", "{", "if", "(", "view", ".", "$el", ".", "hasClass", "(", "\"reactivate\"", ")", ")", "{", "view", ".", "$el", ".", "removeClass", "(", "\"reactivate\"", ")", ".", "addClass", "(", "\"active\"", ")", ";", "}", "// don't update the scroll pos", "view", ".", "_fireSelectionChanged", "(", "false", ")", ";", "}", "}", ")", ";", "}" ]
Deactivates all views so the selection marker does not show @private @param {Boolean} deactivate - true to deactivate, false to reactivate
[ "Deactivates", "all", "views", "so", "the", "selection", "marker", "does", "not", "show" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetView.js#L203-L218
1,810
adobe/brackets
src/project/WorkingSetView.js
_viewFromEl
function _viewFromEl($el) { if (!$el.hasClass("working-set-view")) { $el = $el.parents(".working-set-view"); } var id = $el.attr("id").match(/working\-set\-list\-([\w]+[\w\d\-\.\:\_]*)/).pop(); return _views[id]; }
javascript
function _viewFromEl($el) { if (!$el.hasClass("working-set-view")) { $el = $el.parents(".working-set-view"); } var id = $el.attr("id").match(/working\-set\-list\-([\w]+[\w\d\-\.\:\_]*)/).pop(); return _views[id]; }
[ "function", "_viewFromEl", "(", "$el", ")", "{", "if", "(", "!", "$el", ".", "hasClass", "(", "\"working-set-view\"", ")", ")", "{", "$el", "=", "$el", ".", "parents", "(", "\".working-set-view\"", ")", ";", "}", "var", "id", "=", "$el", ".", "attr", "(", "\"id\"", ")", ".", "match", "(", "/", "working\\-set\\-list\\-([\\w]+[\\w\\d\\-\\.\\:\\_]*)", "/", ")", ".", "pop", "(", ")", ";", "return", "_views", "[", "id", "]", ";", "}" ]
Finds the WorkingSetView object for the specified element @private @param {jQuery} $el - the element to find the view for @return {View} view object
[ "Finds", "the", "WorkingSetView", "object", "for", "the", "specified", "element" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetView.js#L226-L233
1,811
adobe/brackets
src/project/WorkingSetView.js
scroll
function scroll($container, $el, dir, callback) { var container = $container[0], maxScroll = container.scrollHeight - container.clientHeight; if (maxScroll && dir && !interval) { // Scroll view if the mouse is over the first or last pixels of the container interval = window.setInterval(function () { var scrollTop = $container.scrollTop(); if ((dir === -1 && scrollTop <= 0) || (dir === 1 && scrollTop >= maxScroll)) { endScroll($el); } else { $container.scrollTop(scrollTop + 7 * dir); callback($el); } }, 50); } }
javascript
function scroll($container, $el, dir, callback) { var container = $container[0], maxScroll = container.scrollHeight - container.clientHeight; if (maxScroll && dir && !interval) { // Scroll view if the mouse is over the first or last pixels of the container interval = window.setInterval(function () { var scrollTop = $container.scrollTop(); if ((dir === -1 && scrollTop <= 0) || (dir === 1 && scrollTop >= maxScroll)) { endScroll($el); } else { $container.scrollTop(scrollTop + 7 * dir); callback($el); } }, 50); } }
[ "function", "scroll", "(", "$container", ",", "$el", ",", "dir", ",", "callback", ")", "{", "var", "container", "=", "$container", "[", "0", "]", ",", "maxScroll", "=", "container", ".", "scrollHeight", "-", "container", ".", "clientHeight", ";", "if", "(", "maxScroll", "&&", "dir", "&&", "!", "interval", ")", "{", "// Scroll view if the mouse is over the first or last pixels of the container", "interval", "=", "window", ".", "setInterval", "(", "function", "(", ")", "{", "var", "scrollTop", "=", "$container", ".", "scrollTop", "(", ")", ";", "if", "(", "(", "dir", "===", "-", "1", "&&", "scrollTop", "<=", "0", ")", "||", "(", "dir", "===", "1", "&&", "scrollTop", ">=", "maxScroll", ")", ")", "{", "endScroll", "(", "$el", ")", ";", "}", "else", "{", "$container", ".", "scrollTop", "(", "scrollTop", "+", "7", "*", "dir", ")", ";", "callback", "(", "$el", ")", ";", "}", "}", ",", "50", ")", ";", "}", "}" ]
We scroll the list while hovering over the first or last visible list element in the working set, so that positioning a working set item before or after one that has been scrolled out of view can be performed. This function will call the drag interface repeatedly on an interval to allow the item to be dragged while scrolling the list until the mouse is moved off the first or last item or endScroll is called
[ "We", "scroll", "the", "list", "while", "hovering", "over", "the", "first", "or", "last", "visible", "list", "element", "in", "the", "working", "set", "so", "that", "positioning", "a", "working", "set", "item", "before", "or", "after", "one", "that", "has", "been", "scrolled", "out", "of", "view", "can", "be", "performed", ".", "This", "function", "will", "call", "the", "drag", "interface", "repeatedly", "on", "an", "interval", "to", "allow", "the", "item", "to", "be", "dragged", "while", "scrolling", "the", "list", "until", "the", "mouse", "is", "moved", "off", "the", "first", "or", "last", "item", "or", "endScroll", "is", "called" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetView.js#L259-L274
1,812
adobe/brackets
src/project/WorkingSetView.js
preDropCleanup
function preDropCleanup() { window.onmousewheel = window.document.onmousewheel = null; $(window).off(".wsvdragging"); if (dragged) { $workingFilesContainer.removeClass("dragging"); $workingFilesContainer.find(".drag-show-as-selected").removeClass("drag-show-as-selected"); endScroll($el); // re-activate the views (adds the "active" class to the view that was previously active) _deactivateAllViews(false); // turn scroll wheel back on $ghost.remove(); $el.css("opacity", ""); if ($el.next().length === 0) { scrollCurrentViewToBottom(); } } }
javascript
function preDropCleanup() { window.onmousewheel = window.document.onmousewheel = null; $(window).off(".wsvdragging"); if (dragged) { $workingFilesContainer.removeClass("dragging"); $workingFilesContainer.find(".drag-show-as-selected").removeClass("drag-show-as-selected"); endScroll($el); // re-activate the views (adds the "active" class to the view that was previously active) _deactivateAllViews(false); // turn scroll wheel back on $ghost.remove(); $el.css("opacity", ""); if ($el.next().length === 0) { scrollCurrentViewToBottom(); } } }
[ "function", "preDropCleanup", "(", ")", "{", "window", ".", "onmousewheel", "=", "window", ".", "document", ".", "onmousewheel", "=", "null", ";", "$", "(", "window", ")", ".", "off", "(", "\".wsvdragging\"", ")", ";", "if", "(", "dragged", ")", "{", "$workingFilesContainer", ".", "removeClass", "(", "\"dragging\"", ")", ";", "$workingFilesContainer", ".", "find", "(", "\".drag-show-as-selected\"", ")", ".", "removeClass", "(", "\"drag-show-as-selected\"", ")", ";", "endScroll", "(", "$el", ")", ";", "// re-activate the views (adds the \"active\" class to the view that was previously active)", "_deactivateAllViews", "(", "false", ")", ";", "// turn scroll wheel back on", "$ghost", ".", "remove", "(", ")", ";", "$el", ".", "css", "(", "\"opacity\"", ",", "\"\"", ")", ";", "if", "(", "$el", ".", "next", "(", ")", ".", "length", "===", "0", ")", "{", "scrollCurrentViewToBottom", "(", ")", ";", "}", "}", "}" ]
Close down the drag operation
[ "Close", "down", "the", "drag", "operation" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetView.js#L722-L739
1,813
adobe/brackets
src/project/WorkingSetView.js
createWorkingSetViewForPane
function createWorkingSetViewForPane($container, paneId) { var view = _views[paneId]; if (!view) { view = new WorkingSetView($container, paneId); _views[view.paneId] = view; } }
javascript
function createWorkingSetViewForPane($container, paneId) { var view = _views[paneId]; if (!view) { view = new WorkingSetView($container, paneId); _views[view.paneId] = view; } }
[ "function", "createWorkingSetViewForPane", "(", "$container", ",", "paneId", ")", "{", "var", "view", "=", "_views", "[", "paneId", "]", ";", "if", "(", "!", "view", ")", "{", "view", "=", "new", "WorkingSetView", "(", "$container", ",", "paneId", ")", ";", "_views", "[", "view", ".", "paneId", "]", "=", "view", ";", "}", "}" ]
Creates a new WorkingSetView object for the specified pane @param {!jQuery} $container - the WorkingSetView's DOM parent node @param {!string} paneId - the id of the pane the view is being created for
[ "Creates", "a", "new", "WorkingSetView", "object", "for", "the", "specified", "pane" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetView.js#L1427-L1433
1,814
adobe/brackets
src/search/QuickOpen.js
_getPluginsForCurrentContext
function _getPluginsForCurrentContext() { var curDoc = DocumentManager.getCurrentDocument(); if (curDoc) { var languageId = curDoc.getLanguage().getId(); return _providerRegistrationHandler.getProvidersForLanguageId(languageId); } return _providerRegistrationHandler.getProvidersForLanguageId(); //plugins registered for all }
javascript
function _getPluginsForCurrentContext() { var curDoc = DocumentManager.getCurrentDocument(); if (curDoc) { var languageId = curDoc.getLanguage().getId(); return _providerRegistrationHandler.getProvidersForLanguageId(languageId); } return _providerRegistrationHandler.getProvidersForLanguageId(); //plugins registered for all }
[ "function", "_getPluginsForCurrentContext", "(", ")", "{", "var", "curDoc", "=", "DocumentManager", ".", "getCurrentDocument", "(", ")", ";", "if", "(", "curDoc", ")", "{", "var", "languageId", "=", "curDoc", ".", "getLanguage", "(", ")", ".", "getId", "(", ")", ";", "return", "_providerRegistrationHandler", ".", "getProvidersForLanguageId", "(", "languageId", ")", ";", "}", "return", "_providerRegistrationHandler", ".", "getProvidersForLanguageId", "(", ")", ";", "//plugins registered for all", "}" ]
Helper function to get the plugins based on the type of the current document. @private @returns {Array} Returns the plugings based on the languageId of the current document.
[ "Helper", "function", "to", "get", "the", "plugins", "based", "on", "the", "type", "of", "the", "current", "document", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/QuickOpen.js#L111-L120
1,815
adobe/brackets
src/search/QuickOpen.js
QuickOpenPlugin
function QuickOpenPlugin(name, languageIds, done, search, match, itemFocus, itemSelect, resultsFormatter, matcherOptions, label) { this.name = name; this.languageIds = languageIds; this.done = done; this.search = search; this.match = match; this.itemFocus = itemFocus; this.itemSelect = itemSelect; this.resultsFormatter = resultsFormatter; this.matcherOptions = matcherOptions; this.label = label; }
javascript
function QuickOpenPlugin(name, languageIds, done, search, match, itemFocus, itemSelect, resultsFormatter, matcherOptions, label) { this.name = name; this.languageIds = languageIds; this.done = done; this.search = search; this.match = match; this.itemFocus = itemFocus; this.itemSelect = itemSelect; this.resultsFormatter = resultsFormatter; this.matcherOptions = matcherOptions; this.label = label; }
[ "function", "QuickOpenPlugin", "(", "name", ",", "languageIds", ",", "done", ",", "search", ",", "match", ",", "itemFocus", ",", "itemSelect", ",", "resultsFormatter", ",", "matcherOptions", ",", "label", ")", "{", "this", ".", "name", "=", "name", ";", "this", ".", "languageIds", "=", "languageIds", ";", "this", ".", "done", "=", "done", ";", "this", ".", "search", "=", "search", ";", "this", ".", "match", "=", "match", ";", "this", ".", "itemFocus", "=", "itemFocus", ";", "this", ".", "itemSelect", "=", "itemSelect", ";", "this", ".", "resultsFormatter", "=", "resultsFormatter", ";", "this", ".", "matcherOptions", "=", "matcherOptions", ";", "this", ".", "label", "=", "label", ";", "}" ]
Defines API for new QuickOpen plug-ins
[ "Defines", "API", "for", "new", "QuickOpen", "plug", "-", "ins" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/QuickOpen.js#L125-L136
1,816
adobe/brackets
src/search/QuickOpen.js
addQuickOpenPlugin
function addQuickOpenPlugin(pluginDef) { var quickOpenProvider = new QuickOpenPlugin( pluginDef.name, pluginDef.languageIds, pluginDef.done, pluginDef.search, pluginDef.match, pluginDef.itemFocus, pluginDef.itemSelect, pluginDef.resultsFormatter, pluginDef.matcherOptions, pluginDef.label ), providerLanguageIds = pluginDef.languageIds.length ? pluginDef.languageIds : ["all"], providerPriority = pluginDef.priority || 0; _registerQuickOpenProvider(quickOpenProvider, providerLanguageIds, providerPriority); }
javascript
function addQuickOpenPlugin(pluginDef) { var quickOpenProvider = new QuickOpenPlugin( pluginDef.name, pluginDef.languageIds, pluginDef.done, pluginDef.search, pluginDef.match, pluginDef.itemFocus, pluginDef.itemSelect, pluginDef.resultsFormatter, pluginDef.matcherOptions, pluginDef.label ), providerLanguageIds = pluginDef.languageIds.length ? pluginDef.languageIds : ["all"], providerPriority = pluginDef.priority || 0; _registerQuickOpenProvider(quickOpenProvider, providerLanguageIds, providerPriority); }
[ "function", "addQuickOpenPlugin", "(", "pluginDef", ")", "{", "var", "quickOpenProvider", "=", "new", "QuickOpenPlugin", "(", "pluginDef", ".", "name", ",", "pluginDef", ".", "languageIds", ",", "pluginDef", ".", "done", ",", "pluginDef", ".", "search", ",", "pluginDef", ".", "match", ",", "pluginDef", ".", "itemFocus", ",", "pluginDef", ".", "itemSelect", ",", "pluginDef", ".", "resultsFormatter", ",", "pluginDef", ".", "matcherOptions", ",", "pluginDef", ".", "label", ")", ",", "providerLanguageIds", "=", "pluginDef", ".", "languageIds", ".", "length", "?", "pluginDef", ".", "languageIds", ":", "[", "\"all\"", "]", ",", "providerPriority", "=", "pluginDef", ".", "priority", "||", "0", ";", "_registerQuickOpenProvider", "(", "quickOpenProvider", ",", "providerLanguageIds", ",", "providerPriority", ")", ";", "}" ]
Creates and registers a new QuickOpenPlugin @param { name: string, languageIds: !Array.<string>, done: ?function(), search: function(string, !StringMatch.StringMatcher):(!Array.<SearchResult|string>|$.Promise), match: function(string):boolean, itemFocus: ?function(?SearchResult|string, string, boolean), itemSelect: function(?SearchResult|string, string), resultsFormatter: ?function(SearchResult|string, string):string, matcherOptions: ?Object, label: ?string } pluginDef Parameter Documentation: name - plug-in name, **must be unique** languageIds - language Ids array. Example: ["javascript", "css", "html"]. To allow any language, pass []. Required. done - called when quick open is complete. Plug-in should clear its internal state. Optional. search - takes a query string and a StringMatcher (the use of which is optional but can speed up your searches) and returns an array of strings or result objects that match the query; or a Promise that resolves to such an array. Required. match - takes a query string and returns true if this plug-in wants to provide results for this query. Required. itemFocus - performs an action when a result has been highlighted (via arrow keys, or by becoming top of the list). Passed the highlighted search result item (as returned by search()), the current query string, and a flag that is true if the item was highlighted explicitly (arrow keys), not implicitly (at top of list after last search()). Optional. itemSelect - performs an action when a result is chosen. Passed the highlighted search result item (as returned by search()), and the current query string. Required. resultsFormatter - takes a query string and an item string and returns a <LI> item to insert into the displayed search results. Optional. matcherOptions - options to pass along to the StringMatcher (see StringMatch.StringMatcher for available options). Optional. label - if provided, the label to show before the query field. Optional. If itemFocus() makes changes to the current document or cursor/scroll position and then the user cancels Quick Open (via Esc), those changes are automatically reverted.
[ "Creates", "and", "registers", "a", "new", "QuickOpenPlugin" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/QuickOpen.js#L176-L193
1,817
adobe/brackets
src/search/QuickOpen.js
_filter
function _filter(file) { return !LanguageManager.getLanguageForPath(file.fullPath).isBinary() || MainViewFactory.findSuitableFactoryForPath(file.fullPath); }
javascript
function _filter(file) { return !LanguageManager.getLanguageForPath(file.fullPath).isBinary() || MainViewFactory.findSuitableFactoryForPath(file.fullPath); }
[ "function", "_filter", "(", "file", ")", "{", "return", "!", "LanguageManager", ".", "getLanguageForPath", "(", "file", ".", "fullPath", ")", ".", "isBinary", "(", ")", "||", "MainViewFactory", ".", "findSuitableFactoryForPath", "(", "file", ".", "fullPath", ")", ";", "}" ]
Return files that are non-binary, or binary files that have a custom viewer
[ "Return", "files", "that", "are", "non", "-", "binary", "or", "binary", "files", "that", "have", "a", "custom", "viewer" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/QuickOpen.js#L708-L711
1,818
adobe/brackets
src/JSUtils/node/TernNodeDomain.js
handleGetFile
function handleGetFile(file, text) { var next = fileCallBacks[file]; if (next) { try { next(null, text); } catch (e) { _reportError(e, file); } } delete fileCallBacks[file]; }
javascript
function handleGetFile(file, text) { var next = fileCallBacks[file]; if (next) { try { next(null, text); } catch (e) { _reportError(e, file); } } delete fileCallBacks[file]; }
[ "function", "handleGetFile", "(", "file", ",", "text", ")", "{", "var", "next", "=", "fileCallBacks", "[", "file", "]", ";", "if", "(", "next", ")", "{", "try", "{", "next", "(", "null", ",", "text", ")", ";", "}", "catch", "(", "e", ")", "{", "_reportError", "(", "e", ",", "file", ")", ";", "}", "}", "delete", "fileCallBacks", "[", "file", "]", ";", "}" ]
Handle a response from the main thread providing the contents of a file @param {string} file - the name of the file @param {string} text - the contents of the file
[ "Handle", "a", "response", "from", "the", "main", "thread", "providing", "the", "contents", "of", "a", "file" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/node/TernNodeDomain.js#L90-L100
1,819
adobe/brackets
src/JSUtils/node/TernNodeDomain.js
getFile
function getFile(name, next) { // save the callback fileCallBacks[name] = next; setImmediate(function () { try { ExtractContent.extractContent(name, handleGetFile, _requestFileContent); } catch (error) { console.log(error); } }); }
javascript
function getFile(name, next) { // save the callback fileCallBacks[name] = next; setImmediate(function () { try { ExtractContent.extractContent(name, handleGetFile, _requestFileContent); } catch (error) { console.log(error); } }); }
[ "function", "getFile", "(", "name", ",", "next", ")", "{", "// save the callback", "fileCallBacks", "[", "name", "]", "=", "next", ";", "setImmediate", "(", "function", "(", ")", "{", "try", "{", "ExtractContent", ".", "extractContent", "(", "name", ",", "handleGetFile", ",", "_requestFileContent", ")", ";", "}", "catch", "(", "error", ")", "{", "console", ".", "log", "(", "error", ")", ";", "}", "}", ")", ";", "}" ]
Provide the contents of the requested file to tern @param {string} name - the name of the file @param {Function} next - the function to call with the text of the file once it has been read in.
[ "Provide", "the", "contents", "of", "the", "requested", "file", "to", "tern" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/node/TernNodeDomain.js#L133-L144
1,820
adobe/brackets
src/JSUtils/node/TernNodeDomain.js
resetTernServer
function resetTernServer() { // If a server is already created just reset the analysis data if (ternServer) { ternServer.reset(); Infer.resetGuessing(); // tell the main thread we're ready to start processing again self.postMessage({type: MessageIds.TERN_WORKER_READY}); } }
javascript
function resetTernServer() { // If a server is already created just reset the analysis data if (ternServer) { ternServer.reset(); Infer.resetGuessing(); // tell the main thread we're ready to start processing again self.postMessage({type: MessageIds.TERN_WORKER_READY}); } }
[ "function", "resetTernServer", "(", ")", "{", "// If a server is already created just reset the analysis data ", "if", "(", "ternServer", ")", "{", "ternServer", ".", "reset", "(", ")", ";", "Infer", ".", "resetGuessing", "(", ")", ";", "// tell the main thread we're ready to start processing again", "self", ".", "postMessage", "(", "{", "type", ":", "MessageIds", ".", "TERN_WORKER_READY", "}", ")", ";", "}", "}" ]
Resets an existing tern server.
[ "Resets", "an", "existing", "tern", "server", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/node/TernNodeDomain.js#L179-L187
1,821
adobe/brackets
src/JSUtils/node/TernNodeDomain.js
buildRequest
function buildRequest(fileInfo, query, offset) { query = {type: query}; query.start = offset; query.end = offset; query.file = (fileInfo.type === MessageIds.TERN_FILE_INFO_TYPE_PART) ? "#0" : fileInfo.name; query.filter = false; query.sort = false; query.depths = true; query.guess = true; query.origins = true; query.types = true; query.expandWordForward = false; query.lineCharPositions = true; query.docs = true; query.urls = true; var request = {query: query, files: [], offset: offset, timeout: inferenceTimeout}; if (fileInfo.type !== MessageIds.TERN_FILE_INFO_TYPE_EMPTY) { // Create a copy to mutate ahead var fileInfoCopy = JSON.parse(JSON.stringify(fileInfo)); request.files.push(fileInfoCopy); } return request; }
javascript
function buildRequest(fileInfo, query, offset) { query = {type: query}; query.start = offset; query.end = offset; query.file = (fileInfo.type === MessageIds.TERN_FILE_INFO_TYPE_PART) ? "#0" : fileInfo.name; query.filter = false; query.sort = false; query.depths = true; query.guess = true; query.origins = true; query.types = true; query.expandWordForward = false; query.lineCharPositions = true; query.docs = true; query.urls = true; var request = {query: query, files: [], offset: offset, timeout: inferenceTimeout}; if (fileInfo.type !== MessageIds.TERN_FILE_INFO_TYPE_EMPTY) { // Create a copy to mutate ahead var fileInfoCopy = JSON.parse(JSON.stringify(fileInfo)); request.files.push(fileInfoCopy); } return request; }
[ "function", "buildRequest", "(", "fileInfo", ",", "query", ",", "offset", ")", "{", "query", "=", "{", "type", ":", "query", "}", ";", "query", ".", "start", "=", "offset", ";", "query", ".", "end", "=", "offset", ";", "query", ".", "file", "=", "(", "fileInfo", ".", "type", "===", "MessageIds", ".", "TERN_FILE_INFO_TYPE_PART", ")", "?", "\"#0\"", ":", "fileInfo", ".", "name", ";", "query", ".", "filter", "=", "false", ";", "query", ".", "sort", "=", "false", ";", "query", ".", "depths", "=", "true", ";", "query", ".", "guess", "=", "true", ";", "query", ".", "origins", "=", "true", ";", "query", ".", "types", "=", "true", ";", "query", ".", "expandWordForward", "=", "false", ";", "query", ".", "lineCharPositions", "=", "true", ";", "query", ".", "docs", "=", "true", ";", "query", ".", "urls", "=", "true", ";", "var", "request", "=", "{", "query", ":", "query", ",", "files", ":", "[", "]", ",", "offset", ":", "offset", ",", "timeout", ":", "inferenceTimeout", "}", ";", "if", "(", "fileInfo", ".", "type", "!==", "MessageIds", ".", "TERN_FILE_INFO_TYPE_EMPTY", ")", "{", "// Create a copy to mutate ahead", "var", "fileInfoCopy", "=", "JSON", ".", "parse", "(", "JSON", ".", "stringify", "(", "fileInfo", ")", ")", ";", "request", ".", "files", ".", "push", "(", "fileInfoCopy", ")", ";", "}", "return", "request", ";", "}" ]
Build an object that can be used as a request to tern. @param {{type: string, name: string, offsetLines: number, text: string}} fileInfo - type of update, name of file, and the text of the update. For "full" updates, the whole text of the file is present. For "part" updates, the changed portion of the text. For "empty" updates, the file has not been modified and the text is empty. @param {string} query - the type of request being made @param {{line: number, ch: number}} offset -
[ "Build", "an", "object", "that", "can", "be", "used", "as", "a", "request", "to", "tern", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/node/TernNodeDomain.js#L215-L239
1,822
adobe/brackets
src/JSUtils/node/TernNodeDomain.js
getRefs
function getRefs(fileInfo, offset) { var request = buildRequest(fileInfo, "refs", offset); try { ternServer.request(request, function (error, data) { if (error) { _log("Error returned from Tern 'refs' request: " + error); var response = { type: MessageIds.TERN_REFS, error: error.message }; self.postMessage(response); return; } var response = { type: MessageIds.TERN_REFS, file: fileInfo.name, offset: offset, references: data }; // Post a message back to the main thread with the results self.postMessage(response); }); } catch (e) { _reportError(e, fileInfo.name); } }
javascript
function getRefs(fileInfo, offset) { var request = buildRequest(fileInfo, "refs", offset); try { ternServer.request(request, function (error, data) { if (error) { _log("Error returned from Tern 'refs' request: " + error); var response = { type: MessageIds.TERN_REFS, error: error.message }; self.postMessage(response); return; } var response = { type: MessageIds.TERN_REFS, file: fileInfo.name, offset: offset, references: data }; // Post a message back to the main thread with the results self.postMessage(response); }); } catch (e) { _reportError(e, fileInfo.name); } }
[ "function", "getRefs", "(", "fileInfo", ",", "offset", ")", "{", "var", "request", "=", "buildRequest", "(", "fileInfo", ",", "\"refs\"", ",", "offset", ")", ";", "try", "{", "ternServer", ".", "request", "(", "request", ",", "function", "(", "error", ",", "data", ")", "{", "if", "(", "error", ")", "{", "_log", "(", "\"Error returned from Tern 'refs' request: \"", "+", "error", ")", ";", "var", "response", "=", "{", "type", ":", "MessageIds", ".", "TERN_REFS", ",", "error", ":", "error", ".", "message", "}", ";", "self", ".", "postMessage", "(", "response", ")", ";", "return", ";", "}", "var", "response", "=", "{", "type", ":", "MessageIds", ".", "TERN_REFS", ",", "file", ":", "fileInfo", ".", "name", ",", "offset", ":", "offset", ",", "references", ":", "data", "}", ";", "// Post a message back to the main thread with the results", "self", ".", "postMessage", "(", "response", ")", ";", "}", ")", ";", "}", "catch", "(", "e", ")", "{", "_reportError", "(", "e", ",", "fileInfo", ".", "name", ")", ";", "}", "}" ]
Get all References location @param {{type: string, name: string, offsetLines: number, text: string}} fileInfo - type of update, name of file, and the text of the update. For "full" updates, the whole text of the file is present. For "part" updates, the changed portion of the text. For "empty" updates, the file has not been modified and the text is empty. @param {{line: number, ch: number}} offset - the offset into the file for cursor
[ "Get", "all", "References", "location" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/node/TernNodeDomain.js#L252-L277
1,823
adobe/brackets
src/JSUtils/node/TernNodeDomain.js
getScopeData
function getScopeData(fileInfo, offset) { // Create a new tern Server // Existing tern server resolves all the required modules which might take time // We only need to analyze single file for getting the scope ternOptions.plugins = {}; var ternServer = new Tern.Server(ternOptions); ternServer.addFile(fileInfo.name, fileInfo.text); var error; var request = buildRequest(fileInfo, "completions", offset); // for primepump try { // primepump ternServer.request(request, function (ternError, data) { if (ternError) { _log("Error for Tern request: \n" + JSON.stringify(request) + "\n" + ternError); error = ternError.toString(); } else { var file = ternServer.findFile(fileInfo.name); var scope = Infer.scopeAt(file.ast, Tern.resolvePos(file, offset), file.scope); if (scope) { // Remove unwanted properties to remove cycles in the object scope = JSON.parse(JSON.stringify(scope, function(key, value) { if (["proto", "propertyOf", "onNewProp", "sourceFile", "maybeProps"].includes(key)) { return undefined; } else if (key === "fnType") { return value.name || "FunctionExpression"; } else if (key === "props") { for (var key in value) { value[key] = value[key].propertyName; } return value; } else if (key === "originNode") { return value && { start: value.start, end: value.end, type: value.type, body: { start: value.body.start, end: value.body.end } }; } return value; })); } self.postMessage({ type: MessageIds.TERN_SCOPEDATA_MSG, file: _getNormalizedFilename(fileInfo.name), offset: offset, scope: scope }); } }); } catch (e) { _reportError(e, fileInfo.name); } finally { ternServer.reset(); Infer.resetGuessing(); } }
javascript
function getScopeData(fileInfo, offset) { // Create a new tern Server // Existing tern server resolves all the required modules which might take time // We only need to analyze single file for getting the scope ternOptions.plugins = {}; var ternServer = new Tern.Server(ternOptions); ternServer.addFile(fileInfo.name, fileInfo.text); var error; var request = buildRequest(fileInfo, "completions", offset); // for primepump try { // primepump ternServer.request(request, function (ternError, data) { if (ternError) { _log("Error for Tern request: \n" + JSON.stringify(request) + "\n" + ternError); error = ternError.toString(); } else { var file = ternServer.findFile(fileInfo.name); var scope = Infer.scopeAt(file.ast, Tern.resolvePos(file, offset), file.scope); if (scope) { // Remove unwanted properties to remove cycles in the object scope = JSON.parse(JSON.stringify(scope, function(key, value) { if (["proto", "propertyOf", "onNewProp", "sourceFile", "maybeProps"].includes(key)) { return undefined; } else if (key === "fnType") { return value.name || "FunctionExpression"; } else if (key === "props") { for (var key in value) { value[key] = value[key].propertyName; } return value; } else if (key === "originNode") { return value && { start: value.start, end: value.end, type: value.type, body: { start: value.body.start, end: value.body.end } }; } return value; })); } self.postMessage({ type: MessageIds.TERN_SCOPEDATA_MSG, file: _getNormalizedFilename(fileInfo.name), offset: offset, scope: scope }); } }); } catch (e) { _reportError(e, fileInfo.name); } finally { ternServer.reset(); Infer.resetGuessing(); } }
[ "function", "getScopeData", "(", "fileInfo", ",", "offset", ")", "{", "// Create a new tern Server", "// Existing tern server resolves all the required modules which might take time", "// We only need to analyze single file for getting the scope", "ternOptions", ".", "plugins", "=", "{", "}", ";", "var", "ternServer", "=", "new", "Tern", ".", "Server", "(", "ternOptions", ")", ";", "ternServer", ".", "addFile", "(", "fileInfo", ".", "name", ",", "fileInfo", ".", "text", ")", ";", "var", "error", ";", "var", "request", "=", "buildRequest", "(", "fileInfo", ",", "\"completions\"", ",", "offset", ")", ";", "// for primepump", "try", "{", "// primepump", "ternServer", ".", "request", "(", "request", ",", "function", "(", "ternError", ",", "data", ")", "{", "if", "(", "ternError", ")", "{", "_log", "(", "\"Error for Tern request: \\n\"", "+", "JSON", ".", "stringify", "(", "request", ")", "+", "\"\\n\"", "+", "ternError", ")", ";", "error", "=", "ternError", ".", "toString", "(", ")", ";", "}", "else", "{", "var", "file", "=", "ternServer", ".", "findFile", "(", "fileInfo", ".", "name", ")", ";", "var", "scope", "=", "Infer", ".", "scopeAt", "(", "file", ".", "ast", ",", "Tern", ".", "resolvePos", "(", "file", ",", "offset", ")", ",", "file", ".", "scope", ")", ";", "if", "(", "scope", ")", "{", "// Remove unwanted properties to remove cycles in the object", "scope", "=", "JSON", ".", "parse", "(", "JSON", ".", "stringify", "(", "scope", ",", "function", "(", "key", ",", "value", ")", "{", "if", "(", "[", "\"proto\"", ",", "\"propertyOf\"", ",", "\"onNewProp\"", ",", "\"sourceFile\"", ",", "\"maybeProps\"", "]", ".", "includes", "(", "key", ")", ")", "{", "return", "undefined", ";", "}", "else", "if", "(", "key", "===", "\"fnType\"", ")", "{", "return", "value", ".", "name", "||", "\"FunctionExpression\"", ";", "}", "else", "if", "(", "key", "===", "\"props\"", ")", "{", "for", "(", "var", "key", "in", "value", ")", "{", "value", "[", "key", "]", "=", "value", "[", "key", "]", ".", "propertyName", ";", "}", "return", "value", ";", "}", "else", "if", "(", "key", "===", "\"originNode\"", ")", "{", "return", "value", "&&", "{", "start", ":", "value", ".", "start", ",", "end", ":", "value", ".", "end", ",", "type", ":", "value", ".", "type", ",", "body", ":", "{", "start", ":", "value", ".", "body", ".", "start", ",", "end", ":", "value", ".", "body", ".", "end", "}", "}", ";", "}", "return", "value", ";", "}", ")", ")", ";", "}", "self", ".", "postMessage", "(", "{", "type", ":", "MessageIds", ".", "TERN_SCOPEDATA_MSG", ",", "file", ":", "_getNormalizedFilename", "(", "fileInfo", ".", "name", ")", ",", "offset", ":", "offset", ",", "scope", ":", "scope", "}", ")", ";", "}", "}", ")", ";", "}", "catch", "(", "e", ")", "{", "_reportError", "(", "e", ",", "fileInfo", ".", "name", ")", ";", "}", "finally", "{", "ternServer", ".", "reset", "(", ")", ";", "Infer", ".", "resetGuessing", "(", ")", ";", "}", "}" ]
Get scope at the offset in the file @param {{type: string, name: string, offsetLines: number, text: string}} fileInfo - type of update, name of file, and the text of the update. For "full" updates, the whole text of the file is present. For "part" updates, the changed portion of the text. For "empty" updates, the file has not been modified and the text is empty. @param {{line: number, ch: number}} offset - the offset into the file for cursor
[ "Get", "scope", "at", "the", "offset", "in", "the", "file" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/node/TernNodeDomain.js#L289-L354
1,824
adobe/brackets
src/JSUtils/node/TernNodeDomain.js
getTernProperties
function getTernProperties(fileInfo, offset, type) { var request = buildRequest(fileInfo, "properties", offset), i; //_log("tern properties: request " + request.type + dir + " " + file); try { ternServer.request(request, function (error, data) { var properties = []; if (error) { _log("Error returned from Tern 'properties' request: " + error); } else { //_log("tern properties: completions = " + data.completions.length); properties = data.completions.map(function (completion) { return {value: completion, type: completion.type, guess: true}; }); } // Post a message back to the main thread with the completions self.postMessage({type: type, file: _getNormalizedFilename(fileInfo.name), offset: offset, properties: properties }); }); } catch (e) { _reportError(e, fileInfo.name); } }
javascript
function getTernProperties(fileInfo, offset, type) { var request = buildRequest(fileInfo, "properties", offset), i; //_log("tern properties: request " + request.type + dir + " " + file); try { ternServer.request(request, function (error, data) { var properties = []; if (error) { _log("Error returned from Tern 'properties' request: " + error); } else { //_log("tern properties: completions = " + data.completions.length); properties = data.completions.map(function (completion) { return {value: completion, type: completion.type, guess: true}; }); } // Post a message back to the main thread with the completions self.postMessage({type: type, file: _getNormalizedFilename(fileInfo.name), offset: offset, properties: properties }); }); } catch (e) { _reportError(e, fileInfo.name); } }
[ "function", "getTernProperties", "(", "fileInfo", ",", "offset", ",", "type", ")", "{", "var", "request", "=", "buildRequest", "(", "fileInfo", ",", "\"properties\"", ",", "offset", ")", ",", "i", ";", "//_log(\"tern properties: request \" + request.type + dir + \" \" + file);", "try", "{", "ternServer", ".", "request", "(", "request", ",", "function", "(", "error", ",", "data", ")", "{", "var", "properties", "=", "[", "]", ";", "if", "(", "error", ")", "{", "_log", "(", "\"Error returned from Tern 'properties' request: \"", "+", "error", ")", ";", "}", "else", "{", "//_log(\"tern properties: completions = \" + data.completions.length);", "properties", "=", "data", ".", "completions", ".", "map", "(", "function", "(", "completion", ")", "{", "return", "{", "value", ":", "completion", ",", "type", ":", "completion", ".", "type", ",", "guess", ":", "true", "}", ";", "}", ")", ";", "}", "// Post a message back to the main thread with the completions", "self", ".", "postMessage", "(", "{", "type", ":", "type", ",", "file", ":", "_getNormalizedFilename", "(", "fileInfo", ".", "name", ")", ",", "offset", ":", "offset", ",", "properties", ":", "properties", "}", ")", ";", "}", ")", ";", "}", "catch", "(", "e", ")", "{", "_reportError", "(", "e", ",", "fileInfo", ".", "name", ")", ";", "}", "}" ]
Get all the known properties for guessing. @param {{type: string, name: string, offsetLines: number, text: string}} fileInfo - type of update, name of file, and the text of the update. For "full" updates, the whole text of the file is present. For "part" updates, the changed portion of the text. For "empty" updates, the file has not been modified and the text is empty. @param {{line: number, ch: number}} offset - the offset into the file where we want completions for @param {string} type - the type of the message to reply with.
[ "Get", "all", "the", "known", "properties", "for", "guessing", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/node/TernNodeDomain.js#L416-L442
1,825
adobe/brackets
src/JSUtils/node/TernNodeDomain.js
getTernHints
function getTernHints(fileInfo, offset, isProperty) { var request = buildRequest(fileInfo, "completions", offset), i; //_log("request " + dir + " " + file + " " + offset /*+ " " + text */); try { ternServer.request(request, function (error, data) { var completions = []; if (error) { _log("Error returned from Tern 'completions' request: " + error); } else { //_log("found " + data.completions + " for " + file + "@" + offset); completions = data.completions.map(function (completion) { return {value: completion.name, type: completion.type, depth: completion.depth, guess: completion.guess, origin: completion.origin, doc: completion.doc, url: completion.url}; }); } if (completions.length > 0 || !isProperty) { // Post a message back to the main thread with the completions self.postMessage({type: MessageIds.TERN_COMPLETIONS_MSG, file: _getNormalizedFilename(fileInfo.name), offset: offset, completions: completions }); } else { // if there are no completions, then get all the properties getTernProperties(fileInfo, offset, MessageIds.TERN_COMPLETIONS_MSG); } }); } catch (e) { _reportError(e, fileInfo.name); } }
javascript
function getTernHints(fileInfo, offset, isProperty) { var request = buildRequest(fileInfo, "completions", offset), i; //_log("request " + dir + " " + file + " " + offset /*+ " " + text */); try { ternServer.request(request, function (error, data) { var completions = []; if (error) { _log("Error returned from Tern 'completions' request: " + error); } else { //_log("found " + data.completions + " for " + file + "@" + offset); completions = data.completions.map(function (completion) { return {value: completion.name, type: completion.type, depth: completion.depth, guess: completion.guess, origin: completion.origin, doc: completion.doc, url: completion.url}; }); } if (completions.length > 0 || !isProperty) { // Post a message back to the main thread with the completions self.postMessage({type: MessageIds.TERN_COMPLETIONS_MSG, file: _getNormalizedFilename(fileInfo.name), offset: offset, completions: completions }); } else { // if there are no completions, then get all the properties getTernProperties(fileInfo, offset, MessageIds.TERN_COMPLETIONS_MSG); } }); } catch (e) { _reportError(e, fileInfo.name); } }
[ "function", "getTernHints", "(", "fileInfo", ",", "offset", ",", "isProperty", ")", "{", "var", "request", "=", "buildRequest", "(", "fileInfo", ",", "\"completions\"", ",", "offset", ")", ",", "i", ";", "//_log(\"request \" + dir + \" \" + file + \" \" + offset /*+ \" \" + text */);", "try", "{", "ternServer", ".", "request", "(", "request", ",", "function", "(", "error", ",", "data", ")", "{", "var", "completions", "=", "[", "]", ";", "if", "(", "error", ")", "{", "_log", "(", "\"Error returned from Tern 'completions' request: \"", "+", "error", ")", ";", "}", "else", "{", "//_log(\"found \" + data.completions + \" for \" + file + \"@\" + offset);", "completions", "=", "data", ".", "completions", ".", "map", "(", "function", "(", "completion", ")", "{", "return", "{", "value", ":", "completion", ".", "name", ",", "type", ":", "completion", ".", "type", ",", "depth", ":", "completion", ".", "depth", ",", "guess", ":", "completion", ".", "guess", ",", "origin", ":", "completion", ".", "origin", ",", "doc", ":", "completion", ".", "doc", ",", "url", ":", "completion", ".", "url", "}", ";", "}", ")", ";", "}", "if", "(", "completions", ".", "length", ">", "0", "||", "!", "isProperty", ")", "{", "// Post a message back to the main thread with the completions", "self", ".", "postMessage", "(", "{", "type", ":", "MessageIds", ".", "TERN_COMPLETIONS_MSG", ",", "file", ":", "_getNormalizedFilename", "(", "fileInfo", ".", "name", ")", ",", "offset", ":", "offset", ",", "completions", ":", "completions", "}", ")", ";", "}", "else", "{", "// if there are no completions, then get all the properties", "getTernProperties", "(", "fileInfo", ",", "offset", ",", "MessageIds", ".", "TERN_COMPLETIONS_MSG", ")", ";", "}", "}", ")", ";", "}", "catch", "(", "e", ")", "{", "_reportError", "(", "e", ",", "fileInfo", ".", "name", ")", ";", "}", "}" ]
Get the completions for the given offset @param {{type: string, name: string, offsetLines: number, text: string}} fileInfo - type of update, name of file, and the text of the update. For "full" updates, the whole text of the file is present. For "part" updates, the changed portion of the text. For "empty" updates, the file has not been modified and the text is empty. @param {{line: number, ch: number}} offset - the offset into the file where we want completions for @param {boolean} isProperty - true if getting a property hint, otherwise getting an identifier hint.
[ "Get", "the", "completions", "for", "the", "given", "offset" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/node/TernNodeDomain.js#L457-L489
1,826
adobe/brackets
src/JSUtils/node/TernNodeDomain.js
inferArrTypeToString
function inferArrTypeToString(inferArrType) { var result = "Array.<"; result += inferArrType.props["<i>"].types.map(inferTypeToString).join(", "); // workaround case where types is zero length if (inferArrType.props["<i>"].types.length === 0) { result += "Object"; } result += ">"; return result; }
javascript
function inferArrTypeToString(inferArrType) { var result = "Array.<"; result += inferArrType.props["<i>"].types.map(inferTypeToString).join(", "); // workaround case where types is zero length if (inferArrType.props["<i>"].types.length === 0) { result += "Object"; } result += ">"; return result; }
[ "function", "inferArrTypeToString", "(", "inferArrType", ")", "{", "var", "result", "=", "\"Array.<\"", ";", "result", "+=", "inferArrType", ".", "props", "[", "\"<i>\"", "]", ".", "types", ".", "map", "(", "inferTypeToString", ")", ".", "join", "(", "\", \"", ")", ";", "// workaround case where types is zero length", "if", "(", "inferArrType", ".", "props", "[", "\"<i>\"", "]", ".", "types", ".", "length", "===", "0", ")", "{", "result", "+=", "\"Object\"", ";", "}", "result", "+=", "\">\"", ";", "return", "result", ";", "}" ]
Convert an infer array type to a string. Formatted using google closure style. For example: "Array.<string, number>" @param {Infer.Arr} inferArrType @return {string} - array formatted in google closure style.
[ "Convert", "an", "infer", "array", "type", "to", "a", "string", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/node/TernNodeDomain.js#L515-L527
1,827
adobe/brackets
src/JSUtils/node/TernNodeDomain.js
handleFunctionType
function handleFunctionType(fileInfo, offset) { var request = buildRequest(fileInfo, "type", offset), error; request.query.preferFunction = true; var fnType = ""; try { ternServer.request(request, function (ternError, data) { if (ternError) { _log("Error for Tern request: \n" + JSON.stringify(request) + "\n" + ternError); error = ternError.toString(); } else { var file = ternServer.findFile(fileInfo.name); // convert query from partial to full offsets var newOffset = offset; if (fileInfo.type === MessageIds.TERN_FILE_INFO_TYPE_PART) { newOffset = {line: offset.line + fileInfo.offsetLines, ch: offset.ch}; } request = buildRequest(createEmptyUpdate(fileInfo.name), "type", newOffset); var expr = Tern.findQueryExpr(file, request.query); Infer.resetGuessing(); var type = Infer.expressionType(expr); type = type.getFunctionType() || type.getType(); if (type) { fnType = getParameters(type); } else { ternError = "No parameter type found"; _log(ternError); } } }); } catch (e) { _reportError(e, fileInfo.name); } // Post a message back to the main thread with the completions self.postMessage({type: MessageIds.TERN_CALLED_FUNC_TYPE_MSG, file: _getNormalizedFilename(fileInfo.name), offset: offset, fnType: fnType, error: error }); }
javascript
function handleFunctionType(fileInfo, offset) { var request = buildRequest(fileInfo, "type", offset), error; request.query.preferFunction = true; var fnType = ""; try { ternServer.request(request, function (ternError, data) { if (ternError) { _log("Error for Tern request: \n" + JSON.stringify(request) + "\n" + ternError); error = ternError.toString(); } else { var file = ternServer.findFile(fileInfo.name); // convert query from partial to full offsets var newOffset = offset; if (fileInfo.type === MessageIds.TERN_FILE_INFO_TYPE_PART) { newOffset = {line: offset.line + fileInfo.offsetLines, ch: offset.ch}; } request = buildRequest(createEmptyUpdate(fileInfo.name), "type", newOffset); var expr = Tern.findQueryExpr(file, request.query); Infer.resetGuessing(); var type = Infer.expressionType(expr); type = type.getFunctionType() || type.getType(); if (type) { fnType = getParameters(type); } else { ternError = "No parameter type found"; _log(ternError); } } }); } catch (e) { _reportError(e, fileInfo.name); } // Post a message back to the main thread with the completions self.postMessage({type: MessageIds.TERN_CALLED_FUNC_TYPE_MSG, file: _getNormalizedFilename(fileInfo.name), offset: offset, fnType: fnType, error: error }); }
[ "function", "handleFunctionType", "(", "fileInfo", ",", "offset", ")", "{", "var", "request", "=", "buildRequest", "(", "fileInfo", ",", "\"type\"", ",", "offset", ")", ",", "error", ";", "request", ".", "query", ".", "preferFunction", "=", "true", ";", "var", "fnType", "=", "\"\"", ";", "try", "{", "ternServer", ".", "request", "(", "request", ",", "function", "(", "ternError", ",", "data", ")", "{", "if", "(", "ternError", ")", "{", "_log", "(", "\"Error for Tern request: \\n\"", "+", "JSON", ".", "stringify", "(", "request", ")", "+", "\"\\n\"", "+", "ternError", ")", ";", "error", "=", "ternError", ".", "toString", "(", ")", ";", "}", "else", "{", "var", "file", "=", "ternServer", ".", "findFile", "(", "fileInfo", ".", "name", ")", ";", "// convert query from partial to full offsets", "var", "newOffset", "=", "offset", ";", "if", "(", "fileInfo", ".", "type", "===", "MessageIds", ".", "TERN_FILE_INFO_TYPE_PART", ")", "{", "newOffset", "=", "{", "line", ":", "offset", ".", "line", "+", "fileInfo", ".", "offsetLines", ",", "ch", ":", "offset", ".", "ch", "}", ";", "}", "request", "=", "buildRequest", "(", "createEmptyUpdate", "(", "fileInfo", ".", "name", ")", ",", "\"type\"", ",", "newOffset", ")", ";", "var", "expr", "=", "Tern", ".", "findQueryExpr", "(", "file", ",", "request", ".", "query", ")", ";", "Infer", ".", "resetGuessing", "(", ")", ";", "var", "type", "=", "Infer", ".", "expressionType", "(", "expr", ")", ";", "type", "=", "type", ".", "getFunctionType", "(", ")", "||", "type", ".", "getType", "(", ")", ";", "if", "(", "type", ")", "{", "fnType", "=", "getParameters", "(", "type", ")", ";", "}", "else", "{", "ternError", "=", "\"No parameter type found\"", ";", "_log", "(", "ternError", ")", ";", "}", "}", "}", ")", ";", "}", "catch", "(", "e", ")", "{", "_reportError", "(", "e", ",", "fileInfo", ".", "name", ")", ";", "}", "// Post a message back to the main thread with the completions", "self", ".", "postMessage", "(", "{", "type", ":", "MessageIds", ".", "TERN_CALLED_FUNC_TYPE_MSG", ",", "file", ":", "_getNormalizedFilename", "(", "fileInfo", ".", "name", ")", ",", "offset", ":", "offset", ",", "fnType", ":", "fnType", ",", "error", ":", "error", "}", ")", ";", "}" ]
Get the function type for the given offset @param {{type: string, name: string, offsetLines: number, text: string}} fileInfo - type of update, name of file, and the text of the update. For "full" updates, the whole text of the file is present. For "part" updates, the changed portion of the text. For "empty" updates, the file has not been modified and the text is empty. @param {{line: number, ch: number}} offset - the offset into the file where we want completions for
[ "Get", "the", "function", "type", "for", "the", "given", "offset" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/node/TernNodeDomain.js#L728-L776
1,828
adobe/brackets
src/JSUtils/node/TernNodeDomain.js
handleUpdateFile
function handleUpdateFile(path, text) { ternServer.addFile(path, text); self.postMessage({type: MessageIds.TERN_UPDATE_FILE_MSG, path: path }); // reset to get the best hints with the updated file. ternServer.reset(); Infer.resetGuessing(); }
javascript
function handleUpdateFile(path, text) { ternServer.addFile(path, text); self.postMessage({type: MessageIds.TERN_UPDATE_FILE_MSG, path: path }); // reset to get the best hints with the updated file. ternServer.reset(); Infer.resetGuessing(); }
[ "function", "handleUpdateFile", "(", "path", ",", "text", ")", "{", "ternServer", ".", "addFile", "(", "path", ",", "text", ")", ";", "self", ".", "postMessage", "(", "{", "type", ":", "MessageIds", ".", "TERN_UPDATE_FILE_MSG", ",", "path", ":", "path", "}", ")", ";", "// reset to get the best hints with the updated file.", "ternServer", ".", "reset", "(", ")", ";", "Infer", ".", "resetGuessing", "(", ")", ";", "}" ]
Update the context of a file in tern. @param {string} path - full path of file. @param {string} text - content of the file.
[ "Update", "the", "context", "of", "a", "file", "in", "tern", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/node/TernNodeDomain.js#L796-L807
1,829
adobe/brackets
src/JSUtils/node/TernNodeDomain.js
handlePrimePump
function handlePrimePump(path) { var fileName = _getDenormalizedFilename(path); var fileInfo = createEmptyUpdate(fileName), request = buildRequest(fileInfo, "completions", {line: 0, ch: 0}); try { ternServer.request(request, function (error, data) { // Post a message back to the main thread self.postMessage({type: MessageIds.TERN_PRIME_PUMP_MSG, path: _getNormalizedFilename(path) }); }); } catch (e) { _reportError(e, path); } }
javascript
function handlePrimePump(path) { var fileName = _getDenormalizedFilename(path); var fileInfo = createEmptyUpdate(fileName), request = buildRequest(fileInfo, "completions", {line: 0, ch: 0}); try { ternServer.request(request, function (error, data) { // Post a message back to the main thread self.postMessage({type: MessageIds.TERN_PRIME_PUMP_MSG, path: _getNormalizedFilename(path) }); }); } catch (e) { _reportError(e, path); } }
[ "function", "handlePrimePump", "(", "path", ")", "{", "var", "fileName", "=", "_getDenormalizedFilename", "(", "path", ")", ";", "var", "fileInfo", "=", "createEmptyUpdate", "(", "fileName", ")", ",", "request", "=", "buildRequest", "(", "fileInfo", ",", "\"completions\"", ",", "{", "line", ":", "0", ",", "ch", ":", "0", "}", ")", ";", "try", "{", "ternServer", ".", "request", "(", "request", ",", "function", "(", "error", ",", "data", ")", "{", "// Post a message back to the main thread", "self", ".", "postMessage", "(", "{", "type", ":", "MessageIds", ".", "TERN_PRIME_PUMP_MSG", ",", "path", ":", "_getNormalizedFilename", "(", "path", ")", "}", ")", ";", "}", ")", ";", "}", "catch", "(", "e", ")", "{", "_reportError", "(", "e", ",", "path", ")", ";", "}", "}" ]
Make a completions request to tern to force tern to resolve files and create a fast first lookup for the user. @param {string} path - the path of the file
[ "Make", "a", "completions", "request", "to", "tern", "to", "force", "tern", "to", "resolve", "files", "and", "create", "a", "fast", "first", "lookup", "for", "the", "user", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/node/TernNodeDomain.js#L814-L829
1,830
adobe/brackets
src/utils/ViewUtils.js
_updateScrollerShadow
function _updateScrollerShadow($displayElement, $scrollElement, $shadowTop, $shadowBottom, isPositionFixed) { var offsetTop = 0, scrollElement = $scrollElement.get(0), scrollTop = scrollElement.scrollTop, topShadowOffset = Math.min(scrollTop - SCROLL_SHADOW_HEIGHT, 0), displayElementWidth = $displayElement.width(); if ($shadowTop) { $shadowTop.css("background-position", "0px " + topShadowOffset + "px"); if (isPositionFixed) { offsetTop = $displayElement.offset().top; $shadowTop.css("top", offsetTop); } if (isPositionFixed) { $shadowTop.css("width", displayElementWidth); } } if ($shadowBottom) { var clientHeight = scrollElement.clientHeight, outerHeight = $displayElement.outerHeight(), scrollHeight = scrollElement.scrollHeight, bottomShadowOffset = SCROLL_SHADOW_HEIGHT; // outside of shadow div viewport if (scrollHeight > clientHeight) { bottomShadowOffset -= Math.min(SCROLL_SHADOW_HEIGHT, (scrollHeight - (scrollTop + clientHeight))); } $shadowBottom.css("background-position", "0px " + bottomShadowOffset + "px"); $shadowBottom.css("top", offsetTop + outerHeight - SCROLL_SHADOW_HEIGHT); $shadowBottom.css("width", displayElementWidth); } }
javascript
function _updateScrollerShadow($displayElement, $scrollElement, $shadowTop, $shadowBottom, isPositionFixed) { var offsetTop = 0, scrollElement = $scrollElement.get(0), scrollTop = scrollElement.scrollTop, topShadowOffset = Math.min(scrollTop - SCROLL_SHADOW_HEIGHT, 0), displayElementWidth = $displayElement.width(); if ($shadowTop) { $shadowTop.css("background-position", "0px " + topShadowOffset + "px"); if (isPositionFixed) { offsetTop = $displayElement.offset().top; $shadowTop.css("top", offsetTop); } if (isPositionFixed) { $shadowTop.css("width", displayElementWidth); } } if ($shadowBottom) { var clientHeight = scrollElement.clientHeight, outerHeight = $displayElement.outerHeight(), scrollHeight = scrollElement.scrollHeight, bottomShadowOffset = SCROLL_SHADOW_HEIGHT; // outside of shadow div viewport if (scrollHeight > clientHeight) { bottomShadowOffset -= Math.min(SCROLL_SHADOW_HEIGHT, (scrollHeight - (scrollTop + clientHeight))); } $shadowBottom.css("background-position", "0px " + bottomShadowOffset + "px"); $shadowBottom.css("top", offsetTop + outerHeight - SCROLL_SHADOW_HEIGHT); $shadowBottom.css("width", displayElementWidth); } }
[ "function", "_updateScrollerShadow", "(", "$displayElement", ",", "$scrollElement", ",", "$shadowTop", ",", "$shadowBottom", ",", "isPositionFixed", ")", "{", "var", "offsetTop", "=", "0", ",", "scrollElement", "=", "$scrollElement", ".", "get", "(", "0", ")", ",", "scrollTop", "=", "scrollElement", ".", "scrollTop", ",", "topShadowOffset", "=", "Math", ".", "min", "(", "scrollTop", "-", "SCROLL_SHADOW_HEIGHT", ",", "0", ")", ",", "displayElementWidth", "=", "$displayElement", ".", "width", "(", ")", ";", "if", "(", "$shadowTop", ")", "{", "$shadowTop", ".", "css", "(", "\"background-position\"", ",", "\"0px \"", "+", "topShadowOffset", "+", "\"px\"", ")", ";", "if", "(", "isPositionFixed", ")", "{", "offsetTop", "=", "$displayElement", ".", "offset", "(", ")", ".", "top", ";", "$shadowTop", ".", "css", "(", "\"top\"", ",", "offsetTop", ")", ";", "}", "if", "(", "isPositionFixed", ")", "{", "$shadowTop", ".", "css", "(", "\"width\"", ",", "displayElementWidth", ")", ";", "}", "}", "if", "(", "$shadowBottom", ")", "{", "var", "clientHeight", "=", "scrollElement", ".", "clientHeight", ",", "outerHeight", "=", "$displayElement", ".", "outerHeight", "(", ")", ",", "scrollHeight", "=", "scrollElement", ".", "scrollHeight", ",", "bottomShadowOffset", "=", "SCROLL_SHADOW_HEIGHT", ";", "// outside of shadow div viewport", "if", "(", "scrollHeight", ">", "clientHeight", ")", "{", "bottomShadowOffset", "-=", "Math", ".", "min", "(", "SCROLL_SHADOW_HEIGHT", ",", "(", "scrollHeight", "-", "(", "scrollTop", "+", "clientHeight", ")", ")", ")", ";", "}", "$shadowBottom", ".", "css", "(", "\"background-position\"", ",", "\"0px \"", "+", "bottomShadowOffset", "+", "\"px\"", ")", ";", "$shadowBottom", ".", "css", "(", "\"top\"", ",", "offsetTop", "+", "outerHeight", "-", "SCROLL_SHADOW_HEIGHT", ")", ";", "$shadowBottom", ".", "css", "(", "\"width\"", ",", "displayElementWidth", ")", ";", "}", "}" ]
Positions shadow background elements to indicate vertical scrolling. @param {!DOMElement} $displayElement the DOMElement that displays the shadow @param {!Object} $scrollElement the object that is scrolled @param {!DOMElement} $shadowTop div .scroller-shadow.top @param {!DOMElement} $shadowBottom div .scroller-shadow.bottom @param {boolean} isPositionFixed When using absolute position, top remains at 0.
[ "Positions", "shadow", "background", "elements", "to", "indicate", "vertical", "scrolling", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ViewUtils.js#L45-L79
1,831
adobe/brackets
src/utils/ViewUtils.js
addScrollerShadow
function addScrollerShadow(displayElement, scrollElement, showBottom) { // use fixed positioning when the display and scroll elements are the same var isPositionFixed = false; if (!scrollElement) { scrollElement = displayElement; isPositionFixed = true; } // update shadows when the scrolling element is scrolled var $displayElement = $(displayElement), $scrollElement = $(scrollElement); var $shadowTop = getOrCreateShadow($displayElement, "top", isPositionFixed); var $shadowBottom = (showBottom) ? getOrCreateShadow($displayElement, "bottom", isPositionFixed) : null; var doUpdate = function () { _updateScrollerShadow($displayElement, $scrollElement, $shadowTop, $shadowBottom, isPositionFixed); }; // remove any previously installed listeners on this node $scrollElement.off("scroll.scroller-shadow"); $displayElement.off("contentChanged.scroller-shadow"); // add new ones $scrollElement.on("scroll.scroller-shadow", doUpdate); $displayElement.on("contentChanged.scroller-shadow", doUpdate); // update immediately doUpdate(); }
javascript
function addScrollerShadow(displayElement, scrollElement, showBottom) { // use fixed positioning when the display and scroll elements are the same var isPositionFixed = false; if (!scrollElement) { scrollElement = displayElement; isPositionFixed = true; } // update shadows when the scrolling element is scrolled var $displayElement = $(displayElement), $scrollElement = $(scrollElement); var $shadowTop = getOrCreateShadow($displayElement, "top", isPositionFixed); var $shadowBottom = (showBottom) ? getOrCreateShadow($displayElement, "bottom", isPositionFixed) : null; var doUpdate = function () { _updateScrollerShadow($displayElement, $scrollElement, $shadowTop, $shadowBottom, isPositionFixed); }; // remove any previously installed listeners on this node $scrollElement.off("scroll.scroller-shadow"); $displayElement.off("contentChanged.scroller-shadow"); // add new ones $scrollElement.on("scroll.scroller-shadow", doUpdate); $displayElement.on("contentChanged.scroller-shadow", doUpdate); // update immediately doUpdate(); }
[ "function", "addScrollerShadow", "(", "displayElement", ",", "scrollElement", ",", "showBottom", ")", "{", "// use fixed positioning when the display and scroll elements are the same", "var", "isPositionFixed", "=", "false", ";", "if", "(", "!", "scrollElement", ")", "{", "scrollElement", "=", "displayElement", ";", "isPositionFixed", "=", "true", ";", "}", "// update shadows when the scrolling element is scrolled", "var", "$displayElement", "=", "$", "(", "displayElement", ")", ",", "$scrollElement", "=", "$", "(", "scrollElement", ")", ";", "var", "$shadowTop", "=", "getOrCreateShadow", "(", "$displayElement", ",", "\"top\"", ",", "isPositionFixed", ")", ";", "var", "$shadowBottom", "=", "(", "showBottom", ")", "?", "getOrCreateShadow", "(", "$displayElement", ",", "\"bottom\"", ",", "isPositionFixed", ")", ":", "null", ";", "var", "doUpdate", "=", "function", "(", ")", "{", "_updateScrollerShadow", "(", "$displayElement", ",", "$scrollElement", ",", "$shadowTop", ",", "$shadowBottom", ",", "isPositionFixed", ")", ";", "}", ";", "// remove any previously installed listeners on this node", "$scrollElement", ".", "off", "(", "\"scroll.scroller-shadow\"", ")", ";", "$displayElement", ".", "off", "(", "\"contentChanged.scroller-shadow\"", ")", ";", "// add new ones", "$scrollElement", ".", "on", "(", "\"scroll.scroller-shadow\"", ",", "doUpdate", ")", ";", "$displayElement", ".", "on", "(", "\"contentChanged.scroller-shadow\"", ",", "doUpdate", ")", ";", "// update immediately", "doUpdate", "(", ")", ";", "}" ]
Installs event handlers for updatng shadow background elements to indicate vertical scrolling. @param {!DOMElement} displayElement the DOMElement that displays the shadow. Must fire "contentChanged" events when the element is resized or repositioned. @param {?Object} scrollElement the object that is scrolled. Must fire "scroll" events when the element is scrolled. If null, the displayElement is used. @param {?boolean} showBottom optionally show the bottom shadow
[ "Installs", "event", "handlers", "for", "updatng", "shadow", "background", "elements", "to", "indicate", "vertical", "scrolling", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ViewUtils.js#L106-L136
1,832
adobe/brackets
src/utils/ViewUtils.js
removeScrollerShadow
function removeScrollerShadow(displayElement, scrollElement) { if (!scrollElement) { scrollElement = displayElement; } var $displayElement = $(displayElement), $scrollElement = $(scrollElement); // remove scrollerShadow elements from DOM $displayElement.find(".scroller-shadow.top").remove(); $displayElement.find(".scroller-shadow.bottom").remove(); // remove event handlers $scrollElement.off("scroll.scroller-shadow"); $displayElement.off("contentChanged.scroller-shadow"); }
javascript
function removeScrollerShadow(displayElement, scrollElement) { if (!scrollElement) { scrollElement = displayElement; } var $displayElement = $(displayElement), $scrollElement = $(scrollElement); // remove scrollerShadow elements from DOM $displayElement.find(".scroller-shadow.top").remove(); $displayElement.find(".scroller-shadow.bottom").remove(); // remove event handlers $scrollElement.off("scroll.scroller-shadow"); $displayElement.off("contentChanged.scroller-shadow"); }
[ "function", "removeScrollerShadow", "(", "displayElement", ",", "scrollElement", ")", "{", "if", "(", "!", "scrollElement", ")", "{", "scrollElement", "=", "displayElement", ";", "}", "var", "$displayElement", "=", "$", "(", "displayElement", ")", ",", "$scrollElement", "=", "$", "(", "scrollElement", ")", ";", "// remove scrollerShadow elements from DOM", "$displayElement", ".", "find", "(", "\".scroller-shadow.top\"", ")", ".", "remove", "(", ")", ";", "$displayElement", ".", "find", "(", "\".scroller-shadow.bottom\"", ")", ".", "remove", "(", ")", ";", "// remove event handlers", "$scrollElement", ".", "off", "(", "\"scroll.scroller-shadow\"", ")", ";", "$displayElement", ".", "off", "(", "\"contentChanged.scroller-shadow\"", ")", ";", "}" ]
Remove scroller-shadow effect. @param {!DOMElement} displayElement the DOMElement that displays the shadow @param {?Object} scrollElement the object that is scrolled
[ "Remove", "scroller", "-", "shadow", "effect", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ViewUtils.js#L143-L158
1,833
adobe/brackets
src/utils/ViewUtils.js
getElementClipSize
function getElementClipSize($view, elementRect) { var delta, clip = { top: 0, right: 0, bottom: 0, left: 0 }, viewOffset = $view.offset() || { top: 0, left: 0}; // Check if element extends below viewport delta = (elementRect.top + elementRect.height) - (viewOffset.top + $view.height()); if (delta > 0) { clip.bottom = delta; } // Check if element extends above viewport delta = viewOffset.top - elementRect.top; if (delta > 0) { clip.top = delta; } // Check if element extends to the left of viewport delta = viewOffset.left - elementRect.left; if (delta > 0) { clip.left = delta; } // Check if element extends to the right of viewport delta = (elementRect.left + elementRect.width) - (viewOffset.left + $view.width()); if (delta > 0) { clip.right = delta; } return clip; }
javascript
function getElementClipSize($view, elementRect) { var delta, clip = { top: 0, right: 0, bottom: 0, left: 0 }, viewOffset = $view.offset() || { top: 0, left: 0}; // Check if element extends below viewport delta = (elementRect.top + elementRect.height) - (viewOffset.top + $view.height()); if (delta > 0) { clip.bottom = delta; } // Check if element extends above viewport delta = viewOffset.top - elementRect.top; if (delta > 0) { clip.top = delta; } // Check if element extends to the left of viewport delta = viewOffset.left - elementRect.left; if (delta > 0) { clip.left = delta; } // Check if element extends to the right of viewport delta = (elementRect.left + elementRect.width) - (viewOffset.left + $view.width()); if (delta > 0) { clip.right = delta; } return clip; }
[ "function", "getElementClipSize", "(", "$view", ",", "elementRect", ")", "{", "var", "delta", ",", "clip", "=", "{", "top", ":", "0", ",", "right", ":", "0", ",", "bottom", ":", "0", ",", "left", ":", "0", "}", ",", "viewOffset", "=", "$view", ".", "offset", "(", ")", "||", "{", "top", ":", "0", ",", "left", ":", "0", "}", ";", "// Check if element extends below viewport", "delta", "=", "(", "elementRect", ".", "top", "+", "elementRect", ".", "height", ")", "-", "(", "viewOffset", ".", "top", "+", "$view", ".", "height", "(", ")", ")", ";", "if", "(", "delta", ">", "0", ")", "{", "clip", ".", "bottom", "=", "delta", ";", "}", "// Check if element extends above viewport", "delta", "=", "viewOffset", ".", "top", "-", "elementRect", ".", "top", ";", "if", "(", "delta", ">", "0", ")", "{", "clip", ".", "top", "=", "delta", ";", "}", "// Check if element extends to the left of viewport", "delta", "=", "viewOffset", ".", "left", "-", "elementRect", ".", "left", ";", "if", "(", "delta", ">", "0", ")", "{", "clip", ".", "left", "=", "delta", ";", "}", "// Check if element extends to the right of viewport", "delta", "=", "(", "elementRect", ".", "left", "+", "elementRect", ".", "width", ")", "-", "(", "viewOffset", ".", "left", "+", "$view", ".", "width", "(", ")", ")", ";", "if", "(", "delta", ">", "0", ")", "{", "clip", ".", "right", "=", "delta", ";", "}", "return", "clip", ";", "}" ]
Determine how much of an element rect is clipped in view. @param {!DOMElement} $view - A jQuery scrolling container @param {!{top: number, left: number, height: number, width: number}} elementRect - rectangle of element's default position/size @return {{top: number, right: number, bottom: number, left: number}} amount element rect is clipped in each direction
[ "Determine", "how", "much", "of", "an", "element", "rect", "is", "clipped", "in", "view", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ViewUtils.js#L313-L343
1,834
adobe/brackets
src/utils/ViewUtils.js
scrollElementIntoView
function scrollElementIntoView($view, $element, scrollHorizontal) { var elementOffset = $element.offset(); // scroll minimum amount var elementRect = { top: elementOffset.top, left: elementOffset.left, height: $element.height(), width: $element.width() }, clip = getElementClipSize($view, elementRect); if (clip.bottom > 0) { // below viewport $view.scrollTop($view.scrollTop() + clip.bottom); } else if (clip.top > 0) { // above viewport $view.scrollTop($view.scrollTop() - clip.top); } if (scrollHorizontal) { if (clip.left > 0) { $view.scrollLeft($view.scrollLeft() - clip.left); } else if (clip.right > 0) { $view.scrollLeft($view.scrollLeft() + clip.right); } } }
javascript
function scrollElementIntoView($view, $element, scrollHorizontal) { var elementOffset = $element.offset(); // scroll minimum amount var elementRect = { top: elementOffset.top, left: elementOffset.left, height: $element.height(), width: $element.width() }, clip = getElementClipSize($view, elementRect); if (clip.bottom > 0) { // below viewport $view.scrollTop($view.scrollTop() + clip.bottom); } else if (clip.top > 0) { // above viewport $view.scrollTop($view.scrollTop() - clip.top); } if (scrollHorizontal) { if (clip.left > 0) { $view.scrollLeft($view.scrollLeft() - clip.left); } else if (clip.right > 0) { $view.scrollLeft($view.scrollLeft() + clip.right); } } }
[ "function", "scrollElementIntoView", "(", "$view", ",", "$element", ",", "scrollHorizontal", ")", "{", "var", "elementOffset", "=", "$element", ".", "offset", "(", ")", ";", "// scroll minimum amount", "var", "elementRect", "=", "{", "top", ":", "elementOffset", ".", "top", ",", "left", ":", "elementOffset", ".", "left", ",", "height", ":", "$element", ".", "height", "(", ")", ",", "width", ":", "$element", ".", "width", "(", ")", "}", ",", "clip", "=", "getElementClipSize", "(", "$view", ",", "elementRect", ")", ";", "if", "(", "clip", ".", "bottom", ">", "0", ")", "{", "// below viewport", "$view", ".", "scrollTop", "(", "$view", ".", "scrollTop", "(", ")", "+", "clip", ".", "bottom", ")", ";", "}", "else", "if", "(", "clip", ".", "top", ">", "0", ")", "{", "// above viewport", "$view", ".", "scrollTop", "(", "$view", ".", "scrollTop", "(", ")", "-", "clip", ".", "top", ")", ";", "}", "if", "(", "scrollHorizontal", ")", "{", "if", "(", "clip", ".", "left", ">", "0", ")", "{", "$view", ".", "scrollLeft", "(", "$view", ".", "scrollLeft", "(", ")", "-", "clip", ".", "left", ")", ";", "}", "else", "if", "(", "clip", ".", "right", ">", "0", ")", "{", "$view", ".", "scrollLeft", "(", "$view", ".", "scrollLeft", "(", ")", "+", "clip", ".", "right", ")", ";", "}", "}", "}" ]
Within a scrolling DOMElement, if necessary, scroll element into viewport. To Perform the minimum amount of scrolling necessary, cases should be handled as follows: - element already completely in view : no scrolling - element above viewport : scroll view so element is at top - element left of viewport : scroll view so element is at left - element below viewport : scroll view so element is at bottom - element right of viewport : scroll view so element is at right Assumptions: - $view is a scrolling container @param {!DOMElement} $view - A jQuery scrolling container @param {!DOMElement} $element - A jQuery element @param {?boolean} scrollHorizontal - whether to also scroll horizontally
[ "Within", "a", "scrolling", "DOMElement", "if", "necessary", "scroll", "element", "into", "viewport", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ViewUtils.js#L362-L389
1,835
adobe/brackets
src/utils/ViewUtils.js
getFileEntryDisplay
function getFileEntryDisplay(entry) { var name = entry.name, ext = LanguageManager.getCompoundFileExtension(name), i = name.lastIndexOf("." + ext); if (i > 0) { // Escape all HTML-sensitive characters in filename. name = _.escape(name.substring(0, i)) + "<span class='extension'>" + _.escape(name.substring(i)) + "</span>"; } else { name = _.escape(name); } return name; }
javascript
function getFileEntryDisplay(entry) { var name = entry.name, ext = LanguageManager.getCompoundFileExtension(name), i = name.lastIndexOf("." + ext); if (i > 0) { // Escape all HTML-sensitive characters in filename. name = _.escape(name.substring(0, i)) + "<span class='extension'>" + _.escape(name.substring(i)) + "</span>"; } else { name = _.escape(name); } return name; }
[ "function", "getFileEntryDisplay", "(", "entry", ")", "{", "var", "name", "=", "entry", ".", "name", ",", "ext", "=", "LanguageManager", ".", "getCompoundFileExtension", "(", "name", ")", ",", "i", "=", "name", ".", "lastIndexOf", "(", "\".\"", "+", "ext", ")", ";", "if", "(", "i", ">", "0", ")", "{", "// Escape all HTML-sensitive characters in filename.", "name", "=", "_", ".", "escape", "(", "name", ".", "substring", "(", "0", ",", "i", ")", ")", "+", "\"<span class='extension'>\"", "+", "_", ".", "escape", "(", "name", ".", "substring", "(", "i", ")", ")", "+", "\"</span>\"", ";", "}", "else", "{", "name", "=", "_", ".", "escape", "(", "name", ")", ";", "}", "return", "name", ";", "}" ]
HTML formats a file entry name for display in the sidebar. @param {!File} entry File entry to display @return {string} HTML formatted string
[ "HTML", "formats", "a", "file", "entry", "name", "for", "display", "in", "the", "sidebar", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ViewUtils.js#L396-L409
1,836
adobe/brackets
src/utils/ViewUtils.js
getDirNamesForDuplicateFiles
function getDirNamesForDuplicateFiles(files) { // Must have at least two files in list for this to make sense if (files.length <= 1) { return []; } // First collect paths from the list of files and fill map with them var map = {}, filePaths = [], displayPaths = []; files.forEach(function (file, index) { var fp = file.fullPath.split("/"); fp.pop(); // Remove the filename itself displayPaths[index] = fp.pop(); filePaths[index] = fp; if (!map[displayPaths[index]]) { map[displayPaths[index]] = [index]; } else { map[displayPaths[index]].push(index); } }); // This function is used to loop through map and resolve duplicate names var processMap = function (map) { var didSomething = false; _.forEach(map, function (arr, key) { // length > 1 means we have duplicates that need to be resolved if (arr.length > 1) { arr.forEach(function (index) { if (filePaths[index].length !== 0) { displayPaths[index] = filePaths[index].pop() + "/" + displayPaths[index]; didSomething = true; if (!map[displayPaths[index]]) { map[displayPaths[index]] = [index]; } else { map[displayPaths[index]].push(index); } } }); } delete map[key]; }); return didSomething; }; var repeat; do { repeat = processMap(map); } while (repeat); return displayPaths; }
javascript
function getDirNamesForDuplicateFiles(files) { // Must have at least two files in list for this to make sense if (files.length <= 1) { return []; } // First collect paths from the list of files and fill map with them var map = {}, filePaths = [], displayPaths = []; files.forEach(function (file, index) { var fp = file.fullPath.split("/"); fp.pop(); // Remove the filename itself displayPaths[index] = fp.pop(); filePaths[index] = fp; if (!map[displayPaths[index]]) { map[displayPaths[index]] = [index]; } else { map[displayPaths[index]].push(index); } }); // This function is used to loop through map and resolve duplicate names var processMap = function (map) { var didSomething = false; _.forEach(map, function (arr, key) { // length > 1 means we have duplicates that need to be resolved if (arr.length > 1) { arr.forEach(function (index) { if (filePaths[index].length !== 0) { displayPaths[index] = filePaths[index].pop() + "/" + displayPaths[index]; didSomething = true; if (!map[displayPaths[index]]) { map[displayPaths[index]] = [index]; } else { map[displayPaths[index]].push(index); } } }); } delete map[key]; }); return didSomething; }; var repeat; do { repeat = processMap(map); } while (repeat); return displayPaths; }
[ "function", "getDirNamesForDuplicateFiles", "(", "files", ")", "{", "// Must have at least two files in list for this to make sense", "if", "(", "files", ".", "length", "<=", "1", ")", "{", "return", "[", "]", ";", "}", "// First collect paths from the list of files and fill map with them", "var", "map", "=", "{", "}", ",", "filePaths", "=", "[", "]", ",", "displayPaths", "=", "[", "]", ";", "files", ".", "forEach", "(", "function", "(", "file", ",", "index", ")", "{", "var", "fp", "=", "file", ".", "fullPath", ".", "split", "(", "\"/\"", ")", ";", "fp", ".", "pop", "(", ")", ";", "// Remove the filename itself", "displayPaths", "[", "index", "]", "=", "fp", ".", "pop", "(", ")", ";", "filePaths", "[", "index", "]", "=", "fp", ";", "if", "(", "!", "map", "[", "displayPaths", "[", "index", "]", "]", ")", "{", "map", "[", "displayPaths", "[", "index", "]", "]", "=", "[", "index", "]", ";", "}", "else", "{", "map", "[", "displayPaths", "[", "index", "]", "]", ".", "push", "(", "index", ")", ";", "}", "}", ")", ";", "// This function is used to loop through map and resolve duplicate names", "var", "processMap", "=", "function", "(", "map", ")", "{", "var", "didSomething", "=", "false", ";", "_", ".", "forEach", "(", "map", ",", "function", "(", "arr", ",", "key", ")", "{", "// length > 1 means we have duplicates that need to be resolved", "if", "(", "arr", ".", "length", ">", "1", ")", "{", "arr", ".", "forEach", "(", "function", "(", "index", ")", "{", "if", "(", "filePaths", "[", "index", "]", ".", "length", "!==", "0", ")", "{", "displayPaths", "[", "index", "]", "=", "filePaths", "[", "index", "]", ".", "pop", "(", ")", "+", "\"/\"", "+", "displayPaths", "[", "index", "]", ";", "didSomething", "=", "true", ";", "if", "(", "!", "map", "[", "displayPaths", "[", "index", "]", "]", ")", "{", "map", "[", "displayPaths", "[", "index", "]", "]", "=", "[", "index", "]", ";", "}", "else", "{", "map", "[", "displayPaths", "[", "index", "]", "]", ".", "push", "(", "index", ")", ";", "}", "}", "}", ")", ";", "}", "delete", "map", "[", "key", "]", ";", "}", ")", ";", "return", "didSomething", ";", "}", ";", "var", "repeat", ";", "do", "{", "repeat", "=", "processMap", "(", "map", ")", ";", "}", "while", "(", "repeat", ")", ";", "return", "displayPaths", ";", "}" ]
Determine the minimum directory path to distinguish duplicate file names for each file in list. @param {Array.<File>} files - list of Files with the same filename @return {Array.<string>} directory paths to match list of files
[ "Determine", "the", "minimum", "directory", "path", "to", "distinguish", "duplicate", "file", "names", "for", "each", "file", "in", "list", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ViewUtils.js#L418-L469
1,837
adobe/brackets
src/utils/ViewUtils.js
function (map) { var didSomething = false; _.forEach(map, function (arr, key) { // length > 1 means we have duplicates that need to be resolved if (arr.length > 1) { arr.forEach(function (index) { if (filePaths[index].length !== 0) { displayPaths[index] = filePaths[index].pop() + "/" + displayPaths[index]; didSomething = true; if (!map[displayPaths[index]]) { map[displayPaths[index]] = [index]; } else { map[displayPaths[index]].push(index); } } }); } delete map[key]; }); return didSomething; }
javascript
function (map) { var didSomething = false; _.forEach(map, function (arr, key) { // length > 1 means we have duplicates that need to be resolved if (arr.length > 1) { arr.forEach(function (index) { if (filePaths[index].length !== 0) { displayPaths[index] = filePaths[index].pop() + "/" + displayPaths[index]; didSomething = true; if (!map[displayPaths[index]]) { map[displayPaths[index]] = [index]; } else { map[displayPaths[index]].push(index); } } }); } delete map[key]; }); return didSomething; }
[ "function", "(", "map", ")", "{", "var", "didSomething", "=", "false", ";", "_", ".", "forEach", "(", "map", ",", "function", "(", "arr", ",", "key", ")", "{", "// length > 1 means we have duplicates that need to be resolved", "if", "(", "arr", ".", "length", ">", "1", ")", "{", "arr", ".", "forEach", "(", "function", "(", "index", ")", "{", "if", "(", "filePaths", "[", "index", "]", ".", "length", "!==", "0", ")", "{", "displayPaths", "[", "index", "]", "=", "filePaths", "[", "index", "]", ".", "pop", "(", ")", "+", "\"/\"", "+", "displayPaths", "[", "index", "]", ";", "didSomething", "=", "true", ";", "if", "(", "!", "map", "[", "displayPaths", "[", "index", "]", "]", ")", "{", "map", "[", "displayPaths", "[", "index", "]", "]", "=", "[", "index", "]", ";", "}", "else", "{", "map", "[", "displayPaths", "[", "index", "]", "]", ".", "push", "(", "index", ")", ";", "}", "}", "}", ")", ";", "}", "delete", "map", "[", "key", "]", ";", "}", ")", ";", "return", "didSomething", ";", "}" ]
This function is used to loop through map and resolve duplicate names
[ "This", "function", "is", "used", "to", "loop", "through", "map", "and", "resolve", "duplicate", "names" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ViewUtils.js#L440-L461
1,838
adobe/brackets
src/extensibility/ExtensionManagerViewModel.js
filterForKeyword
function filterForKeyword(extensionList, word) { var filteredList = []; extensionList.forEach(function (id) { var entry = self._getEntry(id); if (entry && self._entryMatchesQuery(entry, word)) { filteredList.push(id); } }); return filteredList; }
javascript
function filterForKeyword(extensionList, word) { var filteredList = []; extensionList.forEach(function (id) { var entry = self._getEntry(id); if (entry && self._entryMatchesQuery(entry, word)) { filteredList.push(id); } }); return filteredList; }
[ "function", "filterForKeyword", "(", "extensionList", ",", "word", ")", "{", "var", "filteredList", "=", "[", "]", ";", "extensionList", ".", "forEach", "(", "function", "(", "id", ")", "{", "var", "entry", "=", "self", ".", "_getEntry", "(", "id", ")", ";", "if", "(", "entry", "&&", "self", ".", "_entryMatchesQuery", "(", "entry", ",", "word", ")", ")", "{", "filteredList", ".", "push", "(", "id", ")", ";", "}", "}", ")", ";", "return", "filteredList", ";", "}" ]
Takes 'extensionList' and returns a version filtered to only those that match 'keyword'
[ "Takes", "extensionList", "and", "returns", "a", "version", "filtered", "to", "only", "those", "that", "match", "keyword" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManagerViewModel.js#L214-L223
1,839
adobe/brackets
src/utils/ExtensionLoader.js
loadExtensionModule
function loadExtensionModule(name, config, entryPoint) { var extensionConfig = { context: name, baseUrl: config.baseUrl, paths: globalPaths, locale: brackets.getLocale() }; // Read optional requirejs-config.json var promise = _mergeConfig(extensionConfig).then(function (mergedConfig) { // Create new RequireJS context and load extension entry point var extensionRequire = brackets.libRequire.config(mergedConfig), extensionRequireDeferred = new $.Deferred(); contexts[name] = extensionRequire; extensionRequire([entryPoint], extensionRequireDeferred.resolve, extensionRequireDeferred.reject); return extensionRequireDeferred.promise(); }).then(function (module) { // Extension loaded normally var initPromise; _extensions[name] = module; // Optional sync/async initExtension if (module && module.initExtension && (typeof module.initExtension === "function")) { // optional async extension init try { initPromise = Async.withTimeout(module.initExtension(), _getInitExtensionTimeout()); } catch (err) { // Synchronous error while initializing extension console.error("[Extension] Error -- error thrown during initExtension for " + name + ": " + err); return new $.Deferred().reject(err).promise(); } // initExtension may be synchronous and may not return a promise if (initPromise) { // WARNING: These calls to initPromise.fail() and initPromise.then(), // could also result in a runtime error if initPromise is not a valid // promise. Currently, the promise is wrapped via Async.withTimeout(), // so the call is safe as-is. initPromise.fail(function (err) { if (err === Async.ERROR_TIMEOUT) { console.error("[Extension] Error -- timeout during initExtension for " + name); } else { console.error("[Extension] Error -- failed initExtension for " + name + (err ? ": " + err : "")); } }); return initPromise; } } }, function errback(err) { // Extension failed to load during the initial require() call var additionalInfo = String(err); if (err.requireType === "scripterror" && err.originalError) { // This type has a misleading error message - replace it with something clearer (URL of require() call that got a 404 result) additionalInfo = "Module does not exist: " + err.originalError.target.src; } console.error("[Extension] failed to load " + config.baseUrl + " - " + additionalInfo); if (err.requireType === "define") { // This type has a useful stack (exception thrown by ext code or info on bad getModule() call) console.log(err.stack); } }); return promise; }
javascript
function loadExtensionModule(name, config, entryPoint) { var extensionConfig = { context: name, baseUrl: config.baseUrl, paths: globalPaths, locale: brackets.getLocale() }; // Read optional requirejs-config.json var promise = _mergeConfig(extensionConfig).then(function (mergedConfig) { // Create new RequireJS context and load extension entry point var extensionRequire = brackets.libRequire.config(mergedConfig), extensionRequireDeferred = new $.Deferred(); contexts[name] = extensionRequire; extensionRequire([entryPoint], extensionRequireDeferred.resolve, extensionRequireDeferred.reject); return extensionRequireDeferred.promise(); }).then(function (module) { // Extension loaded normally var initPromise; _extensions[name] = module; // Optional sync/async initExtension if (module && module.initExtension && (typeof module.initExtension === "function")) { // optional async extension init try { initPromise = Async.withTimeout(module.initExtension(), _getInitExtensionTimeout()); } catch (err) { // Synchronous error while initializing extension console.error("[Extension] Error -- error thrown during initExtension for " + name + ": " + err); return new $.Deferred().reject(err).promise(); } // initExtension may be synchronous and may not return a promise if (initPromise) { // WARNING: These calls to initPromise.fail() and initPromise.then(), // could also result in a runtime error if initPromise is not a valid // promise. Currently, the promise is wrapped via Async.withTimeout(), // so the call is safe as-is. initPromise.fail(function (err) { if (err === Async.ERROR_TIMEOUT) { console.error("[Extension] Error -- timeout during initExtension for " + name); } else { console.error("[Extension] Error -- failed initExtension for " + name + (err ? ": " + err : "")); } }); return initPromise; } } }, function errback(err) { // Extension failed to load during the initial require() call var additionalInfo = String(err); if (err.requireType === "scripterror" && err.originalError) { // This type has a misleading error message - replace it with something clearer (URL of require() call that got a 404 result) additionalInfo = "Module does not exist: " + err.originalError.target.src; } console.error("[Extension] failed to load " + config.baseUrl + " - " + additionalInfo); if (err.requireType === "define") { // This type has a useful stack (exception thrown by ext code or info on bad getModule() call) console.log(err.stack); } }); return promise; }
[ "function", "loadExtensionModule", "(", "name", ",", "config", ",", "entryPoint", ")", "{", "var", "extensionConfig", "=", "{", "context", ":", "name", ",", "baseUrl", ":", "config", ".", "baseUrl", ",", "paths", ":", "globalPaths", ",", "locale", ":", "brackets", ".", "getLocale", "(", ")", "}", ";", "// Read optional requirejs-config.json", "var", "promise", "=", "_mergeConfig", "(", "extensionConfig", ")", ".", "then", "(", "function", "(", "mergedConfig", ")", "{", "// Create new RequireJS context and load extension entry point", "var", "extensionRequire", "=", "brackets", ".", "libRequire", ".", "config", "(", "mergedConfig", ")", ",", "extensionRequireDeferred", "=", "new", "$", ".", "Deferred", "(", ")", ";", "contexts", "[", "name", "]", "=", "extensionRequire", ";", "extensionRequire", "(", "[", "entryPoint", "]", ",", "extensionRequireDeferred", ".", "resolve", ",", "extensionRequireDeferred", ".", "reject", ")", ";", "return", "extensionRequireDeferred", ".", "promise", "(", ")", ";", "}", ")", ".", "then", "(", "function", "(", "module", ")", "{", "// Extension loaded normally", "var", "initPromise", ";", "_extensions", "[", "name", "]", "=", "module", ";", "// Optional sync/async initExtension", "if", "(", "module", "&&", "module", ".", "initExtension", "&&", "(", "typeof", "module", ".", "initExtension", "===", "\"function\"", ")", ")", "{", "// optional async extension init", "try", "{", "initPromise", "=", "Async", ".", "withTimeout", "(", "module", ".", "initExtension", "(", ")", ",", "_getInitExtensionTimeout", "(", ")", ")", ";", "}", "catch", "(", "err", ")", "{", "// Synchronous error while initializing extension", "console", ".", "error", "(", "\"[Extension] Error -- error thrown during initExtension for \"", "+", "name", "+", "\": \"", "+", "err", ")", ";", "return", "new", "$", ".", "Deferred", "(", ")", ".", "reject", "(", "err", ")", ".", "promise", "(", ")", ";", "}", "// initExtension may be synchronous and may not return a promise", "if", "(", "initPromise", ")", "{", "// WARNING: These calls to initPromise.fail() and initPromise.then(),", "// could also result in a runtime error if initPromise is not a valid", "// promise. Currently, the promise is wrapped via Async.withTimeout(),", "// so the call is safe as-is.", "initPromise", ".", "fail", "(", "function", "(", "err", ")", "{", "if", "(", "err", "===", "Async", ".", "ERROR_TIMEOUT", ")", "{", "console", ".", "error", "(", "\"[Extension] Error -- timeout during initExtension for \"", "+", "name", ")", ";", "}", "else", "{", "console", ".", "error", "(", "\"[Extension] Error -- failed initExtension for \"", "+", "name", "+", "(", "err", "?", "\": \"", "+", "err", ":", "\"\"", ")", ")", ";", "}", "}", ")", ";", "return", "initPromise", ";", "}", "}", "}", ",", "function", "errback", "(", "err", ")", "{", "// Extension failed to load during the initial require() call", "var", "additionalInfo", "=", "String", "(", "err", ")", ";", "if", "(", "err", ".", "requireType", "===", "\"scripterror\"", "&&", "err", ".", "originalError", ")", "{", "// This type has a misleading error message - replace it with something clearer (URL of require() call that got a 404 result)", "additionalInfo", "=", "\"Module does not exist: \"", "+", "err", ".", "originalError", ".", "target", ".", "src", ";", "}", "console", ".", "error", "(", "\"[Extension] failed to load \"", "+", "config", ".", "baseUrl", "+", "\" - \"", "+", "additionalInfo", ")", ";", "if", "(", "err", ".", "requireType", "===", "\"define\"", ")", "{", "// This type has a useful stack (exception thrown by ext code or info on bad getModule() call)", "console", ".", "log", "(", "err", ".", "stack", ")", ";", "}", "}", ")", ";", "return", "promise", ";", "}" ]
Loads the extension module that lives at baseUrl into its own Require.js context @param {!string} name, used to identify the extension @param {!{baseUrl: string}} config object with baseUrl property containing absolute path of extension @param {!string} entryPoint, name of the main js file to load @return {!$.Promise} A promise object that is resolved when the extension is loaded, or rejected if the extension fails to load or throws an exception immediately when loaded. (Note: if extension contains a JS syntax error, promise is resolved not rejected).
[ "Loads", "the", "extension", "module", "that", "lives", "at", "baseUrl", "into", "its", "own", "Require", ".", "js", "context" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ExtensionLoader.js#L168-L236
1,840
adobe/brackets
src/utils/ExtensionLoader.js
loadExtension
function loadExtension(name, config, entryPoint) { var promise = new $.Deferred(); // Try to load the package.json to figure out if we are loading a theme. ExtensionUtils.loadMetadata(config.baseUrl).always(promise.resolve); return promise .then(function (metadata) { // No special handling for themes... Let the promise propagate into the ExtensionManager if (metadata && metadata.theme) { return; } if (!metadata.disabled) { return loadExtensionModule(name, config, entryPoint); } else { return new $.Deferred().reject("disabled").promise(); } }) .then(function () { exports.trigger("load", config.baseUrl); }, function (err) { if (err === "disabled") { exports.trigger("disabled", config.baseUrl); } else { exports.trigger("loadFailed", config.baseUrl); } }); }
javascript
function loadExtension(name, config, entryPoint) { var promise = new $.Deferred(); // Try to load the package.json to figure out if we are loading a theme. ExtensionUtils.loadMetadata(config.baseUrl).always(promise.resolve); return promise .then(function (metadata) { // No special handling for themes... Let the promise propagate into the ExtensionManager if (metadata && metadata.theme) { return; } if (!metadata.disabled) { return loadExtensionModule(name, config, entryPoint); } else { return new $.Deferred().reject("disabled").promise(); } }) .then(function () { exports.trigger("load", config.baseUrl); }, function (err) { if (err === "disabled") { exports.trigger("disabled", config.baseUrl); } else { exports.trigger("loadFailed", config.baseUrl); } }); }
[ "function", "loadExtension", "(", "name", ",", "config", ",", "entryPoint", ")", "{", "var", "promise", "=", "new", "$", ".", "Deferred", "(", ")", ";", "// Try to load the package.json to figure out if we are loading a theme.", "ExtensionUtils", ".", "loadMetadata", "(", "config", ".", "baseUrl", ")", ".", "always", "(", "promise", ".", "resolve", ")", ";", "return", "promise", ".", "then", "(", "function", "(", "metadata", ")", "{", "// No special handling for themes... Let the promise propagate into the ExtensionManager", "if", "(", "metadata", "&&", "metadata", ".", "theme", ")", "{", "return", ";", "}", "if", "(", "!", "metadata", ".", "disabled", ")", "{", "return", "loadExtensionModule", "(", "name", ",", "config", ",", "entryPoint", ")", ";", "}", "else", "{", "return", "new", "$", ".", "Deferred", "(", ")", ".", "reject", "(", "\"disabled\"", ")", ".", "promise", "(", ")", ";", "}", "}", ")", ".", "then", "(", "function", "(", ")", "{", "exports", ".", "trigger", "(", "\"load\"", ",", "config", ".", "baseUrl", ")", ";", "}", ",", "function", "(", "err", ")", "{", "if", "(", "err", "===", "\"disabled\"", ")", "{", "exports", ".", "trigger", "(", "\"disabled\"", ",", "config", ".", "baseUrl", ")", ";", "}", "else", "{", "exports", ".", "trigger", "(", "\"loadFailed\"", ",", "config", ".", "baseUrl", ")", ";", "}", "}", ")", ";", "}" ]
Loads the extension that lives at baseUrl into its own Require.js context @param {!string} name, used to identify the extension @param {!{baseUrl: string}} config object with baseUrl property containing absolute path of extension @param {!string} entryPoint, name of the main js file to load @return {!$.Promise} A promise object that is resolved when the extension is loaded, or rejected if the extension fails to load or throws an exception immediately when loaded. (Note: if extension contains a JS syntax error, promise is resolved not rejected).
[ "Loads", "the", "extension", "that", "lives", "at", "baseUrl", "into", "its", "own", "Require", ".", "js", "context" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ExtensionLoader.js#L248-L276
1,841
adobe/brackets
src/utils/ExtensionLoader.js
init
function init(paths) { var params = new UrlParams(); if (_init) { // Only init once. Return a resolved promise. return new $.Deferred().resolve().promise(); } if (!paths) { params.parse(); if (params.get("reloadWithoutUserExts") === "true") { paths = ["default"]; } else { paths = [ getDefaultExtensionPath(), "dev", getUserExtensionPath() ]; } } // Load extensions before restoring the project // Get a Directory for the user extension directory and create it if it doesn't exist. // Note that this is an async call and there are no success or failure functions passed // in. If the directory *doesn't* exist, it will be created. Extension loading may happen // before the directory is finished being created, but that is okay, since the extension // loading will work correctly without this directory. // If the directory *does* exist, nothing else needs to be done. It will be scanned normally // during extension loading. var extensionPath = getUserExtensionPath(); FileSystem.getDirectoryForPath(extensionPath).create(); // Create the extensions/disabled directory, too. var disabledExtensionPath = extensionPath.replace(/\/user$/, "/disabled"); FileSystem.getDirectoryForPath(disabledExtensionPath).create(); var promise = Async.doSequentially(paths, function (item) { var extensionPath = item; // If the item has "/" in it, assume it is a full path. Otherwise, load // from our source path + "/extensions/". if (item.indexOf("/") === -1) { extensionPath = FileUtils.getNativeBracketsDirectoryPath() + "/extensions/" + item; } return loadAllExtensionsInNativeDirectory(extensionPath); }, false); promise.always(function () { _init = true; }); return promise; }
javascript
function init(paths) { var params = new UrlParams(); if (_init) { // Only init once. Return a resolved promise. return new $.Deferred().resolve().promise(); } if (!paths) { params.parse(); if (params.get("reloadWithoutUserExts") === "true") { paths = ["default"]; } else { paths = [ getDefaultExtensionPath(), "dev", getUserExtensionPath() ]; } } // Load extensions before restoring the project // Get a Directory for the user extension directory and create it if it doesn't exist. // Note that this is an async call and there are no success or failure functions passed // in. If the directory *doesn't* exist, it will be created. Extension loading may happen // before the directory is finished being created, but that is okay, since the extension // loading will work correctly without this directory. // If the directory *does* exist, nothing else needs to be done. It will be scanned normally // during extension loading. var extensionPath = getUserExtensionPath(); FileSystem.getDirectoryForPath(extensionPath).create(); // Create the extensions/disabled directory, too. var disabledExtensionPath = extensionPath.replace(/\/user$/, "/disabled"); FileSystem.getDirectoryForPath(disabledExtensionPath).create(); var promise = Async.doSequentially(paths, function (item) { var extensionPath = item; // If the item has "/" in it, assume it is a full path. Otherwise, load // from our source path + "/extensions/". if (item.indexOf("/") === -1) { extensionPath = FileUtils.getNativeBracketsDirectoryPath() + "/extensions/" + item; } return loadAllExtensionsInNativeDirectory(extensionPath); }, false); promise.always(function () { _init = true; }); return promise; }
[ "function", "init", "(", "paths", ")", "{", "var", "params", "=", "new", "UrlParams", "(", ")", ";", "if", "(", "_init", ")", "{", "// Only init once. Return a resolved promise.", "return", "new", "$", ".", "Deferred", "(", ")", ".", "resolve", "(", ")", ".", "promise", "(", ")", ";", "}", "if", "(", "!", "paths", ")", "{", "params", ".", "parse", "(", ")", ";", "if", "(", "params", ".", "get", "(", "\"reloadWithoutUserExts\"", ")", "===", "\"true\"", ")", "{", "paths", "=", "[", "\"default\"", "]", ";", "}", "else", "{", "paths", "=", "[", "getDefaultExtensionPath", "(", ")", ",", "\"dev\"", ",", "getUserExtensionPath", "(", ")", "]", ";", "}", "}", "// Load extensions before restoring the project", "// Get a Directory for the user extension directory and create it if it doesn't exist.", "// Note that this is an async call and there are no success or failure functions passed", "// in. If the directory *doesn't* exist, it will be created. Extension loading may happen", "// before the directory is finished being created, but that is okay, since the extension", "// loading will work correctly without this directory.", "// If the directory *does* exist, nothing else needs to be done. It will be scanned normally", "// during extension loading.", "var", "extensionPath", "=", "getUserExtensionPath", "(", ")", ";", "FileSystem", ".", "getDirectoryForPath", "(", "extensionPath", ")", ".", "create", "(", ")", ";", "// Create the extensions/disabled directory, too.", "var", "disabledExtensionPath", "=", "extensionPath", ".", "replace", "(", "/", "\\/user$", "/", ",", "\"/disabled\"", ")", ";", "FileSystem", ".", "getDirectoryForPath", "(", "disabledExtensionPath", ")", ".", "create", "(", ")", ";", "var", "promise", "=", "Async", ".", "doSequentially", "(", "paths", ",", "function", "(", "item", ")", "{", "var", "extensionPath", "=", "item", ";", "// If the item has \"/\" in it, assume it is a full path. Otherwise, load", "// from our source path + \"/extensions/\".", "if", "(", "item", ".", "indexOf", "(", "\"/\"", ")", "===", "-", "1", ")", "{", "extensionPath", "=", "FileUtils", ".", "getNativeBracketsDirectoryPath", "(", ")", "+", "\"/extensions/\"", "+", "item", ";", "}", "return", "loadAllExtensionsInNativeDirectory", "(", "extensionPath", ")", ";", "}", ",", "false", ")", ";", "promise", ".", "always", "(", "function", "(", ")", "{", "_init", "=", "true", ";", "}", ")", ";", "return", "promise", ";", "}" ]
Load extensions. @param {?Array.<string>} A list containing references to extension source location. A source location may be either (a) a folder name inside src/extensions or (b) an absolute path. @return {!$.Promise} A promise object that is resolved when all extensions complete loading.
[ "Load", "extensions", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ExtensionLoader.js#L401-L456
1,842
adobe/brackets
src/filesystem/Directory.js
_applyAllCallbacks
function _applyAllCallbacks(callbacks, args) { if (callbacks.length > 0) { var callback = callbacks.pop(); try { callback.apply(undefined, args); } finally { _applyAllCallbacks(callbacks, args); } } }
javascript
function _applyAllCallbacks(callbacks, args) { if (callbacks.length > 0) { var callback = callbacks.pop(); try { callback.apply(undefined, args); } finally { _applyAllCallbacks(callbacks, args); } } }
[ "function", "_applyAllCallbacks", "(", "callbacks", ",", "args", ")", "{", "if", "(", "callbacks", ".", "length", ">", "0", ")", "{", "var", "callback", "=", "callbacks", ".", "pop", "(", ")", ";", "try", "{", "callback", ".", "apply", "(", "undefined", ",", "args", ")", ";", "}", "finally", "{", "_applyAllCallbacks", "(", "callbacks", ",", "args", ")", ";", "}", "}", "}" ]
Apply each callback in a list to the provided arguments. Callbacks can throw without preventing other callbacks from being applied. @private @param {Array.<function>} callbacks The callbacks to apply @param {Array} args The arguments to which each callback is applied
[ "Apply", "each", "callback", "in", "a", "list", "to", "the", "provided", "arguments", ".", "Callbacks", "can", "throw", "without", "preventing", "other", "callbacks", "from", "being", "applied", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/filesystem/Directory.js#L114-L123
1,843
adobe/brackets
src/project/ProjectModel.js
doCreate
function doCreate(path, isFolder) { var d = new $.Deferred(); var filename = FileUtils.getBaseName(path); // Check if filename if (!isValidFilename(filename)){ return d.reject(ERROR_INVALID_FILENAME).promise(); } // Check if fullpath with filename is valid // This check is used to circumvent directory jumps (Like ../..) if (!isValidPath(path)) { return d.reject(ERROR_INVALID_FILENAME).promise(); } FileSystem.resolve(path, function (err) { if (!err) { // Item already exists, fail with error d.reject(FileSystemError.ALREADY_EXISTS); } else { if (isFolder) { var directory = FileSystem.getDirectoryForPath(path); directory.create(function (err) { if (err) { d.reject(err); } else { d.resolve(directory); } }); } else { // Create an empty file var file = FileSystem.getFileForPath(path); FileUtils.writeText(file, "").then(function () { d.resolve(file); }, d.reject); } } }); return d.promise(); }
javascript
function doCreate(path, isFolder) { var d = new $.Deferred(); var filename = FileUtils.getBaseName(path); // Check if filename if (!isValidFilename(filename)){ return d.reject(ERROR_INVALID_FILENAME).promise(); } // Check if fullpath with filename is valid // This check is used to circumvent directory jumps (Like ../..) if (!isValidPath(path)) { return d.reject(ERROR_INVALID_FILENAME).promise(); } FileSystem.resolve(path, function (err) { if (!err) { // Item already exists, fail with error d.reject(FileSystemError.ALREADY_EXISTS); } else { if (isFolder) { var directory = FileSystem.getDirectoryForPath(path); directory.create(function (err) { if (err) { d.reject(err); } else { d.resolve(directory); } }); } else { // Create an empty file var file = FileSystem.getFileForPath(path); FileUtils.writeText(file, "").then(function () { d.resolve(file); }, d.reject); } } }); return d.promise(); }
[ "function", "doCreate", "(", "path", ",", "isFolder", ")", "{", "var", "d", "=", "new", "$", ".", "Deferred", "(", ")", ";", "var", "filename", "=", "FileUtils", ".", "getBaseName", "(", "path", ")", ";", "// Check if filename", "if", "(", "!", "isValidFilename", "(", "filename", ")", ")", "{", "return", "d", ".", "reject", "(", "ERROR_INVALID_FILENAME", ")", ".", "promise", "(", ")", ";", "}", "// Check if fullpath with filename is valid", "// This check is used to circumvent directory jumps (Like ../..)", "if", "(", "!", "isValidPath", "(", "path", ")", ")", "{", "return", "d", ".", "reject", "(", "ERROR_INVALID_FILENAME", ")", ".", "promise", "(", ")", ";", "}", "FileSystem", ".", "resolve", "(", "path", ",", "function", "(", "err", ")", "{", "if", "(", "!", "err", ")", "{", "// Item already exists, fail with error", "d", ".", "reject", "(", "FileSystemError", ".", "ALREADY_EXISTS", ")", ";", "}", "else", "{", "if", "(", "isFolder", ")", "{", "var", "directory", "=", "FileSystem", ".", "getDirectoryForPath", "(", "path", ")", ";", "directory", ".", "create", "(", "function", "(", "err", ")", "{", "if", "(", "err", ")", "{", "d", ".", "reject", "(", "err", ")", ";", "}", "else", "{", "d", ".", "resolve", "(", "directory", ")", ";", "}", "}", ")", ";", "}", "else", "{", "// Create an empty file", "var", "file", "=", "FileSystem", ".", "getFileForPath", "(", "path", ")", ";", "FileUtils", ".", "writeText", "(", "file", ",", "\"\"", ")", ".", "then", "(", "function", "(", ")", "{", "d", ".", "resolve", "(", "file", ")", ";", "}", ",", "d", ".", "reject", ")", ";", "}", "}", "}", ")", ";", "return", "d", ".", "promise", "(", ")", ";", "}" ]
Creates a new file or folder at the given path. The returned promise is rejected if the filename is invalid, the new path already exists or some other filesystem error comes up. @param {string} path path to create @param {boolean} isFolder true if the new entry is a folder @return {$.Promise} resolved when the file or directory has been created.
[ "Creates", "a", "new", "file", "or", "folder", "at", "the", "given", "path", ".", "The", "returned", "promise", "is", "rejected", "if", "the", "filename", "is", "invalid", "the", "new", "path", "already", "exists", "or", "some", "other", "filesystem", "error", "comes", "up", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/ProjectModel.js#L188-L230
1,844
adobe/brackets
src/project/ProjectModel.js
_isWelcomeProjectPath
function _isWelcomeProjectPath(path, welcomeProjectPath, welcomeProjects) { if (path === welcomeProjectPath) { return true; } // No match on the current path, and it's not a match if there are no previously known projects if (!welcomeProjects) { return false; } var pathNoSlash = FileUtils.stripTrailingSlash(path); // "welcomeProjects" pref has standardized on no trailing "/" return welcomeProjects.indexOf(pathNoSlash) !== -1; }
javascript
function _isWelcomeProjectPath(path, welcomeProjectPath, welcomeProjects) { if (path === welcomeProjectPath) { return true; } // No match on the current path, and it's not a match if there are no previously known projects if (!welcomeProjects) { return false; } var pathNoSlash = FileUtils.stripTrailingSlash(path); // "welcomeProjects" pref has standardized on no trailing "/" return welcomeProjects.indexOf(pathNoSlash) !== -1; }
[ "function", "_isWelcomeProjectPath", "(", "path", ",", "welcomeProjectPath", ",", "welcomeProjects", ")", "{", "if", "(", "path", "===", "welcomeProjectPath", ")", "{", "return", "true", ";", "}", "// No match on the current path, and it's not a match if there are no previously known projects", "if", "(", "!", "welcomeProjects", ")", "{", "return", "false", ";", "}", "var", "pathNoSlash", "=", "FileUtils", ".", "stripTrailingSlash", "(", "path", ")", ";", "// \"welcomeProjects\" pref has standardized on no trailing \"/\"", "return", "welcomeProjects", ".", "indexOf", "(", "pathNoSlash", ")", "!==", "-", "1", ";", "}" ]
Returns true if the given path is the same as one of the welcome projects we've previously opened, or the one for the current build. @param {string} path Path to check to see if it's a welcome project @param {string} welcomeProjectPath Current welcome project path @param {Array.<string>=} welcomeProjects All known welcome projects
[ "Returns", "true", "if", "the", "given", "path", "is", "the", "same", "as", "one", "of", "the", "welcome", "projects", "we", "ve", "previously", "opened", "or", "the", "one", "for", "the", "current", "build", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/ProjectModel.js#L1351-L1363
1,845
adobe/brackets
src/extensions/default/InAppNotifications/main.js
_getVersionInfoUrl
function _getVersionInfoUrl(localeParam) { var locale = localeParam || brackets.getLocale(); if (locale.length > 2) { locale = locale.substring(0, 2); } return brackets.config.notification_info_url.replace("<locale>", locale); }
javascript
function _getVersionInfoUrl(localeParam) { var locale = localeParam || brackets.getLocale(); if (locale.length > 2) { locale = locale.substring(0, 2); } return brackets.config.notification_info_url.replace("<locale>", locale); }
[ "function", "_getVersionInfoUrl", "(", "localeParam", ")", "{", "var", "locale", "=", "localeParam", "||", "brackets", ".", "getLocale", "(", ")", ";", "if", "(", "locale", ".", "length", ">", "2", ")", "{", "locale", "=", "locale", ".", "substring", "(", "0", ",", "2", ")", ";", "}", "return", "brackets", ".", "config", ".", "notification_info_url", ".", "replace", "(", "\"<locale>\"", ",", "locale", ")", ";", "}" ]
Constructs notification info URL for XHR @param {string=} localeParam - optional locale, defaults to 'brackets.getLocale()' when omitted. @returns {string} the new notification info url
[ "Constructs", "notification", "info", "URL", "for", "XHR" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InAppNotifications/main.js#L55-L64
1,846
adobe/brackets
src/extensions/default/InAppNotifications/main.js
_getNotificationInformation
function _getNotificationInformation(_notificationInfoUrl) { // Last time the versionInfoURL was fetched var lastInfoURLFetchTime = PreferencesManager.getViewState("lastNotificationURLFetchTime"); var result = new $.Deferred(); var fetchData = false; var data; // If we don't have data saved in prefs, fetch data = PreferencesManager.getViewState("notificationInfo"); if (!data) { fetchData = true; } // If more than 24 hours have passed since our last fetch, fetch again if (Date.now() > lastInfoURLFetchTime + ONE_DAY) { fetchData = true; } if (fetchData) { var lookupPromise = new $.Deferred(), localNotificationInfoUrl; // If the current locale isn't "en" or "en-US", check whether we actually have a // locale-specific notification target, and fall back to "en" if not. var locale = brackets.getLocale().toLowerCase(); if (locale !== "en" && locale !== "en-us") { localNotificationInfoUrl = _notificationInfoUrl || _getVersionInfoUrl(); // Check if we can reach a locale specific notifications source $.ajax({ url: localNotificationInfoUrl, cache: false, type: "HEAD" }).fail(function (jqXHR, status, error) { // Fallback to "en" locale localNotificationInfoUrl = _getVersionInfoUrl("en"); }).always(function (jqXHR, status, error) { lookupPromise.resolve(); }); } else { localNotificationInfoUrl = _notificationInfoUrl || _getVersionInfoUrl("en"); lookupPromise.resolve(); } lookupPromise.done(function () { $.ajax({ url: localNotificationInfoUrl, dataType: "json", cache: false }).done(function (notificationInfo, textStatus, jqXHR) { lastInfoURLFetchTime = (new Date()).getTime(); PreferencesManager.setViewState("lastNotificationURLFetchTime", lastInfoURLFetchTime); PreferencesManager.setViewState("notificationInfo", notificationInfo); result.resolve(notificationInfo); }).fail(function (jqXHR, status, error) { // When loading data for unit tests, the error handler is // called but the responseText is valid. Try to use it here, // but *don't* save the results in prefs. if (!jqXHR.responseText) { // Text is NULL or empty string, reject(). result.reject(); return; } try { data = JSON.parse(jqXHR.responseText); result.resolve(data); } catch (e) { result.reject(); } }); }); } else { result.resolve(data); } return result.promise(); }
javascript
function _getNotificationInformation(_notificationInfoUrl) { // Last time the versionInfoURL was fetched var lastInfoURLFetchTime = PreferencesManager.getViewState("lastNotificationURLFetchTime"); var result = new $.Deferred(); var fetchData = false; var data; // If we don't have data saved in prefs, fetch data = PreferencesManager.getViewState("notificationInfo"); if (!data) { fetchData = true; } // If more than 24 hours have passed since our last fetch, fetch again if (Date.now() > lastInfoURLFetchTime + ONE_DAY) { fetchData = true; } if (fetchData) { var lookupPromise = new $.Deferred(), localNotificationInfoUrl; // If the current locale isn't "en" or "en-US", check whether we actually have a // locale-specific notification target, and fall back to "en" if not. var locale = brackets.getLocale().toLowerCase(); if (locale !== "en" && locale !== "en-us") { localNotificationInfoUrl = _notificationInfoUrl || _getVersionInfoUrl(); // Check if we can reach a locale specific notifications source $.ajax({ url: localNotificationInfoUrl, cache: false, type: "HEAD" }).fail(function (jqXHR, status, error) { // Fallback to "en" locale localNotificationInfoUrl = _getVersionInfoUrl("en"); }).always(function (jqXHR, status, error) { lookupPromise.resolve(); }); } else { localNotificationInfoUrl = _notificationInfoUrl || _getVersionInfoUrl("en"); lookupPromise.resolve(); } lookupPromise.done(function () { $.ajax({ url: localNotificationInfoUrl, dataType: "json", cache: false }).done(function (notificationInfo, textStatus, jqXHR) { lastInfoURLFetchTime = (new Date()).getTime(); PreferencesManager.setViewState("lastNotificationURLFetchTime", lastInfoURLFetchTime); PreferencesManager.setViewState("notificationInfo", notificationInfo); result.resolve(notificationInfo); }).fail(function (jqXHR, status, error) { // When loading data for unit tests, the error handler is // called but the responseText is valid. Try to use it here, // but *don't* save the results in prefs. if (!jqXHR.responseText) { // Text is NULL or empty string, reject(). result.reject(); return; } try { data = JSON.parse(jqXHR.responseText); result.resolve(data); } catch (e) { result.reject(); } }); }); } else { result.resolve(data); } return result.promise(); }
[ "function", "_getNotificationInformation", "(", "_notificationInfoUrl", ")", "{", "// Last time the versionInfoURL was fetched", "var", "lastInfoURLFetchTime", "=", "PreferencesManager", ".", "getViewState", "(", "\"lastNotificationURLFetchTime\"", ")", ";", "var", "result", "=", "new", "$", ".", "Deferred", "(", ")", ";", "var", "fetchData", "=", "false", ";", "var", "data", ";", "// If we don't have data saved in prefs, fetch", "data", "=", "PreferencesManager", ".", "getViewState", "(", "\"notificationInfo\"", ")", ";", "if", "(", "!", "data", ")", "{", "fetchData", "=", "true", ";", "}", "// If more than 24 hours have passed since our last fetch, fetch again", "if", "(", "Date", ".", "now", "(", ")", ">", "lastInfoURLFetchTime", "+", "ONE_DAY", ")", "{", "fetchData", "=", "true", ";", "}", "if", "(", "fetchData", ")", "{", "var", "lookupPromise", "=", "new", "$", ".", "Deferred", "(", ")", ",", "localNotificationInfoUrl", ";", "// If the current locale isn't \"en\" or \"en-US\", check whether we actually have a", "// locale-specific notification target, and fall back to \"en\" if not.", "var", "locale", "=", "brackets", ".", "getLocale", "(", ")", ".", "toLowerCase", "(", ")", ";", "if", "(", "locale", "!==", "\"en\"", "&&", "locale", "!==", "\"en-us\"", ")", "{", "localNotificationInfoUrl", "=", "_notificationInfoUrl", "||", "_getVersionInfoUrl", "(", ")", ";", "// Check if we can reach a locale specific notifications source", "$", ".", "ajax", "(", "{", "url", ":", "localNotificationInfoUrl", ",", "cache", ":", "false", ",", "type", ":", "\"HEAD\"", "}", ")", ".", "fail", "(", "function", "(", "jqXHR", ",", "status", ",", "error", ")", "{", "// Fallback to \"en\" locale", "localNotificationInfoUrl", "=", "_getVersionInfoUrl", "(", "\"en\"", ")", ";", "}", ")", ".", "always", "(", "function", "(", "jqXHR", ",", "status", ",", "error", ")", "{", "lookupPromise", ".", "resolve", "(", ")", ";", "}", ")", ";", "}", "else", "{", "localNotificationInfoUrl", "=", "_notificationInfoUrl", "||", "_getVersionInfoUrl", "(", "\"en\"", ")", ";", "lookupPromise", ".", "resolve", "(", ")", ";", "}", "lookupPromise", ".", "done", "(", "function", "(", ")", "{", "$", ".", "ajax", "(", "{", "url", ":", "localNotificationInfoUrl", ",", "dataType", ":", "\"json\"", ",", "cache", ":", "false", "}", ")", ".", "done", "(", "function", "(", "notificationInfo", ",", "textStatus", ",", "jqXHR", ")", "{", "lastInfoURLFetchTime", "=", "(", "new", "Date", "(", ")", ")", ".", "getTime", "(", ")", ";", "PreferencesManager", ".", "setViewState", "(", "\"lastNotificationURLFetchTime\"", ",", "lastInfoURLFetchTime", ")", ";", "PreferencesManager", ".", "setViewState", "(", "\"notificationInfo\"", ",", "notificationInfo", ")", ";", "result", ".", "resolve", "(", "notificationInfo", ")", ";", "}", ")", ".", "fail", "(", "function", "(", "jqXHR", ",", "status", ",", "error", ")", "{", "// When loading data for unit tests, the error handler is", "// called but the responseText is valid. Try to use it here,", "// but *don't* save the results in prefs.", "if", "(", "!", "jqXHR", ".", "responseText", ")", "{", "// Text is NULL or empty string, reject().", "result", ".", "reject", "(", ")", ";", "return", ";", "}", "try", "{", "data", "=", "JSON", ".", "parse", "(", "jqXHR", ".", "responseText", ")", ";", "result", ".", "resolve", "(", "data", ")", ";", "}", "catch", "(", "e", ")", "{", "result", ".", "reject", "(", ")", ";", "}", "}", ")", ";", "}", ")", ";", "}", "else", "{", "result", ".", "resolve", "(", "data", ")", ";", "}", "return", "result", ".", "promise", "(", ")", ";", "}" ]
Get a data structure that has information for all Brackets targeted notifications. _notificationInfoUrl is used for unit testing.
[ "Get", "a", "data", "structure", "that", "has", "information", "for", "all", "Brackets", "targeted", "notifications", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InAppNotifications/main.js#L71-L149
1,847
adobe/brackets
src/extensions/default/InAppNotifications/main.js
checkForNotification
function checkForNotification(versionInfoUrl) { var result = new $.Deferred(); _getNotificationInformation(versionInfoUrl) .done(function (notificationInfo) { // Get all available notifications var notifications = notificationInfo.notifications; if (notifications && notifications.length > 0) { // Iterate through notifications and act only on the most recent // applicable notification notifications.every(function(notificationObj) { // Only show the notification overlay if the user hasn't been // alerted of this notification if (_checkNotificationValidity(notificationObj)) { if (notificationObj.silent) { // silent notifications, to gather user validity based on filters HealthLogger.sendAnalyticsData("notification", notificationObj.sequence, "handled"); } else { showNotification(notificationObj); } // Break, we have acted on one notification already return false; } // Continue, we haven't yet got a notification to act on return true; }); } result.resolve(); }) .fail(function () { // Error fetching the update data. If this is a forced check, alert the user result.reject(); }); return result.promise(); }
javascript
function checkForNotification(versionInfoUrl) { var result = new $.Deferred(); _getNotificationInformation(versionInfoUrl) .done(function (notificationInfo) { // Get all available notifications var notifications = notificationInfo.notifications; if (notifications && notifications.length > 0) { // Iterate through notifications and act only on the most recent // applicable notification notifications.every(function(notificationObj) { // Only show the notification overlay if the user hasn't been // alerted of this notification if (_checkNotificationValidity(notificationObj)) { if (notificationObj.silent) { // silent notifications, to gather user validity based on filters HealthLogger.sendAnalyticsData("notification", notificationObj.sequence, "handled"); } else { showNotification(notificationObj); } // Break, we have acted on one notification already return false; } // Continue, we haven't yet got a notification to act on return true; }); } result.resolve(); }) .fail(function () { // Error fetching the update data. If this is a forced check, alert the user result.reject(); }); return result.promise(); }
[ "function", "checkForNotification", "(", "versionInfoUrl", ")", "{", "var", "result", "=", "new", "$", ".", "Deferred", "(", ")", ";", "_getNotificationInformation", "(", "versionInfoUrl", ")", ".", "done", "(", "function", "(", "notificationInfo", ")", "{", "// Get all available notifications", "var", "notifications", "=", "notificationInfo", ".", "notifications", ";", "if", "(", "notifications", "&&", "notifications", ".", "length", ">", "0", ")", "{", "// Iterate through notifications and act only on the most recent", "// applicable notification", "notifications", ".", "every", "(", "function", "(", "notificationObj", ")", "{", "// Only show the notification overlay if the user hasn't been", "// alerted of this notification", "if", "(", "_checkNotificationValidity", "(", "notificationObj", ")", ")", "{", "if", "(", "notificationObj", ".", "silent", ")", "{", "// silent notifications, to gather user validity based on filters", "HealthLogger", ".", "sendAnalyticsData", "(", "\"notification\"", ",", "notificationObj", ".", "sequence", ",", "\"handled\"", ")", ";", "}", "else", "{", "showNotification", "(", "notificationObj", ")", ";", "}", "// Break, we have acted on one notification already", "return", "false", ";", "}", "// Continue, we haven't yet got a notification to act on", "return", "true", ";", "}", ")", ";", "}", "result", ".", "resolve", "(", ")", ";", "}", ")", ".", "fail", "(", "function", "(", ")", "{", "// Error fetching the update data. If this is a forced check, alert the user", "result", ".", "reject", "(", ")", ";", "}", ")", ";", "return", "result", ".", "promise", "(", ")", ";", "}" ]
Check for notifications, notification overlays are always displayed @return {$.Promise} jQuery Promise object that is resolved or rejected after the notification check is complete.
[ "Check", "for", "notifications", "notification", "overlays", "are", "always", "displayed" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InAppNotifications/main.js#L157-L192
1,848
adobe/brackets
src/utils/EventDispatcher.js
splitNs
function splitNs(eventStr) { var dot = eventStr.indexOf("."); if (dot === -1) { return { eventName: eventStr }; } else { return { eventName: eventStr.substring(0, dot), ns: eventStr.substring(dot) }; } }
javascript
function splitNs(eventStr) { var dot = eventStr.indexOf("."); if (dot === -1) { return { eventName: eventStr }; } else { return { eventName: eventStr.substring(0, dot), ns: eventStr.substring(dot) }; } }
[ "function", "splitNs", "(", "eventStr", ")", "{", "var", "dot", "=", "eventStr", ".", "indexOf", "(", "\".\"", ")", ";", "if", "(", "dot", "===", "-", "1", ")", "{", "return", "{", "eventName", ":", "eventStr", "}", ";", "}", "else", "{", "return", "{", "eventName", ":", "eventStr", ".", "substring", "(", "0", ",", "dot", ")", ",", "ns", ":", "eventStr", ".", "substring", "(", "dot", ")", "}", ";", "}", "}" ]
Split "event.namespace" string into its two parts; both parts are optional. @param {string} eventName Event name and/or trailing ".namespace" @return {!{event:string, ns:string}} Uses "" for missing parts.
[ "Split", "event", ".", "namespace", "string", "into", "its", "two", "parts", ";", "both", "parts", "are", "optional", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/EventDispatcher.js#L66-L73
1,849
adobe/brackets
src/extensions/default/NoDistractions/main.js
_hidePanelsIfRequired
function _hidePanelsIfRequired() { var panelIDs = WorkspaceManager.getAllPanelIDs(); _previouslyOpenPanelIDs = []; panelIDs.forEach(function (panelID) { var panel = WorkspaceManager.getPanelForID(panelID); if (panel && panel.isVisible()) { panel.hide(); _previouslyOpenPanelIDs.push(panelID); } }); }
javascript
function _hidePanelsIfRequired() { var panelIDs = WorkspaceManager.getAllPanelIDs(); _previouslyOpenPanelIDs = []; panelIDs.forEach(function (panelID) { var panel = WorkspaceManager.getPanelForID(panelID); if (panel && panel.isVisible()) { panel.hide(); _previouslyOpenPanelIDs.push(panelID); } }); }
[ "function", "_hidePanelsIfRequired", "(", ")", "{", "var", "panelIDs", "=", "WorkspaceManager", ".", "getAllPanelIDs", "(", ")", ";", "_previouslyOpenPanelIDs", "=", "[", "]", ";", "panelIDs", ".", "forEach", "(", "function", "(", "panelID", ")", "{", "var", "panel", "=", "WorkspaceManager", ".", "getPanelForID", "(", "panelID", ")", ";", "if", "(", "panel", "&&", "panel", ".", "isVisible", "(", ")", ")", "{", "panel", ".", "hide", "(", ")", ";", "_previouslyOpenPanelIDs", ".", "push", "(", "panelID", ")", ";", "}", "}", ")", ";", "}" ]
hide all open panels
[ "hide", "all", "open", "panels" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NoDistractions/main.js#L77-L87
1,850
adobe/brackets
src/extensions/default/NoDistractions/main.js
initializeCommands
function initializeCommands() { CommandManager.register(Strings.CMD_TOGGLE_PURE_CODE, CMD_TOGGLE_PURE_CODE, _togglePureCode); CommandManager.register(Strings.CMD_TOGGLE_PANELS, CMD_TOGGLE_PANELS, _togglePanels); Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(CMD_TOGGLE_PANELS, "", Menus.AFTER, Commands.VIEW_HIDE_SIDEBAR); Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(CMD_TOGGLE_PURE_CODE, "", Menus.AFTER, CMD_TOGGLE_PANELS); KeyBindingManager.addBinding(CMD_TOGGLE_PURE_CODE, [ {key: togglePureCodeKey}, {key: togglePureCodeKeyMac, platform: "mac"} ]); //default toggle panel shortcut was ctrl+shift+` as it is present in one vertical line in the keyboard. However, we later learnt //from IQE team than non-English keyboards does not have the ` char. So added one more shortcut ctrl+shift+1 which will be preferred KeyBindingManager.addBinding(CMD_TOGGLE_PANELS, [ {key: togglePanelsKey}, {key: togglePanelsKeyMac, platform: "mac"} ]); KeyBindingManager.addBinding(CMD_TOGGLE_PANELS, [ {key: togglePanelsKey_EN}, {key: togglePanelsKeyMac_EN, platform: "mac"} ]); }
javascript
function initializeCommands() { CommandManager.register(Strings.CMD_TOGGLE_PURE_CODE, CMD_TOGGLE_PURE_CODE, _togglePureCode); CommandManager.register(Strings.CMD_TOGGLE_PANELS, CMD_TOGGLE_PANELS, _togglePanels); Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(CMD_TOGGLE_PANELS, "", Menus.AFTER, Commands.VIEW_HIDE_SIDEBAR); Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(CMD_TOGGLE_PURE_CODE, "", Menus.AFTER, CMD_TOGGLE_PANELS); KeyBindingManager.addBinding(CMD_TOGGLE_PURE_CODE, [ {key: togglePureCodeKey}, {key: togglePureCodeKeyMac, platform: "mac"} ]); //default toggle panel shortcut was ctrl+shift+` as it is present in one vertical line in the keyboard. However, we later learnt //from IQE team than non-English keyboards does not have the ` char. So added one more shortcut ctrl+shift+1 which will be preferred KeyBindingManager.addBinding(CMD_TOGGLE_PANELS, [ {key: togglePanelsKey}, {key: togglePanelsKeyMac, platform: "mac"} ]); KeyBindingManager.addBinding(CMD_TOGGLE_PANELS, [ {key: togglePanelsKey_EN}, {key: togglePanelsKeyMac_EN, platform: "mac"} ]); }
[ "function", "initializeCommands", "(", ")", "{", "CommandManager", ".", "register", "(", "Strings", ".", "CMD_TOGGLE_PURE_CODE", ",", "CMD_TOGGLE_PURE_CODE", ",", "_togglePureCode", ")", ";", "CommandManager", ".", "register", "(", "Strings", ".", "CMD_TOGGLE_PANELS", ",", "CMD_TOGGLE_PANELS", ",", "_togglePanels", ")", ";", "Menus", ".", "getMenu", "(", "Menus", ".", "AppMenuBar", ".", "VIEW_MENU", ")", ".", "addMenuItem", "(", "CMD_TOGGLE_PANELS", ",", "\"\"", ",", "Menus", ".", "AFTER", ",", "Commands", ".", "VIEW_HIDE_SIDEBAR", ")", ";", "Menus", ".", "getMenu", "(", "Menus", ".", "AppMenuBar", ".", "VIEW_MENU", ")", ".", "addMenuItem", "(", "CMD_TOGGLE_PURE_CODE", ",", "\"\"", ",", "Menus", ".", "AFTER", ",", "CMD_TOGGLE_PANELS", ")", ";", "KeyBindingManager", ".", "addBinding", "(", "CMD_TOGGLE_PURE_CODE", ",", "[", "{", "key", ":", "togglePureCodeKey", "}", ",", "{", "key", ":", "togglePureCodeKeyMac", ",", "platform", ":", "\"mac\"", "}", "]", ")", ";", "//default toggle panel shortcut was ctrl+shift+` as it is present in one vertical line in the keyboard. However, we later learnt", "//from IQE team than non-English keyboards does not have the ` char. So added one more shortcut ctrl+shift+1 which will be preferred", "KeyBindingManager", ".", "addBinding", "(", "CMD_TOGGLE_PANELS", ",", "[", "{", "key", ":", "togglePanelsKey", "}", ",", "{", "key", ":", "togglePanelsKeyMac", ",", "platform", ":", "\"mac\"", "}", "]", ")", ";", "KeyBindingManager", ".", "addBinding", "(", "CMD_TOGGLE_PANELS", ",", "[", "{", "key", ":", "togglePanelsKey_EN", "}", ",", "{", "key", ":", "togglePanelsKeyMac_EN", ",", "platform", ":", "\"mac\"", "}", "]", ")", ";", "}" ]
Register the Commands , add the Menu Items and key bindings
[ "Register", "the", "Commands", "add", "the", "Menu", "Items", "and", "key", "bindings" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NoDistractions/main.js#L154-L167
1,851
adobe/brackets
src/LiveDevelopment/Agents/EditAgent.js
_findChangedCharacters
function _findChangedCharacters(oldValue, value) { if (oldValue === value) { return undefined; } var length = oldValue.length; var index = 0; // find the first character that changed var i; for (i = 0; i < length; i++) { if (value[i] !== oldValue[i]) { break; } } index += i; value = value.substr(i); length -= i; // find the last character that changed for (i = 0; i < length; i++) { if (value[value.length - 1 - i] !== oldValue[oldValue.length - 1 - i]) { break; } } length -= i; value = value.substr(0, value.length - i); return { from: index, to: index + length, text: value }; }
javascript
function _findChangedCharacters(oldValue, value) { if (oldValue === value) { return undefined; } var length = oldValue.length; var index = 0; // find the first character that changed var i; for (i = 0; i < length; i++) { if (value[i] !== oldValue[i]) { break; } } index += i; value = value.substr(i); length -= i; // find the last character that changed for (i = 0; i < length; i++) { if (value[value.length - 1 - i] !== oldValue[oldValue.length - 1 - i]) { break; } } length -= i; value = value.substr(0, value.length - i); return { from: index, to: index + length, text: value }; }
[ "function", "_findChangedCharacters", "(", "oldValue", ",", "value", ")", "{", "if", "(", "oldValue", "===", "value", ")", "{", "return", "undefined", ";", "}", "var", "length", "=", "oldValue", ".", "length", ";", "var", "index", "=", "0", ";", "// find the first character that changed", "var", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "if", "(", "value", "[", "i", "]", "!==", "oldValue", "[", "i", "]", ")", "{", "break", ";", "}", "}", "index", "+=", "i", ";", "value", "=", "value", ".", "substr", "(", "i", ")", ";", "length", "-=", "i", ";", "// find the last character that changed", "for", "(", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "if", "(", "value", "[", "value", ".", "length", "-", "1", "-", "i", "]", "!==", "oldValue", "[", "oldValue", ".", "length", "-", "1", "-", "i", "]", ")", "{", "break", ";", "}", "}", "length", "-=", "i", ";", "value", "=", "value", ".", "substr", "(", "0", ",", "value", ".", "length", "-", "i", ")", ";", "return", "{", "from", ":", "index", ",", "to", ":", "index", "+", "length", ",", "text", ":", "value", "}", ";", "}" ]
Find changed characters @param {string} old value @param {string} changed value @return {from, to, text}
[ "Find", "changed", "characters" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/EditAgent.js#L45-L73
1,852
adobe/brackets
src/view/WorkspaceManager.js
updateResizeLimits
function updateResizeLimits() { var editorAreaHeight = $editorHolder.height(); $editorHolder.siblings().each(function (i, elem) { var $elem = $(elem); if ($elem.css("display") === "none") { $elem.data("maxsize", editorAreaHeight); } else { $elem.data("maxsize", editorAreaHeight + $elem.outerHeight()); } }); }
javascript
function updateResizeLimits() { var editorAreaHeight = $editorHolder.height(); $editorHolder.siblings().each(function (i, elem) { var $elem = $(elem); if ($elem.css("display") === "none") { $elem.data("maxsize", editorAreaHeight); } else { $elem.data("maxsize", editorAreaHeight + $elem.outerHeight()); } }); }
[ "function", "updateResizeLimits", "(", ")", "{", "var", "editorAreaHeight", "=", "$editorHolder", ".", "height", "(", ")", ";", "$editorHolder", ".", "siblings", "(", ")", ".", "each", "(", "function", "(", "i", ",", "elem", ")", "{", "var", "$elem", "=", "$", "(", "elem", ")", ";", "if", "(", "$elem", ".", "css", "(", "\"display\"", ")", "===", "\"none\"", ")", "{", "$elem", ".", "data", "(", "\"maxsize\"", ",", "editorAreaHeight", ")", ";", "}", "else", "{", "$elem", ".", "data", "(", "\"maxsize\"", ",", "editorAreaHeight", "+", "$elem", ".", "outerHeight", "(", ")", ")", ";", "}", "}", ")", ";", "}" ]
Updates panel resize limits to disallow making panels big enough to shrink editor area below 0
[ "Updates", "panel", "resize", "limits", "to", "disallow", "making", "panels", "big", "enough", "to", "shrink", "editor", "area", "below", "0" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/WorkspaceManager.js#L91-L102
1,853
adobe/brackets
src/view/WorkspaceManager.js
handleWindowResize
function handleWindowResize() { // These are not initialized in Jasmine Spec Runner window until a test // is run that creates a mock document. if (!$windowContent || !$editorHolder) { return; } // FIXME (issue #4564) Workaround https://github.com/codemirror/CodeMirror/issues/1787 triggerUpdateLayout(); if (!windowResizing) { windowResizing = true; // We don't need any fancy debouncing here - we just need to react before the user can start // resizing any panels at the new window size. So just listen for first mousemove once the // window resize releases mouse capture. $(window.document).one("mousemove", function () { windowResizing = false; updateResizeLimits(); }); } }
javascript
function handleWindowResize() { // These are not initialized in Jasmine Spec Runner window until a test // is run that creates a mock document. if (!$windowContent || !$editorHolder) { return; } // FIXME (issue #4564) Workaround https://github.com/codemirror/CodeMirror/issues/1787 triggerUpdateLayout(); if (!windowResizing) { windowResizing = true; // We don't need any fancy debouncing here - we just need to react before the user can start // resizing any panels at the new window size. So just listen for first mousemove once the // window resize releases mouse capture. $(window.document).one("mousemove", function () { windowResizing = false; updateResizeLimits(); }); } }
[ "function", "handleWindowResize", "(", ")", "{", "// These are not initialized in Jasmine Spec Runner window until a test", "// is run that creates a mock document.", "if", "(", "!", "$windowContent", "||", "!", "$editorHolder", ")", "{", "return", ";", "}", "// FIXME (issue #4564) Workaround https://github.com/codemirror/CodeMirror/issues/1787", "triggerUpdateLayout", "(", ")", ";", "if", "(", "!", "windowResizing", ")", "{", "windowResizing", "=", "true", ";", "// We don't need any fancy debouncing here - we just need to react before the user can start", "// resizing any panels at the new window size. So just listen for first mousemove once the", "// window resize releases mouse capture.", "$", "(", "window", ".", "document", ")", ".", "one", "(", "\"mousemove\"", ",", "function", "(", ")", "{", "windowResizing", "=", "false", ";", "updateResizeLimits", "(", ")", ";", "}", ")", ";", "}", "}" ]
Trigger editor area resize whenever the window is resized
[ "Trigger", "editor", "area", "resize", "whenever", "the", "window", "is", "resized" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/WorkspaceManager.js#L123-L144
1,854
adobe/brackets
src/view/WorkspaceManager.js
createBottomPanel
function createBottomPanel(id, $panel, minSize) { $panel.insertBefore("#status-bar"); $panel.hide(); updateResizeLimits(); // initialize panel's max size panelIDMap[id] = new Panel($panel, minSize); panelIDMap[id].panelID = id; return panelIDMap[id]; }
javascript
function createBottomPanel(id, $panel, minSize) { $panel.insertBefore("#status-bar"); $panel.hide(); updateResizeLimits(); // initialize panel's max size panelIDMap[id] = new Panel($panel, minSize); panelIDMap[id].panelID = id; return panelIDMap[id]; }
[ "function", "createBottomPanel", "(", "id", ",", "$panel", ",", "minSize", ")", "{", "$panel", ".", "insertBefore", "(", "\"#status-bar\"", ")", ";", "$panel", ".", "hide", "(", ")", ";", "updateResizeLimits", "(", ")", ";", "// initialize panel's max size", "panelIDMap", "[", "id", "]", "=", "new", "Panel", "(", "$panel", ",", "minSize", ")", ";", "panelIDMap", "[", "id", "]", ".", "panelID", "=", "id", ";", "return", "panelIDMap", "[", "id", "]", ";", "}" ]
Creates a new resizable panel beneath the editor area and above the status bar footer. Panel is initially invisible. The panel's size & visibility are automatically saved & restored as a view-state preference. @param {!string} id Unique id for this panel. Use package-style naming, e.g. "myextension.feature.panelname" @param {!jQueryObject} $panel DOM content to use as the panel. Need not be in the document yet. Must have an id attribute, for use as a preferences key. @param {number=} minSize Minimum height of panel in px. @return {!Panel}
[ "Creates", "a", "new", "resizable", "panel", "beneath", "the", "editor", "area", "and", "above", "the", "status", "bar", "footer", ".", "Panel", "is", "initially", "invisible", ".", "The", "panel", "s", "size", "&", "visibility", "are", "automatically", "saved", "&", "restored", "as", "a", "view", "-", "state", "preference", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/WorkspaceManager.js#L227-L236
1,855
adobe/brackets
src/view/WorkspaceManager.js
getAllPanelIDs
function getAllPanelIDs() { var property, panelIDs = []; for (property in panelIDMap) { if (panelIDMap.hasOwnProperty(property)) { panelIDs.push(property); } } return panelIDs; }
javascript
function getAllPanelIDs() { var property, panelIDs = []; for (property in panelIDMap) { if (panelIDMap.hasOwnProperty(property)) { panelIDs.push(property); } } return panelIDs; }
[ "function", "getAllPanelIDs", "(", ")", "{", "var", "property", ",", "panelIDs", "=", "[", "]", ";", "for", "(", "property", "in", "panelIDMap", ")", "{", "if", "(", "panelIDMap", ".", "hasOwnProperty", "(", "property", ")", ")", "{", "panelIDs", ".", "push", "(", "property", ")", ";", "}", "}", "return", "panelIDs", ";", "}" ]
Returns an array of all panel ID's @returns {Array} List of ID's of all bottom panels
[ "Returns", "an", "array", "of", "all", "panel", "ID", "s" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/WorkspaceManager.js#L242-L250
1,856
adobe/brackets
src/utils/HealthLogger.js
getAggregatedHealthData
function getAggregatedHealthData() { var healthData = getStoredHealthData(); $.extend(healthData, PerfUtils.getHealthReport()); $.extend(healthData, FindUtils.getHealthReport()); return healthData; }
javascript
function getAggregatedHealthData() { var healthData = getStoredHealthData(); $.extend(healthData, PerfUtils.getHealthReport()); $.extend(healthData, FindUtils.getHealthReport()); return healthData; }
[ "function", "getAggregatedHealthData", "(", ")", "{", "var", "healthData", "=", "getStoredHealthData", "(", ")", ";", "$", ".", "extend", "(", "healthData", ",", "PerfUtils", ".", "getHealthReport", "(", ")", ")", ";", "$", ".", "extend", "(", "healthData", ",", "FindUtils", ".", "getHealthReport", "(", ")", ")", ";", "return", "healthData", ";", "}" ]
Return the aggregate of all health data logged till now from all sources @return {Object} Health Data aggregated till now
[ "Return", "the", "aggregate", "of", "all", "health", "data", "logged", "till", "now", "from", "all", "sources" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/HealthLogger.js#L85-L90
1,857
adobe/brackets
src/utils/HealthLogger.js
setHealthDataLog
function setHealthDataLog(key, dataObject) { var healthData = getStoredHealthData(); healthData[key] = dataObject; setHealthData(healthData); }
javascript
function setHealthDataLog(key, dataObject) { var healthData = getStoredHealthData(); healthData[key] = dataObject; setHealthData(healthData); }
[ "function", "setHealthDataLog", "(", "key", ",", "dataObject", ")", "{", "var", "healthData", "=", "getStoredHealthData", "(", ")", ";", "healthData", "[", "key", "]", "=", "dataObject", ";", "setHealthData", "(", "healthData", ")", ";", "}" ]
Sets the health data for the given key @param {Object} dataObject The object to be stored as health data for the key
[ "Sets", "the", "health", "data", "for", "the", "given", "key" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/HealthLogger.js#L116-L120
1,858
adobe/brackets
src/utils/HealthLogger.js
fileOpened
function fileOpened(filePath, addedToWorkingSet, encoding) { if (!shouldLogHealthData()) { return; } var fileExtension = FileUtils.getFileExtension(filePath), language = LanguageManager.getLanguageForPath(filePath), healthData = getStoredHealthData(), fileExtCountMap = []; healthData.fileStats = healthData.fileStats || { openedFileExt : {}, workingSetFileExt : {}, openedFileEncoding: {} }; if (language.getId() !== "unknown") { fileExtCountMap = addedToWorkingSet ? healthData.fileStats.workingSetFileExt : healthData.fileStats.openedFileExt; if (!fileExtCountMap[fileExtension]) { fileExtCountMap[fileExtension] = 0; } fileExtCountMap[fileExtension]++; setHealthData(healthData); } if (encoding) { var fileEncCountMap = healthData.fileStats.openedFileEncoding; if (!fileEncCountMap) { healthData.fileStats.openedFileEncoding = {}; fileEncCountMap = healthData.fileStats.openedFileEncoding; } if (!fileEncCountMap[encoding]) { fileEncCountMap[encoding] = 0; } fileEncCountMap[encoding]++; setHealthData(healthData); } sendAnalyticsData(commonStrings.USAGE + commonStrings.FILE_OPEN + language._name, commonStrings.USAGE, commonStrings.FILE_OPEN, language._name.toLowerCase() ); }
javascript
function fileOpened(filePath, addedToWorkingSet, encoding) { if (!shouldLogHealthData()) { return; } var fileExtension = FileUtils.getFileExtension(filePath), language = LanguageManager.getLanguageForPath(filePath), healthData = getStoredHealthData(), fileExtCountMap = []; healthData.fileStats = healthData.fileStats || { openedFileExt : {}, workingSetFileExt : {}, openedFileEncoding: {} }; if (language.getId() !== "unknown") { fileExtCountMap = addedToWorkingSet ? healthData.fileStats.workingSetFileExt : healthData.fileStats.openedFileExt; if (!fileExtCountMap[fileExtension]) { fileExtCountMap[fileExtension] = 0; } fileExtCountMap[fileExtension]++; setHealthData(healthData); } if (encoding) { var fileEncCountMap = healthData.fileStats.openedFileEncoding; if (!fileEncCountMap) { healthData.fileStats.openedFileEncoding = {}; fileEncCountMap = healthData.fileStats.openedFileEncoding; } if (!fileEncCountMap[encoding]) { fileEncCountMap[encoding] = 0; } fileEncCountMap[encoding]++; setHealthData(healthData); } sendAnalyticsData(commonStrings.USAGE + commonStrings.FILE_OPEN + language._name, commonStrings.USAGE, commonStrings.FILE_OPEN, language._name.toLowerCase() ); }
[ "function", "fileOpened", "(", "filePath", ",", "addedToWorkingSet", ",", "encoding", ")", "{", "if", "(", "!", "shouldLogHealthData", "(", ")", ")", "{", "return", ";", "}", "var", "fileExtension", "=", "FileUtils", ".", "getFileExtension", "(", "filePath", ")", ",", "language", "=", "LanguageManager", ".", "getLanguageForPath", "(", "filePath", ")", ",", "healthData", "=", "getStoredHealthData", "(", ")", ",", "fileExtCountMap", "=", "[", "]", ";", "healthData", ".", "fileStats", "=", "healthData", ".", "fileStats", "||", "{", "openedFileExt", ":", "{", "}", ",", "workingSetFileExt", ":", "{", "}", ",", "openedFileEncoding", ":", "{", "}", "}", ";", "if", "(", "language", ".", "getId", "(", ")", "!==", "\"unknown\"", ")", "{", "fileExtCountMap", "=", "addedToWorkingSet", "?", "healthData", ".", "fileStats", ".", "workingSetFileExt", ":", "healthData", ".", "fileStats", ".", "openedFileExt", ";", "if", "(", "!", "fileExtCountMap", "[", "fileExtension", "]", ")", "{", "fileExtCountMap", "[", "fileExtension", "]", "=", "0", ";", "}", "fileExtCountMap", "[", "fileExtension", "]", "++", ";", "setHealthData", "(", "healthData", ")", ";", "}", "if", "(", "encoding", ")", "{", "var", "fileEncCountMap", "=", "healthData", ".", "fileStats", ".", "openedFileEncoding", ";", "if", "(", "!", "fileEncCountMap", ")", "{", "healthData", ".", "fileStats", ".", "openedFileEncoding", "=", "{", "}", ";", "fileEncCountMap", "=", "healthData", ".", "fileStats", ".", "openedFileEncoding", ";", "}", "if", "(", "!", "fileEncCountMap", "[", "encoding", "]", ")", "{", "fileEncCountMap", "[", "encoding", "]", "=", "0", ";", "}", "fileEncCountMap", "[", "encoding", "]", "++", ";", "setHealthData", "(", "healthData", ")", ";", "}", "sendAnalyticsData", "(", "commonStrings", ".", "USAGE", "+", "commonStrings", ".", "FILE_OPEN", "+", "language", ".", "_name", ",", "commonStrings", ".", "USAGE", ",", "commonStrings", ".", "FILE_OPEN", ",", "language", ".", "_name", ".", "toLowerCase", "(", ")", ")", ";", "}" ]
Whenever a file is opened call this function. The function will record the number of times the standard file types have been opened. We only log the standard filetypes @param {String} filePath The path of the file to be registered @param {boolean} addedToWorkingSet set to true if extensions of files added to the working set needs to be logged
[ "Whenever", "a", "file", "is", "opened", "call", "this", "function", ".", "The", "function", "will", "record", "the", "number", "of", "times", "the", "standard", "file", "types", "have", "been", "opened", ".", "We", "only", "log", "the", "standard", "filetypes" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/HealthLogger.js#L149-L190
1,859
adobe/brackets
src/utils/HealthLogger.js
fileSaved
function fileSaved(docToSave) { if (!docToSave) { return; } var fileType = docToSave.language ? docToSave.language._name : ""; sendAnalyticsData(commonStrings.USAGE + commonStrings.FILE_SAVE + fileType, commonStrings.USAGE, commonStrings.FILE_SAVE, fileType.toLowerCase() ); }
javascript
function fileSaved(docToSave) { if (!docToSave) { return; } var fileType = docToSave.language ? docToSave.language._name : ""; sendAnalyticsData(commonStrings.USAGE + commonStrings.FILE_SAVE + fileType, commonStrings.USAGE, commonStrings.FILE_SAVE, fileType.toLowerCase() ); }
[ "function", "fileSaved", "(", "docToSave", ")", "{", "if", "(", "!", "docToSave", ")", "{", "return", ";", "}", "var", "fileType", "=", "docToSave", ".", "language", "?", "docToSave", ".", "language", ".", "_name", ":", "\"\"", ";", "sendAnalyticsData", "(", "commonStrings", ".", "USAGE", "+", "commonStrings", ".", "FILE_SAVE", "+", "fileType", ",", "commonStrings", ".", "USAGE", ",", "commonStrings", ".", "FILE_SAVE", ",", "fileType", ".", "toLowerCase", "(", ")", ")", ";", "}" ]
Whenever a file is saved call this function. The function will send the analytics Data We only log the standard filetypes and fileSize @param {String} filePath The path of the file to be registered
[ "Whenever", "a", "file", "is", "saved", "call", "this", "function", ".", "The", "function", "will", "send", "the", "analytics", "Data", "We", "only", "log", "the", "standard", "filetypes", "and", "fileSize" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/HealthLogger.js#L198-L208
1,860
adobe/brackets
src/utils/HealthLogger.js
fileClosed
function fileClosed(file) { if (!file) { return; } var language = LanguageManager.getLanguageForPath(file._path), size = -1; function _sendData(fileSize) { var subType = ""; if(fileSize/1024 <= 1) { if(fileSize < 0) { subType = ""; } if(fileSize <= 10) { subType = "Size_0_10KB"; } else if (fileSize <= 50) { subType = "Size_10_50KB"; } else if (fileSize <= 100) { subType = "Size_50_100KB"; } else if (fileSize <= 500) { subType = "Size_100_500KB"; } else { subType = "Size_500KB_1MB"; } } else { fileSize = fileSize/1024; if(fileSize <= 2) { subType = "Size_1_2MB"; } else if(fileSize <= 5) { subType = "Size_2_5MB"; } else { subType = "Size_Above_5MB"; } } sendAnalyticsData(commonStrings.USAGE + commonStrings.FILE_CLOSE + language._name + subType, commonStrings.USAGE, commonStrings.FILE_CLOSE, language._name.toLowerCase(), subType ); } file.stat(function(err, fileStat) { if(!err) { size = fileStat.size.valueOf()/1024; } _sendData(size); }); }
javascript
function fileClosed(file) { if (!file) { return; } var language = LanguageManager.getLanguageForPath(file._path), size = -1; function _sendData(fileSize) { var subType = ""; if(fileSize/1024 <= 1) { if(fileSize < 0) { subType = ""; } if(fileSize <= 10) { subType = "Size_0_10KB"; } else if (fileSize <= 50) { subType = "Size_10_50KB"; } else if (fileSize <= 100) { subType = "Size_50_100KB"; } else if (fileSize <= 500) { subType = "Size_100_500KB"; } else { subType = "Size_500KB_1MB"; } } else { fileSize = fileSize/1024; if(fileSize <= 2) { subType = "Size_1_2MB"; } else if(fileSize <= 5) { subType = "Size_2_5MB"; } else { subType = "Size_Above_5MB"; } } sendAnalyticsData(commonStrings.USAGE + commonStrings.FILE_CLOSE + language._name + subType, commonStrings.USAGE, commonStrings.FILE_CLOSE, language._name.toLowerCase(), subType ); } file.stat(function(err, fileStat) { if(!err) { size = fileStat.size.valueOf()/1024; } _sendData(size); }); }
[ "function", "fileClosed", "(", "file", ")", "{", "if", "(", "!", "file", ")", "{", "return", ";", "}", "var", "language", "=", "LanguageManager", ".", "getLanguageForPath", "(", "file", ".", "_path", ")", ",", "size", "=", "-", "1", ";", "function", "_sendData", "(", "fileSize", ")", "{", "var", "subType", "=", "\"\"", ";", "if", "(", "fileSize", "/", "1024", "<=", "1", ")", "{", "if", "(", "fileSize", "<", "0", ")", "{", "subType", "=", "\"\"", ";", "}", "if", "(", "fileSize", "<=", "10", ")", "{", "subType", "=", "\"Size_0_10KB\"", ";", "}", "else", "if", "(", "fileSize", "<=", "50", ")", "{", "subType", "=", "\"Size_10_50KB\"", ";", "}", "else", "if", "(", "fileSize", "<=", "100", ")", "{", "subType", "=", "\"Size_50_100KB\"", ";", "}", "else", "if", "(", "fileSize", "<=", "500", ")", "{", "subType", "=", "\"Size_100_500KB\"", ";", "}", "else", "{", "subType", "=", "\"Size_500KB_1MB\"", ";", "}", "}", "else", "{", "fileSize", "=", "fileSize", "/", "1024", ";", "if", "(", "fileSize", "<=", "2", ")", "{", "subType", "=", "\"Size_1_2MB\"", ";", "}", "else", "if", "(", "fileSize", "<=", "5", ")", "{", "subType", "=", "\"Size_2_5MB\"", ";", "}", "else", "{", "subType", "=", "\"Size_Above_5MB\"", ";", "}", "}", "sendAnalyticsData", "(", "commonStrings", ".", "USAGE", "+", "commonStrings", ".", "FILE_CLOSE", "+", "language", ".", "_name", "+", "subType", ",", "commonStrings", ".", "USAGE", ",", "commonStrings", ".", "FILE_CLOSE", ",", "language", ".", "_name", ".", "toLowerCase", "(", ")", ",", "subType", ")", ";", "}", "file", ".", "stat", "(", "function", "(", "err", ",", "fileStat", ")", "{", "if", "(", "!", "err", ")", "{", "size", "=", "fileStat", ".", "size", ".", "valueOf", "(", ")", "/", "1024", ";", "}", "_sendData", "(", "size", ")", ";", "}", ")", ";", "}" ]
Whenever a file is closed call this function. The function will send the analytics Data. We only log the standard filetypes and fileSize @param {String} filePath The path of the file to be registered
[ "Whenever", "a", "file", "is", "closed", "call", "this", "function", ".", "The", "function", "will", "send", "the", "analytics", "Data", ".", "We", "only", "log", "the", "standard", "filetypes", "and", "fileSize" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/HealthLogger.js#L216-L268
1,861
adobe/brackets
src/utils/HealthLogger.js
searchDone
function searchDone(searchType) { var searchDetails = getHealthDataLog("searchDetails"); if (!searchDetails) { searchDetails = {}; } if (!searchDetails[searchType]) { searchDetails[searchType] = 0; } searchDetails[searchType]++; setHealthDataLog("searchDetails", searchDetails); }
javascript
function searchDone(searchType) { var searchDetails = getHealthDataLog("searchDetails"); if (!searchDetails) { searchDetails = {}; } if (!searchDetails[searchType]) { searchDetails[searchType] = 0; } searchDetails[searchType]++; setHealthDataLog("searchDetails", searchDetails); }
[ "function", "searchDone", "(", "searchType", ")", "{", "var", "searchDetails", "=", "getHealthDataLog", "(", "\"searchDetails\"", ")", ";", "if", "(", "!", "searchDetails", ")", "{", "searchDetails", "=", "{", "}", ";", "}", "if", "(", "!", "searchDetails", "[", "searchType", "]", ")", "{", "searchDetails", "[", "searchType", "]", "=", "0", ";", "}", "searchDetails", "[", "searchType", "]", "++", ";", "setHealthDataLog", "(", "\"searchDetails\"", ",", "searchDetails", ")", ";", "}" ]
Increments health log count for a particular kind of search done @param {string} searchType The kind of search type that needs to be logged- should be a js var compatible string
[ "Increments", "health", "log", "count", "for", "a", "particular", "kind", "of", "search", "done" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/HealthLogger.js#L294-L304
1,862
adobe/brackets
src/utils/HealthLogger.js
sendAnalyticsData
function sendAnalyticsData(eventName, eventCategory, eventSubCategory, eventType, eventSubType) { var isEventDataAlreadySent = analyticsEventMap.get(eventName), isHDTracking = PreferencesManager.getExtensionPrefs("healthData").get("healthDataTracking"), eventParams = {}; if (isHDTracking && !isEventDataAlreadySent && eventName && eventCategory) { eventParams = { eventName: eventName, eventCategory: eventCategory, eventSubCategory: eventSubCategory || "", eventType: eventType || "", eventSubType: eventSubType || "" }; notifyHealthManagerToSendData(eventParams); } }
javascript
function sendAnalyticsData(eventName, eventCategory, eventSubCategory, eventType, eventSubType) { var isEventDataAlreadySent = analyticsEventMap.get(eventName), isHDTracking = PreferencesManager.getExtensionPrefs("healthData").get("healthDataTracking"), eventParams = {}; if (isHDTracking && !isEventDataAlreadySent && eventName && eventCategory) { eventParams = { eventName: eventName, eventCategory: eventCategory, eventSubCategory: eventSubCategory || "", eventType: eventType || "", eventSubType: eventSubType || "" }; notifyHealthManagerToSendData(eventParams); } }
[ "function", "sendAnalyticsData", "(", "eventName", ",", "eventCategory", ",", "eventSubCategory", ",", "eventType", ",", "eventSubType", ")", "{", "var", "isEventDataAlreadySent", "=", "analyticsEventMap", ".", "get", "(", "eventName", ")", ",", "isHDTracking", "=", "PreferencesManager", ".", "getExtensionPrefs", "(", "\"healthData\"", ")", ".", "get", "(", "\"healthDataTracking\"", ")", ",", "eventParams", "=", "{", "}", ";", "if", "(", "isHDTracking", "&&", "!", "isEventDataAlreadySent", "&&", "eventName", "&&", "eventCategory", ")", "{", "eventParams", "=", "{", "eventName", ":", "eventName", ",", "eventCategory", ":", "eventCategory", ",", "eventSubCategory", ":", "eventSubCategory", "||", "\"\"", ",", "eventType", ":", "eventType", "||", "\"\"", ",", "eventSubType", ":", "eventSubType", "||", "\"\"", "}", ";", "notifyHealthManagerToSendData", "(", "eventParams", ")", ";", "}", "}" ]
Send Analytics Data @param {string} eventCategory The kind of Event Category that needs to be logged- should be a js var compatible string @param {string} eventSubCategory The kind of Event Sub Category that needs to be logged- should be a js var compatible string @param {string} eventType The kind of Event Type that needs to be logged- should be a js var compatible string @param {string} eventSubType The kind of Event Sub Type that needs to be logged- should be a js var compatible string
[ "Send", "Analytics", "Data" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/HealthLogger.js#L324-L339
1,863
adobe/brackets
src/LiveDevelopment/LiveDevelopmentUtils.js
isStaticHtmlFileExt
function isStaticHtmlFileExt(filePath) { if (!filePath) { return false; } return (_staticHtmlFileExts.indexOf(LanguageManager.getLanguageForPath(filePath).getId()) !== -1); }
javascript
function isStaticHtmlFileExt(filePath) { if (!filePath) { return false; } return (_staticHtmlFileExts.indexOf(LanguageManager.getLanguageForPath(filePath).getId()) !== -1); }
[ "function", "isStaticHtmlFileExt", "(", "filePath", ")", "{", "if", "(", "!", "filePath", ")", "{", "return", "false", ";", "}", "return", "(", "_staticHtmlFileExts", ".", "indexOf", "(", "LanguageManager", ".", "getLanguageForPath", "(", "filePath", ")", ".", "getId", "(", ")", ")", "!==", "-", "1", ")", ";", "}" ]
Determine if file extension is a static html file extension. @param {string} filePath could be a path, a file name or just a file extension @return {boolean} Returns true if fileExt is in the list
[ "Determine", "if", "file", "extension", "is", "a", "static", "html", "file", "extension", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevelopmentUtils.js#L45-L51
1,864
adobe/brackets
src/LiveDevelopment/LiveDevelopmentUtils.js
isServerHtmlFileExt
function isServerHtmlFileExt(filePath) { if (!filePath) { return false; } return (_serverHtmlFileExts.indexOf(LanguageManager.getLanguageForPath(filePath).getId()) !== -1); }
javascript
function isServerHtmlFileExt(filePath) { if (!filePath) { return false; } return (_serverHtmlFileExts.indexOf(LanguageManager.getLanguageForPath(filePath).getId()) !== -1); }
[ "function", "isServerHtmlFileExt", "(", "filePath", ")", "{", "if", "(", "!", "filePath", ")", "{", "return", "false", ";", "}", "return", "(", "_serverHtmlFileExts", ".", "indexOf", "(", "LanguageManager", ".", "getLanguageForPath", "(", "filePath", ")", ".", "getId", "(", ")", ")", "!==", "-", "1", ")", ";", "}" ]
Determine if file extension is a server html file extension. @param {string} filePath could be a path, a file name or just a file extension @return {boolean} Returns true if fileExt is in the list
[ "Determine", "if", "file", "extension", "is", "a", "server", "html", "file", "extension", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevelopmentUtils.js#L58-L64
1,865
adobe/brackets
src/JSUtils/node/ExtractFileContent.js
updateDirtyFilesCache
function updateDirtyFilesCache(name, action) { if (action) { _dirtyFilesCache[name] = true; } else { if (_dirtyFilesCache[name]) { delete _dirtyFilesCache[name]; } } }
javascript
function updateDirtyFilesCache(name, action) { if (action) { _dirtyFilesCache[name] = true; } else { if (_dirtyFilesCache[name]) { delete _dirtyFilesCache[name]; } } }
[ "function", "updateDirtyFilesCache", "(", "name", ",", "action", ")", "{", "if", "(", "action", ")", "{", "_dirtyFilesCache", "[", "name", "]", "=", "true", ";", "}", "else", "{", "if", "(", "_dirtyFilesCache", "[", "name", "]", ")", "{", "delete", "_dirtyFilesCache", "[", "name", "]", ";", "}", "}", "}" ]
Updates the files cache with fullpath when dirty flag changes for a document If the doc is being marked as dirty then an entry is created in the cache If the doc is being marked as clean then the corresponsing entry gets cleared from cache @param {String} name - fullpath of the document @param {boolean} action - whether the document is dirty
[ "Updates", "the", "files", "cache", "with", "fullpath", "when", "dirty", "flag", "changes", "for", "a", "document", "If", "the", "doc", "is", "being", "marked", "as", "dirty", "then", "an", "entry", "is", "created", "in", "the", "cache", "If", "the", "doc", "is", "being", "marked", "as", "clean", "then", "the", "corresponsing", "entry", "gets", "cleared", "from", "cache" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/node/ExtractFileContent.js#L47-L55
1,866
adobe/brackets
src/extensibility/InstallExtensionDialog.js
InstallExtensionDialog
function InstallExtensionDialog(installer, _isUpdate) { this._installer = installer; this._state = STATE_CLOSED; this._installResult = null; this._isUpdate = _isUpdate; // Timeout before we allow user to leave STATE_INSTALL_CANCELING without waiting for a resolution // (per-instance so we can poke it for unit testing) this._cancelTimeout = 10 * 1000; }
javascript
function InstallExtensionDialog(installer, _isUpdate) { this._installer = installer; this._state = STATE_CLOSED; this._installResult = null; this._isUpdate = _isUpdate; // Timeout before we allow user to leave STATE_INSTALL_CANCELING without waiting for a resolution // (per-instance so we can poke it for unit testing) this._cancelTimeout = 10 * 1000; }
[ "function", "InstallExtensionDialog", "(", "installer", ",", "_isUpdate", ")", "{", "this", ".", "_installer", "=", "installer", ";", "this", ".", "_state", "=", "STATE_CLOSED", ";", "this", ".", "_installResult", "=", "null", ";", "this", ".", "_isUpdate", "=", "_isUpdate", ";", "// Timeout before we allow user to leave STATE_INSTALL_CANCELING without waiting for a resolution", "// (per-instance so we can poke it for unit testing)", "this", ".", "_cancelTimeout", "=", "10", "*", "1000", ";", "}" ]
Creates a new extension installer dialog. @constructor @param {{install: function(url), cancel: function()}} installer The installer backend to use.
[ "Creates", "a", "new", "extension", "installer", "dialog", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/InstallExtensionDialog.js#L58-L67
1,867
adobe/brackets
src/project/WorkingSetSort.js
get
function get(command) { var commandID; if (!command) { console.error("Attempting to get a Sort method with a missing required parameter: command"); return; } if (typeof command === "string") { commandID = command; } else { commandID = command.getID(); } return _sorts[commandID]; }
javascript
function get(command) { var commandID; if (!command) { console.error("Attempting to get a Sort method with a missing required parameter: command"); return; } if (typeof command === "string") { commandID = command; } else { commandID = command.getID(); } return _sorts[commandID]; }
[ "function", "get", "(", "command", ")", "{", "var", "commandID", ";", "if", "(", "!", "command", ")", "{", "console", ".", "error", "(", "\"Attempting to get a Sort method with a missing required parameter: command\"", ")", ";", "return", ";", "}", "if", "(", "typeof", "command", "===", "\"string\"", ")", "{", "commandID", "=", "command", ";", "}", "else", "{", "commandID", "=", "command", ".", "getID", "(", ")", ";", "}", "return", "_sorts", "[", "commandID", "]", ";", "}" ]
Retrieves a Sort object by id @param {(string|Command)} command A command ID or a command object. @return {?Sort}
[ "Retrieves", "a", "Sort", "object", "by", "id" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetSort.js#L98-L111
1,868
adobe/brackets
src/project/WorkingSetSort.js
_convertSortPref
function _convertSortPref(sortMethod) { if (!sortMethod) { return null; } if (_sortPrefConversionMap.hasOwnProperty(sortMethod)) { sortMethod = _sortPrefConversionMap[sortMethod]; PreferencesManager.setViewState(_WORKING_SET_SORT_PREF, sortMethod); } else { sortMethod = null; } return sortMethod; }
javascript
function _convertSortPref(sortMethod) { if (!sortMethod) { return null; } if (_sortPrefConversionMap.hasOwnProperty(sortMethod)) { sortMethod = _sortPrefConversionMap[sortMethod]; PreferencesManager.setViewState(_WORKING_SET_SORT_PREF, sortMethod); } else { sortMethod = null; } return sortMethod; }
[ "function", "_convertSortPref", "(", "sortMethod", ")", "{", "if", "(", "!", "sortMethod", ")", "{", "return", "null", ";", "}", "if", "(", "_sortPrefConversionMap", ".", "hasOwnProperty", "(", "sortMethod", ")", ")", "{", "sortMethod", "=", "_sortPrefConversionMap", "[", "sortMethod", "]", ";", "PreferencesManager", ".", "setViewState", "(", "_WORKING_SET_SORT_PREF", ",", "sortMethod", ")", ";", "}", "else", "{", "sortMethod", "=", "null", ";", "}", "return", "sortMethod", ";", "}" ]
Converts the old brackets working set sort preference into the modern paneview sort preference @private @param {!string} sortMethod - sort preference to convert @return {?string} new sort preference string or undefined if an sortMethod is not found
[ "Converts", "the", "old", "brackets", "working", "set", "sort", "preference", "into", "the", "modern", "paneview", "sort", "preference" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetSort.js#L119-L132
1,869
adobe/brackets
src/project/WorkingSetSort.js
_addListeners
function _addListeners() { if (_automaticSort && _currentSort && _currentSort.getEvents()) { MainViewManager .on(_currentSort.getEvents(), function () { _currentSort.sort(); }) .on("_workingSetDisableAutoSort.sort", function () { setAutomatic(false); }); } }
javascript
function _addListeners() { if (_automaticSort && _currentSort && _currentSort.getEvents()) { MainViewManager .on(_currentSort.getEvents(), function () { _currentSort.sort(); }) .on("_workingSetDisableAutoSort.sort", function () { setAutomatic(false); }); } }
[ "function", "_addListeners", "(", ")", "{", "if", "(", "_automaticSort", "&&", "_currentSort", "&&", "_currentSort", ".", "getEvents", "(", ")", ")", "{", "MainViewManager", ".", "on", "(", "_currentSort", ".", "getEvents", "(", ")", ",", "function", "(", ")", "{", "_currentSort", ".", "sort", "(", ")", ";", "}", ")", ".", "on", "(", "\"_workingSetDisableAutoSort.sort\"", ",", "function", "(", ")", "{", "setAutomatic", "(", "false", ")", ";", "}", ")", ";", "}", "}" ]
Adds the current sort MainViewManager listeners. @private
[ "Adds", "the", "current", "sort", "MainViewManager", "listeners", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetSort.js#L170-L180
1,870
adobe/brackets
src/project/WorkingSetSort.js
_setCurrentSort
function _setCurrentSort(newSort) { if (_currentSort !== newSort) { if (_currentSort !== null) { _currentSort.setChecked(false); } if (_automaticSort) { newSort.setChecked(true); } CommandManager.get(Commands.CMD_WORKING_SORT_TOGGLE_AUTO).setEnabled(!!newSort.getEvents()); PreferencesManager.setViewState(_WORKING_SET_SORT_PREF, newSort.getCommandID()); _currentSort = newSort; } }
javascript
function _setCurrentSort(newSort) { if (_currentSort !== newSort) { if (_currentSort !== null) { _currentSort.setChecked(false); } if (_automaticSort) { newSort.setChecked(true); } CommandManager.get(Commands.CMD_WORKING_SORT_TOGGLE_AUTO).setEnabled(!!newSort.getEvents()); PreferencesManager.setViewState(_WORKING_SET_SORT_PREF, newSort.getCommandID()); _currentSort = newSort; } }
[ "function", "_setCurrentSort", "(", "newSort", ")", "{", "if", "(", "_currentSort", "!==", "newSort", ")", "{", "if", "(", "_currentSort", "!==", "null", ")", "{", "_currentSort", ".", "setChecked", "(", "false", ")", ";", "}", "if", "(", "_automaticSort", ")", "{", "newSort", ".", "setChecked", "(", "true", ")", ";", "}", "CommandManager", ".", "get", "(", "Commands", ".", "CMD_WORKING_SORT_TOGGLE_AUTO", ")", ".", "setEnabled", "(", "!", "!", "newSort", ".", "getEvents", "(", ")", ")", ";", "PreferencesManager", ".", "setViewState", "(", "_WORKING_SET_SORT_PREF", ",", "newSort", ".", "getCommandID", "(", ")", ")", ";", "_currentSort", "=", "newSort", ";", "}", "}" ]
Sets the current sort method and checks it on the context menu. @private @param {Sort} newSort
[ "Sets", "the", "current", "sort", "method", "and", "checks", "it", "on", "the", "context", "menu", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetSort.js#L188-L201
1,871
adobe/brackets
src/project/WorkingSetSort.js
register
function register(command, compareFn, events) { var commandID = ""; if (!command || !compareFn) { console.log("Attempting to register a Sort method with a missing required parameter: command or compare function"); return; } if (typeof command === "string") { commandID = command; } else { commandID = command.getID(); } if (_sorts[commandID]) { console.log("Attempting to register an already-registered Sort method: " + command); return; } // Adds ".sort" to the end of each event to make them specific for the automatic sort. if (events) { events = events.split(" "); events.forEach(function (event, index) { events[index] = events[index].trim() + ".sort"; }); events = events.join(" "); } var sort = new Sort(commandID, compareFn, events); _sorts[commandID] = sort; return sort; }
javascript
function register(command, compareFn, events) { var commandID = ""; if (!command || !compareFn) { console.log("Attempting to register a Sort method with a missing required parameter: command or compare function"); return; } if (typeof command === "string") { commandID = command; } else { commandID = command.getID(); } if (_sorts[commandID]) { console.log("Attempting to register an already-registered Sort method: " + command); return; } // Adds ".sort" to the end of each event to make them specific for the automatic sort. if (events) { events = events.split(" "); events.forEach(function (event, index) { events[index] = events[index].trim() + ".sort"; }); events = events.join(" "); } var sort = new Sort(commandID, compareFn, events); _sorts[commandID] = sort; return sort; }
[ "function", "register", "(", "command", ",", "compareFn", ",", "events", ")", "{", "var", "commandID", "=", "\"\"", ";", "if", "(", "!", "command", "||", "!", "compareFn", ")", "{", "console", ".", "log", "(", "\"Attempting to register a Sort method with a missing required parameter: command or compare function\"", ")", ";", "return", ";", "}", "if", "(", "typeof", "command", "===", "\"string\"", ")", "{", "commandID", "=", "command", ";", "}", "else", "{", "commandID", "=", "command", ".", "getID", "(", ")", ";", "}", "if", "(", "_sorts", "[", "commandID", "]", ")", "{", "console", ".", "log", "(", "\"Attempting to register an already-registered Sort method: \"", "+", "command", ")", ";", "return", ";", "}", "// Adds \".sort\" to the end of each event to make them specific for the automatic sort.", "if", "(", "events", ")", "{", "events", "=", "events", ".", "split", "(", "\" \"", ")", ";", "events", ".", "forEach", "(", "function", "(", "event", ",", "index", ")", "{", "events", "[", "index", "]", "=", "events", "[", "index", "]", ".", "trim", "(", ")", "+", "\".sort\"", ";", "}", ")", ";", "events", "=", "events", ".", "join", "(", "\" \"", ")", ";", "}", "var", "sort", "=", "new", "Sort", "(", "commandID", ",", "compareFn", ",", "events", ")", ";", "_sorts", "[", "commandID", "]", "=", "sort", ";", "return", "sort", ";", "}" ]
Registers a working set sort method. @param {(string|Command)} command A command ID or a command object @param {function(File, File): number} compareFn The function that will be used inside JavaScript's sort function. The return a value should be >0 (sort a to a lower index than b), =0 (leaves a and b unchanged with respect to each other) or <0 (sort b to a lower index than a) and must always returns the same value when given a specific pair of elements a and b as its two arguments. Documentation at: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/sort @param {?string} events One or more space-separated event types that DocumentManger uses. Each event passed will trigger the automatic sort. If no events are passed, the automatic sort will be disabled for that sort method. @return {?Sort}
[ "Registers", "a", "working", "set", "sort", "method", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetSort.js#L289-L319
1,872
adobe/brackets
src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js
function () { var attributeString = JSON.stringify(this.attributes); this.attributeSignature = MurmurHash3.hashString(attributeString, attributeString.length, seed); }
javascript
function () { var attributeString = JSON.stringify(this.attributes); this.attributeSignature = MurmurHash3.hashString(attributeString, attributeString.length, seed); }
[ "function", "(", ")", "{", "var", "attributeString", "=", "JSON", ".", "stringify", "(", "this", ".", "attributes", ")", ";", "this", ".", "attributeSignature", "=", "MurmurHash3", ".", "hashString", "(", "attributeString", ",", "attributeString", ".", "length", ",", "seed", ")", ";", "}" ]
Updates the signature of this node's attributes. Call this after making attribute changes.
[ "Updates", "the", "signature", "of", "this", "node", "s", "attributes", ".", "Call", "this", "after", "making", "attribute", "changes", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js#L165-L168
1,873
adobe/brackets
src/LiveDevelopment/Agents/DOMAgent.js
allNodesAtLocation
function allNodesAtLocation(location) { var nodes = []; exports.root.each(function each(n) { if (n.type === DOMNode.TYPE_ELEMENT && n.isAtLocation(location)) { nodes.push(n); } }); return nodes; }
javascript
function allNodesAtLocation(location) { var nodes = []; exports.root.each(function each(n) { if (n.type === DOMNode.TYPE_ELEMENT && n.isAtLocation(location)) { nodes.push(n); } }); return nodes; }
[ "function", "allNodesAtLocation", "(", "location", ")", "{", "var", "nodes", "=", "[", "]", ";", "exports", ".", "root", ".", "each", "(", "function", "each", "(", "n", ")", "{", "if", "(", "n", ".", "type", "===", "DOMNode", ".", "TYPE_ELEMENT", "&&", "n", ".", "isAtLocation", "(", "location", ")", ")", "{", "nodes", ".", "push", "(", "n", ")", ";", "}", "}", ")", ";", "return", "nodes", ";", "}" ]
Get the element node that encloses the given location @param {location}
[ "Get", "the", "element", "node", "that", "encloses", "the", "given", "location" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/DOMAgent.js#L66-L74
1,874
adobe/brackets
src/LiveDevelopment/Agents/DOMAgent.js
nodeAtLocation
function nodeAtLocation(location) { return exports.root.find(function each(n) { return n.isAtLocation(location, false); }); }
javascript
function nodeAtLocation(location) { return exports.root.find(function each(n) { return n.isAtLocation(location, false); }); }
[ "function", "nodeAtLocation", "(", "location", ")", "{", "return", "exports", ".", "root", ".", "find", "(", "function", "each", "(", "n", ")", "{", "return", "n", ".", "isAtLocation", "(", "location", ",", "false", ")", ";", "}", ")", ";", "}" ]
Get the node at the given location @param {location}
[ "Get", "the", "node", "at", "the", "given", "location" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/DOMAgent.js#L79-L83
1,875
adobe/brackets
src/LiveDevelopment/Agents/DOMAgent.js
_cleanURL
function _cleanURL(url) { var index = url.search(/[#\?]/); if (index >= 0) { url = url.substr(0, index); } return url; }
javascript
function _cleanURL(url) { var index = url.search(/[#\?]/); if (index >= 0) { url = url.substr(0, index); } return url; }
[ "function", "_cleanURL", "(", "url", ")", "{", "var", "index", "=", "url", ".", "search", "(", "/", "[#\\?]", "/", ")", ";", "if", "(", "index", ">=", "0", ")", "{", "url", "=", "url", ".", "substr", "(", "0", ",", "index", ")", ";", "}", "return", "url", ";", "}" ]
Eliminate the query string from a URL @param {string} URL
[ "Eliminate", "the", "query", "string", "from", "a", "URL" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/DOMAgent.js#L123-L129
1,876
adobe/brackets
src/LiveDevelopment/Agents/DOMAgent.js
_mapDocumentToSource
function _mapDocumentToSource(source) { var node = exports.root; DOMHelpers.eachNode(source, function each(payload) { if (!node) { return true; } if (payload.closing) { var parent = node.findParentForNextNodeMatchingPayload(payload); if (!parent) { return console.warn("Matching Parent not at " + payload.sourceOffset + " (" + payload.nodeName + ")"); } parent.closeLocation = payload.sourceOffset; parent.closeLength = payload.sourceLength; } else { var next = node.findNextNodeMatchingPayload(payload); if (!next) { return console.warn("Skipping Source Node at " + payload.sourceOffset); } node = next; node.location = payload.sourceOffset; node.length = payload.sourceLength; if (payload.closed) { node.closed = payload.closed; } } }); }
javascript
function _mapDocumentToSource(source) { var node = exports.root; DOMHelpers.eachNode(source, function each(payload) { if (!node) { return true; } if (payload.closing) { var parent = node.findParentForNextNodeMatchingPayload(payload); if (!parent) { return console.warn("Matching Parent not at " + payload.sourceOffset + " (" + payload.nodeName + ")"); } parent.closeLocation = payload.sourceOffset; parent.closeLength = payload.sourceLength; } else { var next = node.findNextNodeMatchingPayload(payload); if (!next) { return console.warn("Skipping Source Node at " + payload.sourceOffset); } node = next; node.location = payload.sourceOffset; node.length = payload.sourceLength; if (payload.closed) { node.closed = payload.closed; } } }); }
[ "function", "_mapDocumentToSource", "(", "source", ")", "{", "var", "node", "=", "exports", ".", "root", ";", "DOMHelpers", ".", "eachNode", "(", "source", ",", "function", "each", "(", "payload", ")", "{", "if", "(", "!", "node", ")", "{", "return", "true", ";", "}", "if", "(", "payload", ".", "closing", ")", "{", "var", "parent", "=", "node", ".", "findParentForNextNodeMatchingPayload", "(", "payload", ")", ";", "if", "(", "!", "parent", ")", "{", "return", "console", ".", "warn", "(", "\"Matching Parent not at \"", "+", "payload", ".", "sourceOffset", "+", "\" (\"", "+", "payload", ".", "nodeName", "+", "\")\"", ")", ";", "}", "parent", ".", "closeLocation", "=", "payload", ".", "sourceOffset", ";", "parent", ".", "closeLength", "=", "payload", ".", "sourceLength", ";", "}", "else", "{", "var", "next", "=", "node", ".", "findNextNodeMatchingPayload", "(", "payload", ")", ";", "if", "(", "!", "next", ")", "{", "return", "console", ".", "warn", "(", "\"Skipping Source Node at \"", "+", "payload", ".", "sourceOffset", ")", ";", "}", "node", "=", "next", ";", "node", ".", "location", "=", "payload", ".", "sourceOffset", ";", "node", ".", "length", "=", "payload", ".", "sourceLength", ";", "if", "(", "payload", ".", "closed", ")", "{", "node", ".", "closed", "=", "payload", ".", "closed", ";", "}", "}", "}", ")", ";", "}" ]
Map the DOM document to the source text @param {string} source
[ "Map", "the", "DOM", "document", "to", "the", "source", "text" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/DOMAgent.js#L134-L160
1,877
adobe/brackets
src/LiveDevelopment/Agents/DOMAgent.js
_onFinishedLoadingDOM
function _onFinishedLoadingDOM() { var request = new XMLHttpRequest(); request.open("GET", exports.url); request.onload = function onLoad() { if ((request.status >= 200 && request.status < 300) || request.status === 304 || request.status === 0) { _mapDocumentToSource(request.response); _load.resolve(); } else { var msg = "Received status " + request.status + " from XMLHttpRequest while attempting to load source file at " + exports.url; _load.reject(msg, { message: msg }); } }; request.onerror = function onError() { var msg = "Could not load source file at " + exports.url; _load.reject(msg, { message: msg }); }; request.send(null); }
javascript
function _onFinishedLoadingDOM() { var request = new XMLHttpRequest(); request.open("GET", exports.url); request.onload = function onLoad() { if ((request.status >= 200 && request.status < 300) || request.status === 304 || request.status === 0) { _mapDocumentToSource(request.response); _load.resolve(); } else { var msg = "Received status " + request.status + " from XMLHttpRequest while attempting to load source file at " + exports.url; _load.reject(msg, { message: msg }); } }; request.onerror = function onError() { var msg = "Could not load source file at " + exports.url; _load.reject(msg, { message: msg }); }; request.send(null); }
[ "function", "_onFinishedLoadingDOM", "(", ")", "{", "var", "request", "=", "new", "XMLHttpRequest", "(", ")", ";", "request", ".", "open", "(", "\"GET\"", ",", "exports", ".", "url", ")", ";", "request", ".", "onload", "=", "function", "onLoad", "(", ")", "{", "if", "(", "(", "request", ".", "status", ">=", "200", "&&", "request", ".", "status", "<", "300", ")", "||", "request", ".", "status", "===", "304", "||", "request", ".", "status", "===", "0", ")", "{", "_mapDocumentToSource", "(", "request", ".", "response", ")", ";", "_load", ".", "resolve", "(", ")", ";", "}", "else", "{", "var", "msg", "=", "\"Received status \"", "+", "request", ".", "status", "+", "\" from XMLHttpRequest while attempting to load source file at \"", "+", "exports", ".", "url", ";", "_load", ".", "reject", "(", "msg", ",", "{", "message", ":", "msg", "}", ")", ";", "}", "}", ";", "request", ".", "onerror", "=", "function", "onError", "(", ")", "{", "var", "msg", "=", "\"Could not load source file at \"", "+", "exports", ".", "url", ";", "_load", ".", "reject", "(", "msg", ",", "{", "message", ":", "msg", "}", ")", ";", "}", ";", "request", ".", "send", "(", "null", ")", ";", "}" ]
Load the source document and match it with the DOM tree
[ "Load", "the", "source", "document", "and", "match", "it", "with", "the", "DOM", "tree" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/DOMAgent.js#L163-L181
1,878
adobe/brackets
src/LiveDevelopment/Agents/DOMAgent.js
applyChange
function applyChange(from, to, text) { var delta = from - to + text.length; var node = nodeAtLocation(from); // insert a text node if (!node) { if (!(/^\s*$/).test(text)) { console.warn("Inserting nodes not supported."); node = nodeBeforeLocation(from); } } else if (node.type === 3) { // update a text node var value = node.value.substr(0, from - node.location); value += text; value += node.value.substr(to - node.location); node.value = value; if (!EditAgent.isEditing) { // only update the DOM if the change was not caused by the edit agent Inspector.DOM.setNodeValue(node.nodeId, node.value); } } else { console.warn("Changing non-text nodes not supported."); } // adjust the location of all nodes after the change if (node) { node.length += delta; exports.root.each(function each(n) { if (n.location > node.location) { n.location += delta; } if (n.closeLocation !== undefined && n.closeLocation > node.location) { n.closeLocation += delta; } }); } }
javascript
function applyChange(from, to, text) { var delta = from - to + text.length; var node = nodeAtLocation(from); // insert a text node if (!node) { if (!(/^\s*$/).test(text)) { console.warn("Inserting nodes not supported."); node = nodeBeforeLocation(from); } } else if (node.type === 3) { // update a text node var value = node.value.substr(0, from - node.location); value += text; value += node.value.substr(to - node.location); node.value = value; if (!EditAgent.isEditing) { // only update the DOM if the change was not caused by the edit agent Inspector.DOM.setNodeValue(node.nodeId, node.value); } } else { console.warn("Changing non-text nodes not supported."); } // adjust the location of all nodes after the change if (node) { node.length += delta; exports.root.each(function each(n) { if (n.location > node.location) { n.location += delta; } if (n.closeLocation !== undefined && n.closeLocation > node.location) { n.closeLocation += delta; } }); } }
[ "function", "applyChange", "(", "from", ",", "to", ",", "text", ")", "{", "var", "delta", "=", "from", "-", "to", "+", "text", ".", "length", ";", "var", "node", "=", "nodeAtLocation", "(", "from", ")", ";", "// insert a text node", "if", "(", "!", "node", ")", "{", "if", "(", "!", "(", "/", "^\\s*$", "/", ")", ".", "test", "(", "text", ")", ")", "{", "console", ".", "warn", "(", "\"Inserting nodes not supported.\"", ")", ";", "node", "=", "nodeBeforeLocation", "(", "from", ")", ";", "}", "}", "else", "if", "(", "node", ".", "type", "===", "3", ")", "{", "// update a text node", "var", "value", "=", "node", ".", "value", ".", "substr", "(", "0", ",", "from", "-", "node", ".", "location", ")", ";", "value", "+=", "text", ";", "value", "+=", "node", ".", "value", ".", "substr", "(", "to", "-", "node", ".", "location", ")", ";", "node", ".", "value", "=", "value", ";", "if", "(", "!", "EditAgent", ".", "isEditing", ")", "{", "// only update the DOM if the change was not caused by the edit agent", "Inspector", ".", "DOM", ".", "setNodeValue", "(", "node", ".", "nodeId", ",", "node", ".", "value", ")", ";", "}", "}", "else", "{", "console", ".", "warn", "(", "\"Changing non-text nodes not supported.\"", ")", ";", "}", "// adjust the location of all nodes after the change", "if", "(", "node", ")", "{", "node", ".", "length", "+=", "delta", ";", "exports", ".", "root", ".", "each", "(", "function", "each", "(", "n", ")", "{", "if", "(", "n", ".", "location", ">", "node", ".", "location", ")", "{", "n", ".", "location", "+=", "delta", ";", "}", "if", "(", "n", ".", "closeLocation", "!==", "undefined", "&&", "n", ".", "closeLocation", ">", "node", ".", "location", ")", "{", "n", ".", "closeLocation", "+=", "delta", ";", "}", "}", ")", ";", "}", "}" ]
Apply a change @param {integer} start offset of the change @param {integer} end offset of the change @param {string} change text
[ "Apply", "a", "change" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/DOMAgent.js#L251-L287
1,879
adobe/brackets
src/language/LanguageManager.js
_validateNonEmptyString
function _validateNonEmptyString(value, description, deferred) { var reportError = deferred ? deferred.reject : console.error; // http://stackoverflow.com/questions/1303646/check-whether-variable-is-number-or-string-in-javascript if (Object.prototype.toString.call(value) !== "[object String]") { reportError(description + " must be a string"); return false; } if (value === "") { reportError(description + " must not be empty"); return false; } return true; }
javascript
function _validateNonEmptyString(value, description, deferred) { var reportError = deferred ? deferred.reject : console.error; // http://stackoverflow.com/questions/1303646/check-whether-variable-is-number-or-string-in-javascript if (Object.prototype.toString.call(value) !== "[object String]") { reportError(description + " must be a string"); return false; } if (value === "") { reportError(description + " must not be empty"); return false; } return true; }
[ "function", "_validateNonEmptyString", "(", "value", ",", "description", ",", "deferred", ")", "{", "var", "reportError", "=", "deferred", "?", "deferred", ".", "reject", ":", "console", ".", "error", ";", "// http://stackoverflow.com/questions/1303646/check-whether-variable-is-number-or-string-in-javascript", "if", "(", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "value", ")", "!==", "\"[object String]\"", ")", "{", "reportError", "(", "description", "+", "\" must be a string\"", ")", ";", "return", "false", ";", "}", "if", "(", "value", "===", "\"\"", ")", "{", "reportError", "(", "description", "+", "\" must not be empty\"", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Helper functions Checks whether value is a non-empty string. Reports an error otherwise. If no deferred is passed, console.error is called. Otherwise the deferred is rejected with the error message. @param {*} value The value to validate @param {!string} description A helpful identifier for value @param {?jQuery.Deferred} deferred A deferred to reject with the error message in case of an error @return {boolean} True if the value is a non-empty string, false otherwise
[ "Helper", "functions", "Checks", "whether", "value", "is", "a", "non", "-", "empty", "string", ".", "Reports", "an", "error", "otherwise", ".", "If", "no", "deferred", "is", "passed", "console", ".", "error", "is", "called", ".", "Otherwise", "the", "deferred", "is", "rejected", "with", "the", "error", "message", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/LanguageManager.js#L189-L202
1,880
adobe/brackets
src/language/LanguageManager.js
_patchCodeMirror
function _patchCodeMirror() { var _original_CodeMirror_defineMode = CodeMirror.defineMode; function _wrapped_CodeMirror_defineMode(name) { if (CodeMirror.modes[name]) { console.error("There already is a CodeMirror mode with the name \"" + name + "\""); return; } _original_CodeMirror_defineMode.apply(CodeMirror, arguments); } CodeMirror.defineMode = _wrapped_CodeMirror_defineMode; }
javascript
function _patchCodeMirror() { var _original_CodeMirror_defineMode = CodeMirror.defineMode; function _wrapped_CodeMirror_defineMode(name) { if (CodeMirror.modes[name]) { console.error("There already is a CodeMirror mode with the name \"" + name + "\""); return; } _original_CodeMirror_defineMode.apply(CodeMirror, arguments); } CodeMirror.defineMode = _wrapped_CodeMirror_defineMode; }
[ "function", "_patchCodeMirror", "(", ")", "{", "var", "_original_CodeMirror_defineMode", "=", "CodeMirror", ".", "defineMode", ";", "function", "_wrapped_CodeMirror_defineMode", "(", "name", ")", "{", "if", "(", "CodeMirror", ".", "modes", "[", "name", "]", ")", "{", "console", ".", "error", "(", "\"There already is a CodeMirror mode with the name \\\"\"", "+", "name", "+", "\"\\\"\"", ")", ";", "return", ";", "}", "_original_CodeMirror_defineMode", ".", "apply", "(", "CodeMirror", ",", "arguments", ")", ";", "}", "CodeMirror", ".", "defineMode", "=", "_wrapped_CodeMirror_defineMode", ";", "}" ]
Monkey-patch CodeMirror to prevent modes from being overwritten by extensions. We may rely on the tokens provided by some of these modes.
[ "Monkey", "-", "patch", "CodeMirror", "to", "prevent", "modes", "from", "being", "overwritten", "by", "extensions", ".", "We", "may", "rely", "on", "the", "tokens", "provided", "by", "some", "of", "these", "modes", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/LanguageManager.js#L208-L218
1,881
adobe/brackets
src/language/LanguageManager.js
_setLanguageForMode
function _setLanguageForMode(mode, language) { if (_modeToLanguageMap[mode]) { console.warn("CodeMirror mode \"" + mode + "\" is already used by language " + _modeToLanguageMap[mode]._name + " - cannot fully register language " + language._name + " using the same mode. Some features will treat all content with this mode as language " + _modeToLanguageMap[mode]._name); return; } _modeToLanguageMap[mode] = language; }
javascript
function _setLanguageForMode(mode, language) { if (_modeToLanguageMap[mode]) { console.warn("CodeMirror mode \"" + mode + "\" is already used by language " + _modeToLanguageMap[mode]._name + " - cannot fully register language " + language._name + " using the same mode. Some features will treat all content with this mode as language " + _modeToLanguageMap[mode]._name); return; } _modeToLanguageMap[mode] = language; }
[ "function", "_setLanguageForMode", "(", "mode", ",", "language", ")", "{", "if", "(", "_modeToLanguageMap", "[", "mode", "]", ")", "{", "console", ".", "warn", "(", "\"CodeMirror mode \\\"\"", "+", "mode", "+", "\"\\\" is already used by language \"", "+", "_modeToLanguageMap", "[", "mode", "]", ".", "_name", "+", "\" - cannot fully register language \"", "+", "language", ".", "_name", "+", "\" using the same mode. Some features will treat all content with this mode as language \"", "+", "_modeToLanguageMap", "[", "mode", "]", ".", "_name", ")", ";", "return", ";", "}", "_modeToLanguageMap", "[", "mode", "]", "=", "language", ";", "}" ]
Adds a global mode-to-language association. @param {!string} mode The mode to associate the language with @param {!Language} language The language to associate with the mode
[ "Adds", "a", "global", "mode", "-", "to", "-", "language", "association", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/LanguageManager.js#L225-L233
1,882
adobe/brackets
src/language/LanguageManager.js
_getLanguageForMode
function _getLanguageForMode(mode) { var language = _modeToLanguageMap[mode]; if (language) { return language; } // In case of unsupported languages console.log("Called LanguageManager._getLanguageForMode with a mode for which no language has been registered:", mode); return _fallbackLanguage; }
javascript
function _getLanguageForMode(mode) { var language = _modeToLanguageMap[mode]; if (language) { return language; } // In case of unsupported languages console.log("Called LanguageManager._getLanguageForMode with a mode for which no language has been registered:", mode); return _fallbackLanguage; }
[ "function", "_getLanguageForMode", "(", "mode", ")", "{", "var", "language", "=", "_modeToLanguageMap", "[", "mode", "]", ";", "if", "(", "language", ")", "{", "return", "language", ";", "}", "// In case of unsupported languages", "console", ".", "log", "(", "\"Called LanguageManager._getLanguageForMode with a mode for which no language has been registered:\"", ",", "mode", ")", ";", "return", "_fallbackLanguage", ";", "}" ]
Resolves a CodeMirror mode to a Language object. @param {!string} mode CodeMirror mode @return {Language} The language for the provided mode or the fallback language
[ "Resolves", "a", "CodeMirror", "mode", "to", "a", "Language", "object", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/LanguageManager.js#L340-L349
1,883
adobe/brackets
src/language/LanguageManager.js
defineLanguage
function defineLanguage(id, definition) { var result = new $.Deferred(); if (_pendingLanguages[id]) { result.reject("Language \"" + id + "\" is waiting to be resolved."); return result.promise(); } if (_languages[id]) { result.reject("Language \"" + id + "\" is already defined"); return result.promise(); } var language = new Language(), name = definition.name, fileExtensions = definition.fileExtensions, fileNames = definition.fileNames, blockComment = definition.blockComment, lineComment = definition.lineComment, i, l; function _finishRegisteringLanguage() { if (fileExtensions) { for (i = 0, l = fileExtensions.length; i < l; i++) { language.addFileExtension(fileExtensions[i]); } } // register language file names after mode has loaded if (fileNames) { for (i = 0, l = fileNames.length; i < l; i++) { language.addFileName(fileNames[i]); } } language._setBinary(!!definition.isBinary); // store language to language map _languages[language.getId()] = language; // restore any preferences for non-default languages if(PreferencesManager) { _updateFromPrefs(_EXTENSION_MAP_PREF); _updateFromPrefs(_NAME_MAP_PREF); } } if (!language._setId(id) || !language._setName(name) || (blockComment && !language.setBlockCommentSyntax(blockComment[0], blockComment[1])) || (lineComment && !language.setLineCommentSyntax(lineComment))) { result.reject(); return result.promise(); } if (definition.isBinary) { // add file extensions and store language to language map _finishRegisteringLanguage(); result.resolve(language); // Not notifying DocumentManager via event LanguageAdded, because DocumentManager // does not care about binary files. } else { // track languages that are currently loading _pendingLanguages[id] = language; language._loadAndSetMode(definition.mode).done(function () { // globally associate mode to language _setLanguageForMode(language.getMode(), language); // add file extensions and store language to language map _finishRegisteringLanguage(); // fire an event to notify DocumentManager of the new language _triggerLanguageAdded(language); result.resolve(language); }).fail(function (error) { console.error(error); result.reject(error); }).always(function () { // delete from pending languages after success and failure delete _pendingLanguages[id]; }); } return result.promise(); }
javascript
function defineLanguage(id, definition) { var result = new $.Deferred(); if (_pendingLanguages[id]) { result.reject("Language \"" + id + "\" is waiting to be resolved."); return result.promise(); } if (_languages[id]) { result.reject("Language \"" + id + "\" is already defined"); return result.promise(); } var language = new Language(), name = definition.name, fileExtensions = definition.fileExtensions, fileNames = definition.fileNames, blockComment = definition.blockComment, lineComment = definition.lineComment, i, l; function _finishRegisteringLanguage() { if (fileExtensions) { for (i = 0, l = fileExtensions.length; i < l; i++) { language.addFileExtension(fileExtensions[i]); } } // register language file names after mode has loaded if (fileNames) { for (i = 0, l = fileNames.length; i < l; i++) { language.addFileName(fileNames[i]); } } language._setBinary(!!definition.isBinary); // store language to language map _languages[language.getId()] = language; // restore any preferences for non-default languages if(PreferencesManager) { _updateFromPrefs(_EXTENSION_MAP_PREF); _updateFromPrefs(_NAME_MAP_PREF); } } if (!language._setId(id) || !language._setName(name) || (blockComment && !language.setBlockCommentSyntax(blockComment[0], blockComment[1])) || (lineComment && !language.setLineCommentSyntax(lineComment))) { result.reject(); return result.promise(); } if (definition.isBinary) { // add file extensions and store language to language map _finishRegisteringLanguage(); result.resolve(language); // Not notifying DocumentManager via event LanguageAdded, because DocumentManager // does not care about binary files. } else { // track languages that are currently loading _pendingLanguages[id] = language; language._loadAndSetMode(definition.mode).done(function () { // globally associate mode to language _setLanguageForMode(language.getMode(), language); // add file extensions and store language to language map _finishRegisteringLanguage(); // fire an event to notify DocumentManager of the new language _triggerLanguageAdded(language); result.resolve(language); }).fail(function (error) { console.error(error); result.reject(error); }).always(function () { // delete from pending languages after success and failure delete _pendingLanguages[id]; }); } return result.promise(); }
[ "function", "defineLanguage", "(", "id", ",", "definition", ")", "{", "var", "result", "=", "new", "$", ".", "Deferred", "(", ")", ";", "if", "(", "_pendingLanguages", "[", "id", "]", ")", "{", "result", ".", "reject", "(", "\"Language \\\"\"", "+", "id", "+", "\"\\\" is waiting to be resolved.\"", ")", ";", "return", "result", ".", "promise", "(", ")", ";", "}", "if", "(", "_languages", "[", "id", "]", ")", "{", "result", ".", "reject", "(", "\"Language \\\"\"", "+", "id", "+", "\"\\\" is already defined\"", ")", ";", "return", "result", ".", "promise", "(", ")", ";", "}", "var", "language", "=", "new", "Language", "(", ")", ",", "name", "=", "definition", ".", "name", ",", "fileExtensions", "=", "definition", ".", "fileExtensions", ",", "fileNames", "=", "definition", ".", "fileNames", ",", "blockComment", "=", "definition", ".", "blockComment", ",", "lineComment", "=", "definition", ".", "lineComment", ",", "i", ",", "l", ";", "function", "_finishRegisteringLanguage", "(", ")", "{", "if", "(", "fileExtensions", ")", "{", "for", "(", "i", "=", "0", ",", "l", "=", "fileExtensions", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "language", ".", "addFileExtension", "(", "fileExtensions", "[", "i", "]", ")", ";", "}", "}", "// register language file names after mode has loaded", "if", "(", "fileNames", ")", "{", "for", "(", "i", "=", "0", ",", "l", "=", "fileNames", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "language", ".", "addFileName", "(", "fileNames", "[", "i", "]", ")", ";", "}", "}", "language", ".", "_setBinary", "(", "!", "!", "definition", ".", "isBinary", ")", ";", "// store language to language map", "_languages", "[", "language", ".", "getId", "(", ")", "]", "=", "language", ";", "// restore any preferences for non-default languages", "if", "(", "PreferencesManager", ")", "{", "_updateFromPrefs", "(", "_EXTENSION_MAP_PREF", ")", ";", "_updateFromPrefs", "(", "_NAME_MAP_PREF", ")", ";", "}", "}", "if", "(", "!", "language", ".", "_setId", "(", "id", ")", "||", "!", "language", ".", "_setName", "(", "name", ")", "||", "(", "blockComment", "&&", "!", "language", ".", "setBlockCommentSyntax", "(", "blockComment", "[", "0", "]", ",", "blockComment", "[", "1", "]", ")", ")", "||", "(", "lineComment", "&&", "!", "language", ".", "setLineCommentSyntax", "(", "lineComment", ")", ")", ")", "{", "result", ".", "reject", "(", ")", ";", "return", "result", ".", "promise", "(", ")", ";", "}", "if", "(", "definition", ".", "isBinary", ")", "{", "// add file extensions and store language to language map", "_finishRegisteringLanguage", "(", ")", ";", "result", ".", "resolve", "(", "language", ")", ";", "// Not notifying DocumentManager via event LanguageAdded, because DocumentManager", "// does not care about binary files.", "}", "else", "{", "// track languages that are currently loading", "_pendingLanguages", "[", "id", "]", "=", "language", ";", "language", ".", "_loadAndSetMode", "(", "definition", ".", "mode", ")", ".", "done", "(", "function", "(", ")", "{", "// globally associate mode to language", "_setLanguageForMode", "(", "language", ".", "getMode", "(", ")", ",", "language", ")", ";", "// add file extensions and store language to language map", "_finishRegisteringLanguage", "(", ")", ";", "// fire an event to notify DocumentManager of the new language", "_triggerLanguageAdded", "(", "language", ")", ";", "result", ".", "resolve", "(", "language", ")", ";", "}", ")", ".", "fail", "(", "function", "(", "error", ")", "{", "console", ".", "error", "(", "error", ")", ";", "result", ".", "reject", "(", "error", ")", ";", "}", ")", ".", "always", "(", "function", "(", ")", "{", "// delete from pending languages after success and failure", "delete", "_pendingLanguages", "[", "id", "]", ";", "}", ")", ";", "}", "return", "result", ".", "promise", "(", ")", ";", "}" ]
Defines a language. @param {!string} id Unique identifier for this language: lowercase letters, digits, and _ separators (e.g. "cpp", "foo_bar", "c99") @param {!Object} definition An object describing the language @param {!string} definition.name Human-readable name of the language, as it's commonly referred to (e.g. "C++") @param {Array.<string>} definition.fileExtensions List of file extensions used by this language (e.g. ["php", "php3"] or ["coffee.md"] - may contain dots) @param {Array.<string>} definition.fileNames List of exact file names (e.g. ["Makefile"] or ["package.json]). Higher precedence than file extension. @param {Array.<string>} definition.blockComment Array with two entries defining the block comment prefix and suffix (e.g. ["<!--", "-->"]) @param {(string|Array.<string>)} definition.lineComment Line comment prefixes (e.g. "//" or ["//", "#"]) @param {(string|Array.<string>)} definition.mode CodeMirror mode (e.g. "htmlmixed"), optionally with a MIME mode defined by that mode ["clike", "text/x-c++src"] Unless the mode is located in thirdparty/CodeMirror/mode/<name>/<name>.js, you need to first load it yourself. @return {$.Promise} A promise object that will be resolved with a Language object
[ "Defines", "a", "language", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/LanguageManager.js#L926-L1013
1,884
adobe/brackets
src/widgets/PopUpManager.js
addPopUp
function addPopUp($popUp, removeHandler, autoRemove) { autoRemove = autoRemove || false; _popUps.push($popUp[0]); $popUp.data("PopUpManager-autoRemove", autoRemove); $popUp.data("PopUpManager-removeHandler", removeHandler); }
javascript
function addPopUp($popUp, removeHandler, autoRemove) { autoRemove = autoRemove || false; _popUps.push($popUp[0]); $popUp.data("PopUpManager-autoRemove", autoRemove); $popUp.data("PopUpManager-removeHandler", removeHandler); }
[ "function", "addPopUp", "(", "$popUp", ",", "removeHandler", ",", "autoRemove", ")", "{", "autoRemove", "=", "autoRemove", "||", "false", ";", "_popUps", ".", "push", "(", "$popUp", "[", "0", "]", ")", ";", "$popUp", ".", "data", "(", "\"PopUpManager-autoRemove\"", ",", "autoRemove", ")", ";", "$popUp", ".", "data", "(", "\"PopUpManager-removeHandler\"", ",", "removeHandler", ")", ";", "}" ]
Add Esc key handling for a popup DOM element. @param {!jQuery} $popUp jQuery object for the DOM element pop-up @param {function} removeHandler Pop-up specific remove (e.g. display:none or DOM removal) @param {?Boolean} autoRemove - Specify true to indicate the PopUpManager should remove the popup from the _popUps array when the popup is closed. Specify false when the popup is always persistant in the _popUps array.
[ "Add", "Esc", "key", "handling", "for", "a", "popup", "DOM", "element", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/widgets/PopUpManager.js#L47-L53
1,885
adobe/brackets
src/xorigin.js
handleError
function handleError(message, url, line) { // Ignore this error if it does not look like the rather vague cross origin error in Chrome // Chrome will print it to the console anyway if (!testCrossOriginError(message, url, line)) { if (previousErrorHandler) { return previousErrorHandler(message, url, line); } return; } // Show an error message window.alert("Oops! This application doesn't run in browsers yet.\n\nIt is built in HTML, but right now it runs as a desktop app so you can use it to edit local files. Please use the application shell in the following repo to run this application:\n\ngithub.com/adobe/brackets-shell"); // Restore the original handler for later errors window.onerror = previousErrorHandler; }
javascript
function handleError(message, url, line) { // Ignore this error if it does not look like the rather vague cross origin error in Chrome // Chrome will print it to the console anyway if (!testCrossOriginError(message, url, line)) { if (previousErrorHandler) { return previousErrorHandler(message, url, line); } return; } // Show an error message window.alert("Oops! This application doesn't run in browsers yet.\n\nIt is built in HTML, but right now it runs as a desktop app so you can use it to edit local files. Please use the application shell in the following repo to run this application:\n\ngithub.com/adobe/brackets-shell"); // Restore the original handler for later errors window.onerror = previousErrorHandler; }
[ "function", "handleError", "(", "message", ",", "url", ",", "line", ")", "{", "// Ignore this error if it does not look like the rather vague cross origin error in Chrome", "// Chrome will print it to the console anyway", "if", "(", "!", "testCrossOriginError", "(", "message", ",", "url", ",", "line", ")", ")", "{", "if", "(", "previousErrorHandler", ")", "{", "return", "previousErrorHandler", "(", "message", ",", "url", ",", "line", ")", ";", "}", "return", ";", "}", "// Show an error message", "window", ".", "alert", "(", "\"Oops! This application doesn't run in browsers yet.\\n\\nIt is built in HTML, but right now it runs as a desktop app so you can use it to edit local files. Please use the application shell in the following repo to run this application:\\n\\ngithub.com/adobe/brackets-shell\"", ")", ";", "// Restore the original handler for later errors", "window", ".", "onerror", "=", "previousErrorHandler", ";", "}" ]
Our error handler
[ "Our", "error", "handler" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/xorigin.js#L55-L70
1,886
adobe/brackets
src/LiveDevelopment/main.js
_loadStyles
function _loadStyles() { var lessText = require("text!LiveDevelopment/main.less"); less.render(lessText, function onParse(err, tree) { console.assert(!err, err); ExtensionUtils.addEmbeddedStyleSheet(tree.css); }); }
javascript
function _loadStyles() { var lessText = require("text!LiveDevelopment/main.less"); less.render(lessText, function onParse(err, tree) { console.assert(!err, err); ExtensionUtils.addEmbeddedStyleSheet(tree.css); }); }
[ "function", "_loadStyles", "(", ")", "{", "var", "lessText", "=", "require", "(", "\"text!LiveDevelopment/main.less\"", ")", ";", "less", ".", "render", "(", "lessText", ",", "function", "onParse", "(", "err", ",", "tree", ")", "{", "console", ".", "assert", "(", "!", "err", ",", "err", ")", ";", "ExtensionUtils", ".", "addEmbeddedStyleSheet", "(", "tree", ".", "css", ")", ";", "}", ")", ";", "}" ]
Load Live Development LESS Style
[ "Load", "Live", "Development", "LESS", "Style" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/main.js#L137-L144
1,887
adobe/brackets
src/LiveDevelopment/main.js
_setLabel
function _setLabel($btn, text, style, tooltip) { // Clear text/styles from previous status $("span", $btn).remove(); $btn.removeClass(_allStatusStyles); // Set text/styles for new status if (text && text.length > 0) { $("<span class=\"label\">") .addClass(style) .text(text) .appendTo($btn); } else { $btn.addClass(style); } if (tooltip) { $btn.attr("title", tooltip); } }
javascript
function _setLabel($btn, text, style, tooltip) { // Clear text/styles from previous status $("span", $btn).remove(); $btn.removeClass(_allStatusStyles); // Set text/styles for new status if (text && text.length > 0) { $("<span class=\"label\">") .addClass(style) .text(text) .appendTo($btn); } else { $btn.addClass(style); } if (tooltip) { $btn.attr("title", tooltip); } }
[ "function", "_setLabel", "(", "$btn", ",", "text", ",", "style", ",", "tooltip", ")", "{", "// Clear text/styles from previous status", "$", "(", "\"span\"", ",", "$btn", ")", ".", "remove", "(", ")", ";", "$btn", ".", "removeClass", "(", "_allStatusStyles", ")", ";", "// Set text/styles for new status", "if", "(", "text", "&&", "text", ".", "length", ">", "0", ")", "{", "$", "(", "\"<span class=\\\"label\\\">\"", ")", ".", "addClass", "(", "style", ")", ".", "text", "(", "text", ")", ".", "appendTo", "(", "$btn", ")", ";", "}", "else", "{", "$btn", ".", "addClass", "(", "style", ")", ";", "}", "if", "(", "tooltip", ")", "{", "$btn", ".", "attr", "(", "\"title\"", ",", "tooltip", ")", ";", "}", "}" ]
Change the appearance of a button. Omit text to remove any extra text; omit style to return to default styling; omit tooltip to leave tooltip unchanged.
[ "Change", "the", "appearance", "of", "a", "button", ".", "Omit", "text", "to", "remove", "any", "extra", "text", ";", "omit", "style", "to", "return", "to", "default", "styling", ";", "omit", "tooltip", "to", "leave", "tooltip", "unchanged", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/main.js#L150-L168
1,888
adobe/brackets
src/LiveDevelopment/main.js
_handleGoLiveCommand
function _handleGoLiveCommand() { if (LiveDevImpl.status >= LiveDevImpl.STATUS_ACTIVE) { LiveDevImpl.close(); } else if (LiveDevImpl.status <= LiveDevImpl.STATUS_INACTIVE) { if (!params.get("skipLiveDevelopmentInfo") && !PreferencesManager.getViewState("livedev.afterFirstLaunch")) { PreferencesManager.setViewState("livedev.afterFirstLaunch", "true"); Dialogs.showModalDialog( DefaultDialogs.DIALOG_ID_INFO, Strings.LIVE_DEVELOPMENT_INFO_TITLE, Strings.LIVE_DEVELOPMENT_INFO_MESSAGE ).done(function (id) { LiveDevImpl.open(); }); } else { LiveDevImpl.open(); } } }
javascript
function _handleGoLiveCommand() { if (LiveDevImpl.status >= LiveDevImpl.STATUS_ACTIVE) { LiveDevImpl.close(); } else if (LiveDevImpl.status <= LiveDevImpl.STATUS_INACTIVE) { if (!params.get("skipLiveDevelopmentInfo") && !PreferencesManager.getViewState("livedev.afterFirstLaunch")) { PreferencesManager.setViewState("livedev.afterFirstLaunch", "true"); Dialogs.showModalDialog( DefaultDialogs.DIALOG_ID_INFO, Strings.LIVE_DEVELOPMENT_INFO_TITLE, Strings.LIVE_DEVELOPMENT_INFO_MESSAGE ).done(function (id) { LiveDevImpl.open(); }); } else { LiveDevImpl.open(); } } }
[ "function", "_handleGoLiveCommand", "(", ")", "{", "if", "(", "LiveDevImpl", ".", "status", ">=", "LiveDevImpl", ".", "STATUS_ACTIVE", ")", "{", "LiveDevImpl", ".", "close", "(", ")", ";", "}", "else", "if", "(", "LiveDevImpl", ".", "status", "<=", "LiveDevImpl", ".", "STATUS_INACTIVE", ")", "{", "if", "(", "!", "params", ".", "get", "(", "\"skipLiveDevelopmentInfo\"", ")", "&&", "!", "PreferencesManager", ".", "getViewState", "(", "\"livedev.afterFirstLaunch\"", ")", ")", "{", "PreferencesManager", ".", "setViewState", "(", "\"livedev.afterFirstLaunch\"", ",", "\"true\"", ")", ";", "Dialogs", ".", "showModalDialog", "(", "DefaultDialogs", ".", "DIALOG_ID_INFO", ",", "Strings", ".", "LIVE_DEVELOPMENT_INFO_TITLE", ",", "Strings", ".", "LIVE_DEVELOPMENT_INFO_MESSAGE", ")", ".", "done", "(", "function", "(", "id", ")", "{", "LiveDevImpl", ".", "open", "(", ")", ";", "}", ")", ";", "}", "else", "{", "LiveDevImpl", ".", "open", "(", ")", ";", "}", "}", "}" ]
Toggles LiveDevelopment and synchronizes the state of UI elements that reports LiveDevelopment status Stop Live Dev when in an active state (ACTIVE, OUT_OF_SYNC, SYNC_ERROR). Start Live Dev when in an inactive state (ERROR, INACTIVE). Do nothing when in a connecting state (CONNECTING, LOADING_AGENTS).
[ "Toggles", "LiveDevelopment", "and", "synchronizes", "the", "state", "of", "UI", "elements", "that", "reports", "LiveDevelopment", "status" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/main.js#L177-L194
1,889
adobe/brackets
src/LiveDevelopment/main.js
_showStatusChangeReason
function _showStatusChangeReason(reason) { // Destroy the previous twipsy (options are not updated otherwise) _$btnGoLive.twipsy("hide").removeData("twipsy"); // If there was no reason or the action was an explicit request by the user, don't show a twipsy if (!reason || reason === "explicit_close") { return; } // Translate the reason var translatedReason = Strings["LIVE_DEV_" + reason.toUpperCase()]; if (!translatedReason) { translatedReason = StringUtils.format(Strings.LIVE_DEV_CLOSED_UNKNOWN_REASON, reason); } // Configure the twipsy var options = { placement: "left", trigger: "manual", autoHideDelay: 5000, title: function () { return translatedReason; } }; // Show the twipsy with the explanation _$btnGoLive.twipsy(options).twipsy("show"); }
javascript
function _showStatusChangeReason(reason) { // Destroy the previous twipsy (options are not updated otherwise) _$btnGoLive.twipsy("hide").removeData("twipsy"); // If there was no reason or the action was an explicit request by the user, don't show a twipsy if (!reason || reason === "explicit_close") { return; } // Translate the reason var translatedReason = Strings["LIVE_DEV_" + reason.toUpperCase()]; if (!translatedReason) { translatedReason = StringUtils.format(Strings.LIVE_DEV_CLOSED_UNKNOWN_REASON, reason); } // Configure the twipsy var options = { placement: "left", trigger: "manual", autoHideDelay: 5000, title: function () { return translatedReason; } }; // Show the twipsy with the explanation _$btnGoLive.twipsy(options).twipsy("show"); }
[ "function", "_showStatusChangeReason", "(", "reason", ")", "{", "// Destroy the previous twipsy (options are not updated otherwise)", "_$btnGoLive", ".", "twipsy", "(", "\"hide\"", ")", ".", "removeData", "(", "\"twipsy\"", ")", ";", "// If there was no reason or the action was an explicit request by the user, don't show a twipsy", "if", "(", "!", "reason", "||", "reason", "===", "\"explicit_close\"", ")", "{", "return", ";", "}", "// Translate the reason", "var", "translatedReason", "=", "Strings", "[", "\"LIVE_DEV_\"", "+", "reason", ".", "toUpperCase", "(", ")", "]", ";", "if", "(", "!", "translatedReason", ")", "{", "translatedReason", "=", "StringUtils", ".", "format", "(", "Strings", ".", "LIVE_DEV_CLOSED_UNKNOWN_REASON", ",", "reason", ")", ";", "}", "// Configure the twipsy", "var", "options", "=", "{", "placement", ":", "\"left\"", ",", "trigger", ":", "\"manual\"", ",", "autoHideDelay", ":", "5000", ",", "title", ":", "function", "(", ")", "{", "return", "translatedReason", ";", "}", "}", ";", "// Show the twipsy with the explanation", "_$btnGoLive", ".", "twipsy", "(", "options", ")", ".", "twipsy", "(", "\"show\"", ")", ";", "}" ]
Called on status change
[ "Called", "on", "status", "change" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/main.js#L197-L224
1,890
adobe/brackets
src/LiveDevelopment/main.js
_setupGoLiveButton
function _setupGoLiveButton() { if (!_$btnGoLive) { _$btnGoLive = $("#toolbar-go-live"); _$btnGoLive.click(function onGoLive() { _handleGoLiveCommand(); }); } LiveDevImpl.on("statusChange", function statusChange(event, status, reason) { // status starts at -1 (error), so add one when looking up name and style // See the comments at the top of LiveDevelopment.js for details on the // various status codes. _setLabel(_$btnGoLive, null, _status[status + 1].style, _status[status + 1].tooltip); _showStatusChangeReason(reason); if (config.autoconnect) { window.sessionStorage.setItem("live.enabled", status === 3); } }); // Initialize tooltip for 'not connected' state _setLabel(_$btnGoLive, null, _status[1].style, _status[1].tooltip); }
javascript
function _setupGoLiveButton() { if (!_$btnGoLive) { _$btnGoLive = $("#toolbar-go-live"); _$btnGoLive.click(function onGoLive() { _handleGoLiveCommand(); }); } LiveDevImpl.on("statusChange", function statusChange(event, status, reason) { // status starts at -1 (error), so add one when looking up name and style // See the comments at the top of LiveDevelopment.js for details on the // various status codes. _setLabel(_$btnGoLive, null, _status[status + 1].style, _status[status + 1].tooltip); _showStatusChangeReason(reason); if (config.autoconnect) { window.sessionStorage.setItem("live.enabled", status === 3); } }); // Initialize tooltip for 'not connected' state _setLabel(_$btnGoLive, null, _status[1].style, _status[1].tooltip); }
[ "function", "_setupGoLiveButton", "(", ")", "{", "if", "(", "!", "_$btnGoLive", ")", "{", "_$btnGoLive", "=", "$", "(", "\"#toolbar-go-live\"", ")", ";", "_$btnGoLive", ".", "click", "(", "function", "onGoLive", "(", ")", "{", "_handleGoLiveCommand", "(", ")", ";", "}", ")", ";", "}", "LiveDevImpl", ".", "on", "(", "\"statusChange\"", ",", "function", "statusChange", "(", "event", ",", "status", ",", "reason", ")", "{", "// status starts at -1 (error), so add one when looking up name and style", "// See the comments at the top of LiveDevelopment.js for details on the", "// various status codes.", "_setLabel", "(", "_$btnGoLive", ",", "null", ",", "_status", "[", "status", "+", "1", "]", ".", "style", ",", "_status", "[", "status", "+", "1", "]", ".", "tooltip", ")", ";", "_showStatusChangeReason", "(", "reason", ")", ";", "if", "(", "config", ".", "autoconnect", ")", "{", "window", ".", "sessionStorage", ".", "setItem", "(", "\"live.enabled\"", ",", "status", "===", "3", ")", ";", "}", "}", ")", ";", "// Initialize tooltip for 'not connected' state", "_setLabel", "(", "_$btnGoLive", ",", "null", ",", "_status", "[", "1", "]", ".", "style", ",", "_status", "[", "1", "]", ".", "tooltip", ")", ";", "}" ]
Create the menu item "Go Live"
[ "Create", "the", "menu", "item", "Go", "Live" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/main.js#L227-L247
1,891
adobe/brackets
src/LiveDevelopment/main.js
_setupGoLiveMenu
function _setupGoLiveMenu() { LiveDevImpl.on("statusChange", function statusChange(event, status) { // Update the checkmark next to 'Live Preview' menu item // Add checkmark when status is STATUS_ACTIVE; otherwise remove it CommandManager.get(Commands.FILE_LIVE_FILE_PREVIEW).setChecked(status === LiveDevImpl.STATUS_ACTIVE); CommandManager.get(Commands.FILE_LIVE_HIGHLIGHT).setEnabled(status === LiveDevImpl.STATUS_ACTIVE); }); }
javascript
function _setupGoLiveMenu() { LiveDevImpl.on("statusChange", function statusChange(event, status) { // Update the checkmark next to 'Live Preview' menu item // Add checkmark when status is STATUS_ACTIVE; otherwise remove it CommandManager.get(Commands.FILE_LIVE_FILE_PREVIEW).setChecked(status === LiveDevImpl.STATUS_ACTIVE); CommandManager.get(Commands.FILE_LIVE_HIGHLIGHT).setEnabled(status === LiveDevImpl.STATUS_ACTIVE); }); }
[ "function", "_setupGoLiveMenu", "(", ")", "{", "LiveDevImpl", ".", "on", "(", "\"statusChange\"", ",", "function", "statusChange", "(", "event", ",", "status", ")", "{", "// Update the checkmark next to 'Live Preview' menu item", "// Add checkmark when status is STATUS_ACTIVE; otherwise remove it", "CommandManager", ".", "get", "(", "Commands", ".", "FILE_LIVE_FILE_PREVIEW", ")", ".", "setChecked", "(", "status", "===", "LiveDevImpl", ".", "STATUS_ACTIVE", ")", ";", "CommandManager", ".", "get", "(", "Commands", ".", "FILE_LIVE_HIGHLIGHT", ")", ".", "setEnabled", "(", "status", "===", "LiveDevImpl", ".", "STATUS_ACTIVE", ")", ";", "}", ")", ";", "}" ]
Maintains state of the Live Preview menu item
[ "Maintains", "state", "of", "the", "Live", "Preview", "menu", "item" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/main.js#L250-L257
1,892
adobe/brackets
src/LiveDevelopment/main.js
_setImplementation
function _setImplementation(multibrowser) { if (multibrowser) { // set implemenation LiveDevImpl = MultiBrowserLiveDev; // update styles for UI status _status = [ { tooltip: Strings.LIVE_DEV_STATUS_TIP_NOT_CONNECTED, style: "warning" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_NOT_CONNECTED, style: "" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_PROGRESS1, style: "info" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_CONNECTED, style: "success" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_OUT_OF_SYNC, style: "out-of-sync" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_SYNC_ERROR, style: "sync-error" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_PROGRESS1, style: "info" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_PROGRESS1, style: "info" } ]; } else { LiveDevImpl = LiveDevelopment; _status = [ { tooltip: Strings.LIVE_DEV_STATUS_TIP_NOT_CONNECTED, style: "warning" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_NOT_CONNECTED, style: "" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_PROGRESS1, style: "info" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_PROGRESS2, style: "info" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_CONNECTED, style: "success" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_OUT_OF_SYNC, style: "out-of-sync" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_SYNC_ERROR, style: "sync-error" } ]; } // setup status changes listeners for new implementation _setupGoLiveButton(); _setupGoLiveMenu(); // toggle the menu _toggleLivePreviewMultiBrowser(multibrowser); }
javascript
function _setImplementation(multibrowser) { if (multibrowser) { // set implemenation LiveDevImpl = MultiBrowserLiveDev; // update styles for UI status _status = [ { tooltip: Strings.LIVE_DEV_STATUS_TIP_NOT_CONNECTED, style: "warning" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_NOT_CONNECTED, style: "" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_PROGRESS1, style: "info" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_CONNECTED, style: "success" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_OUT_OF_SYNC, style: "out-of-sync" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_SYNC_ERROR, style: "sync-error" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_PROGRESS1, style: "info" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_PROGRESS1, style: "info" } ]; } else { LiveDevImpl = LiveDevelopment; _status = [ { tooltip: Strings.LIVE_DEV_STATUS_TIP_NOT_CONNECTED, style: "warning" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_NOT_CONNECTED, style: "" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_PROGRESS1, style: "info" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_PROGRESS2, style: "info" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_CONNECTED, style: "success" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_OUT_OF_SYNC, style: "out-of-sync" }, { tooltip: Strings.LIVE_DEV_STATUS_TIP_SYNC_ERROR, style: "sync-error" } ]; } // setup status changes listeners for new implementation _setupGoLiveButton(); _setupGoLiveMenu(); // toggle the menu _toggleLivePreviewMultiBrowser(multibrowser); }
[ "function", "_setImplementation", "(", "multibrowser", ")", "{", "if", "(", "multibrowser", ")", "{", "// set implemenation", "LiveDevImpl", "=", "MultiBrowserLiveDev", ";", "// update styles for UI status", "_status", "=", "[", "{", "tooltip", ":", "Strings", ".", "LIVE_DEV_STATUS_TIP_NOT_CONNECTED", ",", "style", ":", "\"warning\"", "}", ",", "{", "tooltip", ":", "Strings", ".", "LIVE_DEV_STATUS_TIP_NOT_CONNECTED", ",", "style", ":", "\"\"", "}", ",", "{", "tooltip", ":", "Strings", ".", "LIVE_DEV_STATUS_TIP_PROGRESS1", ",", "style", ":", "\"info\"", "}", ",", "{", "tooltip", ":", "Strings", ".", "LIVE_DEV_STATUS_TIP_CONNECTED", ",", "style", ":", "\"success\"", "}", ",", "{", "tooltip", ":", "Strings", ".", "LIVE_DEV_STATUS_TIP_OUT_OF_SYNC", ",", "style", ":", "\"out-of-sync\"", "}", ",", "{", "tooltip", ":", "Strings", ".", "LIVE_DEV_STATUS_TIP_SYNC_ERROR", ",", "style", ":", "\"sync-error\"", "}", ",", "{", "tooltip", ":", "Strings", ".", "LIVE_DEV_STATUS_TIP_PROGRESS1", ",", "style", ":", "\"info\"", "}", ",", "{", "tooltip", ":", "Strings", ".", "LIVE_DEV_STATUS_TIP_PROGRESS1", ",", "style", ":", "\"info\"", "}", "]", ";", "}", "else", "{", "LiveDevImpl", "=", "LiveDevelopment", ";", "_status", "=", "[", "{", "tooltip", ":", "Strings", ".", "LIVE_DEV_STATUS_TIP_NOT_CONNECTED", ",", "style", ":", "\"warning\"", "}", ",", "{", "tooltip", ":", "Strings", ".", "LIVE_DEV_STATUS_TIP_NOT_CONNECTED", ",", "style", ":", "\"\"", "}", ",", "{", "tooltip", ":", "Strings", ".", "LIVE_DEV_STATUS_TIP_PROGRESS1", ",", "style", ":", "\"info\"", "}", ",", "{", "tooltip", ":", "Strings", ".", "LIVE_DEV_STATUS_TIP_PROGRESS2", ",", "style", ":", "\"info\"", "}", ",", "{", "tooltip", ":", "Strings", ".", "LIVE_DEV_STATUS_TIP_CONNECTED", ",", "style", ":", "\"success\"", "}", ",", "{", "tooltip", ":", "Strings", ".", "LIVE_DEV_STATUS_TIP_OUT_OF_SYNC", ",", "style", ":", "\"out-of-sync\"", "}", ",", "{", "tooltip", ":", "Strings", ".", "LIVE_DEV_STATUS_TIP_SYNC_ERROR", ",", "style", ":", "\"sync-error\"", "}", "]", ";", "}", "// setup status changes listeners for new implementation", "_setupGoLiveButton", "(", ")", ";", "_setupGoLiveMenu", "(", ")", ";", "// toggle the menu", "_toggleLivePreviewMultiBrowser", "(", "multibrowser", ")", ";", "}" ]
Sets the MultiBrowserLiveDev implementation if multibrowser is truthy, keeps default LiveDevelopment implementation based on CDT otherwise. It also resets the listeners and UI elements.
[ "Sets", "the", "MultiBrowserLiveDev", "implementation", "if", "multibrowser", "is", "truthy", "keeps", "default", "LiveDevelopment", "implementation", "based", "on", "CDT", "otherwise", ".", "It", "also", "resets", "the", "listeners", "and", "UI", "elements", "." ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/main.js#L279-L311
1,893
adobe/brackets
src/LiveDevelopment/main.js
_setupDebugHelpers
function _setupDebugHelpers() { window.ld = LiveDevelopment; window.i = Inspector; window.report = function report(params) { window.params = params; console.info(params); }; }
javascript
function _setupDebugHelpers() { window.ld = LiveDevelopment; window.i = Inspector; window.report = function report(params) { window.params = params; console.info(params); }; }
[ "function", "_setupDebugHelpers", "(", ")", "{", "window", ".", "ld", "=", "LiveDevelopment", ";", "window", ".", "i", "=", "Inspector", ";", "window", ".", "report", "=", "function", "report", "(", "params", ")", "{", "window", ".", "params", "=", "params", ";", "console", ".", "info", "(", "params", ")", ";", "}", ";", "}" ]
Setup window references to useful LiveDevelopment modules
[ "Setup", "window", "references", "to", "useful", "LiveDevelopment", "modules" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/main.js#L314-L318
1,894
adobe/brackets
src/extensions/default/AutoUpdate/main.js
checkIfAnotherSessionInProgress
function checkIfAnotherSessionInProgress() { var result = $.Deferred(); if(updateJsonHandler) { var state = updateJsonHandler.state; updateJsonHandler.refresh() .done(function() { var val = updateJsonHandler.get(updateProgressKey); if(val !== null) { result.resolve(val); } else { result.reject(); } }) .fail(function() { updateJsonHandler.state = state; result.reject(); }); } return result.promise(); }
javascript
function checkIfAnotherSessionInProgress() { var result = $.Deferred(); if(updateJsonHandler) { var state = updateJsonHandler.state; updateJsonHandler.refresh() .done(function() { var val = updateJsonHandler.get(updateProgressKey); if(val !== null) { result.resolve(val); } else { result.reject(); } }) .fail(function() { updateJsonHandler.state = state; result.reject(); }); } return result.promise(); }
[ "function", "checkIfAnotherSessionInProgress", "(", ")", "{", "var", "result", "=", "$", ".", "Deferred", "(", ")", ";", "if", "(", "updateJsonHandler", ")", "{", "var", "state", "=", "updateJsonHandler", ".", "state", ";", "updateJsonHandler", ".", "refresh", "(", ")", ".", "done", "(", "function", "(", ")", "{", "var", "val", "=", "updateJsonHandler", ".", "get", "(", "updateProgressKey", ")", ";", "if", "(", "val", "!==", "null", ")", "{", "result", ".", "resolve", "(", "val", ")", ";", "}", "else", "{", "result", ".", "reject", "(", ")", ";", "}", "}", ")", ".", "fail", "(", "function", "(", ")", "{", "updateJsonHandler", ".", "state", "=", "state", ";", "result", ".", "reject", "(", ")", ";", "}", ")", ";", "}", "return", "result", ".", "promise", "(", ")", ";", "}" ]
Checks if an auto update session is currently in progress @returns {boolean} - true if an auto update session is currently in progress, false otherwise
[ "Checks", "if", "an", "auto", "update", "session", "is", "currently", "in", "progress" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L102-L122
1,895
adobe/brackets
src/extensions/default/AutoUpdate/main.js
receiveMessageFromNode
function receiveMessageFromNode(event, msgObj) { if (functionMap[msgObj.fn]) { if(domainID === msgObj.requester) { functionMap[msgObj.fn].apply(null, msgObj.args); } } }
javascript
function receiveMessageFromNode(event, msgObj) { if (functionMap[msgObj.fn]) { if(domainID === msgObj.requester) { functionMap[msgObj.fn].apply(null, msgObj.args); } } }
[ "function", "receiveMessageFromNode", "(", "event", ",", "msgObj", ")", "{", "if", "(", "functionMap", "[", "msgObj", ".", "fn", "]", ")", "{", "if", "(", "domainID", "===", "msgObj", ".", "requester", ")", "{", "functionMap", "[", "msgObj", ".", "fn", "]", ".", "apply", "(", "null", ",", "msgObj", ".", "args", ")", ";", "}", "}", "}" ]
Receives messages from node @param {object} event - event received from node @param {object} msgObj - json containing - { fn - function to execute on Brackets side args - arguments to the above function requester - ID of the current requester domain
[ "Receives", "messages", "from", "node" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L141-L147
1,896
adobe/brackets
src/extensions/default/AutoUpdate/main.js
postMessageToNode
function postMessageToNode(messageId) { var msg = { fn: messageId, args: getFunctionArgs(arguments), requester: domainID }; updateDomain.exec('data', msg); }
javascript
function postMessageToNode(messageId) { var msg = { fn: messageId, args: getFunctionArgs(arguments), requester: domainID }; updateDomain.exec('data', msg); }
[ "function", "postMessageToNode", "(", "messageId", ")", "{", "var", "msg", "=", "{", "fn", ":", "messageId", ",", "args", ":", "getFunctionArgs", "(", "arguments", ")", ",", "requester", ":", "domainID", "}", ";", "updateDomain", ".", "exec", "(", "'data'", ",", "msg", ")", ";", "}" ]
Posts messages to node @param {string} messageId - Message to be passed
[ "Posts", "messages", "to", "node" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L185-L192
1,897
adobe/brackets
src/extensions/default/AutoUpdate/main.js
checkInstallationStatus
function checkInstallationStatus() { var searchParams = { "updateDir": updateDir, "installErrorStr": ["ERROR:"], "bracketsErrorStr": ["ERROR:"], "encoding": "utf8" }, // Below are the possible Windows Installer error strings, which will be searched for in the installer logs to track failures. winInstallErrorStrArr = [ "Installation success or error status", "Reconfiguration success or error status" ]; if (brackets.platform === "win") { searchParams.installErrorStr = winInstallErrorStrArr; searchParams.encoding = "utf16le"; } postMessageToNode(MessageIds.CHECK_INSTALLER_STATUS, searchParams); }
javascript
function checkInstallationStatus() { var searchParams = { "updateDir": updateDir, "installErrorStr": ["ERROR:"], "bracketsErrorStr": ["ERROR:"], "encoding": "utf8" }, // Below are the possible Windows Installer error strings, which will be searched for in the installer logs to track failures. winInstallErrorStrArr = [ "Installation success or error status", "Reconfiguration success or error status" ]; if (brackets.platform === "win") { searchParams.installErrorStr = winInstallErrorStrArr; searchParams.encoding = "utf16le"; } postMessageToNode(MessageIds.CHECK_INSTALLER_STATUS, searchParams); }
[ "function", "checkInstallationStatus", "(", ")", "{", "var", "searchParams", "=", "{", "\"updateDir\"", ":", "updateDir", ",", "\"installErrorStr\"", ":", "[", "\"ERROR:\"", "]", ",", "\"bracketsErrorStr\"", ":", "[", "\"ERROR:\"", "]", ",", "\"encoding\"", ":", "\"utf8\"", "}", ",", "// Below are the possible Windows Installer error strings, which will be searched for in the installer logs to track failures.", "winInstallErrorStrArr", "=", "[", "\"Installation success or error status\"", ",", "\"Reconfiguration success or error status\"", "]", ";", "if", "(", "brackets", ".", "platform", "===", "\"win\"", ")", "{", "searchParams", ".", "installErrorStr", "=", "winInstallErrorStrArr", ";", "searchParams", ".", "encoding", "=", "\"utf16le\"", ";", "}", "postMessageToNode", "(", "MessageIds", ".", "CHECK_INSTALLER_STATUS", ",", "searchParams", ")", ";", "}" ]
Checks Install failure scenarios
[ "Checks", "Install", "failure", "scenarios" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L197-L214
1,898
adobe/brackets
src/extensions/default/AutoUpdate/main.js
checkUpdateStatus
function checkUpdateStatus() { var filesToCache = ['.logs'], downloadCompleted = updateJsonHandler.get("downloadCompleted"), updateInitiatedInPrevSession = updateJsonHandler.get("updateInitiatedInPrevSession"); if (downloadCompleted && updateInitiatedInPrevSession) { var isNewVersion = checkIfVersionUpdated(); updateJsonHandler.reset(); if (isNewVersion) { // We get here if the update was successful UpdateInfoBar.showUpdateBar({ type: "success", title: Strings.UPDATE_SUCCESSFUL, description: "" }); HealthLogger.sendAnalyticsData( autoUpdateEventNames.AUTOUPDATE_INSTALLATION_SUCCESS, "autoUpdate", "install", "complete", "" ); } else { // We get here if the update started but failed checkInstallationStatus(); UpdateInfoBar.showUpdateBar({ type: "error", title: Strings.UPDATE_FAILED, description: Strings.GO_TO_SITE }); } } else if (downloadCompleted && !updateInitiatedInPrevSession) { // We get here if the download was complete and user selected UpdateLater if (brackets.platform === "mac") { filesToCache = ['.dmg', '.json']; } else if (brackets.platform === "win") { filesToCache = ['.msi', '.json']; } } postMessageToNode(MessageIds.PERFORM_CLEANUP, filesToCache); }
javascript
function checkUpdateStatus() { var filesToCache = ['.logs'], downloadCompleted = updateJsonHandler.get("downloadCompleted"), updateInitiatedInPrevSession = updateJsonHandler.get("updateInitiatedInPrevSession"); if (downloadCompleted && updateInitiatedInPrevSession) { var isNewVersion = checkIfVersionUpdated(); updateJsonHandler.reset(); if (isNewVersion) { // We get here if the update was successful UpdateInfoBar.showUpdateBar({ type: "success", title: Strings.UPDATE_SUCCESSFUL, description: "" }); HealthLogger.sendAnalyticsData( autoUpdateEventNames.AUTOUPDATE_INSTALLATION_SUCCESS, "autoUpdate", "install", "complete", "" ); } else { // We get here if the update started but failed checkInstallationStatus(); UpdateInfoBar.showUpdateBar({ type: "error", title: Strings.UPDATE_FAILED, description: Strings.GO_TO_SITE }); } } else if (downloadCompleted && !updateInitiatedInPrevSession) { // We get here if the download was complete and user selected UpdateLater if (brackets.platform === "mac") { filesToCache = ['.dmg', '.json']; } else if (brackets.platform === "win") { filesToCache = ['.msi', '.json']; } } postMessageToNode(MessageIds.PERFORM_CLEANUP, filesToCache); }
[ "function", "checkUpdateStatus", "(", ")", "{", "var", "filesToCache", "=", "[", "'.logs'", "]", ",", "downloadCompleted", "=", "updateJsonHandler", ".", "get", "(", "\"downloadCompleted\"", ")", ",", "updateInitiatedInPrevSession", "=", "updateJsonHandler", ".", "get", "(", "\"updateInitiatedInPrevSession\"", ")", ";", "if", "(", "downloadCompleted", "&&", "updateInitiatedInPrevSession", ")", "{", "var", "isNewVersion", "=", "checkIfVersionUpdated", "(", ")", ";", "updateJsonHandler", ".", "reset", "(", ")", ";", "if", "(", "isNewVersion", ")", "{", "// We get here if the update was successful", "UpdateInfoBar", ".", "showUpdateBar", "(", "{", "type", ":", "\"success\"", ",", "title", ":", "Strings", ".", "UPDATE_SUCCESSFUL", ",", "description", ":", "\"\"", "}", ")", ";", "HealthLogger", ".", "sendAnalyticsData", "(", "autoUpdateEventNames", ".", "AUTOUPDATE_INSTALLATION_SUCCESS", ",", "\"autoUpdate\"", ",", "\"install\"", ",", "\"complete\"", ",", "\"\"", ")", ";", "}", "else", "{", "// We get here if the update started but failed", "checkInstallationStatus", "(", ")", ";", "UpdateInfoBar", ".", "showUpdateBar", "(", "{", "type", ":", "\"error\"", ",", "title", ":", "Strings", ".", "UPDATE_FAILED", ",", "description", ":", "Strings", ".", "GO_TO_SITE", "}", ")", ";", "}", "}", "else", "if", "(", "downloadCompleted", "&&", "!", "updateInitiatedInPrevSession", ")", "{", "// We get here if the download was complete and user selected UpdateLater", "if", "(", "brackets", ".", "platform", "===", "\"mac\"", ")", "{", "filesToCache", "=", "[", "'.dmg'", ",", "'.json'", "]", ";", "}", "else", "if", "(", "brackets", ".", "platform", "===", "\"win\"", ")", "{", "filesToCache", "=", "[", "'.msi'", ",", "'.json'", "]", ";", "}", "}", "postMessageToNode", "(", "MessageIds", ".", "PERFORM_CLEANUP", ",", "filesToCache", ")", ";", "}" ]
Checks and handles the update success and failure scenarios
[ "Checks", "and", "handles", "the", "update", "success", "and", "failure", "scenarios" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L219-L260
1,899
adobe/brackets
src/extensions/default/AutoUpdate/main.js
handleInstallationStatus
function handleInstallationStatus(statusObj) { var errorCode = "", errorline = statusObj.installError; if (errorline) { errorCode = errorline.substr(errorline.lastIndexOf(':') + 2, errorline.length); } HealthLogger.sendAnalyticsData( autoUpdateEventNames.AUTOUPDATE_INSTALLATION_FAILED, "autoUpdate", "install", "fail", errorCode ); }
javascript
function handleInstallationStatus(statusObj) { var errorCode = "", errorline = statusObj.installError; if (errorline) { errorCode = errorline.substr(errorline.lastIndexOf(':') + 2, errorline.length); } HealthLogger.sendAnalyticsData( autoUpdateEventNames.AUTOUPDATE_INSTALLATION_FAILED, "autoUpdate", "install", "fail", errorCode ); }
[ "function", "handleInstallationStatus", "(", "statusObj", ")", "{", "var", "errorCode", "=", "\"\"", ",", "errorline", "=", "statusObj", ".", "installError", ";", "if", "(", "errorline", ")", "{", "errorCode", "=", "errorline", ".", "substr", "(", "errorline", ".", "lastIndexOf", "(", "':'", ")", "+", "2", ",", "errorline", ".", "length", ")", ";", "}", "HealthLogger", ".", "sendAnalyticsData", "(", "autoUpdateEventNames", ".", "AUTOUPDATE_INSTALLATION_FAILED", ",", "\"autoUpdate\"", ",", "\"install\"", ",", "\"fail\"", ",", "errorCode", ")", ";", "}" ]
Send Installer Error Code to Analytics Server
[ "Send", "Installer", "Error", "Code", "to", "Analytics", "Server" ]
d5d00d43602c438266d32b8eda8f8a3ca937b524
https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L266-L279