_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q16900
sendHealthDataToServer
train
function sendHealthDataToServer() { var result = new $.Deferred(); getHealthData().done(function (healthData) { var url = brackets.config.healthDataServerURL, data = JSON.stringify(healthData); $.ajax({ url: url, type: "POST", ...
javascript
{ "resource": "" }
q16901
sendAnalyticsDataToServer
train
function sendAnalyticsDataToServer(eventParams) { var result = new $.Deferred(); var analyticsData = getAnalyticsData(eventParams); $.ajax({ url: brackets.config.analyticsDataServerURL, type: "POST", data: JSON.stringify({events: [analyticsData]}), ...
javascript
{ "resource": "" }
q16902
_setStatus
train
function _setStatus(status, closeReason) { // Don't send a notification when the status didn't actually change if (status === exports.status) { return; } exports.status = status; var reason = status === STATUS_INACTIVE ? closeReason : null; exports.trigger("...
javascript
{ "resource": "" }
q16903
_docIsOutOfSync
train
function _docIsOutOfSync(doc) { var liveDoc = _server && _server.get(doc.file.fullPath), isLiveEditingEnabled = liveDoc && liveDoc.isLiveEditingEnabled(); return doc.isDirty && !isLiveEditingEnabled; }
javascript
{ "resource": "" }
q16904
_styleSheetAdded
train
function _styleSheetAdded(event, url, roots) { var path = _server && _server.urlToPath(url), alreadyAdded = !!_relatedDocuments[url]; // path may be null if loading an external stylesheet. // Also, the stylesheet may already exist and be reported as added twice // due to Chr...
javascript
{ "resource": "" }
q16905
open
train
function open() { // TODO: need to run _onDocumentChange() after load if doc != currentDocument here? Maybe not, since activeEditorChange // doesn't trigger it, while inline editors can still cause edits in doc other than currentDoc... _getInitialDocFromCurrent().done(function (doc) { ...
javascript
{ "resource": "" }
q16906
init
train
function init(config) { exports.config = config; MainViewManager .on("currentFileChange", _onFileChange); DocumentManager .on("documentSaved", _onDocumentSaved) .on("dirtyFlagChange", _onDirtyFlagChange); ProjectManager .on("beforeProjectCl...
javascript
{ "resource": "" }
q16907
getCurrentProjectServerConfig
train
function getCurrentProjectServerConfig() { return { baseUrl: ProjectManager.getBaseUrl(), pathResolver: ProjectManager.makeProjectRelativeIfPossible, root: ProjectManager.getProjectRoot().fullPath }; }
javascript
{ "resource": "" }
q16908
logNodeState
train
function logNodeState() { if (brackets.app && brackets.app.getNodeState) { brackets.app.getNodeState(function (err, port) { if (err) { console.log("[NodeDebugUtils] Node is in error state " + err); } else { console.log("[NodeDeb...
javascript
{ "resource": "" }
q16909
restartNode
train
function restartNode() { try { _nodeConnection.domains.base.restartNode(); } catch (e) { window.alert("Failed trying to restart Node: " + e.message); } }
javascript
{ "resource": "" }
q16910
enableDebugger
train
function enableDebugger() { try { _nodeConnection.domains.base.enableDebugger(); } catch (e) { window.alert("Failed trying to enable Node debugger: " + e.message); } }
javascript
{ "resource": "" }
q16911
formatHints
train
function formatHints(hints, query) { var hasColorSwatch = hints.some(function (token) { return token.color; }); StringMatch.basicMatchSort(hints); return hints.map(function (token) { var $hintObj = $("<span>").addClass("brackets-css-hints"); // highl...
javascript
{ "resource": "" }
q16912
compareFilesWithIndices
train
function compareFilesWithIndices(index1, index2) { return entries[index1]._name.toLocaleLowerCase().localeCompare(entries[index2]._name.toLocaleLowerCase()); }
javascript
{ "resource": "" }
q16913
offsetToLineNum
train
function offsetToLineNum(textOrLines, offset) { if (Array.isArray(textOrLines)) { var lines = textOrLines, total = 0, line; for (line = 0; line < lines.length; line++) { if (total < offset) { // add 1 per line since /n were removed by splitting, bu...
javascript
{ "resource": "" }
q16914
getSearchMatches
train
function getSearchMatches(contents, queryExpr) { if (!contents) { return; } // Quick exit if not found or if we hit the limit if (foundMaximum || contents.search(queryExpr) === -1) { return []; } var match, lineNum, line, ch, totalMatchLength, matchedLines, numMatchedLines, last...
javascript
{ "resource": "" }
q16915
getFilesizeInBytes
train
function getFilesizeInBytes(fileName) { try { var stats = fs.statSync(fileName); return stats.size || 0; } catch (ex) { console.log(ex); return 0; } }
javascript
{ "resource": "" }
q16916
setResults
train
function setResults(fullpath, resultInfo, maxResultsToReturn) { if (results[fullpath]) { numMatches -= results[fullpath].matches.length; delete results[fullpath]; } if (foundMaximum || !resultInfo || !resultInfo.matches || !resultInfo.matches.length) { return; } // Make sur...
javascript
{ "resource": "" }
q16917
doSearchInOneFile
train
function doSearchInOneFile(filepath, text, queryExpr, maxResultsToReturn) { var matches = getSearchMatches(text, queryExpr); setResults(filepath, {matches: matches}, maxResultsToReturn); }
javascript
{ "resource": "" }
q16918
doSearchInFiles
train
function doSearchInFiles(fileList, queryExpr, startFileIndex, maxResultsToReturn) { var i; if (fileList.length === 0) { console.log('no files found'); return; } else { startFileIndex = startFileIndex || 0; for (i = startFileIndex; i < fileList.length && !foundMaximum; i++) {...
javascript
{ "resource": "" }
q16919
fileCrawler
train
function fileCrawler() { if (!files || (files && files.length === 0)) { setTimeout(fileCrawler, 1000); return; } var contents = ""; if (currentCrawlIndex < files.length) { contents = getFileContentsForFile(files[currentCrawlIndex]); if (contents) { cacheSize +...
javascript
{ "resource": "" }
q16920
countNumMatches
train
function countNumMatches(contents, queryExpr) { if (!contents) { return 0; } var matches = contents.match(queryExpr); return matches ? matches.length : 0; }
javascript
{ "resource": "" }
q16921
getNumMatches
train
function getNumMatches(fileList, queryExpr) { var i, matches = 0; for (i = 0; i < fileList.length; i++) { var temp = countNumMatches(getFileContentsForFile(fileList[i]), queryExpr); if (temp) { numFiles++; matches += temp; } if (matches > MAX_TOTAL...
javascript
{ "resource": "" }
q16922
doSearch
train
function doSearch(searchObject, nextPages) { savedSearchObject = searchObject; if (!files) { console.log("no file object found"); return {}; } results = {}; numMatches = 0; numFiles = 0; foundMaximum = false; if (!nextPages) { exceedsMaximum = false; eval...
javascript
{ "resource": "" }
q16923
removeFilesFromCache
train
function removeFilesFromCache(updateObject) { var fileList = updateObject.fileList || [], filesInSearchScope = updateObject.filesInSearchScope || [], i = 0; for (i = 0; i < fileList.length; i++) { delete projectCache[fileList[i]]; } function isNotInRemovedFilesList(path) { ...
javascript
{ "resource": "" }
q16924
addFilesToCache
train
function addFilesToCache(updateObject) { var fileList = updateObject.fileList || [], filesInSearchScope = updateObject.filesInSearchScope || [], i = 0, changedFilesAlreadyInList = [], newFiles = []; for (i = 0; i < fileList.length; i++) { // We just add a null entry indic...
javascript
{ "resource": "" }
q16925
getNextPage
train
function getNextPage() { var send_object = { "results": {}, "numMatches": 0, "foundMaximum": foundMaximum, "exceedsMaximum": exceedsMaximum }; if (!savedSearchObject) { return send_object; } savedSearchObject.startFileIndex = lastSearchedIndex; return d...
javascript
{ "resource": "" }
q16926
getAllResults
train
function getAllResults() { var send_object = { "results": {}, "numMatches": 0, "foundMaximum": foundMaximum, "exceedsMaximum": exceedsMaximum }; if (!savedSearchObject) { return send_object; } savedSearchObject.startFileIndex = 0; savedSearchObject.getA...
javascript
{ "resource": "" }
q16927
train
function (e, autoDismiss) { var $primaryBtn = this.find(".primary"), buttonId = null, which = String.fromCharCode(e.which), $focusedElement = this.find(".dialog-button:focus, a:focus"); function stopEvent() { e.preventDefault(); ...
javascript
{ "resource": "" }
q16928
setDialogMaxSize
train
function setDialogMaxSize() { var maxWidth, maxHeight, $dlgs = $(".modal-inner-wrapper > .instance"); // Verify 1 or more modal dialogs are showing if ($dlgs.length > 0) { maxWidth = $("body").width(); maxHeight = $("body").height(); $dlgs.css({...
javascript
{ "resource": "" }
q16929
showModalDialog
train
function showModalDialog(dlgClass, title, message, buttons, autoDismiss) { var templateVars = { dlgClass: dlgClass, title: title || "", message: message || "", buttons: buttons || [{ className: DIALOG_BTN_CLASS_PRIMARY, id: DIALOG_BTN_OK, text: Strings.OK }...
javascript
{ "resource": "" }
q16930
_loadSHA
train
function _loadSHA(path, callback) { var result = new $.Deferred(); if (brackets.inBrowser) { result.reject(); } else { // HEAD contains a SHA in detached-head mode; otherwise it contains a relative path // to a file in /refs which in turn contains the SHA ...
javascript
{ "resource": "" }
q16931
_getVersionInfoUrl
train
function _getVersionInfoUrl(locale, removeCountryPartOfLocale) { locale = locale || brackets.getLocale(); if (removeCountryPartOfLocale) { locale = locale.substring(0, 2); } //AUTOUPDATE_PRERELEASE_BEGIN // The following code is needed for supporting Auto Update in...
javascript
{ "resource": "" }
q16932
_getUpdateInformation
train
function _getUpdateInformation(force, dontCache, _versionInfoUrl) { // Last time the versionInfoURL was fetched var lastInfoURLFetchTime = PreferencesManager.getViewState("lastInfoURLFetchTime"); var result = new $.Deferred(); var fetchData = false; var data; // If forc...
javascript
{ "resource": "" }
q16933
_stripOldVersionInfo
train
function _stripOldVersionInfo(versionInfo, buildNumber) { // Do a simple linear search. Since we are going in reverse-chronological order, we // should get through the search quickly. var lastIndex = 0; var len = versionInfo.length; var versionEntry; var validBuildEntries...
javascript
{ "resource": "" }
q16934
_showUpdateNotificationDialog
train
function _showUpdateNotificationDialog(updates, force) { Dialogs.showModalDialogUsingTemplate(Mustache.render(UpdateDialogTemplate, Strings)) .done(function (id) { if (id === Dialogs.DIALOG_BTN_DOWNLOAD) { HealthLogger.sendAnalyticsData( ev...
javascript
{ "resource": "" }
q16935
_onRegistryDownloaded
train
function _onRegistryDownloaded() { var availableUpdates = ExtensionManager.getAvailableUpdates(); PreferencesManager.setViewState("extensionUpdateInfo", availableUpdates); PreferencesManager.setViewState("lastExtensionRegistryCheckTime", (new Date()).getTime()); $("#toolbar-extension-man...
javascript
{ "resource": "" }
q16936
handleUpdateProcess
train
function handleUpdateProcess(updates) { var handler = _updateProcessHandler || _defaultUpdateProcessHandler; var initSuccess = handler(updates); if (_updateProcessHandler && !initSuccess) { // Give a chance to default handler in case // the auot update mechanism has faile...
javascript
{ "resource": "" }
q16937
_0xColorToHex
train
function _0xColorToHex(color, convertToStr) { var hexColor = tinycolor(color.replace("0x", "#")); hexColor._format = "0x"; if (convertToStr) { return hexColor.toString(); } return hexColor; }
javascript
{ "resource": "" }
q16938
checkSetFormat
train
function checkSetFormat(color, convertToStr) { if ((/^0x/).test(color)) { return _0xColorToHex(color, convertToStr); } if (convertToStr) { return tinycolor(color).toString(); } return tinycolor(color); }
javascript
{ "resource": "" }
q16939
ColorEditor
train
function ColorEditor($parent, color, callback, swatches) { // Create the DOM structure, filling in localized strings via Mustache this.$element = $(Mustache.render(ColorEditorTemplate, Strings)); $parent.append(this.$element); this._callback = callback; this._handleKeydown = th...
javascript
{ "resource": "" }
q16940
_handleKeydown
train
function _handleKeydown(e) { if (e.keyCode === KeyEvent.DOM_VK_ESCAPE) { e.stopPropagation(); e.preventDefault(); self.close(); } }
javascript
{ "resource": "" }
q16941
_setMenuItemsVisible
train
function _setMenuItemsVisible() { var file = MainViewManager.getCurrentlyViewedFile(MainViewManager.ACTIVE_PANE), cMenuItems = [Commands.FILE_SAVE, Commands.FILE_RENAME, Commands.NAVIGATE_SHOW_IN_FILE_TREE, Commands.NAVIGATE_SHOW_IN_OS], // Enable menu options when no file is present in ...
javascript
{ "resource": "" }
q16942
getUniqueIdentifierName
train
function getUniqueIdentifierName(scopes, prefix, num) { if (!scopes) { return prefix; } var props = scopes.reduce(function(props, scope) { return _.union(props, _.keys(scope.props)); }, []); if (!props) { return prefix; } num...
javascript
{ "resource": "" }
q16943
isStandAloneExpression
train
function isStandAloneExpression(text) { var found = ASTWalker.findNodeAt(getAST(text), 0, text.length, function (nodeType, node) { if (nodeType === "Expression") { return true; } return false; }); return found && found.node; }
javascript
{ "resource": "" }
q16944
getScopeData
train
function getScopeData(session, offset) { var path = session.path, fileInfo = { type: MessageIds.TERN_FILE_INFO_TYPE_FULL, name: path, offsetLines: 0, text: ScopeManager.filterText(session.getJavascriptText()) }; Sco...
javascript
{ "resource": "" }
q16945
normalizeText
train
function normalizeText(text, start, end, removeTrailingSemiColons) { var trimmedText; // Remove leading spaces trimmedText = _.trimLeft(text); if (trimmedText.length < text.length) { start += (text.length - trimmedText.length); } text = trimmedText; ...
javascript
{ "resource": "" }
q16946
findSurroundASTNode
train
function findSurroundASTNode(ast, expn, types) { var foundNode = ASTWalker.findNodeAround(ast, expn.start, function (nodeType, node) { if (expn.end) { return types.includes(nodeType) && node.end >= expn.end; } else { return types.includes(nodeType); ...
javascript
{ "resource": "" }
q16947
train
function (url) { var self = this; this._ws = new WebSocket(url); // One potential source of confusion: the transport sends two "types" of messages - // these are distinct from the protocol's own messages. This is because this transport // needs to send an ini...
javascript
{ "resource": "" }
q16948
train
function (msgStr) { if (this._ws) { // See comment in `connect()` above about why we wrap the message in a transport message // object. this._ws.send(JSON.stringify({ type: "message", message: msgStr }));...
javascript
{ "resource": "" }
q16949
handleClose
train
function handleClose(mode) { var targetIndex = MainViewManager.findInWorkingSet(MainViewManager.ACTIVE_PANE, MainViewManager.getCurrentlyViewedPath(MainViewManager.ACTIVE_PANE)), workingSetList = MainViewManager.getWorkingSet(MainViewManager.ACTIVE_PANE), start = (mode === closeB...
javascript
{ "resource": "" }
q16950
initializeCommands
train
function initializeCommands() { var prefs = getPreferences(); CommandManager.register(Strings.CMD_FILE_CLOSE_BELOW, closeBelow, function () { handleClose(closeBelow); }); CommandManager.register(Strings.CMD_FILE_CLOSE_OTHERS, closeOthers, function () { handleClos...
javascript
{ "resource": "" }
q16951
_ensurePaneIsFocused
train
function _ensurePaneIsFocused(paneId) { var pane = MainViewManager._getPane(paneId); // Defer the focusing until other focus events have occurred. setTimeout(function () { // Focus has most likely changed: give it back to the given pane. pane.focus(); this._l...
javascript
{ "resource": "" }
q16952
tryFocusingCurrentView
train
function tryFocusingCurrentView() { if (self._currentView) { if (self._currentView.focus) { // Views can implement a focus // method for focusing a complex // DOM like codemirror self._currentView.focus(); ...
javascript
{ "resource": "" }
q16953
registerHintProvider
train
function registerHintProvider(providerInfo, languageIds, priority) { var providerObj = { provider: providerInfo, priority: priority || 0 }; if (languageIds.indexOf("all") !== -1) { // Ignore anything else in languageIds and just register for every language. This ...
javascript
{ "resource": "" }
q16954
_endSession
train
function _endSession() { if (!hintList) { return; } hintList.close(); hintList = null; codeHintOpened = false; keyDownEditor = null; sessionProvider = null; sessionEditor = null; if (deferredHints) { deferredHints.reject(); ...
javascript
{ "resource": "" }
q16955
_inSession
train
function _inSession(editor) { if (sessionEditor) { if (sessionEditor === editor && (hintList.isOpen() || (deferredHints && deferredHints.state() === "pending"))) { return true; } else { // the editor has changed ...
javascript
{ "resource": "" }
q16956
_updateHintList
train
function _updateHintList(callMoveUpEvent) { callMoveUpEvent = typeof callMoveUpEvent === "undefined" ? false : callMoveUpEvent; if (deferredHints) { deferredHints.reject(); deferredHints = null; } if (callMoveUpEvent) { return hintList.callMoveUp(ca...
javascript
{ "resource": "" }
q16957
_handleKeydownEvent
train
function _handleKeydownEvent(jqEvent, editor, event) { keyDownEditor = editor; if (!(event.ctrlKey || event.altKey || event.metaKey) && (event.keyCode === KeyEvent.DOM_VK_ENTER || event.keyCode === KeyEvent.DOM_VK_RETURN || event.keyCode === KeyEvent.DOM...
javascript
{ "resource": "" }
q16958
_startNewSession
train
function _startNewSession(editor) { if (isOpen()) { return; } if (!editor) { editor = EditorManager.getFocusedEditor(); } if (editor) { lastChar = null; if (_inSession(editor)) { _endSession(); } ...
javascript
{ "resource": "" }
q16959
_doJumpToDef
train
function _doJumpToDef() { var request = null, result = new $.Deferred(), jumpToDefProvider = null, editor = EditorManager.getActiveEditor(); if (editor) { // Find a suitable provider, if any var language = editor.getLanguageForSelection(), ...
javascript
{ "resource": "" }
q16960
positionHint
train
function positionHint(xpos, ypos, ybot) { var hintWidth = $hintContainer.width(), hintHeight = $hintContainer.height(), top = ypos - hintHeight - POINTER_TOP_OFFSET, left = xpos, $editorHolder = $("#editor-holder"), editorLeft; if ($editorHold...
javascript
{ "resource": "" }
q16961
formatHint
train
function formatHint(hints) { $hintContent.empty(); $hintContent.addClass("brackets-hints"); function appendSeparators(separators) { $hintContent.append(separators); } function appendParameter(param, documentation, index) { if (hints.currentIndex === inde...
javascript
{ "resource": "" }
q16962
dismissHint
train
function dismissHint(editor) { if (hintState.visible) { $hintContainer.hide(); $hintContent.empty(); hintState = {}; if (editor) { editor.off("cursorActivity.ParameterHinting", handleCursorActivity); sessionEditor = null; ...
javascript
{ "resource": "" }
q16963
popUpHint
train
function popUpHint(editor, explicit, onCursorActivity) { var request = null; var $deferredPopUp = $.Deferred(); var sessionProvider = null; dismissHint(editor); // Find a suitable provider, if any var language = editor.getLanguageForSelection(), enabledProvid...
javascript
{ "resource": "" }
q16964
installListeners
train
function installListeners(editor) { editor.on("keydown.ParameterHinting", function (event, editor, domEvent) { if (domEvent.keyCode === KeyEvent.DOM_VK_ESCAPE) { dismissHint(editor); } }).on("scroll.ParameterHinting", function () { ...
javascript
{ "resource": "" }
q16965
readAsText
train
function readAsText(file) { var result = new $.Deferred(); // Measure performance var perfTimerName = PerfUtils.markStart("readAsText:\t" + file.fullPath); result.always(function () { PerfUtils.addMeasurement(perfTimerName); }); // Read file file.rea...
javascript
{ "resource": "" }
q16966
writeText
train
function writeText(file, text, allowBlindWrite) { var result = new $.Deferred(), options = {}; if (allowBlindWrite) { options.blind = true; } file.write(text, options, function (err) { if (!err) { result.resolve(); } else ...
javascript
{ "resource": "" }
q16967
sniffLineEndings
train
function sniffLineEndings(text) { var subset = text.substr(0, 1000); // (length is clipped to text.length) var hasCRLF = /\r\n/.test(subset); var hasLF = /[^\r]\n/.test(subset); if ((hasCRLF && hasLF) || (!hasCRLF && !hasLF)) { return null; } else { retu...
javascript
{ "resource": "" }
q16968
translateLineEndings
train
function translateLineEndings(text, lineEndings) { if (lineEndings !== LINE_ENDINGS_CRLF && lineEndings !== LINE_ENDINGS_LF) { lineEndings = getPlatformLineEndings(); } var eolStr = (lineEndings === LINE_ENDINGS_CRLF ? "\r\n" : "\n"); var findAnyEol = /\r\n|\r|\n/g; ...
javascript
{ "resource": "" }
q16969
makeDialogFileList
train
function makeDialogFileList(paths) { var result = "<ul class='dialog-list'>"; paths.forEach(function (path) { result += "<li><span class='dialog-filename'>"; result += StringUtils.breakableUrl(path); result += "</span></li>"; }); result += "</ul>"; ...
javascript
{ "resource": "" }
q16970
getBaseName
train
function getBaseName(fullPath) { var lastSlash = fullPath.lastIndexOf("/"); if (lastSlash === fullPath.length - 1) { // directory: exclude trailing "/" too return fullPath.slice(fullPath.lastIndexOf("/", fullPath.length - 2) + 1, -1); } else { return fullPath.slice(lastS...
javascript
{ "resource": "" }
q16971
getNativeModuleDirectoryPath
train
function getNativeModuleDirectoryPath(module) { var path; if (module && module.uri) { path = decodeURI(module.uri); // Remove module name and trailing slash from path. path = path.substr(0, path.lastIndexOf("/")); } return path; }
javascript
{ "resource": "" }
q16972
getFilenameWithoutExtension
train
function getFilenameWithoutExtension(filename) { var index = filename.lastIndexOf("."); return index === -1 ? filename : filename.slice(0, index); }
javascript
{ "resource": "" }
q16973
DropdownEventHandler
train
function DropdownEventHandler($list, selectionCallback, closeCallback) { this.$list = $list; this.$items = $list.find("li"); this.selectionCallback = selectionCallback; this.closeCallback = closeCallback; this.scrolling = false; /** * @private * The se...
javascript
{ "resource": "" }
q16974
_keydownHook
train
function _keydownHook(event) { var keyCode; // (page) up, (page) down, enter and tab key are handled by the list if (event.type === "keydown") { keyCode = event.keyCode; if (keyCode === KeyEvent.DOM_VK_TAB) { self.close(); ...
javascript
{ "resource": "" }
q16975
_createTagInfo
train
function _createTagInfo(token, tokenType, offset, exclusionList, tagName, attrName, shouldReplace) { return { token: token || null, tokenType: tokenType || null, offset: offset || 0, exclusionList: exclusionList || [], tagName: tagName || "", ...
javascript
{ "resource": "" }
q16976
_getTagAttributes
train
function _getTagAttributes(editor, constPos) { var pos, ctx, ctxPrev, ctxNext, ctxTemp, tagName, exclusionList = [], shouldReplace; pos = $.extend({}, constPos); ctx = TokenUtils.getInitialContext(editor._codeMirror, pos); // Stop if the cursor is before = or an attribute value. ...
javascript
{ "resource": "" }
q16977
_getTagAttributeValue
train
function _getTagAttributeValue(editor, pos) { var ctx, tagName, attrName, exclusionList = [], offset, textBefore, textAfter; ctx = TokenUtils.getInitialContext(editor._codeMirror, pos); offset = TokenUtils.offsetInToken(ctx); // To support multiple options on the same attribute, we hav...
javascript
{ "resource": "" }
q16978
getTagInfo
train
function getTagInfo(editor, pos) { var ctx, offset, tagAttrs, tagAttrValue; ctx = TokenUtils.getInitialContext(editor._codeMirror, pos); offset = TokenUtils.offsetInToken(ctx); if (ctx.token && ctx.token.type === "tag bracket" && ctx.token.string === "<") { // Returns tagIn...
javascript
{ "resource": "" }
q16979
getValueQuery
train
function getValueQuery(tagInfo) { var query; if (tagInfo.token.string === "=") { return ""; } // Remove quotation marks in query. query = tagInfo.token.string.substr(1, tagInfo.offset - 1); // Get the last option to use as a query to support multiple options....
javascript
{ "resource": "" }
q16980
isAbsolutePathOrUrl
train
function isAbsolutePathOrUrl(pathOrUrl) { return brackets.platform === "win" ? PathUtils.isAbsoluteUrl(pathOrUrl) : FileSystem.isAbsolutePath(pathOrUrl); }
javascript
{ "resource": "" }
q16981
parseLessCode
train
function parseLessCode(code, url) { var result = new $.Deferred(), options; if (url) { var dir = url.slice(0, url.lastIndexOf("/") + 1); options = { filename: url, rootpath: dir }; if (isAbsolutePathOrUrl(url)...
javascript
{ "resource": "" }
q16982
getModulePath
train
function getModulePath(module, path) { var modulePath = module.uri.substr(0, module.uri.lastIndexOf("/") + 1); if (path) { modulePath += path; } return modulePath; }
javascript
{ "resource": "" }
q16983
getModuleUrl
train
function getModuleUrl(module, path) { var url = encodeURI(getModulePath(module, path)); // On Windows, $.get() fails if the url is a full pathname. To work around this, // prepend "file:///". On the Mac, $.get() works fine if the url is a full pathname, // but *doesn't* work if it is pr...
javascript
{ "resource": "" }
q16984
loadFile
train
function loadFile(module, path) { var url = PathUtils.isAbsoluteUrl(path) ? path : getModuleUrl(module, path), promise = $.get(url); return promise; }
javascript
{ "resource": "" }
q16985
loadMetadata
train
function loadMetadata(folder) { var packageJSONFile = FileSystem.getFileForPath(folder + "/package.json"), disabledFile = FileSystem.getFileForPath(folder + "/.disabled"), baseName = FileUtils.getBaseName(folder), result = new $.Deferred(), jsonPromise = new $.Def...
javascript
{ "resource": "" }
q16986
_markTags
train
function _markTags(cm, node) { node.children.forEach(function (childNode) { if (childNode.isElement()) { _markTags(cm, childNode); } }); var mark = cm.markText(node.startPos, node.endPos); mark.tagID = node.tagID; }
javascript
{ "resource": "" }
q16987
_markTextFromDOM
train
function _markTextFromDOM(editor, dom) { var cm = editor._codeMirror; // Remove existing marks var marks = cm.getAllMarks(); cm.operation(function () { marks.forEach(function (mark) { if (mark.hasOwnProperty("tagID")) { mark.clear(); ...
javascript
{ "resource": "" }
q16988
scanDocument
train
function scanDocument(doc) { if (!_cachedValues.hasOwnProperty(doc.file.fullPath)) { // TODO: this doesn't seem to be correct any more. The DOM should never be "dirty" (i.e., out of sync // with the editor) unless the doc is invalid. // $(doc).on("change.htmlInstrumentation", ...
javascript
{ "resource": "" }
q16989
walk
train
function walk(node) { if (node.tag) { var attrText = " data-brackets-id='" + node.tagID + "'"; // If the dom was fully rebuilt, use its offsets. Otherwise, use the marks in the // associated editor, since they'll be more up to date. var startO...
javascript
{ "resource": "" }
q16990
setCachedHintContext
train
function setCachedHintContext(hints, cursor, type, token) { cachedHints = hints; cachedCursor = cursor; cachedType = type; cachedToken = token; }
javascript
{ "resource": "" }
q16991
getSessionHints
train
function getSessionHints(query, cursor, type, token, $deferredHints) { var hintResults = session.getHints(query, getStringMatcher()); if (hintResults.needGuesses) { var guessesResponse = ScopeManager.requestGuesses(session, session.editor.document); if (!$deferr...
javascript
{ "resource": "" }
q16992
requestJumpToDef
train
function requestJumpToDef(session, offset) { var response = ScopeManager.requestJumptoDef(session, session.editor.document, offset); if (response.hasOwnProperty("promise")) { response.promise.done(handleJumpResponse).fail(function () { result....
javascript
{ "resource": "" }
q16993
setJumpSelection
train
function setJumpSelection(start, end, isFunction) { /** * helper function to decide if the tokens on the RHS of an assignment * look like an identifier, or member expr. */ function validIdOrProp(token) { if (!token) ...
javascript
{ "resource": "" }
q16994
validIdOrProp
train
function validIdOrProp(token) { if (!token) { return false; } if (token.string === ".") { return true; } var type = token.type; if (type === "variable-2...
javascript
{ "resource": "" }
q16995
_urlWithoutQueryString
train
function _urlWithoutQueryString(url) { var index = url.search(/[#\?]/); if (index >= 0) { url = url.substr(0, index); } return url; }
javascript
{ "resource": "" }
q16996
_makeHTMLTarget
train
function _makeHTMLTarget(targets, node) { if (node.location) { var url = DOMAgent.url; var location = node.location; if (node.canHaveChildren()) { location += node.length; } url += ":" + location; var name = "&lt;" + node.na...
javascript
{ "resource": "" }
q16997
_makeCSSTarget
train
function _makeCSSTarget(targets, rule) { if (rule.sourceURL) { var url = rule.sourceURL; url += ":" + rule.style.range.start; var name = rule.selectorList.text; var file = _fileFromURL(url); targets.push({"type": "css", "url": url, "name": name, "file"...
javascript
{ "resource": "" }
q16998
_makeJSTarget
train
function _makeJSTarget(targets, callFrame) { var script = ScriptAgent.scriptWithId(callFrame.location.scriptId); if (script && script.url) { var url = script.url; url += ":" + callFrame.location.lineNumber + "," + callFrame.location.columnNumber; var name = callFrame....
javascript
{ "resource": "" }
q16999
_onRemoteShowGoto
train
function _onRemoteShowGoto(event, res) { // res = {nodeId, name, value} var node = DOMAgent.nodeWithId(res.nodeId); // get all css rules that apply to the given node Inspector.CSS.getMatchedStylesForNode(node.nodeId, function onMatchedStyles(res) { var i, targets = []; ...
javascript
{ "resource": "" }