_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q29200
train
function(onDone) { var result = Array.isArray(this._selections) ? this._selections.slice() : []; if (typeof onDone === "function") { //$NON-NLS-0$ onDone(result); } return result; }
javascript
{ "resource": "" }
q29201
inherits
train
function inherits(ctor, sctor) { ctor.prototype = Object.create(sctor.prototype); ctor._super = sctor; }
javascript
{ "resource": "" }
q29202
train
function(type, listener, useCapture) { if (!this._eventTypes) { this._eventTypes = {}; } var state = this._eventTypes[type]; if (!state) { state = this._eventTypes[type] = {level: 0, listeners: []}; } var listeners = state.listeners; listeners.push({listener: listener, useCapture: useCapture}); }
javascript
{ "resource": "" }
q29203
train
function(mouseEvent /* optional */) { var actionTaken = false; if (!this.isVisible()) { this.dispatchEvent({type: "triggered", dropdown: this, event: mouseEvent}); //$NON-NLS-0$ if (this._populate) { this.empty(); this._populate(this._dropdownNode); } var items = this.getItems(); if (items.length > 0) { lib.setFramesEnabled(false); if (this._boundAutoDismiss) { lib.removeAutoDismiss(this._boundAutoDismiss); } this._boundAutoDismiss = this._autoDismiss.bind(this); this._triggerNode.classList.add("dropdownTriggerOpen"); //$NON-NLS-0$ this._triggerNode.setAttribute("aria-expanded", "true"); //$NON-NLS-1$ //$NON-NLS-0$ if (this._selectionClass) { this._triggerNode.classList.add(this._selectionClass); } this._dropdownNode.classList.add("dropdownMenuOpen"); //$NON-NLS-0$ this._isVisible = true; if (this._dropdownNode.scrollHeight > this._dropdownNode.offsetHeight) { this._buttonsAdded = addScrollButtons.call(this); } // add auto dismiss. Clicking anywhere but trigger or a submenu item means close. var submenuNodes = lib.$$array(".dropdownSubMenu", this._dropdownNode); //$NON-NLS-0$ var list = [this._triggerNode].concat(submenuNodes); if (this._buttonsAdded) { list.push(this._topScrollButton); list.push(this._bottomScrollButton); } lib.addAutoDismiss(list, this._boundAutoDismiss); this._positionDropdown(mouseEvent); if (this._buttonsAdded) { positionScrollButtons.call(this); } this._focusDropdownNode(); actionTaken = true; if (this._parentDropdown) { this._parentDropdown.submenuOpen(this); } if (this._trapTabs) { lib.trapTabs(this._dropdownNode); } } } return actionTaken; }
javascript
{ "resource": "" }
q29204
train
function(mouseEvent) {//Sub classes can override this to position the drop down differently. this._dropdownNode.style.left = ""; this._dropdownNode.style.top = ""; if(this._positioningNode) { this._dropdownNode.style.left = this._positioningNode.offsetLeft + "px"; return; } var bounds = lib.bounds(this._dropdownNode); var bodyBounds = lib.bounds(document.body); if (bounds.left + bounds.width > (bodyBounds.left + bodyBounds.width)) { if (this._triggerNode.classList.contains("dropdownMenuItem")) { //$NON-NLS-0$ this._dropdownNode.style.left = -bounds.width + "px"; //$NON-NLS-0$ } else { var totalBounds = lib.bounds(this._boundingNode(this._triggerNode)); var triggerBounds = lib.bounds(this._triggerNode); this._dropdownNode.style.left = (triggerBounds.left - totalBounds.left - bounds.width + triggerBounds.width) + "px"; //$NON-NLS-0$ } } //ensure menu fits on page vertically var overflowY = (bounds.top + bounds.height) - (bodyBounds.top + bodyBounds.height); if (0 < overflowY) { this._dropdownNode.style.top = Math.floor(this._dropdownNode.style.top - overflowY) + "px"; //$NON-NLS-0$ } }
javascript
{ "resource": "" }
q29205
train
function(restoreFocus) { var actionTaken = false; if (this.isVisible()) { this._triggerNode.classList.remove("dropdownTriggerOpen"); //$NON-NLS-0$ this._triggerNode.setAttribute("aria-expanded", "false"); //$NON-NLS-1$ //$NON-NLS-0$ if (this._selectionClass) { this._triggerNode.classList.remove(this._selectionClass); } this._dropdownNode.classList.remove("dropdownMenuOpen"); //$NON-NLS-0$ lib.setFramesEnabled(true); if (restoreFocus) { lib.returnFocus(this._dropdownNode, this._triggerNode); } this._isVisible = false; if (this._selectedItem) { this._selectedItem.classList.remove("dropdownMenuItemSelected"); //$NON-NLS-0$ this._selectedItem = null; } if (this._boundAutoDismiss) { lib.removeAutoDismiss(this._boundAutoDismiss); this._boundAutoDismiss = null; } updateScrollButtonVisibility.call(this, true); actionTaken = true; } return actionTaken; }
javascript
{ "resource": "" }
q29206
train
function(item, direction, select) { while (item.parentNode && (document !== item.parentNode) && item.parentNode.getAttribute("role") !== "menubar") { item = item.parentNode; } if (!item.parentNode || document === item.parentNode) { return; // item is not in a menubar } var trigger = item.childNodes[0]; var menuBar = item.parentNode; var mbItems = menuBar.dropdown.getItems(); var mbItem = null; for (var i = 0; i < mbItems.length; i++) { if (mbItems[i] === trigger) { if (direction === lib.KEY.LEFT) { mbItem = i > 0 ? mbItems[i - 1] : mbItems[mbItems.length - 1]; } else { mbItem = i < mbItems.length - 1 ? mbItems[i + 1] : mbItems[0]; } break; } } trigger.dropdown._closeSelectedSubmenu(); trigger.dropdown.close(false); if (mbItem) { mbItem.dropdown.open(); if (select) { mbItem.dropdown._selectItem(); } } }
javascript
{ "resource": "" }
q29207
train
function(item) { var itemToSelect = item || this.getItems()[0]; if (itemToSelect) { if (this._selectedItem) { this._selectedItem.classList.remove("dropdownMenuItemSelected"); //$NON-NLS-0$ } this._selectedItem = itemToSelect; this._selectedItem.classList.add("dropdownMenuItemSelected"); //$NON-NLS-0$ this._selectedItem.focus(); if (this._buttonsAdded) { var itemBounds = this._selectedItem.getBoundingClientRect(); var menuBounds = this._dropdownNode.getBoundingClientRect(); if (this._selectedItem.offsetTop < this._dropdownNode.scrollTop) { this._selectedItem.scrollIntoView(true); if (this._dropdownNode.scrollTop < 5) { this._dropdownNode.scrollTop = 0; } } else if (itemBounds.bottom > menuBounds.bottom) { this._selectedItem.scrollIntoView(false); if ((this._dropdownNode.scrollHeight - this._dropdownNode.scrollTop - this._dropdownNode.clientHeight) < 5) { this._dropdownNode.scrollTop = this._dropdownNode.scrollHeight - this._dropdownNode.clientHeight; } } updateScrollButtonVisibility.call(this); } } }
javascript
{ "resource": "" }
q29208
train
function(text, innerNodeType) { var li = createMenuItem(text, innerNodeType); this._dropdownNode.appendChild(li); return li; }
javascript
{ "resource": "" }
q29209
createMenuItem
train
function createMenuItem(text, innerNodeType) { innerNodeType = innerNodeType === undefined ? "span" : innerNodeType; //$NON-NLS-0$ var element = document.createElement(innerNodeType); //$NON-NLS-0$ element.className = "dropdownMenuItem"; //$NON-NLS-0$ element.setAttribute("role", "menuitem"); //$NON-NLS-0$ //$NON-NLS-1$ element.tabIndex = -1; element.style.outline = "none"; if (text) { var span = document.createElement("span"); //$NON-NLS-0$ span.appendChild(document.createTextNode(text)); span.classList.add("dropdownCommandName"); //$NON-NLS-0$ element.appendChild(span); } var li = document.createElement("li"); //$NON-NLS-0$ li.setAttribute("role", "none"); //$NON-NLS-0$ //$NON-NLS-1$ li.appendChild(element); //$NON-NLS-0$ return li; }
javascript
{ "resource": "" }
q29210
appendKeyBindingString
train
function appendKeyBindingString(element, keyBindingString) { var span = document.createElement("span"); //$NON-NLS-0$ span.classList.add("dropdownKeyBinding"); //$NON-NLS-0$ span.appendChild(document.createTextNode(keyBindingString)); element.appendChild(span); }
javascript
{ "resource": "" }
q29211
addScrollButtons
train
function addScrollButtons() { var dropdown = this; if(!this._topScrollButton && !this._bottomScrollButton) { // if scroll buttons haven't been made yet this._topScrollButton = document.createElement("button"); this._bottomScrollButton = document.createElement("button"); this._topScrollButton.classList.add("menuScrollButton", "menuTopScrollButton", "core-sprite-openarrow"); this._bottomScrollButton.classList.add("menuScrollButton", "menuBottomScrollButton", "core-sprite-openarrow"); this._topScrollButton.addEventListener("mousedown", function(evt){ //$NON-NLS-0$ if (this._activeScrollInterval) { window.clearInterval(this._activeScrollInterval); } this._activeScrollInterval = window.setInterval(scrollUp.bind(null, evt.shiftKey ? 20 : 2), 10); }.bind(this)); this._topScrollButton.addEventListener("mouseup", function(){ //$NON-NLS-0$ if (this._activeScrollInterval) { window.clearInterval(this._activeScrollInterval); this._activeScrollInterval = null; } }.bind(this)); this._bottomScrollButton.addEventListener("mousedown", function(evt){ //$NON-NLS-0$ if (this._activeScrollInterval) { window.clearInterval(this._activeScrollInterval); } this._activeScrollInterval = window.setInterval(scrollDown.bind(null, evt.shiftKey ? 20 : 2), 10); }.bind(this)); this._bottomScrollButton.addEventListener("mouseup", function(){ //$NON-NLS-0$ if (this._activeScrollInterval) { window.clearInterval(this._activeScrollInterval); this._activeScrollInterval = null; } }.bind(this)); this._dropdownNode.parentNode.insertBefore(this._topScrollButton, this._dropdownNode); this._dropdownNode.parentNode.insertBefore(this._bottomScrollButton, this._dropdownNode.nextElementSibling); this._dropdownNode.style.overflow = "hidden"; } updateScrollButtonVisibility.call(this); return true; function scrollDown(increment) { dropdown._dropdownNode.scrollTop+=increment; updateScrollButtonVisibility.call(dropdown); } function scrollUp(increment) { dropdown._dropdownNode.scrollTop-=increment; updateScrollButtonVisibility.call(dropdown); } }
javascript
{ "resource": "" }
q29212
updateScrollButtonVisibility
train
function updateScrollButtonVisibility(hideAll) { if (hideAll && this._topScrollButton && this._bottomScrollButton) { this._topScrollButton.style.display = "none"; this._bottomScrollButton.style.display = "none"; } else if (!hideAll) { if (this._dropdownNode.scrollTop > 0) { this._topScrollButton.style.display = "block"; } else { this._topScrollButton.style.display = "none"; } if (this._dropdownNode.scrollHeight > this._dropdownNode.scrollTop + this._dropdownNode.offsetHeight) { this._bottomScrollButton.style.display = "block"; } else { this._bottomScrollButton.style.display = "none"; } } }
javascript
{ "resource": "" }
q29213
positionScrollButtons
train
function positionScrollButtons() { this._topScrollButton.style.width = this._dropdownNode.clientWidth + 1 + "px"; this._bottomScrollButton.style.width = this._dropdownNode.clientWidth + 1 + "px"; this._topScrollButton.style.top = this._dropdownNode.style.top; this._topScrollButton.style.left = this._topScrollButton.parentNode.clientWidth + "px"; this._bottomScrollButton.style.top = Number(this._dropdownNode.style.top.replace("px", "")) + (this._dropdownNode.clientHeight-this._bottomScrollButton.clientHeight + 1)+"px"; this._bottomScrollButton.style.left = this._bottomScrollButton.parentNode.clientWidth + "px"; }
javascript
{ "resource": "" }
q29214
train
function (text, type, args, isRtl, locale) { return getHandler(type).format(text, args, isRtl, true, locale); }
javascript
{ "resource": "" }
q29215
train
function (element, type, args, isRtl, locale) { return attachElement(element, type, args, isRtl, locale); }
javascript
{ "resource": "" }
q29216
train
function(env) { var envConfig = this.createEmptyConfig(); if (env) { envConfig.env = env; Object.keys(env).filter(function(name) { return env[name]; }).forEach(function(name) { var environment = Environments.name; if (environment) { if (environment.globals) { assign(envConfig.globals, environment.globals); } if (environment.parserOptions) { assign(envConfig.parserOptions, environment.parserOptions); } } }); } return envConfig; }
javascript
{ "resource": "" }
q29217
train
function(config) { if (config.env && typeof config.env === "object") { return this.merge(this.createEnvironmentConfig(config.env), config); } return config; }
javascript
{ "resource": "" }
q29218
train
function(ruleConfig) { var severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig; if (typeof severity === "string") { severity = RULE_SEVERITY[severity.toLowerCase()] || 0; } return typeof severity === "number" && severity === 2; }
javascript
{ "resource": "" }
q29219
train
function(ruleConfig) { var severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig; if (typeof severity === "string") { severity = severity.toLowerCase(); } return VALID_SEVERITIES.indexOf(severity) !== -1; }
javascript
{ "resource": "" }
q29220
train
function(promise, result, output, isProgress) { var element = document.createElement("div"); //$NON-NLS-0$ var waitCount = 0; var successFn = function(file) { this.callback = function() { var string = i18nUtil.formatMessage( messages["WroteMsg"], typeof(file) === "string" ? file : this.shellPageFileService.computePathString(file)); //$NON-NLS-0$ var writer = new mResultWriters.ShellStringWriter(element); writer.write(string + "\n"); //$NON-NLS-0$ if (--waitCount !== 0 || isProgress) { promise.progress(element); } else { promise.resolve(element); } }.bind(this); return this; }.bind(this); var errorFn = function(file) { this.callback = function(error) { var string = i18nUtil.formatMessage( messages["WriteFailMsg"], typeof(file) === "string" ? file : this.shellPageFileService.computePathString(file)); //$NON-NLS-0$ string += " [" + error + "]"; //$NON-NLS-1$ //$NON-NLS-0$ var writer = new mResultWriters.ShellStringWriter(element); writer.write(string + "\n"); //$NON-NLS-0$ if (--waitCount !== 0 || isProgress) { promise.progress(element); } else { promise.resolve(element); } }.bind(this); return this; }.bind(this); var destination = output || this.shellPageFileService.getCurrentDirectory(); waitCount++; this.shellPageFileService.ensureDirectory(null, destination).then( function(directory) { waitCount--; var files = result.getValue(); if (!result.isArray()) { files = [files]; } files.forEach(function(file) { waitCount++; var pathSegments = file.path.split(this.shellPageFileService.SEPARATOR); /* normalize instances of '.' and '..' in the path */ var index = 0; while (index < pathSegments.length) { var segment = pathSegments[index]; if (segment === ".") { //$NON-NLS-0$ pathSegments.splice(index, 1); } else if (segment === "..") { //$NON-NLS-0$ if (index === 0) { /* invalid, destination must be a descendent of the cwd */ errorFn(i18nUtil.formatMessage(messages["WriteFailNotDescendentOfOutputDir"], file.path)); return; } pathSegments.splice(index-- - 1, 2); } else { index++; } } var writeFile = function(parentNode, fileToWrite, pathSegments) { var segment = pathSegments[0]; pathSegments.splice(0,1); var nodeString = this.shellPageFileService.computePathString(parentNode) + this.shellPageFileService.SEPARATOR + segment; if (pathSegments.length === 0) { /* attempt to write the new resource */ if (fileToWrite.isDirectory) { this.shellPageFileService.ensureDirectory(parentNode, segment).then(successFn(nodeString).callback, errorFn(nodeString).callback); } else { this.shellPageFileService.ensureFile(parentNode, segment).then( function(file) { var writer = new mResultWriters.FileBlobWriter(file, this.shellPageFileService); writer.addBlob(fileToWrite.blob); writer.write().then(successFn(file).callback, errorFn(file).callback); }.bind(this), errorFn(nodeString).callback ); } return; } /* more lead-up path segments to go */ this.shellPageFileService.ensureDirectory(parentNode, segment).then( function(newNode) { writeFile(newNode, fileToWrite, pathSegments); }, errorFn(this.shellPageFileService.computePathString(parentNode) + this.shellPageFileService.SEPARATOR + segment).callback ); }.bind(this); writeFile(directory, file, pathSegments); }.bind(this)); }.bind(this), errorFn(destination).callback ); }
javascript
{ "resource": "" }
q29221
train
function(hunkRangeNo ){ var lastToken = " "; //$NON-NLS-0$ var startNo = this._hunkRanges[hunkRangeNo][0] + 1; var endNo = (hunkRangeNo === (this._hunkRanges.length - 1) ) ? this._diffContents.length : this._hunkRanges[hunkRangeNo+1][0]; var oCursor = 0; var nCursor = 0; var oBlkStart = this._hunkRanges[hunkRangeNo][1]; var nBlkStart = this._hunkRanges[hunkRangeNo][3]; var lastPlusPos = startNo; var lastMinusPos = startNo; for (var i = startNo ; i< endNo ; i++){ if( 0 === this._diffContents[i].length){ continue; } var curToken = this._diffContents[i][0]; if(curToken === "\\"){ //$NON-NLS-0$ if( NO_NEW_LINE === this._diffContents[i].substring(0 , this._diffContents[i].length-1) || NO_NEW_LINE === this._diffContents[i]){ if(lastToken === "-"){ //$NON-NLS-0$ this._oNewLineAtEnd = false; } else if(lastToken === " "){ //$NON-NLS-0$ this._nNewLineAtEnd = false; this._oNewLineAtEnd = false; } else { this._nNewLineAtEnd = false; } if(i > startNo && this._diffContents[i-1][this._diffContents[i-1].length-1] === "\r"){ //$NON-NLS-0$ this._diffContents[i-1] = this._diffContents[i-1].substring(0 , this._diffContents[i-1].length-1); } continue; } } switch(curToken){ case "-": //$NON-NLS-0$ case "+": //$NON-NLS-0$ case " ": //$NON-NLS-0$ break; default: continue; } if(lastToken !== curToken){ if(curToken === "+"){ //$NON-NLS-0$ lastPlusPos = i; } if(curToken === "-"){ //$NON-NLS-0$ lastMinusPos = i; } switch(lastToken){ case " ": //$NON-NLS-0$ oBlkStart = this._hunkRanges[hunkRangeNo][1] + oCursor; nBlkStart = this._hunkRanges[hunkRangeNo][3] + nCursor; break; case "-": //$NON-NLS-0$ this._createMinusBlock(oBlkStart , nBlkStart ,this._hunkRanges[hunkRangeNo][1] + oCursor - oBlkStart, lastMinusPos); break; case "+": //$NON-NLS-0$ this._createPlusBlock(oBlkStart , nBlkStart ,this._hunkRanges[hunkRangeNo][3] + nCursor - nBlkStart , lastPlusPos); break; default: } lastToken = curToken; } switch(curToken){ case "-": //$NON-NLS-0$ oCursor++; break; case "+": //$NON-NLS-0$ nCursor++; break; case " ": //$NON-NLS-0$ oCursor++; nCursor++; break; } } switch(lastToken){ case "-": //$NON-NLS-0$ this._createMinusBlock(oBlkStart , nBlkStart ,this._hunkRanges[hunkRangeNo][1] + oCursor - oBlkStart, lastMinusPos); break; case "+": //$NON-NLS-0$ this._createPlusBlock(oBlkStart , nBlkStart ,this._hunkRanges[hunkRangeNo][3] + nCursor - nBlkStart , lastPlusPos); break; } }
javascript
{ "resource": "" }
q29222
train
function(body , retVal){ if( body ){ var number = parseInt(body, 10); retVal.push( number >= 0 ? number : 1); } else { retVal.push(1); } }
javascript
{ "resource": "" }
q29223
checkRestartQueue
train
function checkRestartQueue() { // Kill one worker only if maximum count are working. if (restartQueue.length > 0 && listeningWorkersCount === workersCount && !currentRestartingPid) { var pid = restartQueue.shift(); try { // Store process id to wait for its finish. currentRestartingPid = pid; // Send SIGTERM signal to worker. SIGTERM starts graceful shutdown of worker inside it. process.kill(pid); } catch(ex) { // Reset current pid. currentRestartingPid = null; // If no process killed, try next in queue. process.nextTick(checkRestartQueue); // Fail silent on 'No such process'. May occur when kill message received after kill initiated but not finished. if (ex.code !== 'ESRCH') { throw ex; } } } }
javascript
{ "resource": "" }
q29224
fork
train
function fork() { cluster.fork().on('message', function(message) { if (message.cmd === 'restart' && message.pid && restartQueue.indexOf(message.pid) === -1) { // When worker asks to restart gracefully in cluster, then add it to restart queue. log('Cluster graceful shutdown: queued. pid=' + message.pid); restartQueue.push(message.pid); checkRestartQueue(); } }); }
javascript
{ "resource": "" }
q29225
checkIfNoWorkersAndExit
train
function checkIfNoWorkersAndExit() { if (!currentWorkersCount) { log('Cluster graceful shutdown: done.'); if (shutdownTimer) clearTimeout(shutdownTimer); exitFunction(); } else { log('Cluster graceful shutdown: wait ' + currentWorkersCount + ' worker' + (currentWorkersCount > 1 ? 's' : '') + '.'); } }
javascript
{ "resource": "" }
q29226
train
function(){ /* * media_query_list * : S* [media_query [ ',' S* media_query ]* ]? * ; */ var tokenStream = this._tokenStream, mediaList = []; this._readWhitespace(); if (tokenStream.peek() === Tokens.IDENT || tokenStream.peek() === Tokens.LPAREN){ mediaList.push(this._media_query()); } while(tokenStream.match(Tokens.COMMA)){ this._readWhitespace(); mediaList.push(this._media_query()); } return mediaList; }
javascript
{ "resource": "" }
q29227
train
function(){ /* * ruleset * : selectors_group * '{' S* declaration? [ ';' S* declaration? ]* '}' S* * ; */ var tokenStream = this._tokenStream, tt, selectors; var node = this.startNode('Rule', tokenStream.curr().range[0], 'body'); //ORION AST generation /* * Error Recovery: If even a single selector fails to parse, * then the entire ruleset should be thrown away. */ try { selectors = this._selectors_group(); } catch (ex){ if (ex instanceof SyntaxError && !this.options.strict){ //fire error event this.fire({ type: "error", error: ex, message: ex.message, line: ex.line, col: ex.col }); //skip over everything until closing brace tt = tokenStream.advance([Tokens.RBRACE]); if (tt === Tokens.RBRACE){ //if there's a right brace, the rule is finished so don't do anything } else { //otherwise, rethrow the error because it wasn't handled properly throw ex; } } else { //not a syntax error, rethrow it throw ex; } //trigger parser to continue return true; } //if it got here, all selectors parsed if (selectors){ this.fire({ type: "startrule", selectors: selectors, line: selectors[0].line, col: selectors[0].col }); this._readDeclarations(true); this.fire({ type: "endrule", selectors: selectors, line: selectors[0].line, col: selectors[0].col }); var rbraceRange = this.findLastTokenRange('RBRACE', node.range[0]); // ORION AST Generation select the RBRACE token this.endNode(node, rbraceRange[1]); //ORION AST Generation } // ORION AST Generation, don't create an empty rule node if no rule selectors found if (selectors === null){ this.removeNode(node, 'body'); } return selectors; }
javascript
{ "resource": "" }
q29228
train
function(checkStart, readMargins){ /* * Reads the pattern * S* '{' S* declaration [ ';' S* declaration ]* '}' S* * or * S* '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S* * Note that this is how it is described in CSS3 Paged Media, but is actually incorrect. * A semicolon is only necessary following a declaration if there's another declaration * or margin afterwards. */ var tokenStream = this._tokenStream, tt; this._readWhitespace(); var node = this.startNode('DeclarationBody', this._tokenStream.curr().range[0], 'declarationBody'); // ORION AST Generation node.declarations = []; // ORION AST Generation if (checkStart){ tokenStream.mustMatch(Tokens.LBRACE); } this._readWhitespace(); try { while(true){ if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())){ //noop } else if (this._declaration()){ if (!tokenStream.match(Tokens.SEMICOLON)){ break; } } else { break; } //if ((!this._margin() && !this._declaration()) || !tokenStream.match(Tokens.SEMICOLON)){ // break; //} this._readWhitespace(); } tokenStream.mustMatch(Tokens.RBRACE); this._readWhitespace(); } catch (ex) { if (ex instanceof SyntaxError && !this.options.strict){ //fire error event this.fire({ type: "error", error: ex, message: ex.message, line: ex.line, col: ex.col }); //see if there's another declaration tt = tokenStream.advance([Tokens.SEMICOLON, Tokens.RBRACE]); if (tt === Tokens.SEMICOLON){ //if there's a semicolon, then there might be another declaration this._readDeclarations(false, readMargins); } else if (tt !== Tokens.RBRACE){ //if there's a right brace, the rule is finished so don't do anything //otherwise, rethrow the error because it wasn't handled properly throw ex; } } else { //not a syntax error, rethrow it throw ex; } } var rbraceRange = this.findLastTokenRange('RBRACE', node.range[0]); // ORION AST Generation select the RBRACE token this.endNode(node, rbraceRange[1]); //ORION AST Generation }
javascript
{ "resource": "" }
q29229
train
function(){ var tokenStream = this._tokenStream, ws = ""; while(tokenStream.match(Tokens.S)){ ws += tokenStream.token().value; } return ws; }
javascript
{ "resource": "" }
q29230
train
function(token){ throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol); }
javascript
{ "resource": "" }
q29231
SelectorSubPart
train
function SelectorSubPart(text, type, line, col) { SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_SUB_PART_TYPE); /** * The type of modifier. * @type String * @property type */ this.type = type; /** * Some subparts have arguments, this represents them. * @type Array * @property args */ this.args = []; }
javascript
{ "resource": "" }
q29232
train
function(other) { var comps = ["a", "b", "c", "d"], i, len; for (i=0, len=comps.length; i < len; i++) { if (this[comps[i]] < other[comps[i]]) { return -1; } else if (this[comps[i]] > other[comps[i]]) { return 1; } } return 0; }
javascript
{ "resource": "" }
q29233
train
function(c, startLine, startCol) { var reader = this._reader, comparison = c + reader.read(), tt = Tokens.type(comparison) || Tokens.CHAR; return this.createToken(tt, comparison, startLine, startCol); }
javascript
{ "resource": "" }
q29234
train
function(first, startLine, startCol) { var reader = this._reader, value = this.readNumber(first), ident, tt = Tokens.NUMBER, c = reader.peek(); if (isIdentStart(c)) { ident = this.readName(reader.read()); value += ident; if (/^em$|^ex$|^px$|^gd$|^rem$|^vw$|^vh$|^vmax$|^vmin$|^ch$|^cm$|^mm$|^in$|^pt$|^pc$/i.test(ident)) { tt = Tokens.LENGTH; } else if (/^deg|^rad$|^grad$|^turn$/i.test(ident)) { tt = Tokens.ANGLE; } else if (/^ms$|^s$/i.test(ident)) { tt = Tokens.TIME; } else if (/^hz$|^khz$/i.test(ident)) { tt = Tokens.FREQ; } else if (/^dpi$|^dpcm$/i.test(ident)) { tt = Tokens.RESOLUTION; } else { tt = Tokens.DIMENSION; } } else if (c === "%") { value += reader.read(); tt = Tokens.PERCENTAGE; } return this.createToken(tt, value, startLine, startCol); }
javascript
{ "resource": "" }
q29235
train
function(first, startLine, startCol) { var value = first + this.readWhitespace(); return this.createToken(Tokens.S, value, startLine, startCol); }
javascript
{ "resource": "" }
q29236
train
function(first) { var reader = this._reader, url = first || "", c; for (c = reader.peek(); c; c = reader.peek()) { // Note that the grammar at // https://www.w3.org/TR/CSS2/grammar.html#scanner // incorrectly includes the backslash character in the // `url` production, although it is correctly omitted in // the `baduri1` production. if (nonascii.test(c) || /^[\-!#$%&*-\[\]-~]$/.test(c)) { url += c; reader.read(); } else if (c === "\\") { if (/^[^\r\n\f]$/.test(reader.peek(2))) { url += this.readEscape(reader.read(), true); } else { break; // bad escape sequence. } } else { break; // bad character } } return url; }
javascript
{ "resource": "" }
q29237
SyntaxError
train
function SyntaxError(message, line, col) { Error.call(this); this.name = this.constructor.name; /** * The column at which the error occurred. * @type int * @property col */ this.col = col; /** * The line at which the error occurred. * @type int * @property line */ this.line = line; /** * The text representation of the unit. * @type String * @property text */ this.message = message; }
javascript
{ "resource": "" }
q29238
train
function(index) { var total = index, tt; if (index > 0) { //TODO: Store 5 somewhere if (index > 5) { throw new Error("Too much lookahead."); } //get all those tokens while (total) { tt = this.get(); total--; } //unget all those tokens while (total < index) { this.unget(); total++; } } else if (index < 0) { if (this._lt[this._ltIndex+index]) { tt = this._lt[this._ltIndex+index].type; } else { throw new Error("Too much lookbehind."); } } else { tt = this._token.type; } return tt; }
javascript
{ "resource": "" }
q29239
applyEmbeddedRuleset
train
function applyEmbeddedRuleset(text, ruleset) { var valueMap, embedded = text && text.match(embeddedRuleset), rules = embedded && embedded[1]; if (rules) { valueMap = { "true": 2, // true is error "": 1, // blank is warning "false": 0, // false is ignore "info": 3, // ORION allow info severity "3": 3, // ORION allow info severity "2": 2, // explicit error "1": 1, // explicit warning "0": 0 // explicit ignore }; rules.toLowerCase().split(",").forEach(function(rule) { var pair = rule.split(":"), property = pair[0] || "", value = pair[1] || ""; ruleset[property.trim()] = valueMap[value.trim()]; }); } return ruleset; }
javascript
{ "resource": "" }
q29240
Reporter
train
function Reporter(lines, ruleset, allow, ignore) { "use strict"; /** * List of messages being reported. * @property messages * @type String[] */ this.messages = []; /** * List of statistics being reported. * @property stats * @type String[] */ this.stats = []; /** * Lines of code being reported on. Used to provide contextual information * for messages. * @property lines * @type String[] */ this.lines = lines; /** * Information about the rules. Used to determine whether an issue is an * error or warning. * @property ruleset * @type Object */ this.ruleset = ruleset; /** * Lines with specific rule messages to leave out of the report. * @property allow * @type Object */ this.allow = allow; if (!this.allow) { this.allow = {}; } /** * Linesets not to include in the report. * @property ignore * @type [][] */ this.ignore = ignore; if (!this.ignore) { this.ignore = []; } }
javascript
{ "resource": "" }
q29241
train
function(message, line, col, rule, data) { "use strict"; var err = { type : "error", line : line, col : col, message : message, evidence: this.lines[line-1], rule : rule || {} }; if (data) { err.data = data; } this.messages.push(err); }
javascript
{ "resource": "" }
q29242
train
function(message, line, col, rule, data) { "use strict"; // Check if rule violation should be allowed if (this.allow.hasOwnProperty(line) && this.allow[line].hasOwnProperty(rule.id)) { return; } var ignore = false; CSSLint.Util.forEach(this.ignore, function (range) { if (range[0] <= line && line <= range[1]) { ignore = true; } }); if (ignore) { return; } var t = "info"; if(this.ruleset[rule.id] === 2) { t = "error"; } else if(this.ruleset[rule.id] === 1) { t = "warning"; } var err = { type : t, line : line, col : col, message : message, evidence: this.lines[line-1], rule : rule }; if(data) { err.data = data; } this.messages.push(err); }
javascript
{ "resource": "" }
q29243
train
function(message, rule) { "use strict"; this.messages.push({ type : "error", rollup : true, message : message, rule : rule }); }
javascript
{ "resource": "" }
q29244
train
function(message, rule, data) { "use strict"; var err = { type : "warning", rollup : true, message : message, rule : rule }; if(data) { err.data = data; } this.messages.push(err); }
javascript
{ "resource": "" }
q29245
train
function() { "use strict"; var ret = ""; if (this.json.length > 0) { if (this.json.length === 1) { ret = JSON.stringify(this.json[0]); } else { ret = JSON.stringify(this.json); } } return ret; }
javascript
{ "resource": "" }
q29246
DiffTreeNavigator
train
function DiffTreeNavigator(charOrWordDiff, oldEditor, newEditor, oldDiffBlockFeeder, newDiffBlockFeeder, curveRuler) { this._root = {type: "root", children: []}; //$NON-NLS-0$ this._initialized = false; this.initAll(charOrWordDiff, oldEditor, newEditor, oldDiffBlockFeeder, newDiffBlockFeeder, curveRuler); }
javascript
{ "resource": "" }
q29247
train
function(changeIndex) { var count = 0; var blockIndex = 0; if (0 <= changeIndex) { // iterate through blocks looking for the one that contains // the change with the specified changeIndex while (blockIndex < this._root.children.length) { var numChangesInCurrentBlock = this._root.children[blockIndex].children.length; if (((count + numChangesInCurrentBlock) - 1) < changeIndex) { count += numChangesInCurrentBlock; //keep going } else { // found block, go to change in block var changeIndexInBlock = changeIndex - count; return this.gotoBlock(blockIndex, changeIndexInBlock); } blockIndex++; } } }
javascript
{ "resource": "" }
q29248
train
function(e) { this.iterate(false, false, e.shiftKey, true); if(!this._ctrlKeyOn(e) && !e.shiftKey){ this.setSelection(this.currentModel(), false, true); } e.preventDefault(); return false; }
javascript
{ "resource": "" }
q29249
train
function(e) { if(this._shouldMoveColumn(e)){ this.moveColumn(null, 1); e.preventDefault(); return true; } var curModel = this._modelIterator.cursor(); if(!curModel){ return false; } if(this.isExpandable(curModel)){ if(!this.isExpanded(curModel)){ this.explorer.myTree.expand(curModel); if (this.explorer.postUserExpand) { this.explorer.postUserExpand(this.model.getId(curModel)); } e.preventDefault(); return false; } } }
javascript
{ "resource": "" }
q29250
train
function(e) { if (!e.target.classList.contains("treeTableRow")) return; if(this.setSelection(this.currentModel(), true, true)) { e.preventDefault(); } }
javascript
{ "resource": "" }
q29251
train
function(e) { var currentGrid = this.getCurrentGrid(this._modelIterator.cursor()); if(currentGrid){ if(currentGrid.widget){ if(typeof currentGrid.onClick === "function"){ //$NON-NLS-0$ currentGrid.onClick(); } else if(typeof currentGrid.widget.focus === "function"){ //$NON-NLS-0$ currentGrid.widget.focus(); } } else { var evt = document.createEvent("MouseEvents"); //$NON-NLS-0$ evt.initMouseEvent("click", true, true, window, //$NON-NLS-0$ 0, 0, 0, 0, 0, this._ctrlKeyOn(e), false, false, false, 0, null); currentGrid.domNode.dispatchEvent(evt); } return; } var curModel = this._modelIterator.cursor(); if(!curModel){ return; } if(this.explorer.renderer.getRowActionElement){ var div = this.explorer.renderer.getRowActionElement(this.model.getId(curModel)); if(div.href){ if(this._ctrlKeyOn(e)){ window.open(urlModifier(div.href)); } else { window.location.href = urlModifier(div.href); } } } if(this.explorer.renderer.performRowAction){ this.explorer.renderer.performRowAction(e, curModel); e.preventDefault(); return false; } }
javascript
{ "resource": "" }
q29252
train
function(model) { var rowDiv = this.getRowDiv(model); if (this.isExpandable(model) && this.isExpanded(model)) { this._modelIterator.collapse(model); this.explorer.myTree.toggle(rowDiv.id); // collapse tree visually } rowDiv.classList.remove("checkedRow"); //$NON-NLS-0$ rowDiv.classList.add("disabledNavRow"); //$NON-NLS-0$ this.setIsNotSelectable(model, true); }
javascript
{ "resource": "" }
q29253
train
function(model) { var rowDiv = this.getRowDiv(model); if (rowDiv) { rowDiv.classList.remove("disabledNavRow"); //$NON-NLS-0$ this.setIsNotSelectable(model, false); } }
javascript
{ "resource": "" }
q29254
train
function(modelItem, rowDomNode){ var modelId = this._model.getId(modelItem); this._dict[modelId] = {model: modelItem, rowDomNode: rowDomNode}; }
javascript
{ "resource": "" }
q29255
train
function(modelItem, lazyCreate) { if(!modelItem){ return null; } var modelId = this._model.getId(modelItem); if(this._dict[modelId]){ if(!this._dict[modelId].gridChildren && lazyCreate){ this._dict[modelId].gridChildren = []; } return this._dict[modelId].gridChildren; } return null; }
javascript
{ "resource": "" }
q29256
train
function(modelItem) { if(!modelItem){ return null; } var modelId = this._model.getId(modelItem); if(this._dict[modelId]){ this._dict[modelId].gridChildren = null; } }
javascript
{ "resource": "" }
q29257
BlankField
train
function BlankField(type, options) { Field.call(this, type, options); this.element = util.createElement(this.document, 'div'); this.onFieldChange = util.createEvent('BlankField.onFieldChange'); }
javascript
{ "resource": "" }
q29258
ProgressService
train
function ProgressService(serviceRegistry, operationsClient, commandRegistry, progressMonitorClass, preferenceService){ this._serviceRegistry = serviceRegistry; this._serviceRegistration = serviceRegistry.registerService("orion.page.progress", this); //$NON-NLS-0$ this._commandRegistry = commandRegistry; this._operationsClient = operationsClient; this._operations = {}; this._operationDeferrds = {}; this._operationsIndex = 0; this._lastOperation = null; this._lastIconClass = null; this._progressMonitorClass = progressMonitorClass; this._preferenceService = preferenceService; }
javascript
{ "resource": "" }
q29259
isSimple
train
function isSimple(typed) { for (var i = 0; i < typed.length; i++) { var c = typed.charAt(i); if (c === ' ' || c === '"' || c === '\'' || c === '{' || c === '}' || c === '\\') { return false; } } return true; }
javascript
{ "resource": "" }
q29260
naiveHasReturn
train
function naiveHasReturn(node) { if (node.type === "BlockStatement") { var body = node.body, lastChildNode = body[body.length - 1]; return lastChildNode && checkForReturn(lastChildNode); } return checkForReturn(node); }
javascript
{ "resource": "" }
q29261
importPlugin
train
function importPlugin(pluginRules, pluginName) { Object.keys(pluginRules).forEach(function(ruleId) { var qualifiedRuleId = pluginName + "/" + ruleId, rule = pluginRules[ruleId]; define(qualifiedRuleId, rule); }); }
javascript
{ "resource": "" }
q29262
_updateMap
train
function _updateMap(arr, state) { if(Array.isArray(arr)) { arr.forEach(function(file) { var f, toQ, toN, n; switch(state) { case 'onCreated': { n = file.result ? file.result.Name : undefined; f = file.result ? file.result.Location : undefined; break; } case 'onDeleted': { f = file.deleteLocation; n = _shortName(file.deleteLocation); break; } case 'onModified': { n = _shortName(file); f = file; break; } case 'onMoved': { toQ = file.result ? file.result.Location : undefined; toN = file.result ? file.result.Name : undefined; n = _shortName(file.source); f = file.source; break; } } delete this.map[f]; _handle.call(this, state, this, f, n, toQ, toN); }.bind(this)); } }
javascript
{ "resource": "" }
q29263
Searcher
train
function Searcher(options) { this._registry= options.serviceRegistry; this._commandService = options.commandService; this._fileClient = options.fileService; //TODO clean up the search client API. Make any helper private this._registry.registerService("orion.core.search.client", this); //$NON-NLS-1$ }
javascript
{ "resource": "" }
q29264
train
function(meta, useParentLocation){ var locationName = ""; var noneRootMeta = null; this._setLocationbyURL(meta); this._searchRootLocation = meta.WorkspaceLocation || this._fileClient.fileServiceRootURL(meta.Location); if(useParentLocation && meta && meta.Parents && meta.Parents.length > 0){ if(useParentLocation.index === "last"){ noneRootMeta = meta.Parents[meta.Parents.length-1]; } else { noneRootMeta = meta.Parents[0]; } } else { noneRootMeta = this._getNoneRootMeta(meta); } if(noneRootMeta){ this.setLocationbyURL(noneRootMeta.Location); locationName = noneRootMeta.Name; this._childrenLocation = noneRootMeta.ChildrenLocation; } else if(meta){ this.setLocationbyURL(this._searchRootLocation); locationName = this._fileClient.fileServiceName(meta.Location); this._childrenLocation = meta.ChildrenLocation; } var searchInputDom = lib.node("search"); //$NON-NLS-0$ if(!locationName){ locationName = ""; } this._searchLocationName = locationName; if(searchInputDom && searchInputDom.placeholder){ searchInputDom.value = ""; var placeHolder = i18nUtil.formatMessage(messages["Search ${0}"], locationName); if(placeHolder.length > 30){ searchInputDom.placeholder = placeHolder.substring(0, 27) + "..."; //$NON-NLS-0$ } else { searchInputDom.placeholder = i18nUtil.formatMessage(messages["Search ${0}"], locationName); } } if(searchInputDom && searchInputDom.title){ searchInputDom.title = messages["TypeKeyOrWildCard"] + locationName; } }
javascript
{ "resource": "" }
q29265
train
function(searchParams, generateMatches, generateMeta) { try { return this.getFileClient().search(searchParams).then(function(jsonData) { var searchResult = this.convert(jsonData, searchParams); return this._generateMatches(searchParams, searchResult, generateMatches).then(function() { return this._generateMeta(searchResult, generateMeta).then(function() { return searchResult; }); }.bind(this)); }.bind(this)); } catch(err){ var error = err.message || err; if(typeof error === "string" && error.toLowerCase().indexOf("search") > -1){ //$NON-NLS-1$ //$NON-NLS-0$ if(!this._crawler) { this._crawler = this._createCrawler(searchParams); } if(searchParams.nameSearch) { return this._crawler.searchName(searchParams).then(function(jsonData) { return this.convert(jsonData, searchParams); }.bind(this)); } var result; return result = this._crawler.search(function() { result.progress(arguments[0], arguments[1]); }).then(function(jsonData) { return this.convert(jsonData, searchParams); }.bind(this)); } throw error; } }
javascript
{ "resource": "" }
q29266
train
function(keyword, nameSearch, useRoot, advancedOptions, searchScope) { var searchOn = useRoot ? this.getSearchRootLocation(): this.getSearchLocation(searchScope); if (nameSearch) { //assume implicit trailing wildcard if there isn't one already //var wildcard= (/\*$/.test(keyword) ? "" : "*"); //$NON-NLS-0$ return { resource: searchOn, sort: "NameLower asc", //$NON-NLS-0$ rows: 100, start: 0, nameSearch: true, keyword: keyword, exclude: (advancedOptions && advancedOptions.exclude) ? advancedOptions.exclude : undefined, }; } return { resource: searchOn, sort: advancedOptions && advancedOptions.sort ? advancedOptions.sort : "Path asc", //$NON-NLS-0$ rows: advancedOptions && advancedOptions.rows ? advancedOptions.rows : 40, start: 0, caseSensitive: advancedOptions ? advancedOptions.caseSensitive : undefined, wholeWord: advancedOptions ? advancedOptions.wholeWord : undefined, regEx: advancedOptions ? advancedOptions.regEx : undefined, fileType: advancedOptions ? advancedOptions.fileType : undefined, fileNamePatterns: (advancedOptions && advancedOptions.fileNamePatterns) ? advancedOptions.fileNamePatterns : undefined, exclude: (advancedOptions && advancedOptions.exclude) ? advancedOptions.exclude : undefined, keyword: keyword, replace: advancedOptions ? advancedOptions.replace : undefined, searchScope: searchScope }; }
javascript
{ "resource": "" }
q29267
displayErrorOnStatus
train
function displayErrorOnStatus(error) { var display = {}; display.Severity = "Error"; //$NON-NLS-0$ display.HTML = false; try { var resp = JSON.parse(error.responseText); display.Message = resp.DetailedMessage ? resp.DetailedMessage : (resp.Message ? resp.Message : messages["Problem while performing the action"]); } catch (Exception) { display.Message = messages["Problem while performing the action"]; } serviceRegistry.getService("orion.page.message").setProgressResult(display); //$NON-NLS-0$ }
javascript
{ "resource": "" }
q29268
train
function(data) { if (data && data.handler.changedItem) { data.handler.changedItem(); } else { explorer.changedItem(); } }
javascript
{ "resource": "" }
q29269
calculateTruePrefix
train
function calculateTruePrefix(buffer, offset, escapeCharacter) { var char = buffer.charAt(offset - 1); switch (char) { case '\n': var escapedPrefix = ""; for (var i = offset - 1; i >= 0; i--) { if (buffer.charAt(i) === '\n') { if (buffer.charAt(i - 1) === escapeCharacter) { i--; } else if (buffer.charAt(i - 1) === '\r' && buffer.charAt(i - 2) === escapeCharacter) { i = i -2; } else { break; } } else if (buffer.charAt(i) === ' ' || buffer.charAt(i) === '\t') { break; } else { escapedPrefix = buffer.charAt(i).toUpperCase() + escapedPrefix; } } if (escapedPrefix !== "") { return escapedPrefix; } break; case '\r': case ' ': case '\t': break; default: var truePrefix = char; prefixCheck: for (i = offset - 2; i >= 0; i--) { char = buffer.charAt(i); switch (char) { case '\r': case '\n': case ' ': case '\t': break prefixCheck; default: for (i = offset - 2; i >= 0; i--) { truePrefix = char + truePrefix; } break; } } return truePrefix; } return ""; }
javascript
{ "resource": "" }
q29270
checkCollabServerToken
train
function checkCollabServerToken(authorization) { if (authorization.substr(0, 7) !== "Bearer ") { return false; } try { var decoded = jwt.verify(authorization.substr(7), options.configParams.get("orion.jwt.secret")); return true; } catch (ex) { return false; } }
javascript
{ "resource": "" }
q29271
train
function(child, branchNameOrSha, asSha) { var _this = this; var shaValue = asSha ? branchNameOrSha : branchNameOrSha + "&path=" + child.CommitPath; return xhr("GET", _this._repoURL.href + "/commits?sha=" + shaValue + "&per_page=1", {//https://developer.github.com/v3/#pagination headers: this._headers, timeout: 15000 }).then(function(result) { var content = JSON.parse(result.response); if(content.length > 0 && content[0].commit && content[0].commit.author && content[0].commit.author.date) { child.LocalTimeStamp = content[0].commit.author.date; child.LastCommit = {}; child.LastCommit.Author = {}; child.LastCommit.Author.Date = content[0].commit.author.date; child.LastCommit.Author.Name = content[0].commit.author.name ? content[0].commit.author.name : ""; child.LastCommit.Author.Email = content[0].commit.author.email ? content[0].commit.author.email : ""; if(content[0].commit.committer) { child.LastCommit.Committer = {}; child.LastCommit.Committer.Date = content[0].commit.committer.date ? content[0].commit.committer.date : ""; child.LastCommit.Committer.Name = content[0].commit.committer.name ? content[0].commit.committer.name : ""; child.LastCommit.Committer.Email = content[0].commit.committer.email ? content[0].commit.committer.email : ""; } child.LastCommit.Message = content[0].commit.message ? content[0].commit.message : ""; child.LastCommit.URL = content[0].sha ? _this._commitURLBase + content[0].sha : null; if(use_gravatar_id && content[0].author && content[0].author.gravatar_id) { child.LastCommit.AvatarURL = "https://www.gravatar.com/avatar/" + content[0].author.gravatar_id + "?d=mm"; } else if(content[0].author && content[0].author.avatar_url) { child.LastCommit.AvatarURL = content[0].author.avatar_url; } } return child; }, function(error) { return _this._handleError(error);}); }
javascript
{ "resource": "" }
q29272
isDoubleLogicalNegating
train
function isDoubleLogicalNegating(node) { return node.operator === "!" && node.argument.type === "UnaryExpression" && node.argument.operator === "!"; }
javascript
{ "resource": "" }
q29273
isAppendEmptyString
train
function isAppendEmptyString(node) { return node.operator === "+=" && node.right.type === "Literal" && node.right.value === ""; }
javascript
{ "resource": "" }
q29274
getOtherOperand
train
function getOtherOperand(node, value) { if (node.left.type === "Literal" && node.left.value === value) { return node.right; } return node.left; }
javascript
{ "resource": "" }
q29275
isInsideOfStorableFunction
train
function isInsideOfStorableFunction(id, rhsNode) { var funcNode = getUpperFunction(id); return ( funcNode && isInside(funcNode, rhsNode) && isStorableFunction(funcNode, rhsNode) ); }
javascript
{ "resource": "" }
q29276
CollabSocket
train
function CollabSocket(hubUrl, sessionId) { var self = this; this.socket = io.connect( hubUrl+ "?sessionId=" +sessionId, { path: "/socket.io/" }); this.socket.on('connect', function() { self.dispatchEvent({ type: 'ready' }); }); this.socket.on('disconnect', function() { self.dispatchEvent({ type: 'close' }); }); this.socket.on('error', function(e) { self.dispatchEvent({ type: 'error', error: e }); console.error(e); }); this.socket.on('message', function(data) { self.dispatchEvent({ type: 'message', data: data }); if (DEBUG) { var msgObj = JSON.parse(data); console.log('CollabSocket In: ' + msgObj.type, msgObj); } }); EventTarget.attach(this); }
javascript
{ "resource": "" }
q29277
OutlineRenderer
train
function OutlineRenderer (options, explorer, title, inputManager) { this.explorer = explorer; this._init(options); this.title = title; this.inputManager = inputManager; }
javascript
{ "resource": "" }
q29278
train
function() { if (!this._isActive()) { return; } this._filterInput.value = ""; //$NON-NLS-0$ lib.empty(this._outlineNode); // display spinner while outline is being calculated var spinner = document.createElement("span"); //$NON-NLS-0$ spinner.classList.add("modelDecorationSprite"); //$NON-NLS-0$ spinner.classList.add("core-sprite-progress"); //$NON-NLS-0$ this._outlineNode.appendChild(spinner); if (this._outlineTimeout) { window.clearTimeout(this._outlineTimeout); } this._outlineTimeout = window.setTimeout(function() { lib.empty(this._outlineNode); var span = document.createElement("span"); //$NON-NLS-0$ span.appendChild(document.createTextNode(messages["outlineTimeout"])); //$NON-NLS-0$ span.classList.add("outlineTimeoutSpan"); //$NON-NLS-0$ this._outlineNode.appendChild(span); }.bind(this), OUTLINE_TIMEOUT_MS); // Bail we're in the process of looking up capable providers if (this._providerLookup) { return; } this._outlineService.emitOutline(this._inputManager); }
javascript
{ "resource": "" }
q29279
train
function(provider) { var isActive = this._slideout.isVisible() && (this === this._slideout.getCurrentViewMode()); if (isActive && provider) { isActive = (provider.getProperty("id") === this.providerId); //$NON-NLS-0$ if (isActive) { isActive = (provider.getProperty("name") === this.providerName); //$NON-NLS-0$ } } return isActive; }
javascript
{ "resource": "" }
q29280
train
function(fileContentType, title) { if (!fileContentType) return; var lspServer = this.languageServerRegistry.getServerByContentType(fileContentType); var filteredProviders = null; var _self = this; if (lspServer) { filteredProviders = []; filteredProviders.push(lspServer); } else { var allOutlineProviders = this._serviceRegistry.getServiceReferences("orion.edit.outliner"); //$NON-NLS-0$ // Filter to capable providers filteredProviders = this.filteredProviders = allOutlineProviders.filter(function(serviceReference) { var contentTypeIds = serviceReference.getProperty("contentType"), //$NON-NLS-0$ pattern = serviceReference.getProperty("pattern"); // for backwards compatibility //$NON-NLS-0$ if (contentTypeIds) { return contentTypeIds.some(function(contentTypeId) { return _self._contentTypeRegistry.isExtensionOf(fileContentType, contentTypeId); }); } else if (pattern && new RegExp(pattern).test(title)) { return true; } return false; }); // Load resource bundles this._providerLookup = true; filteredProviders.forEach(function(provider) { provider.displayName = provider.getProperty("name") || provider.getProperty("nameKey"); //$NON-NLS-0$ }); _self._providerLookup = false; } _self._outlineService.setOutlineProviders(filteredProviders); _self.setOutlineProviders(filteredProviders); _self.generateOutline(); }
javascript
{ "resource": "" }
q29281
getReplacedFileContent
train
function getReplacedFileContent(newContentHolder, updating, fileItem) { mSearchUtils.generateNewContents(updating, fileItem.contents, newContentHolder, fileItem, this._searchHelper.params.replace, this._searchHelper.inFileQuery.searchStrLength); newContentHolder.lineDelim = this._lineDelimiter; }
javascript
{ "resource": "" }
q29282
writeReplacedContents
train
function writeReplacedContents(reportList){ var promises = []; var validFileList = this.getValidFileList(); validFileList.forEach(function(fileItem) { promises.push(this._writeOneFile(fileItem, reportList)); }.bind(this)); return Deferred.all(promises, function(error) { return {_error: error}; }); }
javascript
{ "resource": "" }
q29283
isReflectApply
train
function isReflectApply(node) { return node.type === "MemberExpression" && node.object.type === "Identifier" && node.object.name === "Reflect" && node.property.type === "Identifier" && node.property.name === "apply" && node.computed === false; }
javascript
{ "resource": "" }
q29284
isES5Constructor
train
function isES5Constructor(node) { return node.id && node.id.name[0] !== node.id.name[0].toLocaleLowerCase(); }
javascript
{ "resource": "" }
q29285
train
function(node) { var current = stack.getCurrent(); if (current && !current.valid) { context.report(node, ProblemMessages.noInvalidThis); } }
javascript
{ "resource": "" }
q29286
train
function() { BaseEditor.prototype.destroy.call(this); this._textViewFactory = this._undoStackFactory = this._textDNDFactory = this._annotationFactory = this._foldingRulerFactory = this._lineNumberRulerFactory = this._contentAssistFactory = this._keyBindingFactory = this._hoverFactory = this._zoomRulerFactory = null; }
javascript
{ "resource": "" }
q29287
train
function(start, end) { var annotationModel = this.getAnnotationModel(); if(annotationModel) { var foldingAnnotation = new mAnnotations.FoldingAnnotation(start, end, this.getTextView().getModel()); annotationModel.addAnnotation(foldingAnnotation); return foldingAnnotation; } return null; }
javascript
{ "resource": "" }
q29288
train
function() { if (!this._textView) { return null; } var model = this._textView.getModel(); if (model.getBaseModel) { model = model.getBaseModel(); } return model; }
javascript
{ "resource": "" }
q29289
train
function(visible, force) { if (this._annotationRulerVisible === visible && !force) { return; } this._annotationRulerVisible = visible; if (!this._annotationRuler) { return; } var textView = this._textView; if (visible) { textView.addRuler(this._annotationRuler, 0); } else { textView.removeRuler(this._annotationRuler); } }
javascript
{ "resource": "" }
q29290
train
function(visible, force) { if (this._foldingRulerVisible === visible && !force) { return; } if (!visible) { var textActions = this.getTextActions(); if (textActions) { textActions.expandAnnotations(true); } } this._foldingRulerVisible = visible; if (!this._foldingRuler) { return; } var textView = this._textView; if (!textView.getModel().getBaseModel) { return; } if (visible) { textView.addRuler(this._foldingRuler); } else { textView.removeRuler(this._foldingRuler); } }
javascript
{ "resource": "" }
q29291
train
function(visible, force) { if (this._lineNumberRulerVisible === visible && !force) { return; } this._lineNumberRulerVisible = visible; if (!this._lineNumberRuler) { return; } var textView = this._textView; if (visible) { textView.addRuler(this._lineNumberRuler, !this._annotationRulerVisible ? 0 : 1); } else { textView.removeRuler(this._lineNumberRuler); } }
javascript
{ "resource": "" }
q29292
train
function(visible, force) { if (this._overviewRulerVisible === visible && !force) { return; } this._overviewRulerVisible = visible; if (!this._overviewRuler) { return; } var textView = this._textView; if (visible) { textView.addRuler(this._overviewRuler); } else { textView.removeRuler(this._overviewRuler); } }
javascript
{ "resource": "" }
q29293
train
function(visible, force) { if (this._zoomRulerVisible === visible && !force) { return; } this._zoomRulerVisible = visible; if (!this._zoomRuler) { return; } var textView = this._textView; if (visible) { textView.addRuler(this._zoomRuler); } else { textView.removeRuler(this._zoomRuler); } }
javascript
{ "resource": "" }
q29294
train
function(types) { if (textUtil.compare(this._annotationTypesVisible, types)) return; this._annotationTypesVisible = types; if (!this._annotationRuler || !this._textView || !this._annotationRulerVisible) { return; } this._annotationRuler.setAnnotationTypeVisible(types); this._textView.redrawLines(0, undefined, this._annotationRuler); }
javascript
{ "resource": "" }
q29295
train
function(types) { if (textUtil.compare(this._overviewAnnotationTypesVisible, types)) return; this._overviewAnnotationTypesVisible = types; if (!this._overviewRuler || !this._textView || !this._overviewRulerVisible) { return; } this._overviewRuler.setAnnotationTypeVisible(types); this._textView.redrawLines(0, undefined, this._overviewRuler); }
javascript
{ "resource": "" }
q29296
train
function(types) { if (textUtil.compare(this._textAnnotationTypesVisible, types)) return; this._textAnnotationTypesVisible = types; if (!this._annotationStyler || !this._textView) { return; } this._annotationStyler.setAnnotationTypeVisible(types); this._textView.redrawLines(0, undefined); }
javascript
{ "resource": "" }
q29297
train
function(line) { // Find any existing annotation var annotationModel = this.getAnnotationModel(); var textModel = this.getModel(); if (textModel.getBaseModel) { textModel = textModel.getBaseModel(); } var type = AT.ANNOTATION_HIGHLIGHTED_LINE; var annotations = annotationModel.getAnnotations(0, textModel.getCharCount()); var remove = null; while (annotations.hasNext()) { var annotation = annotations.next(); if (annotation.type === type) { remove = annotation; break; } } var lineStart = textModel.getLineStart(line); var lineEnd = textModel.getLineEnd(line); var add = AT.createAnnotation(type, lineStart, lineEnd); // Replace to or add the new annotation if (remove) { annotationModel.replaceAnnotations([remove], [add]); } else { annotationModel.addAnnotation(add); } }
javascript
{ "resource": "" }
q29298
train
function() { var annotationModel = this.getAnnotationModel(); var textModel = this.getModel(); if (textModel.getBaseModel) { textModel = textModel.getBaseModel(); } var type = AT.ANNOTATION_HIGHLIGHTED_LINE; var annotations = annotationModel.getAnnotations(0, textModel.getCharCount()); var remove = null; while (annotations.hasNext()) { var annotation = annotations.next(); if (annotation.type === type) { remove = annotation; break; } } if (remove) { annotationModel.removeAnnotation(remove); } }
javascript
{ "resource": "" }
q29299
train
function(diffs) { this.showAnnotations(diffs, [ AT.ANNOTATION_DIFF_ADDED, AT.ANNOTATION_DIFF_MODIFIED, AT.ANNOTATION_DIFF_DELETED ], null, function(annotation) { if(annotation.type === "added")//$NON-NLS-0$ return AT.ANNOTATION_DIFF_ADDED; else if (annotation.type === "modified")//$NON-NLS-0$ return AT.ANNOTATION_DIFF_MODIFIED; return AT.ANNOTATION_DIFF_DELETED; // assume deleted if not added or modified }); }
javascript
{ "resource": "" }