code
stringlengths 24
2.07M
| docstring
stringlengths 25
85.3k
| func_name
stringlengths 1
92
| language
stringclasses 1
value | repo
stringlengths 5
64
| path
stringlengths 4
172
| url
stringlengths 44
218
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
function isJSDocConstructSignature(node) {
return node.kind === 261 /* JSDocFunctionType */ &&
node.parameters.length > 0 &&
node.parameters[0].type.kind === 263 /* JSDocConstructorType */;
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | isJSDocConstructSignature | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getJSDocTag(node, kind) {
if (node && node.jsDocComment) {
for (var _i = 0, _a = node.jsDocComment.tags; _i < _a.length; _i++) {
var tag = _a[_i];
if (tag.kind === kind) {
return tag;
}
}
}
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | getJSDocTag | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getJSDocTypeTag(node) {
return getJSDocTag(node, 269 /* JSDocTypeTag */);
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | getJSDocTypeTag | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getJSDocReturnTag(node) {
return getJSDocTag(node, 268 /* JSDocReturnTag */);
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | getJSDocReturnTag | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getJSDocTemplateTag(node) {
return getJSDocTag(node, 270 /* JSDocTemplateTag */);
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | getJSDocTemplateTag | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getCorrespondingJSDocParameterTag(parameter) {
if (parameter.name && parameter.name.kind === 69 /* Identifier */) {
// If it's a parameter, see if the parent has a jsdoc comment with an @param
// annotation.
var parameterName = parameter.name.text;
var docComment = parameter.parent.jsDocComment;
if (docComment) {
return ts.forEach(docComment.tags, function (t) {
if (t.kind === 267 /* JSDocParameterTag */) {
var parameterTag = t;
var name_6 = parameterTag.preParameterName || parameterTag.postParameterName;
if (name_6.text === parameterName) {
return t;
}
}
});
}
}
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | getCorrespondingJSDocParameterTag | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function hasRestParameter(s) {
return isRestParameter(ts.lastOrUndefined(s.parameters));
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | hasRestParameter | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isRestParameter(node) {
if (node) {
if (node.parserContextFlags & 32 /* JavaScriptFile */) {
if (node.type && node.type.kind === 262 /* JSDocVariadicType */) {
return true;
}
var paramTag = getCorrespondingJSDocParameterTag(node);
if (paramTag && paramTag.typeExpression) {
return paramTag.typeExpression.type.kind === 262 /* JSDocVariadicType */;
}
}
return node.dotDotDotToken !== undefined;
}
return false;
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | isRestParameter | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isLiteralKind(kind) {
return 8 /* FirstLiteralToken */ <= kind && kind <= 11 /* LastLiteralToken */;
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | isLiteralKind | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isTextualLiteralKind(kind) {
return kind === 9 /* StringLiteral */ || kind === 11 /* NoSubstitutionTemplateLiteral */;
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | isTextualLiteralKind | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isTemplateLiteralKind(kind) {
return 11 /* FirstTemplateToken */ <= kind && kind <= 14 /* LastTemplateToken */;
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | isTemplateLiteralKind | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isBindingPattern(node) {
return !!node && (node.kind === 162 /* ArrayBindingPattern */ || node.kind === 161 /* ObjectBindingPattern */);
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | isBindingPattern | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isNodeDescendentOf(node, ancestor) {
while (node) {
if (node === ancestor)
return true;
node = node.parent;
}
return false;
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | isNodeDescendentOf | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isInAmbientContext(node) {
while (node) {
if (node.flags & (4 /* Ambient */ | 4096 /* DeclarationFile */)) {
return true;
}
node = node.parent;
}
return false;
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | isInAmbientContext | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isDeclaration(node) {
switch (node.kind) {
case 174 /* ArrowFunction */:
case 163 /* BindingElement */:
case 214 /* ClassDeclaration */:
case 186 /* ClassExpression */:
case 144 /* Constructor */:
case 217 /* EnumDeclaration */:
case 247 /* EnumMember */:
case 230 /* ExportSpecifier */:
case 213 /* FunctionDeclaration */:
case 173 /* FunctionExpression */:
case 145 /* GetAccessor */:
case 223 /* ImportClause */:
case 221 /* ImportEqualsDeclaration */:
case 226 /* ImportSpecifier */:
case 215 /* InterfaceDeclaration */:
case 143 /* MethodDeclaration */:
case 142 /* MethodSignature */:
case 218 /* ModuleDeclaration */:
case 224 /* NamespaceImport */:
case 138 /* Parameter */:
case 245 /* PropertyAssignment */:
case 141 /* PropertyDeclaration */:
case 140 /* PropertySignature */:
case 146 /* SetAccessor */:
case 246 /* ShorthandPropertyAssignment */:
case 216 /* TypeAliasDeclaration */:
case 137 /* TypeParameter */:
case 211 /* VariableDeclaration */:
return true;
}
return false;
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | isDeclaration | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isStatement(n) {
switch (n.kind) {
case 203 /* BreakStatement */:
case 202 /* ContinueStatement */:
case 210 /* DebuggerStatement */:
case 197 /* DoStatement */:
case 195 /* ExpressionStatement */:
case 194 /* EmptyStatement */:
case 200 /* ForInStatement */:
case 201 /* ForOfStatement */:
case 199 /* ForStatement */:
case 196 /* IfStatement */:
case 207 /* LabeledStatement */:
case 204 /* ReturnStatement */:
case 206 /* SwitchStatement */:
case 208 /* ThrowStatement */:
case 209 /* TryStatement */:
case 193 /* VariableStatement */:
case 198 /* WhileStatement */:
case 205 /* WithStatement */:
case 227 /* ExportAssignment */:
return true;
default:
return false;
}
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | isStatement | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isClassElement(n) {
switch (n.kind) {
case 144 /* Constructor */:
case 141 /* PropertyDeclaration */:
case 143 /* MethodDeclaration */:
case 145 /* GetAccessor */:
case 146 /* SetAccessor */:
case 142 /* MethodSignature */:
case 149 /* IndexSignature */:
return true;
default:
return false;
}
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | isClassElement | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getClassExtendsHeritageClauseElement(node) {
var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */);
return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined;
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | getClassExtendsHeritageClauseElement | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getClassImplementsHeritageClauseElements(node) {
var heritageClause = getHeritageClause(node.heritageClauses, 106 /* ImplementsKeyword */);
return heritageClause ? heritageClause.types : undefined;
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | getClassImplementsHeritageClauseElements | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getInterfaceBaseTypeNodes(node) {
var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */);
return heritageClause ? heritageClause.types : undefined;
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | getInterfaceBaseTypeNodes | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getHeritageClause(clauses, kind) {
if (clauses) {
for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) {
var clause = clauses_1[_i];
if (clause.token === kind) {
return clause;
}
}
}
return undefined;
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | getHeritageClause | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function tryResolveScriptReference(host, sourceFile, reference) {
if (!host.getCompilerOptions().noResolve) {
var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName);
return host.getSourceFile(referenceFileName);
}
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | tryResolveScriptReference | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getAncestor(node, kind) {
while (node) {
if (node.kind === kind) {
return node;
}
node = node.parent;
}
return undefined;
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | getAncestor | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getFileReferenceFromReferencePath(comment, commentRange) {
var simpleReferenceRegEx = /^\/\/\/\s*<reference\s+/gim;
var isNoDefaultLibRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)('|")(.+?)\2\s*\/>/gim;
if (simpleReferenceRegEx.test(comment)) {
if (isNoDefaultLibRegEx.test(comment)) {
return {
isNoDefaultLib: true
};
}
else {
var matchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment);
if (matchResult) {
var start = commentRange.pos;
var end = commentRange.end;
return {
fileReference: {
pos: start,
end: end,
fileName: matchResult[3]
},
isNoDefaultLib: false
};
}
else {
return {
diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax,
isNoDefaultLib: false
};
}
}
}
return undefined;
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | getFileReferenceFromReferencePath | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isKeyword(token) {
return 70 /* FirstKeyword */ <= token && token <= 134 /* LastKeyword */;
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | isKeyword | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isTrivia(token) {
return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */;
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | isTrivia | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isAsyncFunctionLike(node) {
return isFunctionLike(node) && (node.flags & 256 /* Async */) !== 0 && !isAccessor(node);
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | isAsyncFunctionLike | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isStringOrNumericLiteral(kind) {
return kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */;
} | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | isStringOrNumericLiteral | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function hasDynamicName(declaration) {
return declaration.name && isDynamicName(declaration.name);
} | A declaration has a dynamic name if both of the following are true:
1. The declaration has a computed property name
2. The computed name is *not* expressed as Symbol.<name>, where name
is a property of the Symbol constructor that denotes a built in
Symbol. | hasDynamicName | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isDynamicName(name) {
return name.kind === 136 /* ComputedPropertyName */ &&
!isStringOrNumericLiteral(name.expression.kind) &&
!isWellKnownSymbolSyntactically(name.expression);
} | A declaration has a dynamic name if both of the following are true:
1. The declaration has a computed property name
2. The computed name is *not* expressed as Symbol.<name>, where name
is a property of the Symbol constructor that denotes a built in
Symbol. | isDynamicName | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isWellKnownSymbolSyntactically(node) {
return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression);
} | Checks if the expression is of the form:
Symbol.name
where Symbol is literally the word "Symbol", and name is any identifierName | isWellKnownSymbolSyntactically | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getPropertyNameForPropertyNameNode(name) {
if (name.kind === 69 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) {
return name.text;
}
if (name.kind === 136 /* ComputedPropertyName */) {
var nameExpression = name.expression;
if (isWellKnownSymbolSyntactically(nameExpression)) {
var rightHandSideName = nameExpression.name.text;
return getPropertyNameForKnownSymbolName(rightHandSideName);
}
}
return undefined;
} | Checks if the expression is of the form:
Symbol.name
where Symbol is literally the word "Symbol", and name is any identifierName | getPropertyNameForPropertyNameNode | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getPropertyNameForKnownSymbolName(symbolName) {
return "__@" + symbolName;
} | Checks if the expression is of the form:
Symbol.name
where Symbol is literally the word "Symbol", and name is any identifierName | getPropertyNameForKnownSymbolName | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isESSymbolIdentifier(node) {
return node.kind === 69 /* Identifier */ && node.text === "Symbol";
} | Includes the word "Symbol" with unicode escapes | isESSymbolIdentifier | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isModifier(token) {
switch (token) {
case 115 /* AbstractKeyword */:
case 118 /* AsyncKeyword */:
case 74 /* ConstKeyword */:
case 122 /* DeclareKeyword */:
case 77 /* DefaultKeyword */:
case 82 /* ExportKeyword */:
case 112 /* PublicKeyword */:
case 110 /* PrivateKeyword */:
case 111 /* ProtectedKeyword */:
case 113 /* StaticKeyword */:
return true;
}
return false;
} | Includes the word "Symbol" with unicode escapes | isModifier | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isParameterDeclaration(node) {
var root = getRootDeclaration(node);
return root.kind === 138 /* Parameter */;
} | Includes the word "Symbol" with unicode escapes | isParameterDeclaration | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getRootDeclaration(node) {
while (node.kind === 163 /* BindingElement */) {
node = node.parent.parent;
}
return node;
} | Includes the word "Symbol" with unicode escapes | getRootDeclaration | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function nodeStartsNewLexicalEnvironment(n) {
return isFunctionLike(n) || n.kind === 218 /* ModuleDeclaration */ || n.kind === 248 /* SourceFile */;
} | Includes the word "Symbol" with unicode escapes | nodeStartsNewLexicalEnvironment | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function cloneEntityName(node) {
if (node.kind === 69 /* Identifier */) {
var clone_1 = createSynthesizedNode(69 /* Identifier */);
clone_1.text = node.text;
return clone_1;
}
else {
var clone_2 = createSynthesizedNode(135 /* QualifiedName */);
clone_2.left = cloneEntityName(node.left);
clone_2.left.parent = clone_2;
clone_2.right = cloneEntityName(node.right);
clone_2.right.parent = clone_2;
return clone_2;
}
} | Includes the word "Symbol" with unicode escapes | cloneEntityName | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function nodeIsSynthesized(node) {
return node.pos === -1;
} | Includes the word "Symbol" with unicode escapes | nodeIsSynthesized | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function createSynthesizedNode(kind, startsOnNewLine) {
var node = ts.createNode(kind, /* pos */ -1, /* end */ -1);
node.startsOnNewLine = startsOnNewLine;
return node;
} | Includes the word "Symbol" with unicode escapes | createSynthesizedNode | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function createSynthesizedNodeArray() {
var array = [];
array.pos = -1;
array.end = -1;
return array;
} | Includes the word "Symbol" with unicode escapes | createSynthesizedNodeArray | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function createDiagnosticCollection() {
var nonFileDiagnostics = [];
var fileDiagnostics = {};
var diagnosticsModified = false;
var modificationCount = 0;
return {
add: add,
getGlobalDiagnostics: getGlobalDiagnostics,
getDiagnostics: getDiagnostics,
getModificationCount: getModificationCount,
reattachFileDiagnostics: reattachFileDiagnostics
};
function getModificationCount() {
return modificationCount;
}
function reattachFileDiagnostics(newFile) {
if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) {
return;
}
for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) {
var diagnostic = _a[_i];
diagnostic.file = newFile;
}
}
function add(diagnostic) {
var diagnostics;
if (diagnostic.file) {
diagnostics = fileDiagnostics[diagnostic.file.fileName];
if (!diagnostics) {
diagnostics = [];
fileDiagnostics[diagnostic.file.fileName] = diagnostics;
}
}
else {
diagnostics = nonFileDiagnostics;
}
diagnostics.push(diagnostic);
diagnosticsModified = true;
modificationCount++;
}
function getGlobalDiagnostics() {
sortAndDeduplicate();
return nonFileDiagnostics;
}
function getDiagnostics(fileName) {
sortAndDeduplicate();
if (fileName) {
return fileDiagnostics[fileName] || [];
}
var allDiagnostics = [];
function pushDiagnostic(d) {
allDiagnostics.push(d);
}
ts.forEach(nonFileDiagnostics, pushDiagnostic);
for (var key in fileDiagnostics) {
if (ts.hasProperty(fileDiagnostics, key)) {
ts.forEach(fileDiagnostics[key], pushDiagnostic);
}
}
return ts.sortAndDeduplicateDiagnostics(allDiagnostics);
}
function sortAndDeduplicate() {
if (!diagnosticsModified) {
return;
}
diagnosticsModified = false;
nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics);
for (var key in fileDiagnostics) {
if (ts.hasProperty(fileDiagnostics, key)) {
fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]);
}
}
}
} | Includes the word "Symbol" with unicode escapes | createDiagnosticCollection | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getModificationCount() {
return modificationCount;
} | Includes the word "Symbol" with unicode escapes | getModificationCount | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function reattachFileDiagnostics(newFile) {
if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) {
return;
}
for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) {
var diagnostic = _a[_i];
diagnostic.file = newFile;
}
} | Includes the word "Symbol" with unicode escapes | reattachFileDiagnostics | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function add(diagnostic) {
var diagnostics;
if (diagnostic.file) {
diagnostics = fileDiagnostics[diagnostic.file.fileName];
if (!diagnostics) {
diagnostics = [];
fileDiagnostics[diagnostic.file.fileName] = diagnostics;
}
}
else {
diagnostics = nonFileDiagnostics;
}
diagnostics.push(diagnostic);
diagnosticsModified = true;
modificationCount++;
} | Includes the word "Symbol" with unicode escapes | add | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getGlobalDiagnostics() {
sortAndDeduplicate();
return nonFileDiagnostics;
} | Includes the word "Symbol" with unicode escapes | getGlobalDiagnostics | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getDiagnostics(fileName) {
sortAndDeduplicate();
if (fileName) {
return fileDiagnostics[fileName] || [];
}
var allDiagnostics = [];
function pushDiagnostic(d) {
allDiagnostics.push(d);
}
ts.forEach(nonFileDiagnostics, pushDiagnostic);
for (var key in fileDiagnostics) {
if (ts.hasProperty(fileDiagnostics, key)) {
ts.forEach(fileDiagnostics[key], pushDiagnostic);
}
}
return ts.sortAndDeduplicateDiagnostics(allDiagnostics);
} | Includes the word "Symbol" with unicode escapes | getDiagnostics | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function sortAndDeduplicate() {
if (!diagnosticsModified) {
return;
}
diagnosticsModified = false;
nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics);
for (var key in fileDiagnostics) {
if (ts.hasProperty(fileDiagnostics, key)) {
fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]);
}
}
} | Includes the word "Symbol" with unicode escapes | sortAndDeduplicate | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getReplacement(c) {
return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0));
} | Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
Note that this doesn't actually wrap the input in double quotes. | getReplacement | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isIntrinsicJsxName(name) {
var ch = name.substr(0, 1);
return ch.toLowerCase() === ch;
} | Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
Note that this doesn't actually wrap the input in double quotes. | isIntrinsicJsxName | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function get16BitUnicodeEscapeSequence(charCode) {
var hexCharCode = charCode.toString(16).toUpperCase();
var paddedHexCode = ("0000" + hexCharCode).slice(-4);
return "\\u" + paddedHexCode;
} | Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
Note that this doesn't actually wrap the input in double quotes. | get16BitUnicodeEscapeSequence | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function escapeNonAsciiCharacters(s) {
// Replace non-ASCII characters with '\uNNNN' escapes if any exist.
// Otherwise just return the original string.
return nonAsciiCharacters.test(s) ?
s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) :
s;
} | Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
Note that this doesn't actually wrap the input in double quotes. | escapeNonAsciiCharacters | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getIndentString(level) {
if (indentStrings[level] === undefined) {
indentStrings[level] = getIndentString(level - 1) + indentStrings[1];
}
return indentStrings[level];
} | Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
Note that this doesn't actually wrap the input in double quotes. | getIndentString | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getIndentSize() {
return indentStrings[1].length;
} | Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
Note that this doesn't actually wrap the input in double quotes. | getIndentSize | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function createTextWriter(newLine) {
var output;
var indent;
var lineStart;
var lineCount;
var linePos;
function write(s) {
if (s && s.length) {
if (lineStart) {
output += getIndentString(indent);
lineStart = false;
}
output += s;
}
}
function reset() {
output = "";
indent = 0;
lineStart = true;
lineCount = 0;
linePos = 0;
}
function rawWrite(s) {
if (s !== undefined) {
if (lineStart) {
lineStart = false;
}
output += s;
}
}
function writeLiteral(s) {
if (s && s.length) {
write(s);
var lineStartsOfS = ts.computeLineStarts(s);
if (lineStartsOfS.length > 1) {
lineCount = lineCount + lineStartsOfS.length - 1;
linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS);
}
}
}
function writeLine() {
if (!lineStart) {
output += newLine;
lineCount++;
linePos = output.length;
lineStart = true;
}
}
function writeTextOfNode(text, node) {
write(getTextOfNodeFromSourceText(text, node));
}
reset();
return {
write: write,
rawWrite: rawWrite,
writeTextOfNode: writeTextOfNode,
writeLiteral: writeLiteral,
writeLine: writeLine,
increaseIndent: function () { return indent++; },
decreaseIndent: function () { return indent--; },
getIndent: function () { return indent; },
getTextPos: function () { return output.length; },
getLine: function () { return lineCount + 1; },
getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; },
getText: function () { return output; },
reset: reset
};
} | Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
Note that this doesn't actually wrap the input in double quotes. | createTextWriter | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function write(s) {
if (s && s.length) {
if (lineStart) {
output += getIndentString(indent);
lineStart = false;
}
output += s;
}
} | Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
Note that this doesn't actually wrap the input in double quotes. | write | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function reset() {
output = "";
indent = 0;
lineStart = true;
lineCount = 0;
linePos = 0;
} | Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
Note that this doesn't actually wrap the input in double quotes. | reset | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function rawWrite(s) {
if (s !== undefined) {
if (lineStart) {
lineStart = false;
}
output += s;
}
} | Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
Note that this doesn't actually wrap the input in double quotes. | rawWrite | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function writeLiteral(s) {
if (s && s.length) {
write(s);
var lineStartsOfS = ts.computeLineStarts(s);
if (lineStartsOfS.length > 1) {
lineCount = lineCount + lineStartsOfS.length - 1;
linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS);
}
}
} | Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
Note that this doesn't actually wrap the input in double quotes. | writeLiteral | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function writeLine() {
if (!lineStart) {
output += newLine;
lineCount++;
linePos = output.length;
lineStart = true;
}
} | Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
Note that this doesn't actually wrap the input in double quotes. | writeLine | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function writeTextOfNode(text, node) {
write(getTextOfNodeFromSourceText(text, node));
} | Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
Note that this doesn't actually wrap the input in double quotes. | writeTextOfNode | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) {
var leadingComments;
var currentDetachedCommentInfo;
if (removeComments) {
// removeComments is true, only reserve pinned comment at the top of file
// For example:
// /*! Pinned Comment */
//
// var x = 10;
if (node.pos === 0) {
leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment);
}
}
else {
// removeComments is false, just get detached as normal and bypass the process to filter comment
leadingComments = ts.getLeadingCommentRanges(text, node.pos);
}
if (leadingComments) {
var detachedComments = [];
var lastComment;
for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) {
var comment = leadingComments_1[_i];
if (lastComment) {
var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end);
var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos);
if (commentLine >= lastCommentLine + 2) {
// There was a blank line between the last comment and this comment. This
// comment is not part of the copyright comments. Return what we have so
// far.
break;
}
}
detachedComments.push(comment);
lastComment = comment;
}
if (detachedComments.length) {
// All comments look like they could have been part of the copyright header. Make
// sure there is at least one blank line between it and the node. If not, it's not
// a copyright header.
var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end);
var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos));
if (nodeLine >= lastCommentLine + 2) {
// Valid detachedComments
emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments);
emitComments(text, lineMap, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment);
currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end };
}
}
}
return currentDetachedCommentInfo;
function isPinnedComment(comment) {
return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ &&
text.charCodeAt(comment.pos + 2) === 33 /* exclamation */;
}
} | Detached comment is a comment at the top of file or function body that is separated from
the next statement by space. | emitDetachedComments | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isPinnedComment(comment) {
return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ &&
text.charCodeAt(comment.pos + 2) === 33 /* exclamation */;
} | Detached comment is a comment at the top of file or function body that is separated from
the next statement by space. | isPinnedComment | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function writeCommentRange(text, lineMap, writer, comment, newLine) {
if (text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) {
var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, comment.pos);
var lineCount = lineMap.length;
var firstCommentLineIndent;
for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) {
var nextLineStart = (currentLine + 1) === lineCount
? text.length + 1
: lineMap[currentLine + 1];
if (pos !== comment.pos) {
// If we are not emitting first line, we need to write the spaces to adjust the alignment
if (firstCommentLineIndent === undefined) {
firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], comment.pos);
}
// These are number of spaces writer is going to write at current indent
var currentWriterIndentSpacing = writer.getIndent() * getIndentSize();
// Number of spaces we want to be writing
// eg: Assume writer indent
// module m {
// /* starts at character 9 this is line 1
// * starts at character pos 4 line --1 = 8 - 8 + 3
// More left indented comment */ --2 = 8 - 8 + 2
// class c { }
// }
// module m {
// /* this is line 1 -- Assume current writer indent 8
// * line --3 = 8 - 4 + 5
// More right indented comment */ --4 = 8 - 4 + 11
// class c { }
// }
var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart);
if (spacesToEmit > 0) {
var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize();
var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize());
// Write indent size string ( in eg 1: = "", 2: "" , 3: string with 8 spaces 4: string with 12 spaces
writer.rawWrite(indentSizeSpaceString);
// Emit the single spaces (in eg: 1: 3 spaces, 2: 2 spaces, 3: 1 space, 4: 3 spaces)
while (numberOfSingleSpacesToEmit) {
writer.rawWrite(" ");
numberOfSingleSpacesToEmit--;
}
}
else {
// No spaces to emit write empty string
writer.rawWrite("");
}
}
// Write the comment line text
writeTrimmedCurrentLine(text, comment, writer, newLine, pos, nextLineStart);
pos = nextLineStart;
}
}
else {
// Single line comment of style //....
writer.write(text.substring(comment.pos, comment.end));
}
} | Detached comment is a comment at the top of file or function body that is separated from
the next statement by space. | writeCommentRange | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function writeTrimmedCurrentLine(text, comment, writer, newLine, pos, nextLineStart) {
var end = Math.min(comment.end, nextLineStart - 1);
var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, "");
if (currentLineText) {
// trimmed forward and ending spaces text
writer.write(currentLineText);
if (end !== comment.end) {
writer.writeLine();
}
}
else {
// Empty string - make sure we write empty line
writer.writeLiteral(newLine);
}
} | Detached comment is a comment at the top of file or function body that is separated from
the next statement by space. | writeTrimmedCurrentLine | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function calculateIndent(text, pos, end) {
var currentLineIndent = 0;
for (; pos < end && ts.isWhiteSpace(text.charCodeAt(pos)); pos++) {
if (text.charCodeAt(pos) === 9 /* tab */) {
// Tabs = TabSize = indent size and go to next tabStop
currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize());
}
else {
// Single space
currentLineIndent++;
}
}
return currentLineIndent;
} | Detached comment is a comment at the top of file or function body that is separated from
the next statement by space. | calculateIndent | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function modifierToFlag(token) {
switch (token) {
case 113 /* StaticKeyword */: return 64 /* Static */;
case 112 /* PublicKeyword */: return 8 /* Public */;
case 111 /* ProtectedKeyword */: return 32 /* Protected */;
case 110 /* PrivateKeyword */: return 16 /* Private */;
case 115 /* AbstractKeyword */: return 128 /* Abstract */;
case 82 /* ExportKeyword */: return 2 /* Export */;
case 122 /* DeclareKeyword */: return 4 /* Ambient */;
case 74 /* ConstKeyword */: return 16384 /* Const */;
case 77 /* DefaultKeyword */: return 512 /* Default */;
case 118 /* AsyncKeyword */: return 256 /* Async */;
}
return 0;
} | Detached comment is a comment at the top of file or function body that is separated from
the next statement by space. | modifierToFlag | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isLeftHandSideExpression(expr) {
if (expr) {
switch (expr.kind) {
case 166 /* PropertyAccessExpression */:
case 167 /* ElementAccessExpression */:
case 169 /* NewExpression */:
case 168 /* CallExpression */:
case 233 /* JsxElement */:
case 234 /* JsxSelfClosingElement */:
case 170 /* TaggedTemplateExpression */:
case 164 /* ArrayLiteralExpression */:
case 172 /* ParenthesizedExpression */:
case 165 /* ObjectLiteralExpression */:
case 186 /* ClassExpression */:
case 173 /* FunctionExpression */:
case 69 /* Identifier */:
case 10 /* RegularExpressionLiteral */:
case 8 /* NumericLiteral */:
case 9 /* StringLiteral */:
case 11 /* NoSubstitutionTemplateLiteral */:
case 183 /* TemplateExpression */:
case 84 /* FalseKeyword */:
case 93 /* NullKeyword */:
case 97 /* ThisKeyword */:
case 99 /* TrueKeyword */:
case 95 /* SuperKeyword */:
return true;
}
}
return false;
} | Detached comment is a comment at the top of file or function body that is separated from
the next statement by space. | isLeftHandSideExpression | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isAssignmentOperator(token) {
return token >= 56 /* FirstAssignment */ && token <= 68 /* LastAssignment */;
} | Detached comment is a comment at the top of file or function body that is separated from
the next statement by space. | isAssignmentOperator | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isExpressionWithTypeArgumentsInClassExtendsClause(node) {
return node.kind === 188 /* ExpressionWithTypeArguments */ &&
node.parent.token === 83 /* ExtendsKeyword */ &&
isClassLike(node.parent.parent);
} | Detached comment is a comment at the top of file or function body that is separated from
the next statement by space. | isExpressionWithTypeArgumentsInClassExtendsClause | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isSupportedExpressionWithTypeArguments(node) {
return isSupportedExpressionWithTypeArgumentsRest(node.expression);
} | Detached comment is a comment at the top of file or function body that is separated from
the next statement by space. | isSupportedExpressionWithTypeArguments | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isSupportedExpressionWithTypeArgumentsRest(node) {
if (node.kind === 69 /* Identifier */) {
return true;
}
else if (isPropertyAccessExpression(node)) {
return isSupportedExpressionWithTypeArgumentsRest(node.expression);
}
else {
return false;
}
} | Detached comment is a comment at the top of file or function body that is separated from
the next statement by space. | isSupportedExpressionWithTypeArgumentsRest | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isRightSideOfQualifiedNameOrPropertyAccess(node) {
return (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) ||
(node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node);
} | Detached comment is a comment at the top of file or function body that is separated from
the next statement by space. | isRightSideOfQualifiedNameOrPropertyAccess | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isEmptyObjectLiteralOrArrayLiteral(expression) {
var kind = expression.kind;
if (kind === 165 /* ObjectLiteralExpression */) {
return expression.properties.length === 0;
}
if (kind === 164 /* ArrayLiteralExpression */) {
return expression.elements.length === 0;
}
return false;
} | Detached comment is a comment at the top of file or function body that is separated from
the next statement by space. | isEmptyObjectLiteralOrArrayLiteral | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getLocalSymbolForExportDefault(symbol) {
return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 512 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined;
} | Detached comment is a comment at the top of file or function body that is separated from
the next statement by space. | getLocalSymbolForExportDefault | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function hasJavaScriptFileExtension(fileName) {
return ts.fileExtensionIs(fileName, ".js") || ts.fileExtensionIs(fileName, ".jsx");
} | Detached comment is a comment at the top of file or function body that is separated from
the next statement by space. | hasJavaScriptFileExtension | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function allowsJsxExpressions(fileName) {
return ts.fileExtensionIs(fileName, ".tsx") || ts.fileExtensionIs(fileName, ".jsx");
} | Detached comment is a comment at the top of file or function body that is separated from
the next statement by space. | allowsJsxExpressions | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function convertToBase64(input) {
var result = "";
var charCodes = getExpandedCharCodes(input);
var i = 0;
var length = charCodes.length;
var byte1, byte2, byte3, byte4;
while (i < length) {
// Convert every 6-bits in the input 3 character points
// into a base64 digit
byte1 = charCodes[i] >> 2;
byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4;
byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6;
byte4 = charCodes[i + 2] & 63;
// We are out of characters in the input, set the extra
// digits to 64 (padding character).
if (i + 1 >= length) {
byte3 = byte4 = 64;
}
else if (i + 2 >= length) {
byte4 = 64;
}
// Write to the ouput
result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4);
i += 3;
}
return result;
} | Converts a string to a base-64 encoded ASCII string. | convertToBase64 | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
return !ts.isRootedDiskPath(absoluteOrRelativePath)
? absoluteOrRelativePath
: ts.getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /* isAbsolutePathAnUrl */ false);
} | Converts a string to a base-64 encoded ASCII string. | convertToRelativePath | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getNewLineCharacter(options) {
if (options.newLine === 0 /* CarriageReturnLineFeed */) {
return carriageReturnLineFeed;
}
else if (options.newLine === 1 /* LineFeed */) {
return lineFeed;
}
else if (ts.sys) {
return ts.sys.newLine;
}
return carriageReturnLineFeed;
} | Converts a string to a base-64 encoded ASCII string. | getNewLineCharacter | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getDefaultLibFileName(options) {
return options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts";
} | Converts a string to a base-64 encoded ASCII string. | getDefaultLibFileName | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function textSpanEnd(span) {
return span.start + span.length;
} | Converts a string to a base-64 encoded ASCII string. | textSpanEnd | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function textSpanIsEmpty(span) {
return span.length === 0;
} | Converts a string to a base-64 encoded ASCII string. | textSpanIsEmpty | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function textSpanContainsPosition(span, position) {
return position >= span.start && position < textSpanEnd(span);
} | Converts a string to a base-64 encoded ASCII string. | textSpanContainsPosition | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function textSpanOverlapsWith(span, other) {
var overlapStart = Math.max(span.start, other.start);
var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other));
return overlapStart < overlapEnd;
} | Converts a string to a base-64 encoded ASCII string. | textSpanOverlapsWith | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function textSpanOverlap(span1, span2) {
var overlapStart = Math.max(span1.start, span2.start);
var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
if (overlapStart < overlapEnd) {
return createTextSpanFromBounds(overlapStart, overlapEnd);
}
return undefined;
} | Converts a string to a base-64 encoded ASCII string. | textSpanOverlap | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function textSpanIntersectsWithTextSpan(span, other) {
return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start;
} | Converts a string to a base-64 encoded ASCII string. | textSpanIntersectsWithTextSpan | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function textSpanIntersectsWith(span, start, length) {
var end = start + length;
return start <= textSpanEnd(span) && end >= span.start;
} | Converts a string to a base-64 encoded ASCII string. | textSpanIntersectsWith | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function decodedTextSpanIntersectsWith(start1, length1, start2, length2) {
var end1 = start1 + length1;
var end2 = start2 + length2;
return start2 <= end1 && end2 >= start1;
} | Converts a string to a base-64 encoded ASCII string. | decodedTextSpanIntersectsWith | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function textSpanIntersectsWithPosition(span, position) {
return position <= textSpanEnd(span) && position >= span.start;
} | Converts a string to a base-64 encoded ASCII string. | textSpanIntersectsWithPosition | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function textSpanIntersection(span1, span2) {
var intersectStart = Math.max(span1.start, span2.start);
var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
if (intersectStart <= intersectEnd) {
return createTextSpanFromBounds(intersectStart, intersectEnd);
}
return undefined;
} | Converts a string to a base-64 encoded ASCII string. | textSpanIntersection | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function createTextSpan(start, length) {
if (start < 0) {
throw new Error("start < 0");
}
if (length < 0) {
throw new Error("length < 0");
}
return { start: start, length: length };
} | Converts a string to a base-64 encoded ASCII string. | createTextSpan | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function createTextSpanFromBounds(start, end) {
return createTextSpan(start, end - start);
} | Converts a string to a base-64 encoded ASCII string. | createTextSpanFromBounds | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function textChangeRangeNewSpan(range) {
return createTextSpan(range.span.start, range.newLength);
} | Converts a string to a base-64 encoded ASCII string. | textChangeRangeNewSpan | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function textChangeRangeIsUnchanged(range) {
return textSpanIsEmpty(range.span) && range.newLength === 0;
} | Converts a string to a base-64 encoded ASCII string. | textChangeRangeIsUnchanged | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function createTextChangeRange(span, newLength) {
if (newLength < 0) {
throw new Error("newLength < 0");
}
return { span: span, newLength: newLength };
} | Converts a string to a base-64 encoded ASCII string. | createTextChangeRange | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function collapseTextChangeRangesAcrossMultipleVersions(changes) {
if (changes.length === 0) {
return ts.unchangedTextChangeRange;
}
if (changes.length === 1) {
return changes[0];
}
// We change from talking about { { oldStart, oldLength }, newLength } to { oldStart, oldEnd, newEnd }
// as it makes things much easier to reason about.
var change0 = changes[0];
var oldStartN = change0.span.start;
var oldEndN = textSpanEnd(change0.span);
var newEndN = oldStartN + change0.newLength;
for (var i = 1; i < changes.length; i++) {
var nextChange = changes[i];
// Consider the following case:
// i.e. two edits. The first represents the text change range { { 10, 50 }, 30 }. i.e. The span starting
// at 10, with length 50 is reduced to length 30. The second represents the text change range { { 30, 30 }, 40 }.
// i.e. the span starting at 30 with length 30 is increased to length 40.
//
// 0 10 20 30 40 50 60 70 80 90 100
// -------------------------------------------------------------------------------------------------------
// | /
// | /----
// T1 | /----
// | /----
// | /----
// -------------------------------------------------------------------------------------------------------
// | \
// | \
// T2 | \
// | \
// | \
// -------------------------------------------------------------------------------------------------------
//
// Merging these turns out to not be too difficult. First, determining the new start of the change is trivial
// it's just the min of the old and new starts. i.e.:
//
// 0 10 20 30 40 50 60 70 80 90 100
// ------------------------------------------------------------*------------------------------------------
// | /
// | /----
// T1 | /----
// | /----
// | /----
// ----------------------------------------$-------------------$------------------------------------------
// . | \
// . | \
// T2 . | \
// . | \
// . | \
// ----------------------------------------------------------------------*--------------------------------
//
// (Note the dots represent the newly inferrred start.
// Determining the new and old end is also pretty simple. Basically it boils down to paying attention to the
// absolute positions at the asterixes, and the relative change between the dollar signs. Basically, we see
// which if the two $'s precedes the other, and we move that one forward until they line up. in this case that
// means:
//
// 0 10 20 30 40 50 60 70 80 90 100
// --------------------------------------------------------------------------------*----------------------
// | /
// | /----
// T1 | /----
// | /----
// | /----
// ------------------------------------------------------------$------------------------------------------
// . | \
// . | \
// T2 . | \
// . | \
// . | \
// ----------------------------------------------------------------------*--------------------------------
//
// In other words (in this case), we're recognizing that the second edit happened after where the first edit
// ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started
// that's the same as if we started at char 80 instead of 60.
//
// As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter
// than pusing the first edit forward to match the second, we'll push the second edit forward to match the
// first.
//
// In this case that means we have { oldStart: 10, oldEnd: 80, newEnd: 70 } or, in TextChangeRange
// semantics: { { start: 10, length: 70 }, newLength: 60 }
//
// The math then works out as follows.
// If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the
// final result like so:
//
// {
// oldStart3: Min(oldStart1, oldStart2),
// oldEnd3 : Max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)),
// newEnd3 : Max(newEnd2, newEnd2 + (newEnd1 - oldEnd2))
// }
var oldStart1 = oldStartN;
var oldEnd1 = oldEndN;
var newEnd1 = newEndN;
var oldStart2 = nextChange.span.start;
var oldEnd2 = textSpanEnd(nextChange.span);
var newEnd2 = oldStart2 + nextChange.newLength;
oldStartN = Math.min(oldStart1, oldStart2);
oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
}
return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN);
} | Called to merge all the changes that occurred across several versions of a script snapshot
into a single change. i.e. if a user keeps making successive edits to a script we will
have a text change from V1 to V2, V2 to V3, ..., Vn.
This function will then merge those changes into a single change range valid between V1 and
Vn. | collapseTextChangeRangesAcrossMultipleVersions | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getTypeParameterOwner(d) {
if (d && d.kind === 137 /* TypeParameter */) {
for (var current = d; current; current = current.parent) {
if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215 /* InterfaceDeclaration */) {
return current;
}
}
}
} | Called to merge all the changes that occurred across several versions of a script snapshot
into a single change. i.e. if a user keeps making successive edits to a script we will
have a text change from V1 to V2, V2 to V3, ..., Vn.
This function will then merge those changes into a single change range valid between V1 and
Vn. | getTypeParameterOwner | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function createNode(kind, pos, end) {
if (kind === 248 /* SourceFile */) {
return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end);
}
else {
return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, pos, end);
}
} | Called to merge all the changes that occurred across several versions of a script snapshot
into a single change. i.e. if a user keeps making successive edits to a script we will
have a text change from V1 to V2, V2 to V3, ..., Vn.
This function will then merge those changes into a single change range valid between V1 and
Vn. | createNode | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.