_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q16700
train
function (context) { context = context || {}; var layerCounter, layers = this._layers, layer, data = this.data; var keySets = [_.difference(_.keys(data), this._exclusions)]; for (layerCounter = 0; layerCounter < layers.length; layerCounter++) { layer = layers[layerCounter]; keySets.push(layer.getKeys(data[layer.key], context)); } return _.union.apply(null, keySets); }
javascript
{ "resource": "" }
q16701
train
function (layer) { this._layers.push(layer); this._layerMap[layer.key] = layer; this._exclusions.push(layer.key); this.trigger(PREFERENCE_CHANGE, { ids: layer.getKeys(this.data[layer.key], {}) }); }
javascript
{ "resource": "" }
q16702
train
function (oldContext, newContext) { var changes = [], data = this.data; _.each(this._layers, function (layer) { if (data[layer.key] && oldContext[layer.key] !== newContext[layer.key]) { var changesInLayer = layer.contextChanged(data[layer.key], oldContext, newContext); if (changesInLayer) { changes.push(changesInLayer); } } }); return _.union.apply(null, changes); }
javascript
{ "resource": "" }
q16703
train
function (data, id) { if (!data || !this.projectPath) { return; } if (data[this.projectPath] && (data[this.projectPath][id] !== undefined)) { return data[this.projectPath][id]; } return; }
javascript
{ "resource": "" }
q16704
train
function (data) { if (!data) { return; } return _.union.apply(null, _.map(_.values(data), _.keys)); }
javascript
{ "resource": "" }
q16705
train
function (data, id, context) { if (!data || !context.language) { return; } if (data[context.language] && (data[context.language][id] !== undefined)) { return data[context.language][id]; } return; }
javascript
{ "resource": "" }
q16706
train
function (data, oldContext, newContext) { // this function is called only if the language has changed if (newContext.language === undefined) { return _.keys(data[oldContext.language]); } if (oldContext.language === undefined) { return _.keys(data[newContext.language]); } return _.union(_.keys(data[newContext.language]), _.keys(data[oldContext.language])); }
javascript
{ "resource": "" }
q16707
train
function (data, id, context) { var glob = this.getPreferenceLocation(data, id, context); if (!glob) { return; } return data[glob][id]; }
javascript
{ "resource": "" }
q16708
train
function (data, id, context) { if (!data) { return; } var relativeFilename = FileUtils.getRelativeFilename(this.prefFilePath, context[this.key]); if (!relativeFilename) { return; } return _findMatchingGlob(data, relativeFilename); }
javascript
{ "resource": "" }
q16709
train
function (data, id, value, context, layerID) { if (!layerID) { layerID = this.getPreferenceLocation(data, id, context); } if (!layerID) { return false; } var section = data[layerID]; if (!section) { data[layerID] = section = {}; } if (!_.isEqual(section[id], value)) { if (value === undefined) { delete section[id]; } else { section[id] = _.cloneDeep(value); } return true; } return false; }
javascript
{ "resource": "" }
q16710
train
function (data, context) { if (!data) { return; } var relativeFilename = FileUtils.getRelativeFilename(this.prefFilePath, context[this.key]); if (relativeFilename) { var glob = _findMatchingGlob(data, relativeFilename); if (glob) { return _.keys(data[glob]); } else { return []; } } return _.union.apply(null, _.map(_.values(data), _.keys)); }
javascript
{ "resource": "" }
q16711
train
function (data, oldContext, newContext) { var newGlob = _findMatchingGlob(data, FileUtils.getRelativeFilename(this.prefFilePath, newContext[this.key])), oldGlob = _findMatchingGlob(data, FileUtils.getRelativeFilename(this.prefFilePath, oldContext[this.key])); if (newGlob === oldGlob) { return; } if (newGlob === undefined) { return _.keys(data[oldGlob]); } if (oldGlob === undefined) { return _.keys(data[newGlob]); } return _.union(_.keys(data[oldGlob]), _.keys(data[newGlob])); }
javascript
{ "resource": "" }
q16712
train
function (id, context) { context = context || {}; return this.base.get(this.prefix + id, this.base._getContext(context)); }
javascript
{ "resource": "" }
q16713
train
function (id, value, options, doNotSave) { return this.base.set(this.prefix + id, value, options, doNotSave); }
javascript
{ "resource": "" }
q16714
train
function (event, preferenceID, handler) { if (typeof preferenceID === "function") { handler = preferenceID; preferenceID = null; } if (preferenceID) { var pref = this.getPreference(preferenceID); pref.on(event, handler); } else { this._installListener(); this._on_internal(event, handler); } }
javascript
{ "resource": "" }
q16715
train
function (event, preferenceID, handler) { if (typeof preferenceID === "function") { handler = preferenceID; preferenceID = null; } if (preferenceID) { var pref = this.getPreference(preferenceID); pref.off(event, handler); } else { this._off_internal(event, handler); } }
javascript
{ "resource": "" }
q16716
PreferencesSystem
train
function PreferencesSystem(contextBuilder) { this.contextBuilder = contextBuilder; this._knownPrefs = {}; this._scopes = { "default": new Scope(new MemoryStorage()) }; this._scopes["default"].load(); this._defaults = { scopeOrder: ["default"], _shadowScopeOrder: [{ id: "default", scope: this._scopes["default"], promise: (new $.Deferred()).resolve().promise() }] }; this._pendingScopes = {}; this._saveInProgress = false; this._nextSaveDeferred = null; // The objects that define the different kinds of path-based Scope handlers. // Examples could include the handler for .brackets.json files or an .editorconfig // handler. this._pathScopeDefinitions = {}; // Names of the files that contain path scopes this._pathScopeFilenames = []; // Keeps track of cached path scope objects. this._pathScopes = {}; // Keeps track of change events that need to be sent when change events are resumed this._changeEventQueue = null; var notifyPrefChange = function (id) { var pref = this._knownPrefs[id]; if (pref) { pref.trigger(PREFERENCE_CHANGE); } }.bind(this); // When we signal a general change message on this manager, we also signal a change // on the individual preference object. this.on(PREFERENCE_CHANGE, function (e, data) { data.ids.forEach(notifyPrefChange); }.bind(this)); }
javascript
{ "resource": "" }
q16717
train
function (id, type, initial, options) { options = options || {}; if (this._knownPrefs.hasOwnProperty(id)) { throw new Error("Preference " + id + " was redefined"); } var pref = this._knownPrefs[id] = new Preference({ type: type, initial: initial, name: options.name, description: options.description, validator: options.validator, excludeFromHints: options.excludeFromHints, keys: options.keys, values: options.values, valueType: options.valueType }); this.set(id, initial, { location: { scope: "default" } }); return pref; }
javascript
{ "resource": "" }
q16718
train
function (id, addBefore) { var shadowScopeOrder = this._defaults._shadowScopeOrder, index = _.findIndex(shadowScopeOrder, function (entry) { return entry.id === id; }), entry; if (index > -1) { entry = shadowScopeOrder[index]; this._addToScopeOrder(entry.id, entry.scope, entry.promise, addBefore); } }
javascript
{ "resource": "" }
q16719
train
function (id) { var scope = this._scopes[id]; if (scope) { _.pull(this._defaults.scopeOrder, id); scope.off(".prefsys"); this.trigger(SCOPEORDER_CHANGE, { id: id, action: "removed" }); this._triggerChange({ ids: scope.getKeys() }); } }
javascript
{ "resource": "" }
q16720
train
function (id, scope, options) { var promise; options = options || {}; if (this._scopes[id]) { throw new Error("Attempt to redefine preferences scope: " + id); } // Check to see if scope is a Storage that needs to be wrapped if (!scope.get) { scope = new Scope(scope); } promise = scope.load(); this._addToScopeOrder(id, scope, promise, options.before); promise .fail(function (err) { // With preferences, it is valid for there to be no file. // It is not valid to have an unparseable file. if (err instanceof ParsingError) { console.error(err); } }); return promise; }
javascript
{ "resource": "" }
q16721
train
function (id) { var scope = this._scopes[id], shadowIndex; if (!scope) { return; } this.removeFromScopeOrder(id); shadowIndex = _.findIndex(this._defaults._shadowScopeOrder, function (entry) { return entry.id === id; }); this._defaults._shadowScopeOrder.splice(shadowIndex, 1); delete this._scopes[id]; }
javascript
{ "resource": "" }
q16722
train
function (id, context) { var scopeCounter; context = this._getContext(context); var scopeOrder = this._getScopeOrder(context); for (scopeCounter = 0; scopeCounter < scopeOrder.length; scopeCounter++) { var scope = this._scopes[scopeOrder[scopeCounter]]; if (scope) { var result = scope.get(id, context); if (result !== undefined) { var pref = this.getPreference(id), validator = pref && pref.validator; if (!validator || validator(result)) { if (pref && pref.type === "object") { result = _.extend({}, pref.initial, result); } return _.cloneDeep(result); } } } } }
javascript
{ "resource": "" }
q16723
train
function (id, context) { var scopeCounter, scopeName; context = this._getContext(context); var scopeOrder = this._getScopeOrder(context); for (scopeCounter = 0; scopeCounter < scopeOrder.length; scopeCounter++) { scopeName = scopeOrder[scopeCounter]; var scope = this._scopes[scopeName]; if (scope) { var result = scope.getPreferenceLocation(id, context); if (result !== undefined) { result.scope = scopeName; return result; } } } }
javascript
{ "resource": "" }
q16724
train
function (id, value, options, doNotSave) { options = options || {}; var context = this._getContext(options.context), // The case where the "default" scope was chosen specifically is special. // Usually "default" would come up only when a preference did not have any // user-set value, in which case we'd want to set the value in a different scope. forceDefault = options.location && options.location.scope === "default" ? true : false, location = options.location || this.getPreferenceLocation(id, context); if (!location || (location.scope === "default" && !forceDefault)) { var scopeOrder = this._getScopeOrder(context); // The default scope for setting a preference is the lowest priority // scope after "default". if (scopeOrder.length > 1) { location = { scope: scopeOrder[scopeOrder.length - 2] }; } else { return { valid: true, stored: false }; } } var scope = this._scopes[location.scope]; if (!scope) { return { valid: true, stored: false }; } var pref = this.getPreference(id), validator = pref && pref.validator; if (validator && !validator(value)) { return { valid: false, stored: false }; } var wasSet = scope.set(id, value, context, location); if (wasSet) { if (!doNotSave) { this.save(); } this._triggerChange({ ids: [id] }); } return { valid: true, stored: wasSet }; }
javascript
{ "resource": "" }
q16725
train
function () { if (this._saveInProgress) { if (!this._nextSaveDeferred) { this._nextSaveDeferred = new $.Deferred(); } return this._nextSaveDeferred.promise(); } var deferred = this._nextSaveDeferred || (new $.Deferred()); this._saveInProgress = true; this._nextSaveDeferred = null; Async.doInParallel(_.values(this._scopes), function (scope) { if (scope) { return scope.save(); } else { return (new $.Deferred()).resolve().promise(); } }.bind(this)) .then(function () { this._saveInProgress = false; if (this._nextSaveDeferred) { this.save(); } deferred.resolve(); }.bind(this)) .fail(function (err) { deferred.reject(err); }); return deferred.promise(); }
javascript
{ "resource": "" }
q16726
train
function (oldContext, newContext) { var changes = []; _.each(this._scopes, function (scope) { var changedInScope = scope.contextChanged(oldContext, newContext); if (changedInScope) { changes.push(changedInScope); } }); changes = _.union.apply(null, changes); if (changes.length > 0) { this._triggerChange({ ids: changes }); } }
javascript
{ "resource": "" }
q16727
_updateWorkingSetState
train
function _updateWorkingSetState() { if (MainViewManager.getPaneCount() === 1 && MainViewManager.getWorkingSetSize(MainViewManager.ACTIVE_PANE) === 0) { $workingSetViewsContainer.hide(); $gearMenu.hide(); } else { $workingSetViewsContainer.show(); $gearMenu.show(); } }
javascript
{ "resource": "" }
q16728
_updateUIStates
train
function _updateUIStates() { var spriteIndex, ICON_CLASSES = ["splitview-icon-none", "splitview-icon-vertical", "splitview-icon-horizontal"], layoutScheme = MainViewManager.getLayoutScheme(); if (layoutScheme.columns > 1) { spriteIndex = 1; } else if (layoutScheme.rows > 1) { spriteIndex = 2; } else { spriteIndex = 0; } // SplitView Icon $splitViewMenu.removeClass(ICON_CLASSES.join(" ")) .addClass(ICON_CLASSES[spriteIndex]); // SplitView Menu _cmdSplitNone.setChecked(spriteIndex === 0); _cmdSplitVertical.setChecked(spriteIndex === 1); _cmdSplitHorizontal.setChecked(spriteIndex === 2); // Options icon _updateWorkingSetState(); }
javascript
{ "resource": "" }
q16729
addCommand
train
function addCommand() { var menu = Menus.getMenu(Menus.AppMenuBar.FILE_MENU), INSTALL_COMMAND_SCRIPT = "file.installCommandScript"; CommandManager.register(Strings.CMD_LAUNCH_SCRIPT_MAC, INSTALL_COMMAND_SCRIPT, handleInstallCommand); menu.addMenuDivider(); menu.addMenuItem(INSTALL_COMMAND_SCRIPT); }
javascript
{ "resource": "" }
q16730
Session
train
function Session(editor) { this.editor = editor; this.path = editor.document.file.fullPath; this.ternHints = []; this.ternGuesses = null; this.fnType = null; this.builtins = null; }
javascript
{ "resource": "" }
q16731
isOnFunctionIdentifier
train
function isOnFunctionIdentifier() { // Check if we might be on function identifier of the function call. var type = token.type, nextToken, localLexical, localCursor = {line: cursor.line, ch: token.end}; if (type === "variable-2" || type === "variable" || type === "property") { nextToken = self.getNextToken(localCursor, true); if (nextToken && nextToken.string === "(") { localLexical = getLexicalState(nextToken); return localLexical; } } return null; }
javascript
{ "resource": "" }
q16732
isInFunctionalCall
train
function isInFunctionalCall(lex) { // in a call, or inside array or object brackets that are inside a function. return (lex && (lex.info === "call" || (lex.info === undefined && (lex.type === "]" || lex.type === "}") && lex.prev.info === "call"))); }
javascript
{ "resource": "" }
q16733
penalizeUnderscoreValueCompare
train
function penalizeUnderscoreValueCompare(a, b) { var aName = a.value.toLowerCase(), bName = b.value.toLowerCase(); // this sort function will cause _ to sort lower than lower case // alphabetical letters if (aName[0] === "_" && bName[0] !== "_") { return 1; } else if (bName[0] === "_" && aName[0] !== "_") { return -1; } if (aName < bName) { return -1; } else if (aName > bName) { return 1; } return 0; }
javascript
{ "resource": "" }
q16734
filterWithQueryAndMatcher
train
function filterWithQueryAndMatcher(hints, matcher) { var matchResults = $.map(hints, function (hint) { var searchResult = matcher.match(hint.value, query); if (searchResult) { searchResult.value = hint.value; searchResult.guess = hint.guess; searchResult.type = hint.type; if (hint.keyword !== undefined) { searchResult.keyword = hint.keyword; } if (hint.literal !== undefined) { searchResult.literal = hint.literal; } if (hint.depth !== undefined) { searchResult.depth = hint.depth; } if (hint.doc) { searchResult.doc = hint.doc; } if (hint.url) { searchResult.url = hint.url; } if (!type.property && !type.showFunctionType && hint.origin && isBuiltin(hint.origin)) { searchResult.builtin = 1; } else { searchResult.builtin = 0; } } return searchResult; }); return matchResults; }
javascript
{ "resource": "" }
q16735
install
train
function install(path, nameHint, _doUpdate) { return _extensionManagerCall(function (extensionManager) { var d = new $.Deferred(), destinationDirectory = ExtensionLoader.getUserExtensionPath(), disabledDirectory = destinationDirectory.replace(/\/user$/, "/disabled"), systemDirectory = FileUtils.getNativeBracketsDirectoryPath() + "/extensions/default/"; var operation = _doUpdate ? "update" : "install"; extensionManager[operation](path, destinationDirectory, { disabledDirectory: disabledDirectory, systemExtensionDirectory: systemDirectory, apiVersion: brackets.metadata.apiVersion, nameHint: nameHint, proxy: PreferencesManager.get("proxy") }) .done(function (result) { result.keepFile = false; if (result.installationStatus !== InstallationStatuses.INSTALLED || _doUpdate) { d.resolve(result); } else { // This was a new extension and everything looked fine. // We load it into Brackets right away. ExtensionLoader.loadExtension(result.name, { // On Windows, it looks like Node converts Unix-y paths to backslashy paths. // We need to convert them back. baseUrl: FileUtils.convertWindowsPathToUnixPath(result.installedTo) }, "main").then(function () { d.resolve(result); }, function () { d.reject(Errors.ERROR_LOADING); }); } }) .fail(function (error) { d.reject(error); }); return d.promise(); }); }
javascript
{ "resource": "" }
q16736
toggleDefaultExtension
train
function toggleDefaultExtension(path, enabled) { var arr = PreferencesManager.get(PREF_EXTENSIONS_DEFAULT_DISABLED); if (!Array.isArray(arr)) { arr = []; } var io = arr.indexOf(path); if (enabled === true && io !== -1) { arr.splice(io, 1); } else if (enabled === false && io === -1) { arr.push(path); } PreferencesManager.set(PREF_EXTENSIONS_DEFAULT_DISABLED, arr); }
javascript
{ "resource": "" }
q16737
disable
train
function disable(path) { var result = new $.Deferred(), file = FileSystem.getFileForPath(path + "/.disabled"); var defaultExtensionPath = ExtensionLoader.getDefaultExtensionPath(); if (file.fullPath.indexOf(defaultExtensionPath) === 0) { toggleDefaultExtension(path, false); result.resolve(); return result.promise(); } file.write("", function (err) { if (err) { return result.reject(err); } result.resolve(); }); return result.promise(); }
javascript
{ "resource": "" }
q16738
enable
train
function enable(path) { var result = new $.Deferred(), file = FileSystem.getFileForPath(path + "/.disabled"); function afterEnable() { ExtensionLoader.loadExtension(FileUtils.getBaseName(path), { baseUrl: path }, "main") .done(result.resolve) .fail(result.reject); } var defaultExtensionPath = ExtensionLoader.getDefaultExtensionPath(); if (file.fullPath.indexOf(defaultExtensionPath) === 0) { toggleDefaultExtension(path, true); afterEnable(); return result.promise(); } file.unlink(function (err) { if (err) { return result.reject(err); } afterEnable(); }); return result.promise(); }
javascript
{ "resource": "" }
q16739
installUpdate
train
function installUpdate(path, nameHint) { var d = new $.Deferred(); install(path, nameHint, true) .done(function (result) { if (result.installationStatus !== InstallationStatuses.INSTALLED) { d.reject(result.errors); } else { d.resolve(result); } }) .fail(function (error) { d.reject(error); }); return d.promise(); }
javascript
{ "resource": "" }
q16740
_cmdSend
train
function _cmdSend(idOrArray, msgStr) { if (!Array.isArray(idOrArray)) { idOrArray = [idOrArray]; } idOrArray.forEach(function (id) { var client = _clients[id]; if (!client) { console.error("nodeSocketTransport: Couldn't find client ID: " + id); } else { client.socket.send(msgStr); } }); }
javascript
{ "resource": "" }
q16741
_cmdClose
train
function _cmdClose(clientId) { var client = _clients[clientId]; if (client) { client.socket.close(); delete _clients[clientId]; } }
javascript
{ "resource": "" }
q16742
nextLine
train
function nextLine() { if (stream) { curOffset++; // account for \n if (curOffset >= length) { return false; } } lineStart = curOffset; var lineEnd = text.indexOf("\n", lineStart); if (lineEnd === -1) { lineEnd = length; } stream = new CodeMirror.StringStream(text.slice(curOffset, lineEnd)); return true; }
javascript
{ "resource": "" }
q16743
_shouldGetFromCache
train
function _shouldGetFromCache(fileInfo) { var result = new $.Deferred(), isChanged = _changedDocumentTracker.isPathChanged(fileInfo.fullPath); if (isChanged && fileInfo.JSUtils) { // See if it's dirty and in the working set first var doc = DocumentManager.getOpenDocumentForPath(fileInfo.fullPath); if (doc && doc.isDirty) { result.resolve(false); } else { // If a cache exists, check the timestamp on disk var file = FileSystem.getFileForPath(fileInfo.fullPath); file.stat(function (err, stat) { if (!err) { result.resolve(fileInfo.JSUtils.timestamp.getTime() === stat.mtime.getTime()); } else { result.reject(err); } }); } } else { // Use the cache if the file did not change and the cache exists result.resolve(!isChanged && fileInfo.JSUtils); } return result.promise(); }
javascript
{ "resource": "" }
q16744
_getFunctionsForFile
train
function _getFunctionsForFile(fileInfo) { var result = new $.Deferred(); _shouldGetFromCache(fileInfo) .done(function (useCache) { if (useCache) { // Return cached data. doc property is undefined since we hit the cache. // _getOffsets() will fetch the Document if necessary. result.resolve({/*doc: undefined,*/fileInfo: fileInfo, functions: fileInfo.JSUtils.functions}); } else { _readFile(fileInfo, result); } }).fail(function (err) { result.reject(err); }); return result.promise(); }
javascript
{ "resource": "" }
q16745
findMatchingFunctions
train
function findMatchingFunctions(functionName, fileInfos, keepAllFiles) { var result = new $.Deferred(), jsFiles = []; if (!keepAllFiles) { // Filter fileInfos for .js files jsFiles = fileInfos.filter(function (fileInfo) { return FileUtils.getFileExtension(fileInfo.fullPath).toLowerCase() === "js"; }); } else { jsFiles = fileInfos; } // RegExp search (or cache lookup) for all functions in the project _getFunctionsInFiles(jsFiles).done(function (docEntries) { // Compute offsets for all matched functions _getOffsetsForFunction(docEntries, functionName).done(function (rangeResults) { result.resolve(rangeResults); }); }); return result.promise(); }
javascript
{ "resource": "" }
q16746
findAllMatchingFunctionsInText
train
function findAllMatchingFunctionsInText(text, searchName) { var allFunctions = _findAllFunctionsInText(text); var result = []; var lines = text.split("\n"); _.forEach(allFunctions, function (functions, functionName) { if (functionName === searchName || searchName === "*") { functions.forEach(function (funcEntry) { var endOffset = _getFunctionEndOffset(text, funcEntry.offsetStart); result.push({ name: functionName, label: funcEntry.label, lineStart: StringUtils.offsetToLineNum(lines, funcEntry.offsetStart), lineEnd: StringUtils.offsetToLineNum(lines, endOffset), nameLineStart: funcEntry.location.start.line - 1, nameLineEnd: funcEntry.location.end.line - 1, columnStart: funcEntry.location.start.column, columnEnd: funcEntry.location.end.column }); }); } }); return result; }
javascript
{ "resource": "" }
q16747
refresh
train
function refresh(force) { if (force) { currentTheme = null; } $.when(force && loadCurrentTheme()).done(function () { var editor = EditorManager.getActiveEditor(); if (!editor || !editor._codeMirror) { return; } var cm = editor._codeMirror; ThemeView.updateThemes(cm); // currentTheme can be undefined, so watch out cm.setOption("addModeClass", !!(currentTheme && currentTheme.addModeClass)); }); }
javascript
{ "resource": "" }
q16748
loadFile
train
function loadFile(fileName, options) { var deferred = new $.Deferred(), file = FileSystem.getFileForPath(fileName), currentThemeName = prefs.get("theme"); file.exists(function (err, exists) { var theme; if (exists) { theme = new Theme(file, options); loadedThemes[theme.name] = theme; ThemeSettings._setThemes(loadedThemes); // For themes that are loaded after ThemeManager has been loaded, // we should check if it's the current theme. If it is, then we just // load it. if (currentThemeName === theme.name) { refresh(true); } deferred.resolve(theme); } else if (err || !exists) { deferred.reject(err); } }); return deferred.promise(); }
javascript
{ "resource": "" }
q16749
loadPackage
train
function loadPackage(themePackage) { var fileName = themePackage.path + "/" + themePackage.metadata.theme.file; return loadFile(fileName, themePackage.metadata); }
javascript
{ "resource": "" }
q16750
animateUsingClass
train
function animateUsingClass(target, animClass, timeoutDuration) { var result = new $.Deferred(), $target = $(target); timeoutDuration = timeoutDuration || 400; function finish(e) { if (e.target === target) { result.resolve(); } } function cleanup() { $target .removeClass(animClass) .off(_transitionEvent, finish); } if ($target.is(":hidden")) { // Don't do anything if the element is hidden because transitionEnd wouldn't fire result.resolve(); } else { // Note that we can't just use $.one() here because we only want to remove // the handler when we get the transition end event for the correct target (not // a child). $target .addClass(animClass) .on(_transitionEvent, finish); } // Use timeout in case transition end event is not sent return Async.withTimeout(result.promise(), timeoutDuration, true) .done(cleanup); }
javascript
{ "resource": "" }
q16751
train
function () { var result = this.props.parentPath + this.props.name; // Add trailing slash for directories if (!FileTreeViewModel.isFile(this.props.entry) && _.last(result) !== "/") { result += "/"; } return result; }
javascript
{ "resource": "" }
q16752
train
function (e) { if (e.keyCode === KeyEvent.DOM_VK_ESCAPE) { this.props.actions.cancelRename(); } else if (e.keyCode === KeyEvent.DOM_VK_RETURN) { this.props.actions.performRename(); } }
javascript
{ "resource": "" }
q16753
train
function (e) { this.props.actions.setRenameValue(this.props.parentPath + this.refs.name.value.trim()); if (e.keyCode !== KeyEvent.DOM_VK_LEFT && e.keyCode !== KeyEvent.DOM_VK_RIGHT) { // update the width of the input field var node = this.refs.name, newWidth = _measureText(node.value); $(node).width(newWidth); } }
javascript
{ "resource": "" }
q16754
train
function () { var fullname = this.props.name, extension = LanguageManager.getCompoundFileExtension(fullname); var node = this.refs.name; node.setSelectionRange(0, _getName(fullname, extension).length); node.focus(); // set focus on the rename input ViewUtils.scrollElementIntoView($("#project-files-container"), $(node), true); }
javascript
{ "resource": "" }
q16755
train
function (e) { e.stopPropagation(); if (e.button === RIGHT_MOUSE_BUTTON || (this.props.platform === "mac" && e.button === LEFT_MOUSE_BUTTON && e.ctrlKey)) { this.props.actions.setContext(this.myPath()); e.preventDefault(); return; } // Return true only for mouse down in rename mode. if (this.props.entry.get("rename")) { return; } }
javascript
{ "resource": "" }
q16756
train
function (nextProps, nextState) { return nextProps.forceRender || this.props.entry !== nextProps.entry || this.props.extensions !== nextProps.extensions; }
javascript
{ "resource": "" }
q16757
train
function (prevProps, prevState) { var wasSelected = prevProps.entry.get("selected"), isSelected = this.props.entry.get("selected"); if (isSelected && !wasSelected) { // TODO: This shouldn't really know about project-files-container // directly. It is probably the case that our Preact tree should actually // start with project-files-container instead of just the interior of // project-files-container and then the file tree will be one self-contained // functional unit. ViewUtils.scrollElementIntoView($("#project-files-container"), $(Preact.findDOMNode(this)), true); } else if (!isSelected && wasSelected && this.state.clickTimer !== null) { this.clearTimer(); } }
javascript
{ "resource": "" }
q16758
train
function (e) { // If we're renaming, allow the click to go through to the rename input. if (this.props.entry.get("rename")) { e.stopPropagation(); return; } if (e.button !== LEFT_MOUSE_BUTTON) { return; } if (this.props.entry.get("selected") && !e.ctrlKey) { if (this.state.clickTimer === null && !this.props.entry.get("rename")) { var timer = window.setTimeout(this.startRename, CLICK_RENAME_MINIMUM); this.setState({ clickTimer: timer }); } } else { this.props.actions.setSelected(this.myPath()); } e.stopPropagation(); e.preventDefault(); }
javascript
{ "resource": "" }
q16759
train
function () { var fullname = this.props.name; var node = this.refs.name; node.setSelectionRange(0, fullname.length); node.focus(); // set focus on the rename input ViewUtils.scrollElementIntoView($("#project-files-container"), $(node), true); }
javascript
{ "resource": "" }
q16760
train
function (nextProps, nextState) { return nextProps.forceRender || this.props.entry !== nextProps.entry || this.props.sortDirectoriesFirst !== nextProps.sortDirectoriesFirst || this.props.extensions !== nextProps.extensions || (nextState !== undefined && this.state.draggedOver !== nextState.draggedOver); }
javascript
{ "resource": "" }
q16761
train
function (event) { if (this.props.entry.get("rename")) { event.stopPropagation(); return; } if (event.button !== LEFT_MOUSE_BUTTON) { return; } var isOpen = this.props.entry.get("open"), setOpen = isOpen ? false : true; if (event.metaKey || event.ctrlKey) { // ctrl-alt-click toggles this directory and its children if (event.altKey) { if (setOpen) { // when opening, we only open the immediate children because // opening a whole subtree could be really slow (consider // a `node_modules` directory, for example). this.props.actions.toggleSubdirectories(this.myPath(), setOpen); this.props.actions.setDirectoryOpen(this.myPath(), setOpen); } else { // When closing, we recursively close the whole subtree. this.props.actions.closeSubtree(this.myPath()); } } else { // ctrl-click toggles the sibling directories this.props.actions.toggleSubdirectories(this.props.parentPath, setOpen); } } else { // directory toggle with no modifier this.props.actions.setDirectoryOpen(this.myPath(), setOpen); } event.stopPropagation(); event.preventDefault(); }
javascript
{ "resource": "" }
q16762
train
function (nextProps, nextState) { return nextProps.forceRender || this.props.contents !== nextProps.contents || this.props.sortDirectoriesFirst !== nextProps.sortDirectoriesFirst || this.props.extensions !== nextProps.extensions; }
javascript
{ "resource": "" }
q16763
train
function (nextProps, nextState) { return nextProps.forceRender || this.props.treeData !== nextProps.treeData || this.props.sortDirectoriesFirst !== nextProps.sortDirectoriesFirst || this.props.extensions !== nextProps.extensions || this.props.selectionViewInfo !== nextProps.selectionViewInfo; }
javascript
{ "resource": "" }
q16764
render
train
function render(element, viewModel, projectRoot, actions, forceRender, platform) { if (!projectRoot) { return; } Preact.render(fileTreeView({ treeData: viewModel.treeData, selectionViewInfo: viewModel.selectionViewInfo, sortDirectoriesFirst: viewModel.sortDirectoriesFirst, parentPath: projectRoot.fullPath, actions: actions, extensions: _extensions, platform: platform, forceRender: forceRender }), element); }
javascript
{ "resource": "" }
q16765
sendLanguageClientInfo
train
function sendLanguageClientInfo() { //Init node with Information required by Language Client clientInfoLoadedPromise = clientInfoDomain.exec("initialize", _bracketsPath, ToolingInfo); function logInitializationError() { console.error("Failed to Initialize LanguageClient Module Information."); } //Attach success and failure function for the clientInfoLoadedPromise clientInfoLoadedPromise.then(function (success) { if (!success) { logInitializationError(); return; } if (Array.isArray(pendingClientsToBeLoaded)) { pendingClientsToBeLoaded.forEach(function (pendingClient) { pendingClient.load(); }); } else { exports.trigger("languageClientModuleInitialized"); } pendingClientsToBeLoaded = null; }, function () { logInitializationError(); }); }
javascript
{ "resource": "" }
q16766
initDomainAndHandleNodeCrash
train
function initDomainAndHandleNodeCrash() { clientInfoDomain = new NodeDomain("LanguageClientInfo", _domainPath); //Initialize LanguageClientInfo once the domain has successfully loaded. clientInfoDomain.promise().done(function () { sendLanguageClientInfo(); //This is to handle the node failure. If the node process dies, we get an on close //event on the websocket connection object. Brackets then spawns another process and //restablishes the connection. Once the connection is restablished we send reinitialize //the LanguageClient info. clientInfoDomain.connection.on("close", function (event, reconnectedPromise) { reconnectedPromise.done(sendLanguageClientInfo); }); }).fail(function (err) { console.error("ClientInfo domain could not be loaded: ", err); }); }
javascript
{ "resource": "" }
q16767
_getStats
train
function _getStats(uri) { return new FileSystemStats({ isFile: true, mtime: SESSION_START_TIME.toISOString(), size: 0, realPath: uri, hash: uri }); }
javascript
{ "resource": "" }
q16768
RemoteFile
train
function RemoteFile(protocol, fullPath, fileSystem) { this._isFile = true; this._isDirectory = false; this.readOnly = true; this._path = fullPath; this._stat = _getStats(fullPath); this._id = fullPath; this._name = _getFileName(fullPath); this._fileSystem = fileSystem; this.donotWatch = true; this.protocol = protocol; this.encodedPath = fullPath; }
javascript
{ "resource": "" }
q16769
formatParameterHint
train
function formatParameterHint(params, appendSeparators, appendParameter, typesOnly) { var result = "", pendingOptional = false; params.forEach(function (value, i) { var param = value.type, separators = ""; if (value.isOptional) { // if an optional param is following by an optional parameter, then // terminate the bracket. Otherwise enclose a required parameter // in the same bracket. if (pendingOptional) { separators += "]"; } pendingOptional = true; } if (i > 0) { separators += ", "; } if (value.isOptional) { separators += "["; } if (appendSeparators) { appendSeparators(separators); } result += separators; if (!typesOnly) { param += " " + value.name; } if (appendParameter) { appendParameter(param, i); } result += param; }); if (pendingOptional) { if (appendSeparators) { appendSeparators("]"); } result += "]"; } return result; }
javascript
{ "resource": "" }
q16770
setDeferredTimeout
train
function setDeferredTimeout(deferred, delay) { var timer = setTimeout(function () { deferred.reject("timeout"); }, delay); deferred.always(function () { clearTimeout(timer); }); }
javascript
{ "resource": "" }
q16771
registerHandlersAndDomains
train
function registerHandlersAndDomains(ws, port) { // Called if we succeed at the final setup function success() { self._ws.onclose = function () { if (self._autoReconnect) { var $promise = self.connect(true); self.trigger("close", $promise); } else { self._cleanup(); self.trigger("close"); } }; deferred.resolve(); } // Called if we fail at the final setup function fail(err) { self._cleanup(); deferred.reject(err); } self._ws = ws; self._port = port; self._ws.onmessage = self._receive.bind(self); // refresh the current domains, then re-register any // "autoregister" modules self._refreshInterface().then( function () { if (self._registeredModules.length > 0) { self.loadDomains(self._registeredModules, false).then( success, fail ); } else { success(); } }, fail ); }
javascript
{ "resource": "" }
q16772
success
train
function success() { self._ws.onclose = function () { if (self._autoReconnect) { var $promise = self.connect(true); self.trigger("close", $promise); } else { self._cleanup(); self.trigger("close"); } }; deferred.resolve(); }
javascript
{ "resource": "" }
q16773
doConnect
train
function doConnect() { attemptCount++; attemptTimestamp = new Date(); attemptSingleConnect().then( registerHandlersAndDomains, // succeded function () { // failed this attempt, possibly try again if (attemptCount < CONNECTION_ATTEMPTS) { //try again // Calculate how long we should wait before trying again var now = new Date(); var delay = Math.max( RETRY_DELAY - (now - attemptTimestamp), 1 ); setTimeout(doConnect, delay); } else { // too many attempts, give up deferred.reject("Max connection attempts reached"); } } ); }
javascript
{ "resource": "" }
q16774
_wrapSelectedStatements
train
function _wrapSelectedStatements (wrapperName, err) { var editor = EditorManager.getActiveEditor(); if (!editor) { return; } initializeRefactoringSession(editor); var startIndex = current.startIndex, endIndex = current.endIndex, selectedText = current.selectedText, pos; if (selectedText.length === 0) { var statementNode = RefactoringUtils.findSurroundASTNode(current.ast, {start: startIndex}, ["Statement"]); if (!statementNode) { current.editor.displayErrorMessageAtCursor(err); return; } selectedText = current.text.substr(statementNode.start, statementNode.end - statementNode.start); startIndex = statementNode.start; endIndex = statementNode.end; } else { var selectionDetails = RefactoringUtils.normalizeText(selectedText, startIndex, endIndex); selectedText = selectionDetails.text; startIndex = selectionDetails.start; endIndex = selectionDetails.end; } if (!RefactoringUtils.checkStatement(current.ast, startIndex, endIndex, selectedText)) { current.editor.displayErrorMessageAtCursor(err); return; } pos = { "start": current.cm.posFromIndex(startIndex), "end": current.cm.posFromIndex(endIndex) }; current.document.batchOperation(function() { current.replaceTextFromTemplate(wrapperName, {body: selectedText}, pos); }); if (wrapperName === TRY_CATCH) { var cursorLine = current.editor.getSelection().end.line - 1, startCursorCh = current.document.getLine(cursorLine).indexOf("\/\/"), endCursorCh = current.document.getLine(cursorLine).length; current.editor.setSelection({"line": cursorLine, "ch": startCursorCh}, {"line": cursorLine, "ch": endCursorCh}); } else if (wrapperName === WRAP_IN_CONDITION) { current.editor.setSelection({"line": pos.start.line, "ch": pos.start.ch + 4}, {"line": pos.start.line, "ch": pos.start.ch + 13}); } }
javascript
{ "resource": "" }
q16775
createGettersAndSetters
train
function createGettersAndSetters() { var editor = EditorManager.getActiveEditor(); if (!editor) { return; } initializeRefactoringSession(editor); var startIndex = current.startIndex, endIndex = current.endIndex, selectedText = current.selectedText; if (selectedText.length >= 1) { var selectionDetails = RefactoringUtils.normalizeText(selectedText, startIndex, endIndex); selectedText = selectionDetails.text; startIndex = selectionDetails.start; endIndex = selectionDetails.end; } var token = TokenUtils.getTokenAt(current.cm, current.cm.posFromIndex(endIndex)), commaString = ",", isLastNode, templateParams, parentNode, propertyEndPos; //Create getters and setters only if selected reference is a property if (token.type !== "property") { current.editor.displayErrorMessageAtCursor(Strings.ERROR_GETTERS_SETTERS); return; } parentNode = current.getParentNode(current.ast, endIndex); // Check if selected propery is child of a object expression if (!parentNode || !parentNode.properties) { current.editor.displayErrorMessageAtCursor(Strings.ERROR_GETTERS_SETTERS); return; } var propertyNodeArray = parentNode.properties; // Find the last Propery Node before endIndex var properyNodeIndex = propertyNodeArray.findIndex(function (element) { return (endIndex >= element.start && endIndex < element.end); }); var propertyNode = propertyNodeArray[properyNodeIndex]; //Get Current Selected Property End Index; propertyEndPos = editor.posFromIndex(propertyNode.end); //We have to add ',' so we need to find position of current property selected isLastNode = current.isLastNodeInScope(current.ast, endIndex); var nextPropertNode, nextPropertyStartPos; if(!isLastNode && properyNodeIndex + 1 <= propertyNodeArray.length - 1) { nextPropertNode = propertyNodeArray[properyNodeIndex + 1]; nextPropertyStartPos = editor.posFromIndex(nextPropertNode.start); if(propertyEndPos.line !== nextPropertyStartPos.line) { propertyEndPos = current.lineEndPosition(current.startPos.line); } else { propertyEndPos = nextPropertyStartPos; commaString = ", "; } } var getSetPos; if (isLastNode) { getSetPos = current.document.adjustPosForChange(propertyEndPos, commaString.split("\n"), propertyEndPos, propertyEndPos); } else { getSetPos = propertyEndPos; } templateParams = { "getName": token.string, "setName": token.string, "tokenName": token.string }; // Replace, setSelection, IndentLine // We need to call batchOperation as indentLine don't have option to add origin as like replaceRange current.document.batchOperation(function() { if (isLastNode) { //Add ',' in the end of current line current.document.replaceRange(commaString, propertyEndPos, propertyEndPos); } current.editor.setSelection(getSetPos); //Selection on line end // Add getters and setters for given token using template at current cursor position current.replaceTextFromTemplate(GETTERS_SETTERS, templateParams); if (!isLastNode) { // Add ',' at the end setter current.document.replaceRange(commaString, current.editor.getSelection().start, current.editor.getSelection().start); } }); }
javascript
{ "resource": "" }
q16776
doSequentiallyInBackground
train
function doSequentiallyInBackground(items, fnProcessItem, maxBlockingTime, idleTime) { maxBlockingTime = maxBlockingTime || 15; idleTime = idleTime || 30; var sliceStartTime = (new Date()).getTime(); return doSequentially(items, function (item, i) { var result = new $.Deferred(); // process the next item fnProcessItem(item, i); // if we've exhausted our maxBlockingTime if ((new Date()).getTime() - sliceStartTime >= maxBlockingTime) { //yield window.setTimeout(function () { sliceStartTime = (new Date()).getTime(); result.resolve(); }, idleTime); } else { //continue processing result.resolve(); } return result; }, false); }
javascript
{ "resource": "" }
q16777
setGotoEnabled
train
function setGotoEnabled(gotoEnabled) { CommandManager.get(Commands.NAVIGATE_GOTO_FIRST_PROBLEM).setEnabled(gotoEnabled); _gotoEnabled = gotoEnabled; }
javascript
{ "resource": "" }
q16778
getProvidersForPath
train
function getProvidersForPath(filePath) { var language = LanguageManager.getLanguageForPath(filePath).getId(), context = PreferencesManager._buildContext(filePath, language), installedProviders = getProvidersForLanguageId(language), preferredProviders, prefPreferredProviderNames = prefs.get(PREF_PREFER_PROVIDERS, context), prefPreferredOnly = prefs.get(PREF_PREFERRED_ONLY, context), providers; if (prefPreferredProviderNames && prefPreferredProviderNames.length) { if (typeof prefPreferredProviderNames === "string") { prefPreferredProviderNames = [prefPreferredProviderNames]; } preferredProviders = prefPreferredProviderNames.reduce(function (result, key) { var provider = _.find(installedProviders, {name: key}); if (provider) { result.push(provider); } return result; }, []); if (prefPreferredOnly) { providers = preferredProviders; } else { providers = _.union(preferredProviders, installedProviders); } } else { providers = installedProviders; } return providers; }
javascript
{ "resource": "" }
q16779
getProviderIDsForLanguage
train
function getProviderIDsForLanguage(languageId) { if (!_providers[languageId]) { return []; } return _providers[languageId].map(function (provider) { return provider.name; }); }
javascript
{ "resource": "" }
q16780
updatePanelTitleAndStatusBar
train
function updatePanelTitleAndStatusBar(numProblems, providersReportingProblems, aborted) { var message, tooltip; if (providersReportingProblems.length === 1) { // don't show a header if there is only one provider available for this file type $problemsPanelTable.find(".inspector-section").hide(); $problemsPanelTable.find("tr").removeClass("forced-hidden"); if (numProblems === 1 && !aborted) { message = StringUtils.format(Strings.SINGLE_ERROR, providersReportingProblems[0].name); } else { if (aborted) { numProblems += "+"; } message = StringUtils.format(Strings.MULTIPLE_ERRORS, providersReportingProblems[0].name, numProblems); } } else if (providersReportingProblems.length > 1) { $problemsPanelTable.find(".inspector-section").show(); if (aborted) { numProblems += "+"; } message = StringUtils.format(Strings.ERRORS_PANEL_TITLE_MULTIPLE, numProblems); } else { return; } $problemsPanel.find(".title").text(message); tooltip = StringUtils.format(Strings.STATUSBAR_CODE_INSPECTION_TOOLTIP, message); StatusBar.updateIndicator(INDICATOR_ID, true, "inspection-errors", tooltip); }
javascript
{ "resource": "" }
q16781
getProvidersForLanguageId
train
function getProvidersForLanguageId(languageId) { var result = []; if (_providers[languageId]) { result = result.concat(_providers[languageId]); } if (_providers['*']) { result = result.concat(_providers['*']); } return result; }
javascript
{ "resource": "" }
q16782
updateListeners
train
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
{ "resource": "" }
q16783
toggleEnabled
train
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
{ "resource": "" }
q16784
_firstNotWs
train
function _firstNotWs(doc, lineNum) { var text = doc.getLine(lineNum); if (text === null || text === undefined) { return 0; } return text.search(/\S|$/); }
javascript
{ "resource": "" }
q16785
prepareEditorForProvider
train
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
{ "resource": "" }
q16786
refresh
train
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
{ "resource": "" }
q16787
_updateListItemSelection
train
function _updateListItemSelection(listItem, selectedFile) { var shouldBeSelected = (selectedFile && $(listItem).data(_FILE_KEY).fullPath === selectedFile.fullPath); ViewUtils.toggleClass($(listItem), "selected", shouldBeSelected); }
javascript
{ "resource": "" }
q16788
_isOpenAndDirty
train
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
{ "resource": "" }
q16789
_suppressScrollShadowsOnAllViews
train
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
{ "resource": "" }
q16790
_deactivateAllViews
train
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
{ "resource": "" }
q16791
_viewFromEl
train
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
{ "resource": "" }
q16792
scroll
train
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
{ "resource": "" }
q16793
preDropCleanup
train
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
{ "resource": "" }
q16794
createWorkingSetViewForPane
train
function createWorkingSetViewForPane($container, paneId) { var view = _views[paneId]; if (!view) { view = new WorkingSetView($container, paneId); _views[view.paneId] = view; } }
javascript
{ "resource": "" }
q16795
_getPluginsForCurrentContext
train
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
{ "resource": "" }
q16796
QuickOpenPlugin
train
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
{ "resource": "" }
q16797
addQuickOpenPlugin
train
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
{ "resource": "" }
q16798
_filter
train
function _filter(file) { return !LanguageManager.getLanguageForPath(file.fullPath).isBinary() || MainViewFactory.findSuitableFactoryForPath(file.fullPath); }
javascript
{ "resource": "" }
q16799
handleGetFile
train
function handleGetFile(file, text) { var next = fileCallBacks[file]; if (next) { try { next(null, text); } catch (e) { _reportError(e, file); } } delete fileCallBacks[file]; }
javascript
{ "resource": "" }