_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q43900
parseJsonConfig
train
function parseJsonConfig(string, location, messages) { var items = {}; // Parses a JSON-like comment by the same way as parsing CLI option. /*try { items = levn.parse("Object", string) || {}; // Some tests say that it should ignore invalid comments such as `/*eslint no-alert:abc* /`. // Also, commaless notations have invalid severity: // "no-alert: 2 no-console: 2" --> {"no-alert": "2 no-console: 2"} // Should ignore that case as well. if (ConfigOps.isEverySeverityValid(items)) { return items; } } catch (ex) { // ignore to parse the string by a fallback. }*/ // Optionator cannot parse commaless notations. // But we are supporting that. So this is a fallback for that. items = {}; string = string.replace(/([a-zA-Z0-9\-\/]+):/g, "\"$1\":").replace(/(\]|[0-9])\s+(?=")/, "$1,"); try { items = JSON.parse("{" + string + "}"); } catch (ex) { messages.push({ ruleId: null, fatal: true, severity: 2, source: null, message: "Failed to parse JSON from '" + string + "': " + ex.message, line: location.start.line, column: location.start.column + 1 }); } return items; }
javascript
{ "resource": "" }
q43901
parseListConfig
train
function parseListConfig(string) { var items = {}; // Collapse whitespace around , string = string.replace(/\s*,\s*/g, ","); string.split(/,+/).forEach(function(name) { name = name.trim(); if (!name) { return; } items[name] = true; }); return items; }
javascript
{ "resource": "" }
q43902
addDeclaredGlobals
train
function addDeclaredGlobals(program, globalScope, config) { var declaredGlobals = {}, exportedGlobals = {}, explicitGlobals = {}, builtin = Environments.get("builtin"); assign(declaredGlobals, builtin); Object.keys(config.env).forEach(function(name) { if (config.env[name]) { var env = Environments.get(name), environmentGlobals = env && env.globals; if (environmentGlobals) { assign(declaredGlobals, environmentGlobals); } } }); assign(exportedGlobals, config.exported); assign(declaredGlobals, config.globals); assign(explicitGlobals, config.astGlobals); Object.keys(declaredGlobals).forEach(function(name) { var variable = globalScope.set.get(name); if (!variable) { variable = new escope.Variable(name, globalScope); variable.eslintExplicitGlobal = false; globalScope.variables.push(variable); globalScope.set.set(name, variable); } variable.writeable = declaredGlobals[name]; }); Object.keys(explicitGlobals).forEach(function(name) { var variable = globalScope.set.get(name); if (!variable) { variable = new escope.Variable(name, globalScope); variable.eslintExplicitGlobal = true; variable.eslintExplicitGlobalComment = explicitGlobals[name].comment; globalScope.variables.push(variable); globalScope.set.set(name, variable); } variable.writeable = explicitGlobals[name].value; }); // mark all exported variables as such Object.keys(exportedGlobals).forEach(function(name) { var variable = globalScope.set.get(name); if (variable) { variable.eslintUsed = true; } }); /* * "through" contains all references which definitions cannot be found. * Since we augment the global scope using configuration, we need to update * references and remove the ones that were added by configuration. */ globalScope.through = globalScope.through.filter(function(reference) { var name = reference.identifier.name; var variable = globalScope.set.get(name); if (variable) { /* * Links the variable and the reference. * And this reference is removed from `Scope#through`. */ reference.resolved = variable; variable.references.push(reference); return false; } return true; }); }
javascript
{ "resource": "" }
q43903
disableReporting
train
function disableReporting(reportingConfig, start, rulesToDisable) { if (rulesToDisable.length) { rulesToDisable.forEach(function(rule) { reportingConfig.push({ start: start, end: null, rule: rule }); }); } else { reportingConfig.push({ start: start, end: null, rule: null }); } }
javascript
{ "resource": "" }
q43904
enableReporting
train
function enableReporting(reportingConfig, start, rulesToEnable) { var i; if (rulesToEnable.length) { rulesToEnable.forEach(function(rule) { for (i = reportingConfig.length - 1; i >= 0; i--) { if (!reportingConfig[i].end && reportingConfig[i].rule === rule) { reportingConfig[i].end = start; break; } } }); } else { // find all previous disabled locations if they was started as list of rules var prevStart; for (i = reportingConfig.length - 1; i >= 0; i--) { if (prevStart && prevStart !== reportingConfig[i].start) { break; } if (!reportingConfig[i].end) { reportingConfig[i].end = start; prevStart = reportingConfig[i].start; } } } }
javascript
{ "resource": "" }
q43905
isDisabledByReportingConfig
train
function isDisabledByReportingConfig(reportingConfig, ruleId, location) { for (var i = 0, c = reportingConfig.length; i < c; i++) { var ignore = reportingConfig[i]; if ((!ignore.rule || ignore.rule === ruleId) && (location.line > ignore.start.line || (location.line === ignore.start.line && location.column >= ignore.start.column)) && (!ignore.end || (location.line < ignore.end.line || (location.line === ignore.end.line && location.column <= ignore.end.column)))) { return true; } } return false; }
javascript
{ "resource": "" }
q43906
prepareConfig
train
function prepareConfig(config) { config.globals = config.globals || config.global || {}; delete config.global; var copiedRules = {}, parserOptions = {}, preparedConfig; if (typeof config.rules === "object") { Object.keys(config.rules).forEach(function(k) { var rule = config.rules[k]; if (rule === null) { throw new Error("Invalid config for rule '" + k + "'\."); } if (Array.isArray(rule)) { copiedRules[k] = rule.slice(); } else { copiedRules[k] = rule; } }); } // merge in environment parserOptions if (typeof config.env === "object") { Object.keys(config.env).forEach(function(envName) { var env = Environments.get(envName); if (config.env[envName] && env && env.parserOptions) { parserOptions = ConfigOps.merge(parserOptions, env.parserOptions); } }); } preparedConfig = { rules: copiedRules, parser: config.parser || DEFAULT_PARSER, globals: ConfigOps.merge({}, config.globals), env: ConfigOps.merge({}, config.env || {}), settings: ConfigOps.merge({}, config.settings || {}), parserOptions: ConfigOps.merge(parserOptions, config.parserOptions || {}), tern: config.tern // ORION }; if (preparedConfig.parserOptions.sourceType === "module") { if (!preparedConfig.parserOptions.ecmaFeatures) { preparedConfig.parserOptions.ecmaFeatures = {}; } // can't have global return inside of modules preparedConfig.parserOptions.ecmaFeatures.globalReturn = false; // also need at least ES6 for modules if (!preparedConfig.parserOptions.ecmaVersion || preparedConfig.parserOptions.ecmaVersion < 6) { preparedConfig.parserOptions.ecmaVersion = 6; } } return preparedConfig; }
javascript
{ "resource": "" }
q43907
createStubRule
train
function createStubRule(message) { /** * Creates a fake rule object * @param {object} context context object for each rule * @returns {object} collection of node to listen on */ function createRuleModule(context) { return { Program: function(node) { context.report(node, message); } }; } if (message) { return createRuleModule; } else { throw new Error("No message passed to stub rule"); } }
javascript
{ "resource": "" }
q43908
getRuleReplacementMessage
train
function getRuleReplacementMessage(ruleId) { if (ruleId in replacements.rules) { var newRules = replacements.rules[ruleId]; return "Rule \'" + ruleId + "\' was removed and replaced by: " + newRules.join(", "); } return null; }
javascript
{ "resource": "" }
q43909
train
function(repository, userCredentials){ var credentials = { gitSshUsername : "", gitSshPassword : "", gitPrivateKey : "", gitPassphrase : "" }; if(userCredentials !== undefined){ if(userCredentials.gitSshUsername !== undefined && userCredentials.gitSshUsername !== null) { credentials.gitSshUsername = userCredentials.gitSshUsername; } if(userCredentials.gitSshPassword !== undefined && userCredentials.gitSshPassword !== null) { credentials.gitSshPassword = userCredentials.gitSshPassword; } if(userCredentials.gitPrivateKey !== undefined && userCredentials.gitPrivateKey !== null) { credentials.gitPrivateKey = userCredentials.gitPrivateKey; } if(userCredentials.gitPassphrase !== undefined && userCredentials.gitPassphrase !== null) { credentials.gitPassphrase = userCredentials.gitPassphrase; } } var d = new Deferred(); this._preferenceService.get(this._prefix, undefined, {scope: 2}).then( function(pref){ var settings = pref["settings"]; if(settings === undefined){ d.reject(); return; } if(settings.enabled){ var data = {}; data[repository] = credentials; this._preferenceService.put(this._prefix, data, {scope: 2}).then(d.resolve, d.reject); } else { d.reject(); } }.bind(this) ); return d; }
javascript
{ "resource": "" }
q43910
train
function(repository){ var credentials = { gitSshUsername : "", gitSshPassword : "", gitPrivateKey : "", gitPassphrase : "" }; var d = new Deferred(); this._preferenceService.get(this._prefix, undefined, {scope: 2}).then( function(pref){ var settings = pref["settings"]; if(settings === undefined){ d.reject(); return; } if(settings.enabled){ var userCredentials = pref[repository]; if(userCredentials !== undefined) { d.resolve(userCredentials); } else { d.resolve(credentials); } } else { d.reject(); } } ); return d; }
javascript
{ "resource": "" }
q43911
train
function(){ var d = new Deferred(); this._preferenceService.get(this._prefix, undefined, {scope: 2}).then( function(pref){ var settings = pref["settings"]; if(settings === undefined){ d.resolve(false); return; } d.resolve(settings.enabled); } ); return d; }
javascript
{ "resource": "" }
q43912
train
function(){ var d = new Deferred(); this._preferenceService.get(this._prefix, undefined, {scope: 2}).then( function(pref){ var result = []; var repositories = Object.keys(pref); for(var i=0; i<repositories.length; ++i){ if(repositories[i] !== "settings"){ result.push(repositories[i]); } } d.resolve(result); } ); return d; }
javascript
{ "resource": "" }
q43913
Selection
train
function Selection (start, end, caret) { /** * The selection start offset. * * @name orion.editor.Selection#start */ this.start = start; /** * The selection end offset. * * @name orion.editor.Selection#end */ this.end = end; /** @private */ this.caret = caret; //true if the start, false if the caret is at end /** @private */ this._columnX = -1; }
javascript
{ "resource": "" }
q43914
TextLine
train
function TextLine (view, lineIndex, lineDiv) { /** * The view. * * @name orion.editor.TextLine#view * @private */ this.view = view; /** * The line index. * * @name orion.editor.TextLine#lineIndex * @private */ this.lineIndex = lineIndex; this._lineDiv = lineDiv; }
javascript
{ "resource": "" }
q43915
train
function(mode, index) { var keyModes = this._keyModes; if (index !== undefined) { keyModes.splice(index, 0, mode); } else { keyModes.push(mode); } //TODO: API needed for this if (mode._modeAdded) { mode._modeAdded(); } }
javascript
{ "resource": "" }
q43916
train
function(offset, options) { var selection = new Selection(offset, offset, false); this._doMove(options, selection); return selection.getCaret(); }
javascript
{ "resource": "" }
q43917
train
function(x, y) { if (!this._clientDiv) { return 0; } var lineIndex = this._getLineIndex(y); var line = this._getLine(lineIndex); var offset = line.getOffset(x, y - this._getLinePixel(lineIndex)); line.destroy(); return offset; }
javascript
{ "resource": "" }
q43918
train
function (mode) { var keyModes = this._keyModes; for (var i=0; i<keyModes.length; i++) { if (keyModes[i] === mode) { keyModes.splice(i, 1); break; } } //TODO: API needed for this if (mode._modeRemoved) { mode._modeRemoved(); } }
javascript
{ "resource": "" }
q43919
train
function (ruler) { var rulers = this._rulers; for (var i=0; i<rulers.length; i++) { if (rulers[i] === ruler) { rulers.splice(i, 1); ruler.setView(null); this._destroyRuler(ruler); this._update(); break; } } }
javascript
{ "resource": "" }
q43920
train
function(offset, show, callback) { var charCount = this._model.getCharCount(); offset = Math.max(0, Math.min (offset, charCount)); var selection = new Selection(offset, offset, false); this._setSelection (selection, show === undefined || show, true, callback); }
javascript
{ "resource": "" }
q43921
train
function(model) { if (model === this._model) { return; } model = model || new mTextModel.TextModel(); this._model.removeEventListener("preChanging", this._modelListener.onChanging); //$NON-NLS-1$ this._model.removeEventListener("postChanged", this._modelListener.onChanged); //$NON-NLS-1$ var oldLineCount = this._model.getLineCount(); var oldCharCount = this._model.getCharCount(); var newLineCount = model.getLineCount(); var newCharCount = model.getCharCount(); var newText = model.getText(); var e = { type: "ModelChanging", //$NON-NLS-1$ text: newText, start: 0, removedCharCount: oldCharCount, addedCharCount: newCharCount, removedLineCount: oldLineCount, addedLineCount: newLineCount }; this.onModelChanging(e); this._model = model; e = { type: "ModelChanged", //$NON-NLS-1$ start: 0, removedCharCount: oldCharCount, addedCharCount: newCharCount, removedLineCount: oldLineCount, addedLineCount: newLineCount }; this.onModelChanged(e); this._model.addEventListener("preChanging", this._modelListener.onChanging); //$NON-NLS-1$ this._model.addEventListener("postChanged", this._modelListener.onChanged); //$NON-NLS-1$ this._reset(); this._update(); }
javascript
{ "resource": "" }
q43922
train
function (options) { var defaultOptions = this._defaultOptions(); for (var option in options) { if (options.hasOwnProperty(option)) { var newValue = options[option], oldValue = this["_" + option]; //$NON-NLS-1$ if (compare(oldValue, newValue)) { continue; } var update = defaultOptions[option] ? defaultOptions[option].update : null; if (update) { update.call(this, newValue); continue; } this["_" + option] = clone(newValue); //$NON-NLS-1$ } } this.onOptions({type: "Options", options: options}); //$NON-NLS-1$ }
javascript
{ "resource": "" }
q43923
train
function(editorContext, context, astManager) { return astManager.getAST(editorContext).then(function(ast) { var node = Finder.findNode(context.annotation.start, ast, {parents:true}); if(node && node.type === 'ArrayExpression') { var model = new TextModel.TextModel(ast.sourceFile.text.slice(context.annotation.start, context.annotation.end)); var len = node.elements.length; var idx = len-1; var item = node.elements[idx]; if(item === null) { var end = Finder.findToken(node.range[1], ast.tokens); if(end.value !== ']') { //for a follow-on token we want the previous - i.e. a token immediately following the ']' that has no space end = ast.tokens[end.index-1]; } //wipe all trailing entries first using the ']' token start as the end for(; idx > -1; idx--) { item = node.elements[idx]; if(item !== null) { break; } } if(item === null) { //whole array is sparse - wipe it return editorContext.setText('', context.annotation.start+1, context.annotation.end-1); } model.setText('', item.range[1]-context.annotation.start, end.range[0]-context.annotation.start); } var prev = item; for(; idx > -1; idx--) { item = node.elements[idx]; if(item === null || item.range[0] === prev.range[0]) { continue; } model.setText(', ', item.range[1]-context.annotation.start, prev.range[0]-context.annotation.start); //$NON-NLS-1$ prev = item; } if(item === null && prev !== null) { //need to wipe the front of the array model.setText('', node.range[0]+1-context.annotation.start, prev.range[0]-context.annotation.start); } return editorContext.setText(model.getText(), context.annotation.start, context.annotation.end); } return null; }); }
javascript
{ "resource": "" }
q43924
isModifyingReference
train
function isModifyingReference(reference, index, references) { var identifier = reference.identifier; return identifier && reference.init === false && reference.isWrite() && // Destructuring assignments can have multiple default value, // so possibly there are multiple writeable references for the same identifier. (index === 0 || references[index - 1].identifier !== identifier ); }
javascript
{ "resource": "" }
q43925
train
function(location, line, description, enabled) { this.location = location; this.line = line; this.description = description; this.enabled = enabled; }
javascript
{ "resource": "" }
q43926
train
function(location, functionName, description, enabled) { this.location = location; this.function = functionName; this.description = description; this.enabled = enabled; }
javascript
{ "resource": "" }
q43927
deserialize
train
function deserialize(plain) { plain = plain || {}; plain.location = plain.location || ""; plain.description = plain.description || ""; switch (plain.type) { case 'LineBookmark': if (!isFinite(plain.line)) break; return new LineBookmark(plain.location, plain.line, plain.description); case 'LineBreakpoint': if (!isFinite(plain.line)) break; return new LineBreakpoint(plain.location, plain.line, plain.description, !!plain.enabled); case 'LineConditionalBreakpoint': if (!isFinite(plain.line)) break; if (!plain.condition) break; return new LineConditionalBreakpoint(plain.location, plain.line, plain.description, plain.condition, !!plain.enabled); case 'FunctionBreakpoint': if (!plain.function) break; return new FunctionBreakpoint(plain.location, plain.function, plain.description, !!plain.enabled); case 'ExceptionBreakpoint': if (!plain.label) break; return new ExceptionBreakpoint(plain.label, plain.description, !!plain.enabled); } return null; }
javascript
{ "resource": "" }
q43928
Explorer
train
function Explorer(serviceRegistry, selection, renderer, commandRegistry) { this.registry = serviceRegistry; this.selection = selection; this.commandService = commandRegistry; this.setRenderer(renderer); this.myTree = null; }
javascript
{ "resource": "" }
q43929
train
function(parent, children) { if (this.myTree) { this.myTree.refresh.bind(this.myTree)(parent, children, true); } }
javascript
{ "resource": "" }
q43930
train
function() { var topLevelNodes = this._navHandler.getTopLevelNodes(); for (var i = 0; i < topLevelNodes.length ; i++){ this.myTree.collapse(topLevelNodes[i]); } }
javascript
{ "resource": "" }
q43931
train
function(nodeModel, excludes) { if(nodeModel){ this._expandRecursively(nodeModel, excludes); } else { if(!this._navHandler){ return; } //We already know what the top level children is under the root, from the navigation handler. var topLevelNodes = this._navHandler.getTopLevelNodes(); for (var i = 0; i < topLevelNodes.length ; i++){ this._expandRecursively(topLevelNodes[i], excludes); } } }
javascript
{ "resource": "" }
q43932
train
function (parentId, model, options){ parentId = typeof parentId === "string" ? parentId : (parentId.id || parentId); //$NON-NLS-0$ if(this.selection) { this.selection.setSelections([]); } if(this.getNavHandler()){ this.getNavHandler().destroy(); this._navHandler = null; } var treeId = parentId + "innerTree"; //$NON-NLS-0$ var existing = lib.node(treeId); if (existing) { lib.empty(existing); } if (model){ model.rootId = treeId + "Root"; //$NON-NLS-0$ } this.model = model; this._parentId = parentId; this.role = options && options.role; this._treeOptions = options; var useSelection = !options || (options && !options.noSelection); if(useSelection){ this.selectionPolicy = options ? options.selectionPolicy : ""; this._navDict = new mNavHandler.ExplorerNavDict(this.model); } this.myTree = new mTreeTable.TableTree({ id: treeId, role: options ? options.role : undefined, name: options ? options.name : undefined, model: model, parent: parentId, onComplete: function(tree) { if(this.selectionPolicy === "cursorOnly"){ //$NON-NLS-0$ this.initNavHandler(); var navHandler = this.getNavHandler(); if (navHandler) { navHandler.rowsChanged(); } } if (options.onComplete) options.onComplete(tree); }.bind(this), labelColumnIndex: this.renderer.getLabelColumnIndex(), renderer: this.renderer, showRoot: options ? !!options.showRoot : false, indent: options ? options.indent: undefined, preCollapse: options ? options.preCollapse: undefined, onCollapse: options && options.onCollapse ? options.onCollapse : function(model) { var navHandler = this.getNavHandler(); if (navHandler) { navHandler.onCollapse(model); } }.bind(this), navHandlerFactory: options ? options.navHandlerFactory: undefined, tableElement: options ? options.tableElement : undefined, tableBodyElement: options ? options.tableBodyElement : undefined, tableRowElement: options ? options.tableRowElement : undefined }); this.renderer._initializeUIState(); }
javascript
{ "resource": "" }
q43933
ExplorerModel
train
function ExplorerModel(rootPath, /* function returning promise */fetchItems, idPrefix) { this.rootPath = rootPath; this.fetchItems = fetchItems; this.idPrefix = idPrefix || ""; }
javascript
{ "resource": "" }
q43934
ExplorerFlatModel
train
function ExplorerFlatModel(rootPath, fetchItems, root) { this.rootPath = rootPath; this.fetchItems = fetchItems; this.root = root; }
javascript
{ "resource": "" }
q43935
train
function(prefPath) { var didRestoreSelections = false; var expanded = window.sessionStorage[prefPath+"expanded"]; //$NON-NLS-0$ if (typeof expanded=== "string") { //$NON-NLS-0$ if (expanded.length > 0) { expanded= JSON.parse(expanded); } else { expanded = null; } } var i; if (expanded) { for (i=0; i<expanded.length; i++) { var row= lib.node(expanded[i]); if (row) { this._expanded.push(expanded[i]); // restore selections after expansion in case an expanded item was selected. var self = this; this.tableTree.expand(expanded[i], function() { self._restoreSelections(prefPath); }); didRestoreSelections = true; } } } return !didRestoreSelections; }
javascript
{ "resource": "" }
q43936
SimpleFlatModel
train
function SimpleFlatModel(items, idPrefix, getKey) { this.items = items; this.getKey = getKey; this.idPrefix = idPrefix; this.root = {children: items}; }
javascript
{ "resource": "" }
q43937
makeRelative
train
function makeRelative(location) { if (!location) { return location; } var hostName = window.location.protocol + "//" + window.location.host; //$NON-NLS-0$ if (location.indexOf(hostName) === 0) { return location.substring(hostName.length); } return location; }
javascript
{ "resource": "" }
q43938
isAtRoot
train
function isAtRoot(path) { if (!path) { return false; } if (path === "/workspace") { return true; // sad but true } var pathUrl = new URL(path, window.location.href); return pathUrl.href.indexOf(_workspaceUrlHref) === 0; //$NON-NLS-0$ }
javascript
{ "resource": "" }
q43939
JavascriptField
train
function JavascriptField(type, options) { Field.call(this, type, options); this.onInputChange = this.onInputChange.bind(this); this.arg = new ScriptArgument('', '{ ', ' }'); this.element = util.createElement(this.document, 'div'); this.input = util.createElement(this.document, 'input'); this.input.type = 'text'; this.input.addEventListener('keyup', this.onInputChange, false); this.input.classList.add('gcli-field'); this.input.classList.add('gcli-field-javascript'); this.element.appendChild(this.input); this.menu = new Menu({ document: this.document, field: true, type: type }); this.element.appendChild(this.menu.element); var initial = new Conversion(undefined, new ScriptArgument(''), Status.INCOMPLETE, ''); this.setConversion(initial); this.onFieldChange = util.createEvent('JavascriptField.onFieldChange'); // i.e. Register this.onItemClick as the default action for a menu click this.menu.onItemClick.add(this.itemClicked, this); }
javascript
{ "resource": "" }
q43940
ProgressSpinner
train
function ProgressSpinner(id, anchor){ if(id === undefined){ throw new Error("Missing reqired argument: id"); } if(anchor === undefined){ throw new Error("Missing reqired argument: anchor"); } this._id = id; this._anchor = anchor; // we add a prefix for the id label this._prefix = "progressSpinner:"; }
javascript
{ "resource": "" }
q43941
ProgressDots
train
function ProgressDots(id, anchor){ if(id === undefined){ throw new Error("Missing reqired argument: id"); } if(anchor === undefined){ throw new Error("Missing reqired argument: anchor"); } this._id = id; this._anchor = anchor; // we add a prefix for the id label this._prefix = "progressDots:"; }
javascript
{ "resource": "" }
q43942
DynamicContentModel
train
function DynamicContentModel(objects, populate){ if(!objects) { throw new Error("Missing reqired argument: objects"); } if(!populate) { throw new Error("Missing reqired argument: populate"); } this._objects = objects; this._populate = populate; }
javascript
{ "resource": "" }
q43943
train
function(i){ return function(resp){ if(that._errorHandler) { that._errorHandler(i, resp); } else { throw new Error(resp); } }; }
javascript
{ "resource": "" }
q43944
train
function(item, tableRow) { mExplorer.SelectionRenderer.prototype.renderRow.call(this, item, tableRow); if (item.type !== "file") { //$NON-NLS-0$ tableRow.classList.add("searchDetailRow"); //$NON-NLS-0$ } }
javascript
{ "resource": "" }
q43945
checkReference
train
function checkReference(reference, index, references) { var identifier = reference.identifier; if (reference.init === false && reference.isWrite() && // Destructuring assignments can have multiple default value, // so possibly there are multiple writeable references for the same identifier. (index === 0 || references[index - 1].identifier !== identifier) ) { context.report({ node: identifier, message: ProblemMessages.noNativeReassign, data: {name: identifier.name} }); } }
javascript
{ "resource": "" }
q43946
CompareTreeModel
train
function CompareTreeModel(rootPath, fetchItems, root) { this.rootPath = rootPath; this.fetchItems = fetchItems; this.root = root; }
javascript
{ "resource": "" }
q43947
generateAuthToken
train
function generateAuthToken(bytes, callback) { crypto.randomBytes(bytes, function(err, randomBytes) { if(err) { return callback(err); } callback(null, randomBytes.toString('hex')); }); }
javascript
{ "resource": "" }
q43948
train
function() { var parent; if (this.domNode.tooltip) { this.domNode.tooltip.destroy(); this.domNode.tooltip = null; } if (this.domNode) { parent = this.domNode.parentNode; if (parent) parent.removeChild(this.domNode); this.domNode = null; } if (this._contentParent) { parent = this._contentParent.parentNode; if (parent) parent.removeChild(this._contentParent); this._contentParent = null; } if (this._sectionContainer) { parent = this._sectionContainer.parentNode; if (parent) parent.removeChild(this._sectionContainer); this._sectionContainer = null; } }
javascript
{ "resource": "" }
q43949
train
function(content){ if (typeof content === 'string') { //$NON-NLS-0$ this._contentParent.innerHTML = content; } else { this._contentParent.innerHTML = ""; //NON-NLS-0$ this._contentParent.appendChild(content); } }
javascript
{ "resource": "" }
q43950
withCommand
train
function withCommand(element, action) { var command = element.getAttribute('data-command'); if (!command) { command = element.querySelector('*[data-command]') .getAttribute('data-command'); } if (command) { action(command); } else { console.warn('Missing data-command for ' + util.findCssSelector(element)); } }
javascript
{ "resource": "" }
q43951
deleteAllOperations
train
function deleteAllOperations(req, res) { taskStore.getTasksForUser(req.user.username, function(err, tasks) { if (err) { return writeError(500, res, err.toString()); } var locations = []; var doneCount = 0; var done = function() { if (!tasks.length || ++doneCount === tasks.length) { writeResponse(200, res, null, locations); } }; if (!tasks.length) { done(); return; } tasks.forEach(function(task) { if (task.result || task.Result) { // task in single user case doesn't have Location, it has keep instead taskStore.deleteTask(getTaskMeta(req, (task.Location && task.Location.substring(req.baseUrl.length)) || task.keep, task.id), done); /* task is completed */ } else { locations.push(toJSON(task, true).Location); done(); } }); }); }
javascript
{ "resource": "" }
q43952
train
function(text, parent) { //define div if one isn't provided var result = parent || document.createElement('div'); //$NON-NLS-0$ var linkScanners = this._registry.getServiceReferences("orion.core.linkScanner"); //$NON-NLS-0$ if (linkScanners.length > 0) { //TODO: support multiple scanners by picking the scanner with the first match var linkScanner = linkScanners[0]; var pattern = new RegExp(linkScanner.getProperty("pattern"), "i"); //$NON-NLS-1$ //$NON-NLS-0$ var words= linkScanner.getProperty("words"); //$NON-NLS-0$ var anchor = linkScanner.getProperty("anchor"); //$NON-NLS-0$ var index = text.search(pattern); while (index >= 0) { text = this._replaceLink(text, result, pattern, words, anchor); index = text.search(pattern); } } //append a text node for any remaining text if (text.length > 0) { result.appendChild(document.createTextNode(text)); } return result; }
javascript
{ "resource": "" }
q43953
train
function(slideoutViewMode) { this._previousActiveElement = document.activeElement; lib.trapTabs(this._wrapperNode); // replace _contentNode's contents if (this._currentViewMode !== slideoutViewMode) { lib.empty(this._contentNode); this._contentNode.appendChild(slideoutViewMode.getWrapperNode()); this._currentViewMode = slideoutViewMode; } if (this._visibilityTransitionTimeout) { this._wrapperNode.classList.remove("slideoutWrapperHiding"); //$NON-NLS-0$ window.clearTimeout(this._visibilityTransitionTimeout); this._visibilityTransitionTimeout = null; } this._wrapperNode.classList.add("slideoutWrapperVisible"); //$NON-NLS-0$ }
javascript
{ "resource": "" }
q43954
train
function() { lib.returnFocus(this._wrapperNode, this._previousActiveElement); this._previousActiveElement = null; this._wrapperNode.classList.remove("slideoutWrapperVisible"); //$NON-NLS-0$ this._wrapperNode.classList.add("slideoutWrapperHiding"); //$NON-NLS-0$ this._visibilityTransitionTimeout = window.setTimeout(function() { this._visibilityTransitionTimeout = null; this._wrapperNode.classList.remove("slideoutWrapperHiding"); //$NON-NLS-0$ }.bind(this), VISIBILITY_TRANSITION_MS); }
javascript
{ "resource": "" }
q43955
train
function(relatedLinks, exclusions) { this._categorizedRelatedLinks = {}; relatedLinks.forEach(function(info) { var relatedLink = info.relatedLink; var command = info.command; var invocation = info.invocation; if (!exclusions || exclusions.indexOf(relatedLink.id) === -1) { var category = relatedLink.category; this._categorizedRelatedLinks[category] = this._categorizedRelatedLinks[category] || []; this._categorizedRelatedLinks[category].push({ title: command.name, order: relatedLink.order || 100, href: command.hrefCallback.call(invocation.handler, invocation) }); } }, this); this._updateCategoryAnchors(); this._updateCategoryNotifications(); }
javascript
{ "resource": "" }
q43956
getCategoriesInfo
train
function getCategoriesInfo(serviceRegistry) { // Read categories. var categoryInfos; if (!_cachedCategories) { categoryInfos = []; var navLinkCategories = serviceRegistry.getServiceReferences("orion.page.link.category"); //$NON-NLS-0$ navLinkCategories.forEach(function(serviceRef) { var info = _getPropertiesMap(serviceRef); if (!info.id || (!info.name && !info.nameKey)) { return; } info.service = serviceRegistry.getService(serviceRef); info.textContent = info.name; categoryInfos.push(new Deferred().resolve(info)); }); return Deferred.all(categoryInfos).then(function(infos) { _cachedCategories = new CategoriesInfo(infos); return _cachedCategories; }); } return new Deferred().resolve(_cachedCategories); }
javascript
{ "resource": "" }
q43957
makeSegments
train
function makeSegments(context, begin, end, create) { var list = context.segmentsList; if (begin < 0) { begin = list.length + begin; } if (end < 0) { end = list.length + end; } var segments = []; for (var i = 0; i < context.count; ++i) { var allPrevSegments = []; for (var j = begin; j <= end; ++j) { allPrevSegments.push(list[j][i]); } segments.push(create(context.idGenerator.next(), allPrevSegments)); } return segments; }
javascript
{ "resource": "" }
q43958
train
function(context) { var source = context.segmentsList; for (var i = 0; i < source.length; ++i) { this.segmentsList.push(source[i]); } }
javascript
{ "resource": "" }
q43959
train
function(location, users) { // Remove trailing "/" if(location.substr(-1) === '/') { location = location.substr(0, location.length - 1); } this.location = location; console.assert(Array.isArray(users)); this.users = users; }
javascript
{ "resource": "" }
q43960
deepCopy
train
function deepCopy(obj) { var ret = {}, key, val; for (key in obj) { if (obj.hasOwnProperty(key)) { val = obj[key]; if (typeof val === 'object' && val !== null) { ret[key] = deepCopy(val); } else { ret[key] = val; } } } return ret; }
javascript
{ "resource": "" }
q43961
report
train
function report(node) { var nodeParent = node.parent; // memberexpression context.report( nodeParent.property, ProblemMessages.noExtraBind); }
javascript
{ "resource": "" }
q43962
getPropertyName
train
function getPropertyName(node) { if (node.computed) { switch (node.property.type) { case "Literal": return String(node.property.value); case "TemplateLiteral": if (node.property.expressions.length === 0) { return node.property.quasis[0].value.cooked; } // fallthrough default: return false; } } return node.property.name; }
javascript
{ "resource": "" }
q43963
enterFunction
train
function enterFunction(node) { scopeInfo = { isBound: isCalleeOfBindMethod(node), thisFound: false, upper: scopeInfo }; }
javascript
{ "resource": "" }
q43964
load
train
function load() { Object.keys(envs).forEach(function(envName) { environments[envName] = envs[envName]; }); }
javascript
{ "resource": "" }
q43965
train
function(plugin, pluginName) { if (plugin.environments) { Object.keys(plugin.environments).forEach(function(envName) { this.define(pluginName + "/" + envName, plugin.environments[envName]); }, this); } }
javascript
{ "resource": "" }
q43966
each
train
function each(ary, func) { if (ary) { var i; for (i = 0; i < ary.length; i += 1) { if (ary[i] && func(ary[i], i, ary)) { break; } } } }
javascript
{ "resource": "" }
q43967
getGlobal
train
function getGlobal(value) { if (!value) { return value; } var g = global; each(value.split('.'), function (part) { g = g[part]; }); return g; }
javascript
{ "resource": "" }
q43968
train
function (depMap) { var mod = getOwn(registry, depMap.id); if (mod) { getModule(depMap).enable(); } }
javascript
{ "resource": "" }
q43969
getUserMetadataFileName
train
function getUserMetadataFileName(options, user) { let userId; if(typeof user === "string") { userId = user; } else if(user && typeof user.username === 'string') { userId = user.username; } else { return null; } return nodePath.join(getUserRootLocation(options, userId), FILENAME_USER_METADATA); }
javascript
{ "resource": "" }
q43970
FsMetastore
train
function FsMetastore(options) { this._options = options; this._taskList = {}; this._lockMap = {}; this._isSingleUser = !!options.configParams.get('orion.single.user'); this._isFormAuthType = options.configParams.get('orion.auth.name') === 'FORM+OAuth'; }
javascript
{ "resource": "" }
q43971
train
function(workspaceId, workspacedata, callback) { var userId = metaUtil.decodeUserIdFromWorkspaceId(workspaceId); Promise.using(this.lock(userId, false), function() { return new Promise(function(resolve, reject) { this._readWorkspaceMetadata(workspaceId, function(error, metadata) { if (error) { return reject(error); } if (typeof workspacedata === "function") { workspacedata = workspacedata(this._convertWorkspace(metadata)); if (!workspacedata) { return resolve(); } } //TODO other properties metadata.Properties = workspacedata.properties; this._updateWorkspaceMetadata(workspaceId, metadata, function(error) { if (error) { return reject(error); } resolve(); }); }.bind(this)); }.bind(this)); }.bind(this)).then( function(result) { callback(null, result); }, callback /* error case */ ); }
javascript
{ "resource": "" }
q43972
train
function(id, callback) { if(this._options.configParams.get('orion.single.user')) { return callback(new Error("The default user cannot be deleted in single user mode")); } let userLocation = getUserRootLocation(this._options, id); fs.access(userLocation, (err) => { if(err) { return callback(err); } rimraf(userLocation, (err) => { if(err) { return callback(err); } callback(); }); }); }
javascript
{ "resource": "" }
q43973
Traverser
train
function Traverser() { var controller = Object.create(new estraverse.Controller()), originalTraverse = controller.traverse; // intercept call to traverse() and add the fallback key to the visitor controller.traverse = function(node, visitor) { visitor.fallback = Traverser.getKeys; return originalTraverse.call(this, node, visitor); }; return controller; }
javascript
{ "resource": "" }
q43974
addProjectToUser
train
function addProjectToUser(user, project) { return addUser(user) .then(function(doc) { return userProject.findOneAndUpdate({username: user}, {$addToSet: {'sharedProjects': project} }, { safe: true, w: 'majority' }).exec(); }); }
javascript
{ "resource": "" }
q43975
removeProjectFromUser
train
function removeProjectFromUser(user, project) { return userProject.findOneAndUpdate({username: user}, {$pull: {'sharedProjects': { $in: [project]}} }, { safe: true, w: 'majority' }).exec(); }
javascript
{ "resource": "" }
q43976
getUserSharedProjects
train
function getUserSharedProjects(user) { return userProject.findOne({'username': user}, 'sharedProjects') .then(function(doc) { if (!doc) { return undefined; } var projects = doc.sharedProjects; projects = projects.map(function(project) { var name = path.win32.basename(project); return {'Name': name, 'Location': project}; }); return projects; }); }
javascript
{ "resource": "" }
q43977
makeLooped
train
function makeLooped(state, fromSegments, toSegments) { var end = Math.min(fromSegments.length, toSegments.length); for (var i = 0; i < end; ++i) { var fromSegment = fromSegments[i]; var toSegment = toSegments[i]; if (toSegment.reachable) { fromSegment.nextSegments.push(toSegment); } if (fromSegment.reachable) { toSegment.prevSegments.push(fromSegment); } fromSegment.allNextSegments.push(toSegment); toSegment.allPrevSegments.push(fromSegment); if (toSegment.allPrevSegments.length >= 2) { CodePathSegment.markPrevSegmentAsLooped(toSegment, fromSegment); } state.notifyLooped(fromSegment, toSegment); } }
javascript
{ "resource": "" }
q43978
train
function() { var lastContext = this.forkContext; this.forkContext = lastContext.upper; this.forkContext.replaceHead(lastContext.makeNext(0, -1)); return lastContext; }
javascript
{ "resource": "" }
q43979
train
function() { var context = this.choiceContext; this.choiceContext = context.upper; var forkContext = this.forkContext; var headSegments = forkContext.head; switch (context.kind) { case "&&": case "||": /* * If any result were not transferred from child contexts, * this sets the head segments to both cases. * The head segments are the path of the right-hand operand. */ if (!context.processed) { context.trueForkContext.add(headSegments); context.falseForkContext.add(headSegments); } /* * Transfers results to upper context if this context is in * test chunk. */ if (context.isForkingAsResult) { var parentContext = this.choiceContext; parentContext.trueForkContext.addAll(context.trueForkContext); parentContext.falseForkContext.addAll(context.falseForkContext); parentContext.processed = true; return context; } break; case "test": if (!context.processed) { /* * The head segments are the path of the `if` block here. * Updates the `true` path with the end of the `if` block. */ context.trueForkContext.clear(); context.trueForkContext.add(headSegments); } else { /* * The head segments are the path of the `else` block here. * Updates the `false` path with the end of the `else` * block. */ context.falseForkContext.clear(); context.falseForkContext.add(headSegments); } break; case "loop": /* * Loops are addressed in popLoopContext(). * This is called from popLoopContext(). */ return context; /* istanbul ignore next */ default: throw new Error("unreachable"); } // Merges all paths. var prevForkContext = context.trueForkContext; prevForkContext.addAll(context.falseForkContext); forkContext.replaceHead(prevForkContext.makeNext(0, -1)); return context; }
javascript
{ "resource": "" }
q43980
train
function() { var context = this.choiceContext; var forkContext = this.forkContext; if (context.processed) { /* * This got segments already from the child choice context. * Creates the next path from own true/false fork context. */ var prevForkContext = context.kind === "&&" ? context.trueForkContext : /* kind === "||" */ context.falseForkContext; forkContext.replaceHead(prevForkContext.makeNext(0, -1)); prevForkContext.clear(); context.processed = false; } else { /* * This did not get segments from the child choice context. * So addresses the head segments. * The head segments are the path of the left-hand operand. */ if (context.kind === "&&") { // The path does short-circuit if false. context.falseForkContext.add(forkContext.head); } else { // The path does short-circuit if true. context.trueForkContext.add(forkContext.head); } forkContext.replaceHead(forkContext.makeNext(-1, -1)); } }
javascript
{ "resource": "" }
q43981
train
function() { var context = this.choiceContext; var forkContext = this.forkContext; /* * If any result were not transferred from child contexts, * this sets the head segments to both cases. * The head segments are the path of the test expression. */ if (!context.processed) { context.trueForkContext.add(forkContext.head); context.falseForkContext.add(forkContext.head); } context.processed = false; // Creates new path from the `true` case. forkContext.replaceHead( context.trueForkContext.makeNext(0, -1) ); }
javascript
{ "resource": "" }
q43982
train
function() { var context = this.choiceContext; var forkContext = this.forkContext; /* * The head segments are the path of the `if` block. * Updates the `true` path with the end of the `if` block. */ context.trueForkContext.clear(); context.trueForkContext.add(forkContext.head); context.processed = true; // Creates new path from the `false` case. forkContext.replaceHead( context.falseForkContext.makeNext(0, -1) ); }
javascript
{ "resource": "" }
q43983
train
function() { var context = this.switchContext; this.switchContext = context.upper; var forkContext = this.forkContext; var brokenForkContext = this.popBreakContext().brokenForkContext; if (context.countForks === 0) { /* * When there is only one `default` chunk and there is one or more * `break` statements, even if forks are nothing, it needs to merge * those. */ if (!brokenForkContext.empty) { brokenForkContext.add(forkContext.makeNext(-1, -1)); forkContext.replaceHead(brokenForkContext.makeNext(0, -1)); } return; } var lastSegments = forkContext.head; this.forkBypassPath(); var lastCaseSegments = forkContext.head; /* * `brokenForkContext` is used to make the next segment. * It must add the last segment into `brokenForkContext`. */ brokenForkContext.add(lastSegments); /* * A path which is failed in all case test should be connected to path * of `default` chunk. */ if (!context.lastIsDefault) { if (context.defaultBodySegments) { /* * Remove a link from `default` label to its chunk. * It's false route. */ removeConnection(context.defaultSegments, context.defaultBodySegments); makeLooped(this, lastCaseSegments, context.defaultBodySegments); } else { /* * It handles the last case body as broken if `default` chunk * does not exist. */ brokenForkContext.add(lastCaseSegments); } } // Pops the segment context stack until the entry segment. for (var i = 0; i < context.countForks; ++i) { this.forkContext = this.forkContext.upper; } /* * Creates a path from all brokenForkContext paths. * This is a path after switch statement. */ this.forkContext.replaceHead(brokenForkContext.makeNext(0, -1)); }
javascript
{ "resource": "" }
q43984
train
function(isEmpty, isDefault) { var context = this.switchContext; if (!context.hasCase) { return; } /* * Merge forks. * The parent fork context has two segments. * Those are from the current case and the body of the previous case. */ var parentForkContext = this.forkContext; var forkContext = this.pushForkContext(); forkContext.add(parentForkContext.makeNext(0, -1)); /* * Save `default` chunk info. * If the `default` label is not at the last, we must make a path from * the last `case` to the `default` chunk. */ if (isDefault) { context.defaultSegments = parentForkContext.head; if (isEmpty) { context.foundDefault = true; } else { context.defaultBodySegments = forkContext.head; } } else { if (!isEmpty && context.foundDefault) { context.foundDefault = false; context.defaultBodySegments = forkContext.head; } } context.lastIsDefault = isDefault; context.countForks += 1; }
javascript
{ "resource": "" }
q43985
train
function() { var context = this.tryContext; this.tryContext = context.upper; if (context.position === "catch") { // Merges two paths from the `try` block and `catch` block merely. this.popForkContext(); return; } /* * The following process is executed only when there is the `finally` * block. */ var returned = context.returnedForkContext; var thrown = context.thrownForkContext; if (returned.empty && thrown.empty) { return; } // Separate head to normal paths and leaving paths. var headSegments = this.forkContext.head; this.forkContext = this.forkContext.upper; var normalSegments = headSegments.slice(0, headSegments.length / 2 | 0); var leavingSegments = headSegments.slice(headSegments.length / 2 | 0); // Forwards the leaving path to upper contexts. if (!returned.empty) { getReturnContext(this).returnedForkContext.add(leavingSegments); } if (!thrown.empty) { getThrowContext(this).thrownForkContext.add(leavingSegments); } // Sets the normal path as the next. this.forkContext.replaceHead(normalSegments); // If both paths of the `try` block and the `catch` block are // unreachable, the next path becomes unreachable as well. if (!context.lastOfTryIsReachable && !context.lastOfCatchIsReachable) { this.forkContext.makeUnreachable(); } }
javascript
{ "resource": "" }
q43986
train
function() { var context = this.tryContext; var forkContext = this.forkContext; var thrown = context.thrownForkContext; // Update state. context.position = "catch"; context.thrownForkContext = ForkContext.newEmpty(forkContext); context.lastOfTryIsReachable = forkContext.reachable; // Merge thrown paths. thrown.add(forkContext.head); var thrownSegments = thrown.makeNext(0, -1); // Fork to a bypass and the merged thrown path. this.pushForkContext(); this.forkBypassPath(); this.forkContext.add(thrownSegments); }
javascript
{ "resource": "" }
q43987
train
function() { var context = this.tryContext; var forkContext = this.forkContext; var returned = context.returnedForkContext; var thrown = context.thrownForkContext; var headOfLeavingSegments = forkContext.head; // Update state. if (context.position === "catch") { // Merges two paths from the `try` block and `catch` block. this.popForkContext(); forkContext = this.forkContext; context.lastOfCatchIsReachable = forkContext.reachable; } else { context.lastOfTryIsReachable = forkContext.reachable; } context.position = "finally"; if (returned.empty && thrown.empty) { // This path does not leave. return; } /* * Create a parallel segment from merging returned and thrown. * This segment will leave at the end of this finally block. */ var segments = forkContext.makeNext(-1, -1); var j; for (var i = 0; i < forkContext.count; ++i) { var prevSegsOfLeavingSegment = [headOfLeavingSegments[i]]; for (j = 0; j < returned.segmentsList.length; ++j) { prevSegsOfLeavingSegment.push(returned.segmentsList[j][i]); } for (j = 0; j < thrown.segmentsList.length; ++j) { prevSegsOfLeavingSegment.push(thrown.segmentsList[j][i]); } segments.push(CodePathSegment.newNext( this.idGenerator.next(), prevSegsOfLeavingSegment)); } this.pushForkContext(true); this.forkContext.add(segments); }
javascript
{ "resource": "" }
q43988
train
function() { var forkContext = this.forkContext; if (!forkContext.reachable) { return; } var context = getThrowContext(this); if (context === this || context.position !== "try" || !context.thrownForkContext.empty ) { return; } context.thrownForkContext.add(forkContext.head); forkContext.replaceHead(forkContext.makeNext(-1, -1)); }
javascript
{ "resource": "" }
q43989
train
function() { var context = this.loopContext; this.loopContext = context.upper; var forkContext = this.forkContext; var brokenForkContext = this.popBreakContext().brokenForkContext; var choiceContext; // Creates a looped path. switch (context.type) { case "WhileStatement": case "ForStatement": choiceContext = this.popChoiceContext(); makeLooped( this, forkContext.head, context.continueDestSegments); break; case "DoWhileStatement": choiceContext = this.popChoiceContext(); if (!choiceContext.processed) { choiceContext.trueForkContext.add(forkContext.head); choiceContext.falseForkContext.add(forkContext.head); } if (context.test !== true) { brokenForkContext.addAll(choiceContext.falseForkContext); } // `true` paths go to looping. var segmentsList = choiceContext.trueForkContext.segmentsList; for (var i = 0; i < segmentsList.length; ++i) { makeLooped( this, segmentsList[i], context.entrySegments); } break; case "ForInStatement": case "ForOfStatement": brokenForkContext.add(forkContext.head); makeLooped( this, forkContext.head, context.leftSegments); break; /* istanbul ignore next */ default: throw new Error("unreachable"); } // Go next. if (brokenForkContext.empty) { forkContext.replaceHead(forkContext.makeUnreachable(-1, -1)); } else { forkContext.replaceHead(brokenForkContext.makeNext(0, -1)); } }
javascript
{ "resource": "" }
q43990
train
function(test) { var context = this.loopContext; var forkContext = this.forkContext; var testSegments = forkContext.makeNext(0, -1); // Update state. context.test = test; context.continueDestSegments = testSegments; forkContext.replaceHead(testSegments); }
javascript
{ "resource": "" }
q43991
train
function() { var context = this.loopContext; var choiceContext = this.choiceContext; var forkContext = this.forkContext; if (!choiceContext.processed) { choiceContext.trueForkContext.add(forkContext.head); choiceContext.falseForkContext.add(forkContext.head); } // Update state. if (context.test !== true) { context.brokenForkContext.addAll(choiceContext.falseForkContext); } forkContext.replaceHead(choiceContext.trueForkContext.makeNext(0, -1)); }
javascript
{ "resource": "" }
q43992
train
function() { var context = this.loopContext; var forkContext = this.forkContext; var bodySegments = forkContext.makeNext(-1, -1); // Update state. context.entrySegments = bodySegments; forkContext.replaceHead(bodySegments); }
javascript
{ "resource": "" }
q43993
train
function(test) { var context = this.loopContext; var forkContext = this.forkContext; context.test = test; // Creates paths of `continue` statements. if (!context.continueForkContext.empty) { context.continueForkContext.add(forkContext.head); var testSegments = context.continueForkContext.makeNext(0, -1); forkContext.replaceHead(testSegments); } }
javascript
{ "resource": "" }
q43994
train
function(test) { var context = this.loopContext; var forkContext = this.forkContext; var endOfInitSegments = forkContext.head; var testSegments = forkContext.makeNext(-1, -1); // Update state. context.test = test; context.endOfInitSegments = endOfInitSegments; context.continueDestSegments = context.testSegments = testSegments; forkContext.replaceHead(testSegments); }
javascript
{ "resource": "" }
q43995
train
function() { var context = this.loopContext; var choiceContext = this.choiceContext; var forkContext = this.forkContext; // Make the next paths of the test. if (context.testSegments) { finalizeTestSegmentsOfFor( context, choiceContext, forkContext.head); } else { context.endOfInitSegments = forkContext.head; } // Update state. var updateSegments = forkContext.makeDisconnected(-1, -1); context.continueDestSegments = context.updateSegments = updateSegments; forkContext.replaceHead(updateSegments); }
javascript
{ "resource": "" }
q43996
train
function() { var context = this.loopContext; var choiceContext = this.choiceContext; var forkContext = this.forkContext; // Update state. if (context.updateSegments) { context.endOfUpdateSegments = forkContext.head; // `update` -> `test` if (context.testSegments) { makeLooped( this, context.endOfUpdateSegments, context.testSegments); } } else if (context.testSegments) { finalizeTestSegmentsOfFor( context, choiceContext, forkContext.head); } else { context.endOfInitSegments = forkContext.head; } var bodySegments = context.endOfTestSegments; if (!bodySegments) { /* * If there is not the `test` part, the `body` path comes from the * `init` part and the `update` part. */ var prevForkContext = ForkContext.newEmpty(forkContext); prevForkContext.add(context.endOfInitSegments); if (context.endOfUpdateSegments) { prevForkContext.add(context.endOfUpdateSegments); } bodySegments = prevForkContext.makeNext(0, -1); } context.continueDestSegments = context.continueDestSegments || bodySegments; forkContext.replaceHead(bodySegments); }
javascript
{ "resource": "" }
q43997
train
function() { var context = this.loopContext; var forkContext = this.forkContext; var leftSegments = forkContext.makeDisconnected(-1, -1); // Update state. context.prevSegments = forkContext.head; context.leftSegments = context.continueDestSegments = leftSegments; forkContext.replaceHead(leftSegments); }
javascript
{ "resource": "" }
q43998
train
function() { var context = this.loopContext; var forkContext = this.forkContext; var temp = ForkContext.newEmpty(forkContext); temp.add(context.prevSegments); var rightSegments = temp.makeNext(-1, -1); // Update state. context.endOfLeftSegments = forkContext.head; forkContext.replaceHead(rightSegments); }
javascript
{ "resource": "" }
q43999
train
function() { var context = this.loopContext; var forkContext = this.forkContext; var temp = ForkContext.newEmpty(forkContext); temp.add(context.endOfLeftSegments); var bodySegments = temp.makeNext(-1, -1); // Make a path: `right` -> `left`. makeLooped(this, forkContext.head, context.leftSegments); // Update state. context.brokenForkContext.add(forkContext.head); forkContext.replaceHead(bodySegments); }
javascript
{ "resource": "" }