mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-28 09:22:42 -05:00
Delete unused files
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export function settingsChangeAffectsSyntax(before: ts.CompilerOptions, after: ts.CompilerOptions): boolean {
|
||||
// If the automatic semicolon insertion option has changed, then we have to dump all
|
||||
// syntax trees in order to reparse them with the new option.
|
||||
//
|
||||
// If the language version changed, then that affects what types of things we parse. So
|
||||
// we have to dump all syntax trees.
|
||||
//
|
||||
// If propagateEnumConstants changes, then that affects the constant value data we've
|
||||
// stored in the ISyntaxElement.
|
||||
return before.module !== after.module || before.target !== after.target;
|
||||
}
|
||||
}
|
||||
@@ -1,472 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript.Services {
|
||||
// Information about a specific host file.
|
||||
class HostFileInformation {
|
||||
private _sourceText: TypeScript.IScriptSnapshot;
|
||||
|
||||
constructor(
|
||||
public fileName: string,
|
||||
private host: ILanguageServiceHost,
|
||||
public version: number,
|
||||
public isOpen: boolean,
|
||||
public byteOrderMark: TypeScript.ByteOrderMark) {
|
||||
this._sourceText = null;
|
||||
}
|
||||
|
||||
public getScriptSnapshot(): TypeScript.IScriptSnapshot {
|
||||
if (this._sourceText === null) {
|
||||
this._sourceText = this.host.getScriptSnapshot(this.fileName);
|
||||
}
|
||||
|
||||
return this._sourceText;
|
||||
}
|
||||
}
|
||||
|
||||
// Cache host information about scripts. Should be refreshed
|
||||
// at each language service public entry point, since we don't know when
|
||||
// set of scripts handled by the host changes.
|
||||
class HostCache {
|
||||
private _fileNameToEntry: TypeScript.StringHashTable<HostFileInformation>;
|
||||
private _compilationSettings: TypeScript.ImmutableCompilationSettings;
|
||||
|
||||
constructor(host: ILanguageServiceHost) {
|
||||
// script id => script index
|
||||
this._fileNameToEntry = new TypeScript.StringHashTable<HostFileInformation>();
|
||||
|
||||
var fileNames = host.getScriptFileNames();
|
||||
for (var i = 0, n = fileNames.length; i < n; i++) {
|
||||
var fileName = fileNames[i];
|
||||
this._fileNameToEntry.add(TypeScript.switchToForwardSlashes(fileName), new HostFileInformation(
|
||||
fileName, host, host.getScriptVersion(fileName), host.getScriptIsOpen(fileName), host.getScriptByteOrderMark(fileName)));
|
||||
}
|
||||
|
||||
var settings = host.getCompilationSettings();
|
||||
if (!settings) {
|
||||
// Set "ES5" target by default for language service
|
||||
settings = new TypeScript.CompilationSettings();
|
||||
settings.codeGenTarget = TypeScript.LanguageVersion.EcmaScript5;
|
||||
}
|
||||
|
||||
this._compilationSettings = TypeScript.ImmutableCompilationSettings.fromCompilationSettings(settings);
|
||||
}
|
||||
|
||||
public compilationSettings() {
|
||||
return this._compilationSettings;
|
||||
}
|
||||
|
||||
public contains(fileName: string): boolean {
|
||||
return this._fileNameToEntry.lookup(TypeScript.switchToForwardSlashes(fileName)) !== null;
|
||||
}
|
||||
|
||||
public getHostFileName(fileName: string) {
|
||||
var hostCacheEntry = this._fileNameToEntry.lookup(TypeScript.switchToForwardSlashes(fileName));
|
||||
if (hostCacheEntry) {
|
||||
return hostCacheEntry.fileName;
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public getFileNames(): string[]{
|
||||
return this._fileNameToEntry.getAllKeys();
|
||||
}
|
||||
|
||||
public getVersion(fileName: string): number {
|
||||
return this._fileNameToEntry.lookup(TypeScript.switchToForwardSlashes(fileName)).version;
|
||||
}
|
||||
|
||||
public isOpen(fileName: string): boolean {
|
||||
return this._fileNameToEntry.lookup(TypeScript.switchToForwardSlashes(fileName)).isOpen;
|
||||
}
|
||||
|
||||
public getByteOrderMark(fileName: string): TypeScript.ByteOrderMark {
|
||||
return this._fileNameToEntry.lookup(TypeScript.switchToForwardSlashes(fileName)).byteOrderMark;
|
||||
}
|
||||
|
||||
public getScriptSnapshot(fileName: string): TypeScript.IScriptSnapshot {
|
||||
return this._fileNameToEntry.lookup(TypeScript.switchToForwardSlashes(fileName)).getScriptSnapshot();
|
||||
}
|
||||
|
||||
public getScriptTextChangeRangeSinceVersion(fileName: string, lastKnownVersion: number): TypeScript.TextChangeRange {
|
||||
var currentVersion = this.getVersion(fileName);
|
||||
if (lastKnownVersion === currentVersion) {
|
||||
return TypeScript.TextChangeRange.unchanged; // "No changes"
|
||||
}
|
||||
|
||||
var scriptSnapshot = this.getScriptSnapshot(fileName);
|
||||
return scriptSnapshot.getTextChangeRangeSinceVersion(lastKnownVersion);
|
||||
}
|
||||
}
|
||||
|
||||
export class SyntaxTreeCache {
|
||||
private _hostCache: HostCache;
|
||||
|
||||
// For our syntactic only features, we also keep a cache of the syntax tree for the
|
||||
// currently edited file.
|
||||
private _currentFileName: string = "";
|
||||
private _currentFileVersion: number = -1;
|
||||
private _currentFileSyntaxTree: TypeScript.SyntaxTree = null;
|
||||
private _currentFileScriptSnapshot: TypeScript.IScriptSnapshot = null;
|
||||
|
||||
constructor(private _host: ILanguageServiceHost) {
|
||||
this._hostCache = new HostCache(_host);
|
||||
}
|
||||
|
||||
public getCurrentFileSyntaxTree(fileName: string): TypeScript.SyntaxTree {
|
||||
this._hostCache = new HostCache(this._host);
|
||||
|
||||
var version = this._hostCache.getVersion(fileName);
|
||||
var syntaxTree: TypeScript.SyntaxTree = null;
|
||||
|
||||
if (this._currentFileSyntaxTree === null || this._currentFileName !== fileName) {
|
||||
var scriptSnapshot = this._hostCache.getScriptSnapshot(fileName);
|
||||
syntaxTree = this.createSyntaxTree(fileName, scriptSnapshot);
|
||||
}
|
||||
else if (this._currentFileVersion !== version) {
|
||||
var scriptSnapshot = this._hostCache.getScriptSnapshot(fileName);
|
||||
syntaxTree = this.updateSyntaxTree(fileName, scriptSnapshot, this._currentFileSyntaxTree, this._currentFileVersion);
|
||||
}
|
||||
|
||||
if (syntaxTree !== null) {
|
||||
// All done, ensure state is up to date
|
||||
this._currentFileScriptSnapshot = scriptSnapshot;
|
||||
this._currentFileVersion = version;
|
||||
this._currentFileName = fileName;
|
||||
this._currentFileSyntaxTree = syntaxTree;
|
||||
}
|
||||
|
||||
return this._currentFileSyntaxTree;
|
||||
}
|
||||
|
||||
private createSyntaxTree(fileName: string, scriptSnapshot: TypeScript.IScriptSnapshot): TypeScript.SyntaxTree {
|
||||
var text = TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot);
|
||||
|
||||
// For the purposes of features that use this syntax tree, we can just use the default
|
||||
// compilation settings. The features only use the syntax (and not the diagnostics),
|
||||
// and the syntax isn't affected by the compilation settings.
|
||||
var syntaxTree = TypeScript.Parser.parse(fileName, text,
|
||||
TypeScript.ImmutableCompilationSettings.defaultSettings().codeGenTarget(), TypeScript.isDTSFile(fileName));
|
||||
|
||||
return syntaxTree;
|
||||
}
|
||||
|
||||
private updateSyntaxTree(fileName: string, scriptSnapshot: TypeScript.IScriptSnapshot, previousSyntaxTree: TypeScript.SyntaxTree, previousFileVersion: number): TypeScript.SyntaxTree {
|
||||
var editRange = this._hostCache.getScriptTextChangeRangeSinceVersion(fileName, previousFileVersion);
|
||||
|
||||
// Debug.assert(newLength >= 0);
|
||||
|
||||
// The host considers the entire buffer changed. So parse a completely new tree.
|
||||
if (editRange === null) {
|
||||
return this.createSyntaxTree(fileName, scriptSnapshot);
|
||||
}
|
||||
|
||||
var nextSyntaxTree = IncrementalParser.parse(
|
||||
previousSyntaxTree, editRange, SimpleText.fromScriptSnapshot(scriptSnapshot));
|
||||
|
||||
this.ensureInvariants(fileName, editRange, nextSyntaxTree, this._currentFileScriptSnapshot, scriptSnapshot);
|
||||
|
||||
return nextSyntaxTree;
|
||||
}
|
||||
|
||||
private ensureInvariants(fileName: string, editRange: TypeScript.TextChangeRange, incrementalTree: TypeScript.SyntaxTree, oldScriptSnapshot: TypeScript.IScriptSnapshot, newScriptSnapshot: TypeScript.IScriptSnapshot) {
|
||||
// First, verify that the edit range and the script snapshots make sense.
|
||||
|
||||
// If this fires, then the edit range is completely bogus. Somehow the lengths of the
|
||||
// old snapshot, the change range and the new snapshot aren't in sync. This is very
|
||||
// bad.
|
||||
var expectedNewLength = oldScriptSnapshot.getLength() - editRange.span().length() + editRange.newLength();
|
||||
var actualNewLength = newScriptSnapshot.getLength();
|
||||
|
||||
function provideMoreDebugInfo() {
|
||||
|
||||
var debugInformation = ["expected length:", expectedNewLength, "and actual length:", actualNewLength, "are not equal\r\n"];
|
||||
|
||||
var oldSpan = editRange.span();
|
||||
|
||||
function prettyPrintString(s: string): string {
|
||||
return '"' + s.replace(/\r/g, '\\r').replace(/\n/g, '\\n') + '"';
|
||||
}
|
||||
|
||||
debugInformation.push('Edit range (old text) (start: ' + oldSpan.start() + ', end: ' + oldSpan.end() + ') \r\n');
|
||||
debugInformation.push('Old text edit range contents: ' + prettyPrintString(oldScriptSnapshot.getText(oldSpan.start(), oldSpan.end())));
|
||||
|
||||
var newSpan = editRange.newSpan();
|
||||
|
||||
debugInformation.push('Edit range (new text) (start: ' + newSpan.start() + ', end: ' + newSpan.end() + ') \r\n');
|
||||
debugInformation.push('New text edit range contents: ' + prettyPrintString(newScriptSnapshot.getText(newSpan.start(), newSpan.end())));
|
||||
|
||||
return debugInformation.join(' ');
|
||||
}
|
||||
|
||||
Debug.assert(
|
||||
expectedNewLength === actualNewLength,
|
||||
"Expected length is different from actual!",
|
||||
provideMoreDebugInfo);
|
||||
|
||||
if (Debug.shouldAssert(AssertionLevel.VeryAggressive)) {
|
||||
// If this fires, the text change range is bogus. It says the change starts at point
|
||||
// 'X', but we can see a text difference *before* that point.
|
||||
var oldPrefixText = oldScriptSnapshot.getText(0, editRange.span().start());
|
||||
var newPrefixText = newScriptSnapshot.getText(0, editRange.span().start());
|
||||
Debug.assert(oldPrefixText === newPrefixText, 'Expected equal prefix texts!');
|
||||
|
||||
// If this fires, the text change range is bogus. It says the change goes only up to
|
||||
// point 'X', but we can see a text difference *after* that point.
|
||||
var oldSuffixText = oldScriptSnapshot.getText(editRange.span().end(), oldScriptSnapshot.getLength());
|
||||
var newSuffixText = newScriptSnapshot.getText(editRange.newSpan().end(), newScriptSnapshot.getLength());
|
||||
Debug.assert(oldSuffixText === newSuffixText, 'Expected equal suffix texts!');
|
||||
|
||||
// Ok, text change range and script snapshots look ok. Let's verify that our
|
||||
// incremental parsing worked properly.
|
||||
//var normalTree = this.createSyntaxTree(fileName, newScriptSnapshot);
|
||||
//Debug.assert(normalTree.structuralEquals(incrementalTree), 'Expected equal incremental and normal trees');
|
||||
|
||||
// Ok, the trees looked good. So at least our incremental parser agrees with the
|
||||
// normal parser. Now, verify that the incremental tree matches the contents of the
|
||||
// script snapshot.
|
||||
var incrementalTreeText = fullText(incrementalTree.sourceUnit());
|
||||
var actualSnapshotText = newScriptSnapshot.getText(0, newScriptSnapshot.getLength());
|
||||
Debug.assert(incrementalTreeText === actualSnapshotText, 'Expected full texts to be equal');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class LanguageServiceCompiler {
|
||||
private logger: TypeScript.ILogger;
|
||||
|
||||
// The underlying typescript compiler we defer most operations to.
|
||||
private compiler: TypeScript.TypeScriptCompiler = null;
|
||||
|
||||
// A cache of all the information about the files on the host side.
|
||||
private hostCache: HostCache = null;
|
||||
|
||||
constructor(private host: ILanguageServiceHost, private documentRegistry: IDocumentRegistry, private cancellationToken: CancellationToken) {
|
||||
this.logger = this.host;
|
||||
}
|
||||
|
||||
private synchronizeHostData(): void {
|
||||
TypeScript.timeFunction(this.logger, "synchronizeHostData()", () => {
|
||||
this.synchronizeHostDataWorker();
|
||||
});
|
||||
}
|
||||
|
||||
private synchronizeHostDataWorker(): void {
|
||||
// Reset the cache at start of every refresh
|
||||
this.hostCache = new HostCache(this.host);
|
||||
|
||||
var compilationSettings = this.hostCache.compilationSettings();
|
||||
|
||||
// If we don't have a compiler, then create a new one.
|
||||
if (this.compiler === null) {
|
||||
this.compiler = new TypeScript.TypeScriptCompiler(this.logger, compilationSettings);
|
||||
}
|
||||
|
||||
var oldSettings = this.compiler.compilationSettings();
|
||||
|
||||
var changesInCompilationSettingsAffectSyntax =
|
||||
oldSettings && compilationSettings && !compareDataObjects(oldSettings, compilationSettings) && settingsChangeAffectsSyntax(oldSettings, compilationSettings);
|
||||
|
||||
// let the compiler know about the current compilation settings.
|
||||
this.compiler.setCompilationSettings(compilationSettings);
|
||||
|
||||
// Now, remove any files from the compiler that are no longer in the host.
|
||||
var compilerFileNames = this.compiler.fileNames();
|
||||
|
||||
for (var i = 0, n = compilerFileNames.length; i < n; i++) {
|
||||
|
||||
this.cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
var fileName = compilerFileNames[i];
|
||||
|
||||
if (!this.hostCache.contains(fileName) || changesInCompilationSettingsAffectSyntax) {
|
||||
this.compiler.removeFile(fileName);
|
||||
this.documentRegistry.releaseDocument(fileName, oldSettings);
|
||||
}
|
||||
}
|
||||
|
||||
// Now, for every file the host knows about, either add the file (if the compiler
|
||||
// doesn't know about it.). Or notify the compiler about any changes (if it does
|
||||
// know about it.)
|
||||
var hostFileNames = this.hostCache.getFileNames();
|
||||
|
||||
for (var i = 0, n = hostFileNames.length; i < n; i++) {
|
||||
var fileName = hostFileNames[i];
|
||||
|
||||
var version = this.hostCache.getVersion(fileName);
|
||||
var isOpen = this.hostCache.isOpen(fileName);
|
||||
var scriptSnapshot = this.hostCache.getScriptSnapshot(fileName);
|
||||
|
||||
var document: Document = this.compiler.getDocument(fileName)
|
||||
if (document) {
|
||||
//
|
||||
// If the document is the same, assume no update
|
||||
//
|
||||
if (document.version === version && document.isOpen === isOpen) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Only perform incremental parsing on open files that are being edited. If a file was
|
||||
// open, but is now closed, we want to reparse entirely so we don't have any tokens that
|
||||
// are holding onto expensive script snapshot instances on the host. Similarly, if a
|
||||
// file was closed, then we always want to reparse. This is so our tree doesn't keep
|
||||
// the old buffer alive that represented the file on disk (as the host has moved to a
|
||||
// new text buffer).
|
||||
var textChangeRange: TextChangeRange = null;
|
||||
if (document.isOpen && isOpen) {
|
||||
textChangeRange = this.hostCache.getScriptTextChangeRangeSinceVersion(fileName, document.version);
|
||||
}
|
||||
|
||||
document = this.documentRegistry.updateDocument(document, fileName, compilationSettings, scriptSnapshot, version, isOpen, textChangeRange);
|
||||
}
|
||||
else {
|
||||
document = this.documentRegistry.acquireDocument(fileName, compilationSettings, scriptSnapshot, this.hostCache.getByteOrderMark(fileName), version, isOpen, []);
|
||||
}
|
||||
|
||||
this.compiler.addOrUpdateFile(document);
|
||||
}
|
||||
}
|
||||
|
||||
// Methods that defer to the host cache to get the result.
|
||||
|
||||
public getScriptSnapshot(fileName: string): TypeScript.IScriptSnapshot {
|
||||
this.synchronizeHostData();
|
||||
return this.hostCache.getScriptSnapshot(fileName);
|
||||
}
|
||||
|
||||
// Methods that does not require updating the host cache information
|
||||
public getCachedHostFileName(fileName: string) {
|
||||
if (!this.hostCache) {
|
||||
this.synchronizeHostData();
|
||||
}
|
||||
|
||||
return this.hostCache.getHostFileName(fileName);
|
||||
}
|
||||
|
||||
public getCachedTopLevelDeclaration(fileName: string) {
|
||||
if (!this.hostCache) {
|
||||
this.synchronizeHostData();
|
||||
}
|
||||
|
||||
return this.compiler.topLevelDeclaration(fileName);
|
||||
}
|
||||
|
||||
// Methods that defer to the compiler to get the result.
|
||||
|
||||
public compilationSettings(): TypeScript.ImmutableCompilationSettings {
|
||||
this.synchronizeHostData();
|
||||
return this.compiler.compilationSettings();
|
||||
}
|
||||
|
||||
public fileNames(): string[] {
|
||||
this.synchronizeHostData();
|
||||
return this.compiler.fileNames();
|
||||
}
|
||||
|
||||
public cleanupSemanticCache(): void {
|
||||
this.compiler.cleanupSemanticCache();
|
||||
}
|
||||
|
||||
public getDocument(fileName: string): TypeScript.Document {
|
||||
this.synchronizeHostData();
|
||||
return this.compiler.getDocument(fileName);
|
||||
}
|
||||
|
||||
public getSemanticInfoChain(): SemanticInfoChain {
|
||||
this.synchronizeHostData();
|
||||
return this.compiler.getSemanticInfoChain();
|
||||
}
|
||||
|
||||
public getSyntacticDiagnostics(fileName: string): TypeScript.Diagnostic[] {
|
||||
this.synchronizeHostData();
|
||||
return this.compiler.getSyntacticDiagnostics(fileName);
|
||||
}
|
||||
|
||||
public getSemanticDiagnostics(fileName: string): TypeScript.Diagnostic[] {
|
||||
this.synchronizeHostData();
|
||||
return this.compiler.getSemanticDiagnostics(fileName);
|
||||
}
|
||||
|
||||
public getCompilerOptionsDiagnostics(resolvePath: (path: string) => string): TypeScript.Diagnostic[] {
|
||||
this.synchronizeHostData();
|
||||
return this.compiler.getCompilerOptionsDiagnostics(resolvePath);
|
||||
}
|
||||
|
||||
public getSymbolInformationFromAST(ast: TypeScript.ISyntaxElement, document: TypeScript.Document) {
|
||||
this.synchronizeHostData();
|
||||
return this.compiler.pullGetSymbolInformationFromAST(ast, document);
|
||||
}
|
||||
|
||||
public getCallInformationFromAST(ast: TypeScript.ISyntaxElement, document: TypeScript.Document) {
|
||||
this.synchronizeHostData();
|
||||
return this.compiler.pullGetCallInformationFromAST(ast, document);
|
||||
}
|
||||
|
||||
public getVisibleMemberSymbolsFromAST(ast: TypeScript.ISyntaxElement, document: TypeScript.Document) {
|
||||
this.synchronizeHostData();
|
||||
return this.compiler.pullGetVisibleMemberSymbolsFromAST(ast, document);
|
||||
}
|
||||
|
||||
public getVisibleDeclsFromAST(ast: TypeScript.ISyntaxElement, document: TypeScript.Document) {
|
||||
this.synchronizeHostData();
|
||||
return this.compiler.pullGetVisibleDeclsFromAST(ast, document);
|
||||
}
|
||||
|
||||
public getContextualMembersFromAST(ast: TypeScript.ISyntaxElement, document: TypeScript.Document) {
|
||||
this.synchronizeHostData();
|
||||
return this.compiler.pullGetContextualMembersFromAST(ast, document);
|
||||
}
|
||||
|
||||
public pullGetDeclInformation(decl: TypeScript.PullDecl, ast: TypeScript.ISyntaxElement, document: TypeScript.Document) {
|
||||
this.synchronizeHostData();
|
||||
return this.compiler.pullGetDeclInformation(decl, ast, document);
|
||||
}
|
||||
|
||||
public topLevelDeclaration(fileName: string) {
|
||||
this.synchronizeHostData();
|
||||
return this.compiler.topLevelDeclaration(fileName);
|
||||
}
|
||||
|
||||
public getDeclForAST(ast: TypeScript.ISyntaxElement): TypeScript.PullDecl {
|
||||
this.synchronizeHostData();
|
||||
return this.compiler.getDeclForAST(ast);
|
||||
}
|
||||
|
||||
public emit(fileName: string, resolvePath: (path: string) => string): TypeScript.EmitOutput {
|
||||
this.synchronizeHostData();
|
||||
return this.compiler.emit(fileName, resolvePath);
|
||||
}
|
||||
|
||||
public emitDeclarations(fileName: string, resolvePath: (path: string) => string): TypeScript.EmitOutput {
|
||||
this.synchronizeHostData();
|
||||
return this.compiler.emitDeclarations(fileName, resolvePath);
|
||||
}
|
||||
|
||||
public canEmitDeclarations(fileName: string) {
|
||||
this.synchronizeHostData();
|
||||
return this.compiler.canEmitDeclarations(fileName);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
if (this.compiler) {
|
||||
var fileNames = this.compiler.fileNames();
|
||||
for (var i = 0; i < fileNames.length; ++i) {
|
||||
this.documentRegistry.releaseDocument(fileNames[i], this.compiler.compilationSettings());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript.Services {
|
||||
|
||||
export interface CachedCompletionEntryDetails extends CompletionEntryDetails{
|
||||
isResolved(): boolean;
|
||||
}
|
||||
|
||||
export class ResolvedCompletionEntry implements CachedCompletionEntryDetails {
|
||||
constructor(public name: string,
|
||||
public kind: string,
|
||||
public kindModifiers: string,
|
||||
public type: string,
|
||||
public fullSymbolName: string,
|
||||
public docComment: string) {
|
||||
}
|
||||
|
||||
public isResolved(): boolean {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export class DeclReferenceCompletionEntry implements CachedCompletionEntryDetails {
|
||||
public type: string = null;
|
||||
public fullSymbolName: string = null;
|
||||
public docComment: string = null;
|
||||
|
||||
private hasBeenResolved = false;
|
||||
|
||||
constructor(public name: string,
|
||||
public kind: string,
|
||||
public kindModifiers: string,
|
||||
public decl: TypeScript.PullDecl) {
|
||||
}
|
||||
|
||||
public isResolved(): boolean {
|
||||
return this.hasBeenResolved;
|
||||
}
|
||||
|
||||
public resolve(type: string, fullSymbolName: string, docComments: string) {
|
||||
this.type = type;
|
||||
this.fullSymbolName = fullSymbolName;
|
||||
this.docComment = docComments;
|
||||
this.hasBeenResolved = true;
|
||||
}
|
||||
}
|
||||
|
||||
export class CompletionSession {
|
||||
constructor(public fileName: string,
|
||||
public position: number,
|
||||
public entries: TypeScript.IdentiferNameHashTable<CachedCompletionEntryDetails>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export interface IBitMatrix {
|
||||
// Returns true if the bit at the specified indices is set. False otherwise.
|
||||
valueAt(x: number, y: number): boolean;
|
||||
|
||||
// Sets the value at this specified indices.
|
||||
setValueAt(x: number, y: number, value: boolean): void;
|
||||
|
||||
// Releases the bit matrix, allowing its resources to be used by another matrix.
|
||||
// This instance cannot be used after it is released.
|
||||
release(): void;
|
||||
}
|
||||
|
||||
export module BitMatrix {
|
||||
var pool: BitMatrixImpl[] = [];
|
||||
|
||||
class BitMatrixImpl implements IBitMatrix {
|
||||
public isReleased = false;
|
||||
private vectors: IBitVector[] = [];
|
||||
|
||||
constructor(public allowUndefinedValues: boolean) {
|
||||
}
|
||||
|
||||
public valueAt(x: number, y: number): boolean {
|
||||
Debug.assert(!this.isReleased, "Should not use a released bitvector");
|
||||
var vector = this.vectors[x];
|
||||
if (!vector) {
|
||||
return this.allowUndefinedValues ? undefined : false;
|
||||
}
|
||||
|
||||
return vector.valueAt(y);
|
||||
}
|
||||
|
||||
public setValueAt(x: number, y: number, value: boolean): void {
|
||||
Debug.assert(!this.isReleased, "Should not use a released bitvector");
|
||||
var vector = this.vectors[x];
|
||||
if (!vector) {
|
||||
if (value === undefined) {
|
||||
// If they're storing an undefined value, and we don't even have a vector,
|
||||
// then we can short circuit early here.
|
||||
return;
|
||||
}
|
||||
|
||||
vector = BitVector.getBitVector(this.allowUndefinedValues);
|
||||
this.vectors[x] = vector;
|
||||
}
|
||||
|
||||
vector.setValueAt(y, value);
|
||||
}
|
||||
|
||||
public release() {
|
||||
Debug.assert(!this.isReleased, "Should not use a released bitvector");
|
||||
this.isReleased = true;
|
||||
|
||||
// Release all the vectors back.
|
||||
for (var name in this.vectors) {
|
||||
if (this.vectors.hasOwnProperty(name)) {
|
||||
var vector = this.vectors[name];
|
||||
vector.release();
|
||||
}
|
||||
}
|
||||
|
||||
this.vectors.length = 0;
|
||||
pool.push(this);
|
||||
}
|
||||
}
|
||||
|
||||
export function getBitMatrix(allowUndefinedValues: boolean): IBitMatrix {
|
||||
if (pool.length === 0) {
|
||||
return new BitMatrixImpl(allowUndefinedValues);
|
||||
}
|
||||
|
||||
var matrix = pool.pop();
|
||||
matrix.isReleased = false;
|
||||
matrix.allowUndefinedValues = allowUndefinedValues;
|
||||
|
||||
return matrix;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
///<reference path='references.ts'/>
|
||||
|
||||
module TypeScript {
|
||||
export interface IBitVector {
|
||||
// Returns the value at the specified index. If this is a bi-state vector, then the result
|
||||
// will only be 'true' or 'false'. If this is a tri-state vector, then the result can be
|
||||
// 'true', 'false', or 'undefined'.
|
||||
valueAt(index: number): boolean;
|
||||
|
||||
// Sets the value at this specified bit. For a bi-state vector the value must be 'true' or
|
||||
// 'false'. For a tri-state vector, it can be 'true', 'false', or 'undefined'.
|
||||
setValueAt(index: number, value: boolean): void;
|
||||
|
||||
// Releases the bit vector, allowing its resources to be used by another BitVector.
|
||||
// This instance cannot be used after it is released.
|
||||
release(): void;
|
||||
}
|
||||
|
||||
export module BitVector {
|
||||
var pool: BitVectorImpl[] = [];
|
||||
enum Constants {
|
||||
// We only use up to 30 bits in a number. That way the encoded value can always fit
|
||||
// within an int so that the underlying engine doesn't use a 64bit float here.
|
||||
MaxBitsPerEncodedNumber = 30,
|
||||
BitsPerEncodedBiStateValue = 1,
|
||||
|
||||
// For a tri state vector we need 2 bits per encoded value. 00 for 'undefined',
|
||||
// '01' for 'false' and '10' for true.
|
||||
BitsPerEncodedTriStateValue = 2,
|
||||
|
||||
BiStateEncodedTrue = 1, // 1
|
||||
BiStateClearBitsMask = 1, // 1
|
||||
|
||||
TriStateEncodedFalse = 1, // 01
|
||||
TriStateEncodedTrue = 2, // 10
|
||||
TriStateClearBitsMask = 3, // 11
|
||||
}
|
||||
|
||||
class BitVectorImpl implements IBitVector {
|
||||
public isReleased = false;
|
||||
private bits: number[] = [];
|
||||
|
||||
constructor(public allowUndefinedValues: boolean) {
|
||||
}
|
||||
|
||||
private computeTriStateArrayIndex(index: number): number {
|
||||
// The number of values that can be encoded in a single number.
|
||||
var encodedValuesPerNumber = Constants.MaxBitsPerEncodedNumber / Constants.BitsPerEncodedTriStateValue;
|
||||
|
||||
return (index / encodedValuesPerNumber) >>> 0;
|
||||
}
|
||||
|
||||
private computeBiStateArrayIndex(index: number): number {
|
||||
// The number of values that can be encoded in a single number.
|
||||
var encodedValuesPerNumber = Constants.MaxBitsPerEncodedNumber / Constants.BitsPerEncodedBiStateValue;
|
||||
|
||||
return (index / encodedValuesPerNumber) >>> 0;
|
||||
}
|
||||
|
||||
private computeTriStateEncodedValueIndex(index: number): number {
|
||||
// The number of values that can be encoded in a single number.
|
||||
var encodedValuesPerNumber = Constants.MaxBitsPerEncodedNumber / Constants.BitsPerEncodedTriStateValue;
|
||||
|
||||
return (index % encodedValuesPerNumber) * Constants.BitsPerEncodedTriStateValue;
|
||||
}
|
||||
|
||||
private computeBiStateEncodedValueIndex(index: number): number {
|
||||
// The number of values that can be encoded in a single number.
|
||||
var encodedValuesPerNumber = Constants.MaxBitsPerEncodedNumber / Constants.BitsPerEncodedBiStateValue;
|
||||
|
||||
return (index % encodedValuesPerNumber) * Constants.BitsPerEncodedBiStateValue;
|
||||
}
|
||||
|
||||
public valueAt(index: number): boolean {
|
||||
Debug.assert(!this.isReleased, "Should not use a released bitvector");
|
||||
if (this.allowUndefinedValues) {
|
||||
// tri-state bit vector. 2 bits per value.
|
||||
|
||||
var arrayIndex = this.computeTriStateArrayIndex(index);
|
||||
var encoded = this.bits[arrayIndex];
|
||||
if (encoded === undefined) {
|
||||
// We don't even have an encoded value at this array position. That's
|
||||
// equivalent to 'undefined' for a tri-state vector.
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var bitIndex = this.computeTriStateEncodedValueIndex(index);
|
||||
if (encoded & (Constants.TriStateEncodedTrue << bitIndex)) {
|
||||
return true;
|
||||
}
|
||||
else if (encoded & (Constants.TriStateEncodedFalse << bitIndex)) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Normal bitvector. One bit per value stored.
|
||||
|
||||
var arrayIndex = this.computeBiStateArrayIndex(index);
|
||||
var encoded = this.bits[arrayIndex];
|
||||
if (encoded === undefined) {
|
||||
// We don't even have an encoded value at this array position. That's
|
||||
// equivalent to 'false' for a bi-state vector.
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we don't support undefined values, then we use one bit per value. Just
|
||||
// index to that bit and see if it's set or not.
|
||||
var bitIndex = this.computeBiStateEncodedValueIndex(index);
|
||||
if (encoded & (Constants.BiStateEncodedTrue << bitIndex)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public setValueAt(index: number, value: boolean): void {
|
||||
Debug.assert(!this.isReleased, "Should not use a released bitvector");
|
||||
if (this.allowUndefinedValues) {
|
||||
Debug.assert(value === true || value === false || value === undefined, "value must only be true, false or undefined.");
|
||||
|
||||
var arrayIndex = this.computeTriStateArrayIndex(index);
|
||||
var encoded = this.bits[arrayIndex];
|
||||
if (encoded === undefined) {
|
||||
if (value === undefined) {
|
||||
// They're trying to set a bit to undefined that we don't even have an entry
|
||||
// for. We can bail out quickly here.
|
||||
return;
|
||||
}
|
||||
|
||||
encoded = 0;
|
||||
}
|
||||
|
||||
// First, we clear out any bits set at the appropriate index.
|
||||
var bitIndex = this.computeTriStateEncodedValueIndex(index);
|
||||
|
||||
// Create a mask similar to: 11111111100111111
|
||||
// i.e. all 1's except for 2 zeroes in the appropriate place.
|
||||
var clearMask = ~(Constants.TriStateClearBitsMask << bitIndex)
|
||||
encoded = encoded & clearMask;
|
||||
|
||||
if (value === true) {
|
||||
encoded = encoded | (Constants.TriStateEncodedTrue << bitIndex);
|
||||
}
|
||||
else if (value === false) {
|
||||
encoded = encoded | (Constants.TriStateEncodedFalse << bitIndex);
|
||||
}
|
||||
// else {
|
||||
// They're setting the value to 'undefined'. We already cleared the value
|
||||
// so there's nothing we need to do here.
|
||||
// }
|
||||
|
||||
this.bits[arrayIndex] = encoded;
|
||||
}
|
||||
else {
|
||||
Debug.assert(value === true || value === false, "value must only be true or false.");
|
||||
|
||||
var arrayIndex = this.computeBiStateArrayIndex(index);
|
||||
var encoded = this.bits[arrayIndex];
|
||||
if (encoded === undefined) {
|
||||
if (value === false) {
|
||||
// They're trying to set a bit to false that we don't even have an entry
|
||||
// for. We can bail out quickly here.
|
||||
return;
|
||||
}
|
||||
|
||||
encoded = 0;
|
||||
}
|
||||
|
||||
var bitIndex = this.computeBiStateEncodedValueIndex(index);
|
||||
// First, clear out the bit at this location.
|
||||
encoded = encoded & ~(Constants.BiStateClearBitsMask << bitIndex);
|
||||
|
||||
if (value) {
|
||||
encoded = encoded | (Constants.BiStateEncodedTrue << bitIndex);
|
||||
}
|
||||
// else {
|
||||
// They're setting the value to 'false'. We already cleared the value
|
||||
// so there's nothing we need to do here.
|
||||
// }
|
||||
|
||||
this.bits[arrayIndex] = encoded;
|
||||
}
|
||||
}
|
||||
|
||||
public release() {
|
||||
Debug.assert(!this.isReleased, "Should not use a released bitvector");
|
||||
this.isReleased = true;
|
||||
this.bits.length = 0;
|
||||
pool.push(this);
|
||||
}
|
||||
}
|
||||
|
||||
export function getBitVector(allowUndefinedValues: boolean): IBitVector {
|
||||
if (pool.length === 0) {
|
||||
return new BitVectorImpl(allowUndefinedValues);
|
||||
}
|
||||
|
||||
var vector = pool.pop();
|
||||
vector.isReleased = false;
|
||||
vector.allowUndefinedValues = allowUndefinedValues;
|
||||
|
||||
return vector;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
interface ICancellationToken {
|
||||
isCancellationRequested(): boolean;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
///<reference path='ICancellationToken.ts' />
|
||||
|
||||
interface ICancellationTokenSource {
|
||||
token(): ICancellationToken;
|
||||
|
||||
cancel(): void;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export enum Constants {
|
||||
// 2^30-1
|
||||
Max31BitInteger = 1073741823,
|
||||
Min31BitInteger = -1073741824,
|
||||
}
|
||||
}
|
||||
@@ -1,505 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
///<reference path='..\compiler\enumerator.ts' />
|
||||
///<reference path='..\compiler\process.ts' />
|
||||
|
||||
declare var Buffer: {
|
||||
new (str: string, encoding?: string): any;
|
||||
}
|
||||
|
||||
module TypeScript {
|
||||
export var nodeMakeDirectoryTime = 0;
|
||||
export var nodeCreateBufferTime = 0;
|
||||
export var nodeWriteFileSyncTime = 0;
|
||||
|
||||
export enum ByteOrderMark {
|
||||
None = 0,
|
||||
Utf8 = 1,
|
||||
Utf16BigEndian = 2,
|
||||
Utf16LittleEndian = 3,
|
||||
}
|
||||
|
||||
export class FileInformation {
|
||||
constructor(public contents: string, public byteOrderMark: ByteOrderMark) {
|
||||
}
|
||||
}
|
||||
|
||||
export interface IFileWatcher {
|
||||
close(): void;
|
||||
}
|
||||
|
||||
export interface IEnvironment {
|
||||
supportsCodePage(): boolean;
|
||||
readFile(path: string, codepage: number): FileInformation;
|
||||
writeFile(path: string, contents: string, writeByteOrderMark: boolean): void;
|
||||
deleteFile(path: string): void;
|
||||
fileExists(path: string): boolean;
|
||||
directoryExists(path: string): boolean;
|
||||
directoryName(path: string): string;
|
||||
createDirectory(path: string): void;
|
||||
absolutePath(path: string): string;
|
||||
listFiles(path: string, re?: RegExp, options?: { recursive?: boolean; }): string[];
|
||||
|
||||
arguments: string[];
|
||||
standardOut: ITextWriter;
|
||||
standardError: ITextWriter;
|
||||
|
||||
executingFilePath(): string;
|
||||
currentDirectory(): string;
|
||||
newLine: string;
|
||||
|
||||
watchFile(fileName: string, callback: (x: string) => void): IFileWatcher;
|
||||
quit(exitCode?: number): void;
|
||||
}
|
||||
|
||||
function throwIOError(message: string, error: Error) {
|
||||
var errorMessage = message;
|
||||
if (error && error.message) {
|
||||
errorMessage += (" " + error.message);
|
||||
}
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
|
||||
export var Environment: IEnvironment = (function () {
|
||||
// Create an IO object for use inside WindowsScriptHost hosts
|
||||
// Depends on WSCript and FileSystemObject
|
||||
function getWindowsScriptHostEnvironment(): IEnvironment {
|
||||
try {
|
||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var streamObjectPool: any[] = [];
|
||||
|
||||
function getStreamObject(): any {
|
||||
if (streamObjectPool.length > 0) {
|
||||
return streamObjectPool.pop();
|
||||
}
|
||||
else {
|
||||
return new ActiveXObject("ADODB.Stream");
|
||||
}
|
||||
}
|
||||
|
||||
function releaseStreamObject(obj: any) {
|
||||
streamObjectPool.push(obj);
|
||||
}
|
||||
|
||||
var args: string[] = [];
|
||||
for (var i = 0; i < WScript.Arguments.length; i++) {
|
||||
args[i] = WScript.Arguments.Item(i);
|
||||
}
|
||||
|
||||
return {
|
||||
// On windows, the newline sequence is always "\r\n";
|
||||
newLine: "\r\n",
|
||||
|
||||
currentDirectory: () => (<any>WScript).CreateObject("WScript.Shell").CurrentDirectory,
|
||||
|
||||
supportsCodePage: () => (<any>WScript).ReadFile,
|
||||
|
||||
absolutePath: path => fso.GetAbsolutePathName(path),
|
||||
|
||||
readFile: function (path, codepage) {
|
||||
try {
|
||||
// If a codepage is requested, defer to our host to do the reading. If it
|
||||
// fails, fall back to our normal BOM/utf8 logic.
|
||||
if (codepage !== null && this.supportsCodePage()) {
|
||||
try {
|
||||
var contents = (<any>WScript).ReadFile(path, codepage);
|
||||
return new FileInformation(contents, ByteOrderMark.None);
|
||||
}
|
||||
catch (e) {
|
||||
// We couldn't read it with that code page. Fall back to the normal
|
||||
// BOM/utf8 logic below.
|
||||
}
|
||||
}
|
||||
|
||||
// Initially just read the first two bytes of the file to see if there's a bom.
|
||||
var streamObj = getStreamObject();
|
||||
streamObj.Open();
|
||||
streamObj.Type = 2; // Text data
|
||||
|
||||
// Start reading individual chars without any interpretation. That way we can check for a bom.
|
||||
streamObj.Charset = 'x-ansi';
|
||||
|
||||
streamObj.LoadFromFile(path);
|
||||
var bomChar = streamObj.ReadText(2); // Read the BOM char
|
||||
|
||||
// Position has to be at 0 before changing the encoding
|
||||
streamObj.Position = 0;
|
||||
|
||||
var byteOrderMark = ByteOrderMark.None;
|
||||
|
||||
if (bomChar.charCodeAt(0) === 0xFE && bomChar.charCodeAt(1) === 0xFF) {
|
||||
streamObj.Charset = 'unicode';
|
||||
byteOrderMark = ByteOrderMark.Utf16BigEndian;
|
||||
}
|
||||
else if (bomChar.charCodeAt(0) === 0xFF && bomChar.charCodeAt(1) === 0xFE) {
|
||||
streamObj.Charset = 'unicode';
|
||||
byteOrderMark = ByteOrderMark.Utf16LittleEndian;
|
||||
}
|
||||
else if (bomChar.charCodeAt(0) === 0xEF && bomChar.charCodeAt(1) === 0xBB) {
|
||||
streamObj.Charset = 'utf-8';
|
||||
byteOrderMark = ByteOrderMark.Utf8;
|
||||
}
|
||||
else {
|
||||
// Always read a file as utf8 if it has no bom.
|
||||
streamObj.Charset = 'utf-8';
|
||||
}
|
||||
|
||||
// Read the whole file
|
||||
var contents = streamObj.ReadText(-1 /* read from the current position to EOS */);
|
||||
streamObj.Close();
|
||||
releaseStreamObject(streamObj);
|
||||
return new FileInformation(contents, byteOrderMark);
|
||||
}
|
||||
catch (err) {
|
||||
// -2147024809 is the javascript value for 0x80070057 which is the HRESULT for
|
||||
// "the parameter is incorrect".
|
||||
var message: string;
|
||||
if (err.number === -2147024809) {
|
||||
message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unsupported_file_encoding, null);
|
||||
}
|
||||
else {
|
||||
message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Cannot_read_file_0_1, [path, err.message]);
|
||||
}
|
||||
|
||||
throw new Error(message);
|
||||
}
|
||||
},
|
||||
|
||||
writeFile: (path, contents, writeByteOrderMark) => {
|
||||
// First, convert the text contents passed in to binary in UTF8 format.
|
||||
var textStream = getStreamObject();
|
||||
textStream.Charset = 'utf-8';
|
||||
textStream.Open();
|
||||
textStream.WriteText(contents, 0 /*do not add newline*/);
|
||||
|
||||
// If they don't want the BOM, then skip it (it will be added automatically
|
||||
// when we write the utf8 bytes out above).
|
||||
if (!writeByteOrderMark) {
|
||||
textStream.Position = 3;
|
||||
}
|
||||
else {
|
||||
textStream.Position = 0;
|
||||
}
|
||||
|
||||
// Now, write all those bytes out to a file.
|
||||
var fileStream = getStreamObject();
|
||||
fileStream.Type = 1; //binary data.
|
||||
fileStream.Open();
|
||||
|
||||
textStream.CopyTo(fileStream);
|
||||
|
||||
// Flush and save the file.
|
||||
fileStream.Flush();
|
||||
fileStream.SaveToFile(path, 2 /*overwrite*/);
|
||||
fileStream.Close();
|
||||
|
||||
textStream.Flush();
|
||||
textStream.Close();
|
||||
},
|
||||
|
||||
fileExists: path => fso.FileExists(path),
|
||||
|
||||
deleteFile: path => {
|
||||
if (fso.FileExists(path)) {
|
||||
fso.DeleteFile(path, true); // true: delete read-only files
|
||||
}
|
||||
},
|
||||
|
||||
directoryExists: path => <boolean>fso.FolderExists(path),
|
||||
|
||||
directoryName: path => fso.GetParentFolderName(path),
|
||||
|
||||
createDirectory: function (path) {
|
||||
try {
|
||||
if (!this.directoryExists(path)) {
|
||||
fso.CreateFolder(path);
|
||||
}
|
||||
} catch (e) {
|
||||
throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_create_directory_0, [path]), e);
|
||||
}
|
||||
},
|
||||
|
||||
listFiles: (path, spec?, options?) => {
|
||||
options = options || <{ recursive?: boolean; }>{};
|
||||
function filesInFolder(folder: any, root: string): string[] {
|
||||
var paths: string[] = [];
|
||||
var fc: Enumerator;
|
||||
|
||||
if (options.recursive) {
|
||||
fc = new Enumerator(folder.subfolders);
|
||||
|
||||
for (; !fc.atEnd(); fc.moveNext()) {
|
||||
paths = paths.concat(filesInFolder(fc.item(), root + "\\" + fc.item().Name));
|
||||
}
|
||||
}
|
||||
|
||||
fc = new Enumerator(folder.files);
|
||||
|
||||
for (; !fc.atEnd(); fc.moveNext()) {
|
||||
if (!spec || fc.item().Name.match(spec)) {
|
||||
paths.push(root + "\\" + fc.item().Name);
|
||||
}
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
var folder: any = fso.GetFolder(path);
|
||||
var paths: string[] = [];
|
||||
|
||||
return filesInFolder(folder, path);
|
||||
},
|
||||
|
||||
arguments: <string[]>args,
|
||||
|
||||
standardOut: WScript.StdOut,
|
||||
standardError: WScript.StdErr,
|
||||
|
||||
executingFilePath: () => WScript.ScriptFullName,
|
||||
|
||||
quit: (exitCode = 0) => {
|
||||
try {
|
||||
WScript.Quit(exitCode);
|
||||
} catch (e) {
|
||||
}
|
||||
},
|
||||
|
||||
watchFile: null,
|
||||
};
|
||||
};
|
||||
|
||||
function getNodeEnvironment(): IEnvironment {
|
||||
var _fs = require('fs');
|
||||
var _path = require('path');
|
||||
var _module = require('module');
|
||||
var _os = require('os');
|
||||
|
||||
return {
|
||||
// On node pick up the newline character from the OS
|
||||
newLine: _os.EOL,
|
||||
|
||||
currentDirectory: () => (<any>process).cwd(),
|
||||
|
||||
supportsCodePage: () => false,
|
||||
|
||||
absolutePath: path => _path.resolve(path),
|
||||
|
||||
readFile: (file, codepage) => {
|
||||
if (codepage !== null) {
|
||||
throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.codepage_option_not_supported_on_current_platform, null));
|
||||
}
|
||||
|
||||
var buffer = _fs.readFileSync(file);
|
||||
switch (buffer[0]) {
|
||||
case 0xFE:
|
||||
if (buffer[1] === 0xFF) {
|
||||
// utf16-be. Reading the buffer as big endian is not supported, so convert it to
|
||||
// Little Endian first
|
||||
var i = 0;
|
||||
while ((i + 1) < buffer.length) {
|
||||
var temp = buffer[i];
|
||||
buffer[i] = buffer[i + 1];
|
||||
buffer[i + 1] = temp;
|
||||
i += 2;
|
||||
}
|
||||
return new FileInformation(buffer.toString("ucs2", 2), ByteOrderMark.Utf16BigEndian);
|
||||
}
|
||||
break;
|
||||
case 0xFF:
|
||||
if (buffer[1] === 0xFE) {
|
||||
// utf16-le
|
||||
return new FileInformation(buffer.toString("ucs2", 2), ByteOrderMark.Utf16LittleEndian);
|
||||
}
|
||||
break;
|
||||
case 0xEF:
|
||||
if (buffer[1] === 0xBB) {
|
||||
// utf-8
|
||||
return new FileInformation(buffer.toString("utf8", 3), ByteOrderMark.Utf8);
|
||||
}
|
||||
}
|
||||
|
||||
// Default behaviour
|
||||
return new FileInformation(buffer.toString("utf8", 0), ByteOrderMark.None);
|
||||
},
|
||||
|
||||
writeFile: (path, contents, writeByteOrderMark) => {
|
||||
function mkdirRecursiveSync(path: string) {
|
||||
var stats = _fs.statSync(path);
|
||||
if (stats.isFile()) {
|
||||
throw "\"" + path + "\" exists but isn't a directory.";
|
||||
}
|
||||
else if (stats.isDirectory()) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
mkdirRecursiveSync(_path.dirname(path));
|
||||
_fs.mkdirSync(path, 509 /*775 in octal*/);
|
||||
}
|
||||
}
|
||||
var start = new Date().getTime();
|
||||
mkdirRecursiveSync(_path.dirname(path));
|
||||
TypeScript.nodeMakeDirectoryTime += new Date().getTime() - start;
|
||||
|
||||
if (writeByteOrderMark) {
|
||||
contents = '\uFEFF' + contents;
|
||||
}
|
||||
|
||||
var start = new Date().getTime();
|
||||
|
||||
var chunkLength = 4 * 1024;
|
||||
var fileDescriptor = _fs.openSync(path, "w");
|
||||
try {
|
||||
for (var index = 0; index < contents.length; index += chunkLength) {
|
||||
var bufferStart = new Date().getTime();
|
||||
var buffer = new Buffer(contents.substr(index, chunkLength), "utf8");
|
||||
TypeScript.nodeCreateBufferTime += new Date().getTime() - bufferStart;
|
||||
|
||||
_fs.writeSync(fileDescriptor, buffer, 0, buffer.length, null);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
_fs.closeSync(fileDescriptor);
|
||||
}
|
||||
|
||||
TypeScript.nodeWriteFileSyncTime += new Date().getTime() - start;
|
||||
},
|
||||
|
||||
fileExists: path => _fs.existsSync(path),
|
||||
|
||||
deleteFile: path => {
|
||||
try {
|
||||
_fs.unlinkSync(path);
|
||||
} catch (e) {
|
||||
}
|
||||
},
|
||||
|
||||
directoryExists: path =>
|
||||
_fs.existsSync(path) && _fs.statSync(path).isDirectory(),
|
||||
|
||||
directoryName: path => {
|
||||
var dirPath = _path.dirname(path);
|
||||
|
||||
// Node will just continue to repeat the root path, rather than return null
|
||||
if (dirPath === path) {
|
||||
dirPath = null;
|
||||
}
|
||||
|
||||
return dirPath;
|
||||
},
|
||||
|
||||
createDirectory: function (path) {
|
||||
try {
|
||||
if (!this.directoryExists(path)) {
|
||||
_fs.mkdirSync(path);
|
||||
}
|
||||
} catch (e) {
|
||||
throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_create_directory_0, [path]), e);
|
||||
}
|
||||
},
|
||||
|
||||
listFiles: (path, spec?, options?) => {
|
||||
options = options || <{ recursive?: boolean; }>{};
|
||||
|
||||
function filesInFolder(folder: string): string[] {
|
||||
var paths: string[] = [];
|
||||
|
||||
var files = _fs.readdirSync(folder);
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var pathToFile = _path.join(folder, files[i]);
|
||||
var stat = _fs.statSync(pathToFile);
|
||||
if (options.recursive && stat.isDirectory()) {
|
||||
paths = paths.concat(filesInFolder(pathToFile));
|
||||
}
|
||||
else if (stat.isFile() && (!spec || files[i].match(spec))) {
|
||||
paths.push(pathToFile);
|
||||
}
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
return filesInFolder(path);
|
||||
},
|
||||
|
||||
arguments: process.argv.slice(2),
|
||||
|
||||
standardOut: {
|
||||
Write: str => process.stdout.write(str),
|
||||
WriteLine: str => process.stdout.write(str + '\n'),
|
||||
Close() { }
|
||||
},
|
||||
|
||||
standardError: {
|
||||
Write: str => process.stderr.write(str),
|
||||
WriteLine: str => process.stderr.write(str + '\n'),
|
||||
Close() { }
|
||||
},
|
||||
|
||||
executingFilePath: () => process.mainModule.filename,
|
||||
|
||||
quit: code => {
|
||||
var stderrFlushed = process.stderr.write('');
|
||||
var stdoutFlushed = process.stdout.write('');
|
||||
process.stderr.on('drain', function () {
|
||||
stderrFlushed = true;
|
||||
if (stdoutFlushed) {
|
||||
process.exit(code);
|
||||
}
|
||||
});
|
||||
process.stdout.on('drain', function () {
|
||||
stdoutFlushed = true;
|
||||
if (stderrFlushed) {
|
||||
process.exit(code);
|
||||
}
|
||||
});
|
||||
setTimeout(function () {
|
||||
process.exit(code);
|
||||
}, 5);
|
||||
},
|
||||
|
||||
watchFile: (fileName, callback) => {
|
||||
var firstRun = true;
|
||||
var processingChange = false;
|
||||
|
||||
var fileChanged: any = function (curr: any, prev: any) {
|
||||
if (!firstRun) {
|
||||
if (curr.mtime < prev.mtime) {
|
||||
return;
|
||||
}
|
||||
|
||||
_fs.unwatchFile(fileName, fileChanged);
|
||||
if (!processingChange) {
|
||||
processingChange = true;
|
||||
callback(fileName);
|
||||
setTimeout(function () { processingChange = false; }, 100);
|
||||
}
|
||||
}
|
||||
firstRun = false;
|
||||
_fs.watchFile(fileName, { persistent: true, interval: 500 }, fileChanged);
|
||||
};
|
||||
|
||||
fileChanged();
|
||||
return {
|
||||
fileName: fileName,
|
||||
close: function () {
|
||||
_fs.unwatchFile(fileName, fileChanged);
|
||||
}
|
||||
};
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") {
|
||||
return getWindowsScriptHostEnvironment();
|
||||
}
|
||||
else if (typeof module !== 'undefined' && module.exports) {
|
||||
return getNodeEnvironment();
|
||||
}
|
||||
else {
|
||||
return null; // Unsupported host
|
||||
}
|
||||
})();
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
///<reference path='references.ts'/>
|
||||
|
||||
module TypeScript {
|
||||
export interface IIndexable<T> {
|
||||
[s: string]: T;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/// <reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export interface Iterator<T> {
|
||||
moveNext(): boolean;
|
||||
current(): T;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export interface ILineAndCharacter {
|
||||
line: number;
|
||||
character: number;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
// Forward declarations of the variables we use from 'node'.
|
||||
declare var require: any;
|
||||
declare var module: any;
|
||||
@@ -1,363 +0,0 @@
|
||||
///<reference path='..\compiler\io.ts'/>
|
||||
///<reference path='..\compiler\typescript.ts'/>
|
||||
///<reference path='..\..\samples\node\node.d.ts'/>
|
||||
|
||||
module DiagnosticsParser {
|
||||
|
||||
class FourSlashGenerator {
|
||||
|
||||
private fsFiles: { [s: string]: IFourSlashFile; };
|
||||
|
||||
constructor(private diagnosticsFile: string) {
|
||||
this.fsFiles = {};
|
||||
}
|
||||
|
||||
public generate(args: string[]): void {
|
||||
|
||||
if (IO.fileExists(this.diagnosticsFile)) {
|
||||
|
||||
this.parseDiagnostics(args);
|
||||
|
||||
if (args !== undefined) {
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
for (var fsFile in this.fsFiles) {
|
||||
var strippedScriptId = fsFile.replace(/.+\\/, '');
|
||||
if (strippedScriptId === args[i]) {
|
||||
this.writeFile(fsFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (var fsFile in this.fsFiles) {
|
||||
this.writeFile(fsFile);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private parseDiagnostics(args: string[]) {
|
||||
|
||||
var file: string = IO.readFile(this.diagnosticsFile);
|
||||
var lines: string[] = file.split('\r\n');
|
||||
|
||||
var updateMode: boolean;
|
||||
var scriptId: string;
|
||||
|
||||
var editBlock: string;
|
||||
var editRange: TypeScript.ScriptEditRange;
|
||||
|
||||
var startPosition: number;
|
||||
var caretPosition: number;
|
||||
var collapsingBlock: string;
|
||||
|
||||
var openEditTag = /^.*<Edit>/;
|
||||
var closeEditTag = /<Edit\/>.*/;
|
||||
|
||||
// Loops through the lines of the diagnostics file
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
|
||||
// Indicates the user opening a file
|
||||
if (lines[i].match(/\/\/=New=\\\\/)) {
|
||||
|
||||
updateMode = false;
|
||||
|
||||
// Indicates the user making updates to an opened file
|
||||
} else if (lines[i].match(/\/\/=Update=\\\\/)) {
|
||||
|
||||
updateMode = true;
|
||||
|
||||
// Record the filePath of the opened/modified file
|
||||
} else if (lines[i].match(/^scriptId: /)) {
|
||||
|
||||
var newScriptId = lines[i].replace(/^scriptId: /, '');
|
||||
if (scriptId !== undefined && newScriptId !== scriptId && collapsingBlock !== undefined) {
|
||||
this.fsFiles[scriptId].insertAt(startPosition, caretPosition, collapsingBlock);
|
||||
|
||||
startPosition = undefined;
|
||||
caretPosition = undefined;
|
||||
collapsingBlock = undefined
|
||||
}
|
||||
scriptId = newScriptId;
|
||||
|
||||
// Records the editRange (minChar, limChar, deltaOfCaret)
|
||||
} else if (lines[i].match(/^editRange\(/)) {
|
||||
|
||||
//Capture numbers in editRange(minChar=###, limChar=###, delta=###)
|
||||
var match = /editRange\(minChar=([0-9]+), limChar=([0-9]+), delta=(-?[0-9]+)\)/.exec(lines[i]);
|
||||
if (match !== null) {
|
||||
editRange = new TypeScript.ScriptEditRange(parseInt(match[1], 10), parseInt(match[2], 10), parseInt(match[3], 10));
|
||||
}
|
||||
|
||||
// Indicates the beginning of added text and records
|
||||
} else if (lines[i].match(openEditTag)) {
|
||||
|
||||
var editLines: string[] = [];
|
||||
|
||||
lines[i] = lines[i].replace(openEditTag, '');
|
||||
while (lines[i].match(closeEditTag) === null) {
|
||||
editLines.push(lines[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
editLines.push(lines[i].replace(closeEditTag, ''));
|
||||
editBlock = editLines.join('\r\n');
|
||||
|
||||
// Indicates the end of the edit block, and then adds the text to the relevant file
|
||||
} else if (lines[i].match(/\\\\=====\/\//) && editRange !== null) {
|
||||
|
||||
if (updateMode) {
|
||||
|
||||
var range: number = editRange.limChar - editRange.minChar;
|
||||
var deleting: boolean = (range !== 0);
|
||||
|
||||
if (deleting) {
|
||||
|
||||
if (collapsingBlock !== undefined) {
|
||||
this.fsFiles[scriptId].insertAt(startPosition, caretPosition, collapsingBlock);
|
||||
}
|
||||
|
||||
caretPosition = editRange.minChar + (editBlock !== undefined ? editBlock.length : 0);
|
||||
|
||||
this.fsFiles[scriptId].deleteAt(editRange.limChar, caretPosition, range, editBlock);
|
||||
|
||||
startPosition = undefined;
|
||||
caretPosition = undefined;
|
||||
collapsingBlock = undefined;
|
||||
|
||||
} else {
|
||||
if (editRange.minChar === caretPosition) {
|
||||
collapsingBlock += editBlock;
|
||||
} else {
|
||||
if (collapsingBlock !== undefined) {
|
||||
this.fsFiles[scriptId].insertAt(startPosition, caretPosition, collapsingBlock);
|
||||
}
|
||||
startPosition = editRange.minChar;
|
||||
collapsingBlock = editBlock;
|
||||
}
|
||||
caretPosition = editRange.minChar + editRange.delta;
|
||||
}
|
||||
} else {
|
||||
this.fsFiles[scriptId] = new FourSlashFile(scriptId, editBlock);
|
||||
}
|
||||
editBlock = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Add any text that hasn't been stored to its relevant file
|
||||
if (collapsingBlock !== undefined) {
|
||||
this.fsFiles[scriptId].insertAt(startPosition, caretPosition, collapsingBlock);
|
||||
}
|
||||
}
|
||||
|
||||
private writeFile(scriptId: string): void {
|
||||
if (this.fsFiles[scriptId] !== undefined) {
|
||||
var fsFileName = this.fsFiles[scriptId].getFsFileName();
|
||||
IO.writeFile(fsFileName, this.fsFiles[scriptId].getFile());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface IFourSlashFile {
|
||||
getFile(): string;
|
||||
getFsFileName(): string;
|
||||
getOriginalScriptId(): string;
|
||||
updateInternalFile(minChar: number, limChar: number, content: string): void;
|
||||
insertAt(position: number, caretPosition: number, content: string): void;
|
||||
deleteAt(position: number, caretPosition: number, amount: number, content?: string): void;
|
||||
addInternalState(caretPosition: number): void;
|
||||
}
|
||||
|
||||
interface IFourSlashNode {
|
||||
getNode(): string;
|
||||
}
|
||||
|
||||
class FourSlashFile implements IFourSlashFile {
|
||||
|
||||
private static header = "/// <reference path=\"fourslash.ts\" />" + '\r\n' + '\r\n';
|
||||
|
||||
private fsScriptId: string;
|
||||
|
||||
private commands: IFourSlashNode[];
|
||||
|
||||
private internalState: string;
|
||||
|
||||
constructor(private originalScriptId: string, private startingContent: string) {
|
||||
|
||||
this.fsScriptId = 'tests\\cases\\fourslash\\' + originalScriptId.replace(/.+\\(.+).ts/, '$1_generated.ts');
|
||||
this.commands = [];
|
||||
this.internalState = startingContent;
|
||||
|
||||
}
|
||||
|
||||
public getFile(): string {
|
||||
var file: string;
|
||||
|
||||
//Split on \r\n and add ////
|
||||
var rnlines = this.startingContent.split('\r\n');
|
||||
rnlines.forEach((line, index, array) => { array[index] = '////' + line });
|
||||
var rnfile = rnlines.join('\r\n');
|
||||
|
||||
//Repeat for \n
|
||||
var nlines = rnfile.split(/([^\r]\n|\r[^\n])/);
|
||||
nlines.forEach((line, index, array) => { if (line.indexOf('////') !== 0) { array[index] = '////' + line } });
|
||||
var nfile = nlines.join('\n');
|
||||
|
||||
file = FourSlashFile.header + nfile + '\r\n' + '\r\n';
|
||||
this.commands.forEach((command, index, array) => { file += command.getNode() });
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
private getWithWhitespace(text: string) {
|
||||
return text.replace(/ /g, '\u00B7').replace(/\r/g, '\u00B6').replace(/\n/g, '\u2193\n').replace(/\t/g, '\u2192\ ');
|
||||
}
|
||||
|
||||
public getFsFileName(): string {
|
||||
return this.fsScriptId;
|
||||
}
|
||||
|
||||
public getOriginalScriptId(): string {
|
||||
return this.originalScriptId;
|
||||
}
|
||||
|
||||
public updateInternalFile(minChar: number, limChar: number, content: string): void {
|
||||
this.internalState = this.internalState.substring(0, minChar) + content + this.internalState.substr(limChar);
|
||||
}
|
||||
|
||||
public insertAt(position: number, caretPosition: number, content: string): void {
|
||||
var posOffset = this.getInsertOffset(position);
|
||||
var insertNode = new FourSlashInsert(position - posOffset, content.replace(/(\r\n|\r|\n)/g, '\n'));
|
||||
this.commands.push(insertNode);
|
||||
this.updateInternalFile(position, position, content);
|
||||
this.addInternalState(caretPosition);
|
||||
}
|
||||
|
||||
public deleteAt(position: number, caretPosition: number, amount: number, content?: string): void {
|
||||
var posOffset = this.getInsertOffset(position);
|
||||
var amountOffset = this.getDeleteOffset(position, amount);
|
||||
var deleteNode = new FourSlashDelete(position - posOffset, amount - amountOffset, (content !== undefined ? content.replace(/(\r\n|\r|\n)/g, '\n') : undefined));
|
||||
this.commands.push(deleteNode);
|
||||
this.updateInternalFile(position - amount, position, content);
|
||||
this.addInternalState(caretPosition);
|
||||
}
|
||||
|
||||
public addInternalState(caretPosition: number): void {
|
||||
var caretedState = this.internalState.substr(0, caretPosition) + '|' + this.internalState.substr(caretPosition);
|
||||
var internalState = new FourSlashStateComment(caretedState);
|
||||
this.commands.push(internalState);
|
||||
}
|
||||
|
||||
private getInsertOffset(position: number) {
|
||||
var offset: number = 0;
|
||||
var match = this.internalState.substring(0, position).match(/\r\n/g);
|
||||
if (match !== null) {
|
||||
offset = match.length;
|
||||
}
|
||||
offset = (match !== null ? match.length : 0);
|
||||
return offset;
|
||||
}
|
||||
|
||||
private getDeleteOffset(position: number, amount: number) {
|
||||
var offset: number = 0;
|
||||
var match = this.internalState.substring(position - amount, position).match(/\r\n/g);
|
||||
if (match !== null) {
|
||||
offset = match.length;
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class FourSlashInsert implements IFourSlashNode {
|
||||
|
||||
constructor(private position: number, private content: string) {
|
||||
this.content = this.content.replace(/([\/\\"'])/g, '\\$1');
|
||||
this.content = this.content.replace(/\r\n/g, '\\r\\n');
|
||||
this.content = this.content.replace(/(\r|\n)/g, '\\n');
|
||||
}
|
||||
|
||||
public getNode(): string {
|
||||
var insertNode: string = "goTo.position(" + this.position.toString() + ");" + "\n" +
|
||||
"edit.insert(\'" + this.content + "\');" + "\n";
|
||||
return insertNode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class FourSlashDelete implements IFourSlashNode {
|
||||
|
||||
constructor(private position: number, private deletionAmount: number, private content: string) {
|
||||
if (this.content !== undefined) {
|
||||
this.content = this.content.replace(/([\/\\"'])/g, '\\$1');
|
||||
this.content = this.content.replace(/\r\n/g, '\\r\\n');
|
||||
this.content = this.content.replace(/(\r|\n)/g, '\\n');
|
||||
}
|
||||
}
|
||||
|
||||
public getNode(): string {
|
||||
var deleteNode: string = "goTo.position(" + this.position.toString() + ");" + "\n" +
|
||||
"edit.backspace(" + this.deletionAmount + ");" + "\n";
|
||||
if (this.content !== undefined && this.content !== "") {
|
||||
deleteNode += "edit.insert(\'" + this.content + "\');" + "\n";
|
||||
}
|
||||
return deleteNode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class FourSlashStateComment implements IFourSlashNode {
|
||||
|
||||
constructor(private state: string) { }
|
||||
|
||||
public getNode(): string {
|
||||
|
||||
var lines = this.state.replace(/\r\n|\r|\n/g, '\r\n').split('\n');
|
||||
lines.forEach((line, index, array) => { array[index] = '//-' + line; });
|
||||
var stateNode = lines.join('\n');
|
||||
|
||||
return stateNode + '\n' + '\n';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class DiagnosticsLocator {
|
||||
|
||||
private diagnosticsFile: string = 'diagnostics.txt';
|
||||
|
||||
public find(): string {
|
||||
return this.findDiagnosticsInFolder("C:/Users");
|
||||
}
|
||||
|
||||
private findDiagnosticsInFolder(path: string): string {
|
||||
if (IO.directoryExists(path)) {
|
||||
var diagnosticsPath = undefined;
|
||||
var dir: string[] = IO.dir(path, undefined, { recursive: true });
|
||||
for (var i = 0; i < dir.length; i++) {
|
||||
if (dir[i].indexOf(this.diagnosticsFile) !== -1) {
|
||||
diagnosticsPath = dir[i];
|
||||
}
|
||||
}
|
||||
return diagnosticsPath;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var diagnosticsFile: string = undefined;
|
||||
var diagnosticArgs: string[] = undefined
|
||||
if (process.argv.length > 2) {
|
||||
if (IO.fileExists(process.argv[2])) {
|
||||
diagnosticsFile = process.argv[2];
|
||||
}
|
||||
//Grab remaining arguments
|
||||
diagnosticArgs = process.argv.slice(3, process.argv.length - 1);
|
||||
}
|
||||
|
||||
if (diagnosticsFile !== undefined) {
|
||||
new FourSlashGenerator(diagnosticsFile).generate(diagnosticArgs);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,354 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
/*----------------- ThirdPartyNotices -------------------------------------------------------
|
||||
|
||||
This file is based on or incorporates material from the projects listed below
|
||||
(collectively "Third Party Code"). Microsoft is not the original author of the
|
||||
Third Party Code. The original copyright notice and the license, under which
|
||||
Microsoft received such Third Party Code, are set forth below. Such license and
|
||||
notices are provided for informational purposes only. Microsoft licenses the Third
|
||||
Party Code to you under the terms of the Apache 2.0 License.
|
||||
|
||||
--
|
||||
Array filter Compatibility Method,
|
||||
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/filter
|
||||
|
||||
Array forEach Compatibility Method,
|
||||
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach
|
||||
|
||||
Array indexOf Compatibility Method,
|
||||
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf
|
||||
|
||||
Array map Compatibility Method,
|
||||
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/map
|
||||
|
||||
Array Reduce Compatibility Method,
|
||||
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/Reduce
|
||||
|
||||
Array some Compatibility Method,
|
||||
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/some
|
||||
|
||||
String Trim Compatibility Method,
|
||||
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/Trim
|
||||
|
||||
Date now Compatibility Method,
|
||||
Available at https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/now
|
||||
|
||||
Copyright (c) 2007 - 2012 Mozilla Developer Network and individual contributors
|
||||
|
||||
Licensed by Microsoft under the Apache License, Version 2.0 (the "License"); you
|
||||
may not use this file except in compliance with the License. You may obtain a copy
|
||||
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR
|
||||
CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
--
|
||||
Original License provided for Informational Purposes Only
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
------------- End of ThirdPartyNotices --------------------------------------------------- */
|
||||
|
||||
|
||||
// Compatibility with non ES5 compliant engines
|
||||
if (!String.prototype.trim) {
|
||||
String.prototype.trim = function() {
|
||||
return this.replace(/^\s+|\s+$/g, '');
|
||||
};
|
||||
}
|
||||
|
||||
// Compatibility with non ES5 compliant engines
|
||||
if (!Array.prototype.indexOf) {
|
||||
Array.prototype.indexOf = function (searchElement: any, fromIndex?: any) {
|
||||
"use strict";
|
||||
if (this == null) {
|
||||
throw new TypeError();
|
||||
}
|
||||
var t = Object(this);
|
||||
var len: any = t.length >>> 0;
|
||||
if (len === 0) {
|
||||
return -1;
|
||||
}
|
||||
var n: any = 0;
|
||||
if (arguments.length > 0) {
|
||||
n = Number(arguments[1]);
|
||||
if (n != n) { // shortcut for verifying if it's NaN
|
||||
n = 0;
|
||||
}
|
||||
else if (n != 0 && n != Infinity && n != -Infinity) {
|
||||
n = (n > 0 || <any>-1) * Math.floor(Math.abs(n));
|
||||
}
|
||||
}
|
||||
if (n >= len) {
|
||||
return -1;
|
||||
}
|
||||
var k: any = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
|
||||
for (; k < len; k++) {
|
||||
if (k in t && t[k] === searchElement) {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Array.prototype.filter)
|
||||
{
|
||||
Array.prototype.filter = function(fun: any, thisp?: any)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (this == null)
|
||||
throw new TypeError();
|
||||
|
||||
var t = Object(this);
|
||||
var len = t.length >>> 0;
|
||||
if (typeof fun != "function")
|
||||
throw new TypeError();
|
||||
|
||||
var res: any[] = [];
|
||||
for (var i = 0; i < len; i++)
|
||||
{
|
||||
if (<any>i in t)
|
||||
{
|
||||
var val = t[i]; // in case fun mutates this
|
||||
if (fun.call(thisp, val, i, t))
|
||||
res.push(val);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
}
|
||||
|
||||
// Production steps of ECMA-262, Edition 5, 15.4.4.19
|
||||
// Reference: http://es5.github.com/#x15.4.4.19
|
||||
if (!Array.prototype.map) {
|
||||
Array.prototype.map = function(callback: any, thisArg?: any) {
|
||||
|
||||
var T: any = undefined, A: any, k: any;
|
||||
|
||||
if (this == null) {
|
||||
throw new TypeError(" this is null or not defined");
|
||||
}
|
||||
|
||||
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
|
||||
var O = Object(this);
|
||||
|
||||
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
|
||||
// 3. Let len be ToUint32(lenValue).
|
||||
var len = O.length >>> 0;
|
||||
|
||||
// 4. If IsCallable(callback) is false, throw a TypeError exception.
|
||||
// See: http://es5.github.com/#x9.11
|
||||
if ({}.toString.call(callback) != "[object Function]") {
|
||||
throw new TypeError(callback + " is not a function");
|
||||
}
|
||||
|
||||
// 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
||||
if (thisArg) {
|
||||
T = thisArg;
|
||||
}
|
||||
|
||||
// 6. Let A be a new array created as if by the expression new Array(len) where Array is
|
||||
// the standard built-in constructor with that name and len is the value of len.
|
||||
A = new Array(len);
|
||||
|
||||
// 7. Let k be 0
|
||||
k = 0;
|
||||
|
||||
// 8. Repeat, while k < len
|
||||
while(k < len) {
|
||||
|
||||
var kValue: any, mappedValue: any;
|
||||
|
||||
// a. Let Pk be ToString(k).
|
||||
// This is implicit for LHS operands of the in operator
|
||||
// b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
|
||||
// This step can be combined with c
|
||||
// c. If kPresent is true, then
|
||||
if (k in O) {
|
||||
|
||||
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
|
||||
kValue = O[ k ];
|
||||
|
||||
// ii. Let mappedValue be the result of calling the Call internal method of callback
|
||||
// with T as the this value and argument list containing kValue, k, and O.
|
||||
mappedValue = callback.call(T, kValue, k, O);
|
||||
|
||||
// iii. Call the DefineOwnProperty internal method of A with arguments
|
||||
// Pk, Property Descriptor {Value: mappedValue, : true, Enumerable: true, Configurable: true},
|
||||
// and false.
|
||||
|
||||
// In browsers that support Object.defineProperty, use the following:
|
||||
// Object.defineProperty(A, Pk, { value: mappedValue, writable: true, enumerable: true, configurable: true });
|
||||
|
||||
// For best browser support, use the following:
|
||||
A[ k ] = mappedValue;
|
||||
}
|
||||
// d. Increase k by 1.
|
||||
k++;
|
||||
}
|
||||
|
||||
// 9. return A
|
||||
return A;
|
||||
};
|
||||
}
|
||||
|
||||
if (!Array.prototype.reduce) {
|
||||
Array.prototype.reduce = function reduce(accumulator: any){
|
||||
if (this===null || this===undefined) throw new TypeError("Object is null or undefined");
|
||||
var i = 0, l = this.length >> 0, curr: any;
|
||||
|
||||
if(typeof accumulator !== "function") // ES5 : "If IsCallable(callbackfn) is false, throw a TypeError exception."
|
||||
throw new TypeError("First argument is not callable");
|
||||
|
||||
if(arguments.length < 2) {
|
||||
if (l === 0) throw new TypeError("Array length is 0 and no second argument");
|
||||
curr = this[0];
|
||||
i = 1; // start accumulating at the second element
|
||||
}
|
||||
else
|
||||
curr = arguments[1];
|
||||
|
||||
while (i < l) {
|
||||
if(<any>i in this) curr = accumulator.call(undefined, curr, this[i], i, this);
|
||||
++i;
|
||||
}
|
||||
|
||||
return curr;
|
||||
};
|
||||
}
|
||||
|
||||
// Compatibility with non ES5 compliant engines
|
||||
// Production steps of ECMA-262, Edition 5, 15.4.4.18
|
||||
// Reference: http://es5.github.com/#x15.4.4.18
|
||||
if (!Array.prototype.forEach) {
|
||||
Array.prototype.forEach = function(callback: any, thisArg?: any) {
|
||||
|
||||
var T: any, k: any;
|
||||
|
||||
if (this == null) {
|
||||
throw new TypeError(" this is null or not defined");
|
||||
}
|
||||
|
||||
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
|
||||
var O = Object(this);
|
||||
|
||||
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
|
||||
// 3. Let len be ToUint32(lenValue).
|
||||
var len = O.length >>> 0; // Hack to convert O.length to a UInt32
|
||||
|
||||
// 4. If IsCallable(callback) is false, throw a TypeError exception.
|
||||
// See: http://es5.github.com/#x9.11
|
||||
if ({ }.toString.call(callback) != "[object Function]") {
|
||||
throw new TypeError(callback + " is not a function");
|
||||
}
|
||||
|
||||
// 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
||||
if (thisArg) {
|
||||
T = thisArg;
|
||||
}
|
||||
else {
|
||||
T = undefined; // added to stop definite assignment error
|
||||
}
|
||||
|
||||
// 6. Let k be 0
|
||||
k = 0;
|
||||
|
||||
// 7. Repeat, while k < len
|
||||
while (k < len) {
|
||||
|
||||
var kValue: any;
|
||||
|
||||
// a. Let Pk be ToString(k).
|
||||
// This is implicit for LHS operands of the in operator
|
||||
// b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
|
||||
// This step can be combined with c
|
||||
// c. If kPresent is true, then
|
||||
if (k in O) {
|
||||
|
||||
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
|
||||
kValue = O[k];
|
||||
|
||||
// ii. Call the Call internal method of callback with T as the this value and
|
||||
// argument list containing kValue, k, and O.
|
||||
callback.call(T, kValue, k, O);
|
||||
}
|
||||
// d. Increase k by 1.
|
||||
k++;
|
||||
}
|
||||
// 8. return undefined
|
||||
};
|
||||
}
|
||||
|
||||
// Compatibility with non ES5 compliant engines
|
||||
if (!Date.now) {
|
||||
Date.now = function() {
|
||||
return (new Date()).getTime();
|
||||
};
|
||||
}
|
||||
|
||||
// Compatibility with non ES5 compliant engines
|
||||
// Production steps of ECMA-262, Edition 5.1, 15.4.4.17
|
||||
if (!Array.prototype.some)
|
||||
{
|
||||
Array.prototype.some = function(fun: any /*, thisp */)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (this == null)
|
||||
throw new TypeError();
|
||||
|
||||
var t = Object(this);
|
||||
var len = t.length >>> 0;
|
||||
if (typeof fun != "function")
|
||||
throw new TypeError();
|
||||
|
||||
var thisp = arguments[1];
|
||||
for (var i = 0; i < len; i++)
|
||||
{
|
||||
var idx = i.toString(); // REVIEW: this line is not from the Mozilla page, necessary to avoid our compile time checks against non-string/any types in an in expression
|
||||
if (idx in t && fun.call(thisp, t[i], i, t))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
}
|
||||
@@ -1,207 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript.Services {
|
||||
export class Indenter {
|
||||
public static getIndentation(node: TypeScript.SourceUnitSyntax, soruceText: TypeScript.IScriptSnapshot, position: number, editorOptions: TypeScript.Services.EditorOptions): number {
|
||||
var indentation = 0;
|
||||
var currentToken = TypeScript.findToken(node, position);
|
||||
var currentNode: TypeScript.ISyntaxElement = currentToken;
|
||||
|
||||
if (currentToken.kind() === TypeScript.SyntaxKind.EndOfFileToken) {
|
||||
// Ignore EOF tokens, pick the one before it
|
||||
currentNode = previousToken(currentToken);
|
||||
}
|
||||
else if (Indenter.belongsToBracket(soruceText, currentToken, position)) {
|
||||
// Let braces and brackets take the indentation of thier parents
|
||||
currentNode = currentToken.parent;
|
||||
}
|
||||
|
||||
if (currentNode === null) {
|
||||
return indentation;
|
||||
}
|
||||
|
||||
// Check if this is a valid node to provide indentation
|
||||
if (currentNode.kind() === TypeScript.SyntaxKind.StringLiteral ||
|
||||
currentNode.kind() === TypeScript.SyntaxKind.RegularExpressionLiteral) {
|
||||
return indentation;
|
||||
}
|
||||
|
||||
var currentElement = currentNode;
|
||||
var parent = currentNode.parent;
|
||||
|
||||
while (parent !== null) {
|
||||
// Skip nodes that start at the position, these will have the indentation level of thier parent
|
||||
if (fullStart(parent) !== fullStart(currentNode)) {
|
||||
if (Indenter.isInContainerNode(parent, currentElement)) {
|
||||
indentation += editorOptions.IndentSize;
|
||||
}
|
||||
else {
|
||||
var listIndentation = Indenter.getCustomListIndentation(parent, currentElement);
|
||||
if (listIndentation !== -1) {
|
||||
// Found a list node with special indentation, If the list items span multiple lines, we want
|
||||
// to use the user-specified indentation; return.
|
||||
return indentation + listIndentation;
|
||||
}
|
||||
}
|
||||
}
|
||||
currentNode = parent;
|
||||
currentElement = parent;
|
||||
parent = parent.parent;
|
||||
}
|
||||
|
||||
return indentation;
|
||||
}
|
||||
|
||||
private static belongsToBracket(sourceText: TypeScript.IScriptSnapshot, token: TypeScript.ISyntaxToken, position: number): boolean {
|
||||
switch (token.kind()) {
|
||||
case TypeScript.SyntaxKind.OpenBraceToken:
|
||||
case TypeScript.SyntaxKind.CloseBraceToken:
|
||||
case TypeScript.SyntaxKind.OpenParenToken:
|
||||
case TypeScript.SyntaxKind.CloseParenToken:
|
||||
case TypeScript.SyntaxKind.OpenBracketToken:
|
||||
case TypeScript.SyntaxKind.CloseBracketToken:
|
||||
// the current token is a bracket, check if the current position is separated from it by a new line
|
||||
if (position < start(token)) {
|
||||
var text = sourceText.getText(position, start(token));
|
||||
for(var i = 0; i< text.length; i++){
|
||||
if (TypeScript.CharacterInfo.isLineTerminator(text.charCodeAt(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static isInContainerNode(parent: TypeScript.ISyntaxElement, element: TypeScript.ISyntaxElement): boolean {
|
||||
switch (parent.kind()) {
|
||||
case TypeScript.SyntaxKind.ClassDeclaration:
|
||||
case TypeScript.SyntaxKind.ModuleDeclaration:
|
||||
case TypeScript.SyntaxKind.EnumDeclaration:
|
||||
case TypeScript.SyntaxKind.ImportDeclaration:
|
||||
case TypeScript.SyntaxKind.Block:
|
||||
case TypeScript.SyntaxKind.SwitchStatement:
|
||||
case TypeScript.SyntaxKind.CaseSwitchClause:
|
||||
case TypeScript.SyntaxKind.DefaultSwitchClause:
|
||||
return true;
|
||||
|
||||
case TypeScript.SyntaxKind.ObjectType:
|
||||
return true;
|
||||
|
||||
case TypeScript.SyntaxKind.InterfaceDeclaration:
|
||||
return element.kind() !== TypeScript.SyntaxKind.ObjectType;
|
||||
|
||||
case TypeScript.SyntaxKind.FunctionDeclaration:
|
||||
case TypeScript.SyntaxKind.MemberFunctionDeclaration:
|
||||
case TypeScript.SyntaxKind.GetAccessor:
|
||||
case TypeScript.SyntaxKind.SetAccessor:
|
||||
case TypeScript.SyntaxKind.FunctionExpression:
|
||||
case TypeScript.SyntaxKind.CatchClause:
|
||||
case TypeScript.SyntaxKind.FinallyClause:
|
||||
case TypeScript.SyntaxKind.FunctionDeclaration:
|
||||
case TypeScript.SyntaxKind.ConstructorDeclaration:
|
||||
case TypeScript.SyntaxKind.ForStatement:
|
||||
case TypeScript.SyntaxKind.ForInStatement:
|
||||
case TypeScript.SyntaxKind.WhileStatement:
|
||||
case TypeScript.SyntaxKind.DoStatement:
|
||||
case TypeScript.SyntaxKind.WithStatement:
|
||||
case TypeScript.SyntaxKind.IfStatement:
|
||||
case TypeScript.SyntaxKind.ElseClause:
|
||||
// The block has already been conted before, ignore the container node
|
||||
return element.kind() !== TypeScript.SyntaxKind.Block;
|
||||
|
||||
case TypeScript.SyntaxKind.TryStatement:
|
||||
// If inside the try body, the block element will take care of the indentation
|
||||
// If not, we do not want to indent, as the next token would probally be catch or finally
|
||||
// and we want these on the same indentation level.
|
||||
return false;
|
||||
default:
|
||||
return isNode(parent) && SyntaxUtilities.isStatement(parent);
|
||||
}
|
||||
}
|
||||
|
||||
private static getCustomListIndentation(list: TypeScript.ISyntaxElement, element: TypeScript.ISyntaxElement): number {
|
||||
switch (list.kind()) {
|
||||
case TypeScript.SyntaxKind.SeparatedList:
|
||||
// If it is the first in the list, let it have its parents indentation; no custom indentation here.
|
||||
for (var i = 0, n = childCount(list); i < n ; i++) {
|
||||
var child = childAt(list, i);
|
||||
if (child !== null && child === element)
|
||||
return Indenter.getListItemIndentation(list, i - 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case TypeScript.SyntaxKind.ArgumentList:
|
||||
// The separated list has been handled in the previous case, this is just if we are after
|
||||
// the last element of the list, we want to get the indentation of the last element of the list
|
||||
var argumentList = <TypeScript.ArgumentListSyntax> list;
|
||||
var _arguments = argumentList.arguments;
|
||||
if (_arguments !== null && argumentList.closeParenToken === element) {
|
||||
return Indenter.getListItemIndentation(_arguments, childCount(_arguments) - 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case TypeScript.SyntaxKind.ParameterList:
|
||||
// The separated list has been handled in the previous case, this is just if we are after
|
||||
// the last element of the list, we want to get the indentation of the last element of the list
|
||||
var parameterList = <TypeScript.ParameterListSyntax> list;
|
||||
var parameters = parameterList.parameters;
|
||||
if (parameters !== null && parameterList.closeParenToken === element) {
|
||||
return Indenter.getListItemIndentation(parameters, childCount(parameters) - 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case TypeScript.SyntaxKind.TypeArgumentList:
|
||||
// The separated list has been handled in the previous case, this is just if we are after
|
||||
// the last element of the list, we want to get the indentation of the last element of the list
|
||||
var typeArgumentList = <TypeScript.TypeArgumentListSyntax> list;
|
||||
var typeArguments = typeArgumentList.typeArguments;
|
||||
if (typeArguments !== null && typeArgumentList.greaterThanToken === element) {
|
||||
return Indenter.getListItemIndentation(typeArguments, childCount(typeArguments) - 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case TypeScript.SyntaxKind.TypeParameterList:
|
||||
// The separated list has been handled in the previous case, this is just if we are after
|
||||
// the last element of the list, we want to get the indentation of the last element of the list
|
||||
var typeParameterList = <TypeScript.TypeParameterListSyntax> list;
|
||||
var typeParameters = typeParameterList.typeParameters;
|
||||
if (typeParameters !== null && typeParameterList.greaterThanToken === element) {
|
||||
return Indenter.getListItemIndentation(typeParameters, childCount(typeParameters) - 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static getListItemIndentation(list: TypeScript.ISyntaxElement, elementIndex: number): number {
|
||||
for (var i = elementIndex; i > 0 ; i--) {
|
||||
var child = childAt(list, i);
|
||||
var previousChild = childAt(list, i - 1);
|
||||
if ((child !== null && firstToken(child).leadingTrivia().hasNewLine()) ||
|
||||
(previousChild !== null && lastToken(previousChild).trailingTrivia().hasNewLine())) {
|
||||
|
||||
// TODO: get the trivia after new line
|
||||
return leadingTriviaWidth(child);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,342 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
///<reference path='typescriptServices.ts' />
|
||||
///<reference path='diagnosticServices.ts' />
|
||||
|
||||
module TypeScript.Services {
|
||||
|
||||
//
|
||||
// Public interface of the host of a language service instance.
|
||||
//
|
||||
export interface ILanguageServiceHost extends TypeScript.ILogger, TypeScript.IReferenceResolverHost {
|
||||
getCompilationSettings(): TypeScript.CompilationSettings;
|
||||
|
||||
getScriptFileNames(): string[];
|
||||
getScriptVersion(fileName: string): number;
|
||||
getScriptIsOpen(fileName: string): boolean;
|
||||
getScriptByteOrderMark(fileName: string): TypeScript.ByteOrderMark;
|
||||
getScriptSnapshot(fileName: string): TypeScript.IScriptSnapshot;
|
||||
getDiagnosticsObject(): TypeScript.Services.ILanguageServicesDiagnostics;
|
||||
getLocalizedDiagnosticMessages(): any;
|
||||
}
|
||||
|
||||
//
|
||||
// Public services of a language service instance associated
|
||||
// with a language service host instance
|
||||
//
|
||||
export interface ILanguageService {
|
||||
// Note: refresh is a no-op now. It is only around for back compat purposes.
|
||||
refresh(): void;
|
||||
|
||||
cleanupSemanticCache(): void;
|
||||
|
||||
getSyntacticDiagnostics(fileName: string): TypeScript.Diagnostic[];
|
||||
getSemanticDiagnostics(fileName: string): TypeScript.Diagnostic[];
|
||||
getCompilerOptionsDiagnostics(): TypeScript.Diagnostic[];
|
||||
|
||||
getCompletionsAtPosition(fileName: string, position: number, isMemberCompletion: boolean): CompletionInfo;
|
||||
getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails;
|
||||
|
||||
getTypeAtPosition(fileName: string, position: number): TypeInfo;
|
||||
|
||||
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): SpanInfo;
|
||||
|
||||
getBreakpointStatementAtPosition(fileName: string, position: number): SpanInfo;
|
||||
|
||||
getSignatureAtPosition(fileName: string, position: number): SignatureInfo;
|
||||
|
||||
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
|
||||
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
|
||||
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
|
||||
getImplementorsAtPosition(fileName: string, position: number): ReferenceEntry[];
|
||||
|
||||
getNavigateToItems(searchValue: string): NavigateToItem[];
|
||||
getScriptLexicalStructure(fileName: string): NavigateToItem[];
|
||||
|
||||
getOutliningRegions(fileName: string): TypeScript.TextSpan[];
|
||||
getBraceMatchingAtPosition(fileName: string, position: number): TypeScript.TextSpan[];
|
||||
getIndentationAtPosition(fileName: string, position: number, options: TypeScript.Services.EditorOptions): number;
|
||||
|
||||
getFormattingEditsForRange(fileName: string, minChar: number, limChar: number, options: FormatCodeOptions): TextEdit[];
|
||||
getFormattingEditsForDocument(fileName: string, minChar: number, limChar: number, options: FormatCodeOptions): TextEdit[];
|
||||
getFormattingEditsOnPaste(fileName: string, minChar: number, limChar: number, options: FormatCodeOptions): TextEdit[];
|
||||
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextEdit[];
|
||||
|
||||
getEmitOutput(fileName: string): TypeScript.EmitOutput;
|
||||
|
||||
getSyntaxTree(fileName: string): TypeScript.SyntaxTree;
|
||||
}
|
||||
|
||||
export function logInternalError(logger: TypeScript.ILogger, err: Error) {
|
||||
logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message);
|
||||
}
|
||||
|
||||
export class ReferenceEntry {
|
||||
public fileName: string = ""
|
||||
public minChar: number = -1;
|
||||
public limChar: number = -1;
|
||||
public isWriteAccess: boolean = false;
|
||||
|
||||
constructor(fileName: string, minChar: number, limChar: number, isWriteAccess: boolean) {
|
||||
this.fileName = fileName;
|
||||
this.minChar = minChar;
|
||||
this.limChar = limChar;
|
||||
this.isWriteAccess = isWriteAccess;
|
||||
}
|
||||
}
|
||||
|
||||
export class NavigateToItem {
|
||||
public name: string = "";
|
||||
public kind: string = ""; // see ScriptElementKind
|
||||
public kindModifiers: string = ""; // see ScriptElementKindModifier, comma separated
|
||||
public matchKind: string = "";
|
||||
public fileName: string = "";
|
||||
public minChar: number = -1;
|
||||
public limChar: number = -1;
|
||||
public additionalSpans: SpanInfo[] = null;
|
||||
public containerName: string = "";
|
||||
public containerKind: string = ""; // see ScriptElementKind
|
||||
}
|
||||
|
||||
export class TextEdit {
|
||||
constructor(public minChar: number, public limChar: number, public text: string) {
|
||||
}
|
||||
|
||||
static createInsert(pos: number, text: string): TextEdit {
|
||||
return new TextEdit(pos, pos, text);
|
||||
}
|
||||
static createDelete(minChar: number, limChar: number): TextEdit {
|
||||
return new TextEdit(minChar, limChar, "");
|
||||
}
|
||||
static createReplace(minChar: number, limChar: number, text: string): TextEdit {
|
||||
return new TextEdit(minChar, limChar, text);
|
||||
}
|
||||
}
|
||||
|
||||
export class EditorOptions {
|
||||
public IndentSize: number = 4;
|
||||
public TabSize: number = 4;
|
||||
public NewLineCharacter: string = "\r\n";
|
||||
public ConvertTabsToSpaces: boolean = true;
|
||||
|
||||
public static clone(objectToClone: EditorOptions): EditorOptions {
|
||||
var editorOptions = new EditorOptions();
|
||||
editorOptions.IndentSize = objectToClone.IndentSize;
|
||||
editorOptions.TabSize = objectToClone.TabSize;
|
||||
editorOptions.NewLineCharacter = objectToClone.NewLineCharacter;
|
||||
editorOptions.ConvertTabsToSpaces = objectToClone.ConvertTabsToSpaces;
|
||||
return editorOptions;
|
||||
}
|
||||
}
|
||||
|
||||
export class FormatCodeOptions extends EditorOptions {
|
||||
public InsertSpaceAfterCommaDelimiter: boolean = true;
|
||||
public InsertSpaceAfterSemicolonInForStatements: boolean = true;
|
||||
public InsertSpaceBeforeAndAfterBinaryOperators: boolean = true;
|
||||
public InsertSpaceAfterKeywordsInControlFlowStatements: boolean = true;
|
||||
public InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean = false;
|
||||
public InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean = false;
|
||||
public PlaceOpenBraceOnNewLineForFunctions: boolean = false;
|
||||
public PlaceOpenBraceOnNewLineForControlBlocks: boolean = false;
|
||||
|
||||
public static clone(objectToClone: FormatCodeOptions ): FormatCodeOptions {
|
||||
var formatCodeOptions = <FormatCodeOptions>EditorOptions.clone(objectToClone);
|
||||
formatCodeOptions.InsertSpaceAfterCommaDelimiter = objectToClone.InsertSpaceAfterCommaDelimiter;
|
||||
formatCodeOptions.InsertSpaceAfterSemicolonInForStatements = objectToClone.InsertSpaceAfterSemicolonInForStatements;
|
||||
formatCodeOptions.InsertSpaceBeforeAndAfterBinaryOperators = objectToClone.InsertSpaceBeforeAndAfterBinaryOperators;
|
||||
formatCodeOptions.InsertSpaceAfterKeywordsInControlFlowStatements = objectToClone.InsertSpaceAfterKeywordsInControlFlowStatements;
|
||||
formatCodeOptions.InsertSpaceAfterFunctionKeywordForAnonymousFunctions = objectToClone.InsertSpaceAfterFunctionKeywordForAnonymousFunctions;
|
||||
formatCodeOptions.InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis = objectToClone.InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis;
|
||||
formatCodeOptions.PlaceOpenBraceOnNewLineForFunctions = objectToClone.PlaceOpenBraceOnNewLineForFunctions;
|
||||
formatCodeOptions.PlaceOpenBraceOnNewLineForControlBlocks = objectToClone.PlaceOpenBraceOnNewLineForControlBlocks;
|
||||
return formatCodeOptions;
|
||||
}
|
||||
}
|
||||
|
||||
export class DefinitionInfo {
|
||||
constructor(
|
||||
public fileName: string,
|
||||
public minChar: number,
|
||||
public limChar: number,
|
||||
public kind: string,
|
||||
public name: string,
|
||||
public containerKind: string,
|
||||
public containerName: string) {
|
||||
}
|
||||
}
|
||||
|
||||
export class TypeInfo {
|
||||
constructor(
|
||||
public memberName: TypeScript.MemberName,
|
||||
public docComment: string,
|
||||
public fullSymbolName: string,
|
||||
public kind: string,
|
||||
public minChar: number,
|
||||
public limChar: number) {
|
||||
}
|
||||
}
|
||||
|
||||
export class SpanInfo {
|
||||
constructor(public minChar: number, public limChar: number, public text: string = null) {
|
||||
}
|
||||
}
|
||||
|
||||
export class SignatureInfo {
|
||||
public actual: ActualSignatureInfo;
|
||||
public formal: FormalSignatureItemInfo[] = []; // Formal signatures
|
||||
public activeFormal: number; // Index of the "best match" formal signature
|
||||
}
|
||||
|
||||
export class FormalSignatureItemInfo {
|
||||
public signatureInfo: string;
|
||||
public typeParameters: FormalTypeParameterInfo[] = [];
|
||||
public parameters: FormalParameterInfo[] = []; // Array of parameters
|
||||
public docComment: string; // Help for the signature
|
||||
}
|
||||
|
||||
export class FormalTypeParameterInfo {
|
||||
public name: string; // Type parameter name
|
||||
public docComment: string; // Comments that contain help for the parameter
|
||||
public minChar: number; // minChar for parameter info in the formal signature info string
|
||||
public limChar: number; // lim char for parameter info in the formal signature info string
|
||||
}
|
||||
|
||||
export class FormalParameterInfo {
|
||||
public name: string; // Parameter name
|
||||
public isVariable: boolean; // true if parameter is var args
|
||||
public docComment: string; // Comments that contain help for the parameter
|
||||
public minChar: number; // minChar for parameter info in the formal signature info string
|
||||
public limChar: number; // lim char for parameter info in the formal signature info string
|
||||
}
|
||||
|
||||
export class ActualSignatureInfo {
|
||||
public parameterMinChar: number;
|
||||
public parameterLimChar: number;
|
||||
public currentParameterIsTypeParameter: boolean; // current parameter is a type argument or a normal argument
|
||||
public currentParameter: number; // Index of active parameter in "parameters" or "typeParamters" array
|
||||
}
|
||||
|
||||
export class CompletionInfo {
|
||||
public maybeInaccurate = false;
|
||||
public isMemberCompletion = false;
|
||||
public entries: CompletionEntry[] = [];
|
||||
}
|
||||
|
||||
export interface CompletionEntry {
|
||||
name: string;
|
||||
kind: string; // see ScriptElementKind
|
||||
kindModifiers: string; // see ScriptElementKindModifier, comma separated
|
||||
}
|
||||
|
||||
export interface CompletionEntryDetails {
|
||||
name: string;
|
||||
kind: string; // see ScriptElementKind
|
||||
kindModifiers: string; // see ScriptElementKindModifier, comma separated
|
||||
type: string;
|
||||
fullSymbolName: string;
|
||||
docComment: string;
|
||||
}
|
||||
|
||||
|
||||
export class ScriptElementKind {
|
||||
static unknown = "";
|
||||
|
||||
// predefined type (void) or keyword (class)
|
||||
static keyword = "keyword";
|
||||
|
||||
// top level script node
|
||||
static scriptElement = "script";
|
||||
|
||||
// module foo {}
|
||||
static moduleElement = "module";
|
||||
|
||||
// class X {}
|
||||
static classElement = "class";
|
||||
|
||||
// interface Y {}
|
||||
static interfaceElement = "interface";
|
||||
|
||||
// enum E
|
||||
static enumElement = "enum";
|
||||
|
||||
// Inside module and script only
|
||||
// var v = ..
|
||||
static variableElement = "var";
|
||||
|
||||
// Inside function
|
||||
static localVariableElement = "local var";
|
||||
|
||||
// Inside module and script only
|
||||
// function f() { }
|
||||
static functionElement = "function";
|
||||
|
||||
// Inside function
|
||||
static localFunctionElement = "local function";
|
||||
|
||||
// class X { [public|private]* foo() {} }
|
||||
static memberFunctionElement = "method";
|
||||
|
||||
// class X { [public|private]* [get|set] foo:number; }
|
||||
static memberGetAccessorElement = "getter";
|
||||
static memberSetAccessorElement = "setter";
|
||||
|
||||
// class X { [public|private]* foo:number; }
|
||||
// interface Y { foo:number; }
|
||||
static memberVariableElement = "property";
|
||||
|
||||
// class X { constructor() { } }
|
||||
static constructorImplementationElement = "constructor";
|
||||
|
||||
// interface Y { ():number; }
|
||||
static callSignatureElement = "call";
|
||||
|
||||
// interface Y { []:number; }
|
||||
static indexSignatureElement = "index";
|
||||
|
||||
// interface Y { new():Y; }
|
||||
static constructSignatureElement = "construct";
|
||||
|
||||
// function foo(*Y*: string)
|
||||
static parameterElement = "parameter";
|
||||
|
||||
static typeParameterElement = "type parameter";
|
||||
|
||||
static primitiveType = "primitive type";
|
||||
}
|
||||
|
||||
export class ScriptElementKindModifier {
|
||||
static none = "";
|
||||
static publicMemberModifier = "public";
|
||||
static privateMemberModifier = "private";
|
||||
static exportedModifier = "export";
|
||||
static ambientModifier = "declare";
|
||||
static staticModifier = "static";
|
||||
}
|
||||
|
||||
export class MatchKind {
|
||||
static none: string = null;
|
||||
static exact = "exact";
|
||||
static subString = "substring";
|
||||
static prefix = "prefix";
|
||||
}
|
||||
|
||||
export class DiagnosticCategory {
|
||||
static none = "";
|
||||
static error = "error";
|
||||
static warning = "warning";
|
||||
static message = "message";
|
||||
}
|
||||
}
|
||||
@@ -1,708 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export class SyntaxRewriter implements ISyntaxVisitor {
|
||||
public visitToken(token: ISyntaxToken): ISyntaxToken {
|
||||
return token;
|
||||
}
|
||||
|
||||
public visitNode(node: ISyntaxNode): ISyntaxNode {
|
||||
return visitNodeOrToken(this, node);
|
||||
}
|
||||
|
||||
public visitNodeOrToken(node: ISyntaxNodeOrToken): ISyntaxNodeOrToken {
|
||||
return isToken(node) ? <ISyntaxNodeOrToken>this.visitToken(<ISyntaxToken>node) : this.visitNode(<ISyntaxNode>node);
|
||||
}
|
||||
|
||||
public visitList<T extends ISyntaxNodeOrToken>(list: T[]): T[] {
|
||||
var newItems: T[] = null;
|
||||
|
||||
for (var i = 0, n = list.length; i < n; i++) {
|
||||
var item = list[i];
|
||||
var newItem = <T>this.visitNodeOrToken(item);
|
||||
|
||||
if (item !== newItem && newItems === null) {
|
||||
newItems = [];
|
||||
for (var j = 0; j < i; j++) {
|
||||
newItems.push(list[j]);
|
||||
}
|
||||
}
|
||||
|
||||
if (newItems) {
|
||||
newItems.push(newItem);
|
||||
}
|
||||
}
|
||||
|
||||
// Debug.assert(newItems === null || newItems.length === childCount(list));
|
||||
return newItems === null ? list : Syntax.list<T>(newItems);
|
||||
}
|
||||
|
||||
public visitSeparatedList<T extends ISyntaxNodeOrToken>(list: T[]): T[] {
|
||||
var newItems: ISyntaxNodeOrToken[] = null;
|
||||
|
||||
for (var i = 0, n = childCount(list); i < n; i++) {
|
||||
var item = childAt(list, i);
|
||||
var newItem = isToken(item) ? <ISyntaxNodeOrToken>this.visitToken(<ISyntaxToken>item) : this.visitNode(<ISyntaxNode>item);
|
||||
|
||||
if (item !== newItem && newItems === null) {
|
||||
newItems = [];
|
||||
for (var j = 0; j < i; j++) {
|
||||
newItems.push(childAt(list, j));
|
||||
}
|
||||
}
|
||||
|
||||
if (newItems) {
|
||||
newItems.push(newItem);
|
||||
}
|
||||
}
|
||||
|
||||
// Debug.assert(newItems === null || newItems.length === childCount(list));
|
||||
return newItems === null ? list : Syntax.separatedList<T>(newItems);
|
||||
}
|
||||
|
||||
public visitSourceUnit(node: SourceUnitSyntax): any {
|
||||
return node.update(
|
||||
this.visitList(node.moduleElements),
|
||||
this.visitToken(node.endOfFileToken));
|
||||
}
|
||||
|
||||
public visitQualifiedName(node: QualifiedNameSyntax): any {
|
||||
return node.update(
|
||||
<INameSyntax>this.visitNodeOrToken(node.left),
|
||||
this.visitToken(node.dotToken),
|
||||
this.visitToken(node.right));
|
||||
}
|
||||
|
||||
public visitObjectType(node: ObjectTypeSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.openBraceToken),
|
||||
this.visitSeparatedList(node.typeMembers),
|
||||
this.visitToken(node.closeBraceToken));
|
||||
}
|
||||
|
||||
public visitFunctionType(node: FunctionTypeSyntax): any {
|
||||
return node.update(
|
||||
node.typeParameterList === null ? null : <TypeParameterListSyntax>this.visitNode(node.typeParameterList),
|
||||
<ParameterListSyntax>this.visitNode(node.parameterList),
|
||||
this.visitToken(node.equalsGreaterThanToken),
|
||||
<ITypeSyntax>this.visitNodeOrToken(node.type));
|
||||
}
|
||||
|
||||
public visitArrayType(node: ArrayTypeSyntax): any {
|
||||
return node.update(
|
||||
<ITypeSyntax>this.visitNodeOrToken(node.type),
|
||||
this.visitToken(node.openBracketToken),
|
||||
this.visitToken(node.closeBracketToken));
|
||||
}
|
||||
|
||||
public visitConstructorType(node: ConstructorTypeSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.newKeyword),
|
||||
node.typeParameterList === null ? null : <TypeParameterListSyntax>this.visitNode(node.typeParameterList),
|
||||
<ParameterListSyntax>this.visitNode(node.parameterList),
|
||||
this.visitToken(node.equalsGreaterThanToken),
|
||||
<ITypeSyntax>this.visitNodeOrToken(node.type));
|
||||
}
|
||||
|
||||
public visitGenericType(node: GenericTypeSyntax): any {
|
||||
return node.update(
|
||||
<INameSyntax>this.visitNodeOrToken(node.name),
|
||||
<TypeArgumentListSyntax>this.visitNode(node.typeArgumentList));
|
||||
}
|
||||
|
||||
public visitTypeQuery(node: TypeQuerySyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.typeOfKeyword),
|
||||
<INameSyntax>this.visitNodeOrToken(node.name));
|
||||
}
|
||||
|
||||
public visitInterfaceDeclaration(node: InterfaceDeclarationSyntax): any {
|
||||
return node.update(
|
||||
this.visitList(node.modifiers),
|
||||
this.visitToken(node.interfaceKeyword),
|
||||
this.visitToken(node.identifier),
|
||||
node.typeParameterList === null ? null : <TypeParameterListSyntax>this.visitNode(node.typeParameterList),
|
||||
this.visitList(node.heritageClauses),
|
||||
<ObjectTypeSyntax>this.visitNode(node.body));
|
||||
}
|
||||
|
||||
public visitFunctionDeclaration(node: FunctionDeclarationSyntax): any {
|
||||
return node.update(
|
||||
this.visitList(node.modifiers),
|
||||
this.visitToken(node.functionKeyword),
|
||||
this.visitToken(node.identifier),
|
||||
<CallSignatureSyntax>this.visitNode(node.callSignature),
|
||||
node.block === null ? null : <BlockSyntax>this.visitNode(node.block),
|
||||
node.semicolonToken === null ? null : this.visitToken(node.semicolonToken));
|
||||
}
|
||||
|
||||
public visitModuleDeclaration(node: ModuleDeclarationSyntax): any {
|
||||
return node.update(
|
||||
this.visitList(node.modifiers),
|
||||
this.visitToken(node.moduleKeyword),
|
||||
node.name === null ? null : <INameSyntax>this.visitNodeOrToken(node.name),
|
||||
node.stringLiteral === null ? null : this.visitToken(node.stringLiteral),
|
||||
this.visitToken(node.openBraceToken),
|
||||
this.visitList(node.moduleElements),
|
||||
this.visitToken(node.closeBraceToken));
|
||||
}
|
||||
|
||||
public visitClassDeclaration(node: ClassDeclarationSyntax): any {
|
||||
return node.update(
|
||||
this.visitList(node.modifiers),
|
||||
this.visitToken(node.classKeyword),
|
||||
this.visitToken(node.identifier),
|
||||
node.typeParameterList === null ? null : <TypeParameterListSyntax>this.visitNode(node.typeParameterList),
|
||||
this.visitList(node.heritageClauses),
|
||||
this.visitToken(node.openBraceToken),
|
||||
this.visitList(node.classElements),
|
||||
this.visitToken(node.closeBraceToken));
|
||||
}
|
||||
|
||||
public visitEnumDeclaration(node: EnumDeclarationSyntax): any {
|
||||
return node.update(
|
||||
this.visitList(node.modifiers),
|
||||
this.visitToken(node.enumKeyword),
|
||||
this.visitToken(node.identifier),
|
||||
this.visitToken(node.openBraceToken),
|
||||
this.visitSeparatedList(node.enumElements),
|
||||
this.visitToken(node.closeBraceToken));
|
||||
}
|
||||
|
||||
public visitImportDeclaration(node: ImportDeclarationSyntax): any {
|
||||
return node.update(
|
||||
this.visitList(node.modifiers),
|
||||
this.visitToken(node.importKeyword),
|
||||
this.visitToken(node.identifier),
|
||||
this.visitToken(node.equalsToken),
|
||||
<IModuleReferenceSyntax>this.visitNodeOrToken(node.moduleReference),
|
||||
node.semicolonToken === null ? null : this.visitToken(node.semicolonToken));
|
||||
}
|
||||
|
||||
public visitExportAssignment(node: ExportAssignmentSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.exportKeyword),
|
||||
this.visitToken(node.equalsToken),
|
||||
this.visitToken(node.identifier),
|
||||
node.semicolonToken === null ? null : this.visitToken(node.semicolonToken));
|
||||
}
|
||||
|
||||
public visitMemberFunctionDeclaration(node: MemberFunctionDeclarationSyntax): any {
|
||||
return node.update(
|
||||
this.visitList(node.modifiers),
|
||||
this.visitToken(node.propertyName),
|
||||
<CallSignatureSyntax>this.visitNode(node.callSignature),
|
||||
node.block === null ? null : <BlockSyntax>this.visitNode(node.block),
|
||||
node.semicolonToken === null ? null : this.visitToken(node.semicolonToken));
|
||||
}
|
||||
|
||||
public visitMemberVariableDeclaration(node: MemberVariableDeclarationSyntax): any {
|
||||
return node.update(
|
||||
this.visitList(node.modifiers),
|
||||
<VariableDeclaratorSyntax>this.visitNode(node.variableDeclarator),
|
||||
node.semicolonToken === null ? null : this.visitToken(node.semicolonToken));
|
||||
}
|
||||
|
||||
public visitConstructorDeclaration(node: ConstructorDeclarationSyntax): any {
|
||||
return node.update(
|
||||
this.visitList(node.modifiers),
|
||||
this.visitToken(node.constructorKeyword),
|
||||
<CallSignatureSyntax>this.visitNode(node.callSignature),
|
||||
node.block === null ? null : <BlockSyntax>this.visitNode(node.block),
|
||||
node.semicolonToken === null ? null : this.visitToken(node.semicolonToken));
|
||||
}
|
||||
|
||||
public visitIndexMemberDeclaration(node: IndexMemberDeclarationSyntax): any {
|
||||
return node.update(
|
||||
this.visitList(node.modifiers),
|
||||
<IndexSignatureSyntax>this.visitNode(node.indexSignature),
|
||||
node.semicolonToken === null ? null : this.visitToken(node.semicolonToken));
|
||||
}
|
||||
|
||||
public visitGetAccessor(node: GetAccessorSyntax): any {
|
||||
return node.update(
|
||||
this.visitList(node.modifiers),
|
||||
this.visitToken(node.getKeyword),
|
||||
this.visitToken(node.propertyName),
|
||||
<CallSignatureSyntax>this.visitNode(node.callSignature),
|
||||
<BlockSyntax>this.visitNode(node.block));
|
||||
}
|
||||
|
||||
public visitSetAccessor(node: SetAccessorSyntax): any {
|
||||
return node.update(
|
||||
this.visitList(node.modifiers),
|
||||
this.visitToken(node.setKeyword),
|
||||
this.visitToken(node.propertyName),
|
||||
<CallSignatureSyntax>this.visitNode(node.callSignature),
|
||||
<BlockSyntax>this.visitNode(node.block));
|
||||
}
|
||||
|
||||
public visitPropertySignature(node: PropertySignatureSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.propertyName),
|
||||
node.questionToken === null ? null : this.visitToken(node.questionToken),
|
||||
node.typeAnnotation === null ? null : <TypeAnnotationSyntax>this.visitNode(node.typeAnnotation));
|
||||
}
|
||||
|
||||
public visitCallSignature(node: CallSignatureSyntax): any {
|
||||
return node.update(
|
||||
node.typeParameterList === null ? null : <TypeParameterListSyntax>this.visitNode(node.typeParameterList),
|
||||
<ParameterListSyntax>this.visitNode(node.parameterList),
|
||||
node.typeAnnotation === null ? null : <TypeAnnotationSyntax>this.visitNode(node.typeAnnotation));
|
||||
}
|
||||
|
||||
public visitConstructSignature(node: ConstructSignatureSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.newKeyword),
|
||||
<CallSignatureSyntax>this.visitNode(node.callSignature));
|
||||
}
|
||||
|
||||
public visitIndexSignature(node: IndexSignatureSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.openBracketToken),
|
||||
this.visitSeparatedList(node.parameters),
|
||||
this.visitToken(node.closeBracketToken),
|
||||
node.typeAnnotation === null ? null : <TypeAnnotationSyntax>this.visitNode(node.typeAnnotation));
|
||||
}
|
||||
|
||||
public visitMethodSignature(node: MethodSignatureSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.propertyName),
|
||||
node.questionToken === null ? null : this.visitToken(node.questionToken),
|
||||
<CallSignatureSyntax>this.visitNode(node.callSignature));
|
||||
}
|
||||
|
||||
public visitBlock(node: BlockSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.openBraceToken),
|
||||
this.visitList(node.statements),
|
||||
this.visitToken(node.closeBraceToken));
|
||||
}
|
||||
|
||||
public visitIfStatement(node: IfStatementSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.ifKeyword),
|
||||
this.visitToken(node.openParenToken),
|
||||
<IExpressionSyntax>this.visitNodeOrToken(node.condition),
|
||||
this.visitToken(node.closeParenToken),
|
||||
<IStatementSyntax>this.visitNodeOrToken(node.statement),
|
||||
node.elseClause === null ? null : <ElseClauseSyntax>this.visitNode(node.elseClause));
|
||||
}
|
||||
|
||||
public visitVariableStatement(node: VariableStatementSyntax): any {
|
||||
return node.update(
|
||||
this.visitList(node.modifiers),
|
||||
<VariableDeclarationSyntax>this.visitNode(node.variableDeclaration),
|
||||
node.semicolonToken === null ? null : this.visitToken(node.semicolonToken));
|
||||
}
|
||||
|
||||
public visitExpressionStatement(node: ExpressionStatementSyntax): any {
|
||||
return node.update(
|
||||
<IExpressionSyntax>this.visitNodeOrToken(node.expression),
|
||||
node.semicolonToken === null ? null : this.visitToken(node.semicolonToken));
|
||||
}
|
||||
|
||||
public visitReturnStatement(node: ReturnStatementSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.returnKeyword),
|
||||
node.expression === null ? null : <IExpressionSyntax>this.visitNodeOrToken(node.expression),
|
||||
node.semicolonToken === null ? null : this.visitToken(node.semicolonToken));
|
||||
}
|
||||
|
||||
public visitSwitchStatement(node: SwitchStatementSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.switchKeyword),
|
||||
this.visitToken(node.openParenToken),
|
||||
<IExpressionSyntax>this.visitNodeOrToken(node.expression),
|
||||
this.visitToken(node.closeParenToken),
|
||||
this.visitToken(node.openBraceToken),
|
||||
this.visitList(node.switchClauses),
|
||||
this.visitToken(node.closeBraceToken));
|
||||
}
|
||||
|
||||
public visitBreakStatement(node: BreakStatementSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.breakKeyword),
|
||||
node.identifier === null ? null : this.visitToken(node.identifier),
|
||||
node.semicolonToken === null ? null : this.visitToken(node.semicolonToken));
|
||||
}
|
||||
|
||||
public visitContinueStatement(node: ContinueStatementSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.continueKeyword),
|
||||
node.identifier === null ? null : this.visitToken(node.identifier),
|
||||
node.semicolonToken === null ? null : this.visitToken(node.semicolonToken));
|
||||
}
|
||||
|
||||
public visitForStatement(node: ForStatementSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.forKeyword),
|
||||
this.visitToken(node.openParenToken),
|
||||
node.variableDeclaration === null ? null : <VariableDeclarationSyntax>this.visitNode(node.variableDeclaration),
|
||||
node.initializer === null ? null : <IExpressionSyntax>this.visitNodeOrToken(node.initializer),
|
||||
this.visitToken(node.firstSemicolonToken),
|
||||
node.condition === null ? null : <IExpressionSyntax>this.visitNodeOrToken(node.condition),
|
||||
this.visitToken(node.secondSemicolonToken),
|
||||
node.incrementor === null ? null : <IExpressionSyntax>this.visitNodeOrToken(node.incrementor),
|
||||
this.visitToken(node.closeParenToken),
|
||||
<IStatementSyntax>this.visitNodeOrToken(node.statement));
|
||||
}
|
||||
|
||||
public visitForInStatement(node: ForInStatementSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.forKeyword),
|
||||
this.visitToken(node.openParenToken),
|
||||
node.variableDeclaration === null ? null : <VariableDeclarationSyntax>this.visitNode(node.variableDeclaration),
|
||||
node.left === null ? null : <IExpressionSyntax>this.visitNodeOrToken(node.left),
|
||||
this.visitToken(node.inKeyword),
|
||||
<IExpressionSyntax>this.visitNodeOrToken(node.expression),
|
||||
this.visitToken(node.closeParenToken),
|
||||
<IStatementSyntax>this.visitNodeOrToken(node.statement));
|
||||
}
|
||||
|
||||
public visitEmptyStatement(node: EmptyStatementSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.semicolonToken));
|
||||
}
|
||||
|
||||
public visitThrowStatement(node: ThrowStatementSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.throwKeyword),
|
||||
<IExpressionSyntax>this.visitNodeOrToken(node.expression),
|
||||
node.semicolonToken === null ? null : this.visitToken(node.semicolonToken));
|
||||
}
|
||||
|
||||
public visitWhileStatement(node: WhileStatementSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.whileKeyword),
|
||||
this.visitToken(node.openParenToken),
|
||||
<IExpressionSyntax>this.visitNodeOrToken(node.condition),
|
||||
this.visitToken(node.closeParenToken),
|
||||
<IStatementSyntax>this.visitNodeOrToken(node.statement));
|
||||
}
|
||||
|
||||
public visitTryStatement(node: TryStatementSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.tryKeyword),
|
||||
<BlockSyntax>this.visitNode(node.block),
|
||||
node.catchClause === null ? null : <CatchClauseSyntax>this.visitNode(node.catchClause),
|
||||
node.finallyClause === null ? null : <FinallyClauseSyntax>this.visitNode(node.finallyClause));
|
||||
}
|
||||
|
||||
public visitLabeledStatement(node: LabeledStatementSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.identifier),
|
||||
this.visitToken(node.colonToken),
|
||||
<IStatementSyntax>this.visitNodeOrToken(node.statement));
|
||||
}
|
||||
|
||||
public visitDoStatement(node: DoStatementSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.doKeyword),
|
||||
<IStatementSyntax>this.visitNodeOrToken(node.statement),
|
||||
this.visitToken(node.whileKeyword),
|
||||
this.visitToken(node.openParenToken),
|
||||
<IExpressionSyntax>this.visitNodeOrToken(node.condition),
|
||||
this.visitToken(node.closeParenToken),
|
||||
node.semicolonToken === null ? null : this.visitToken(node.semicolonToken));
|
||||
}
|
||||
|
||||
public visitDebuggerStatement(node: DebuggerStatementSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.debuggerKeyword),
|
||||
node.semicolonToken === null ? null : this.visitToken(node.semicolonToken));
|
||||
}
|
||||
|
||||
public visitWithStatement(node: WithStatementSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.withKeyword),
|
||||
this.visitToken(node.openParenToken),
|
||||
<IExpressionSyntax>this.visitNodeOrToken(node.condition),
|
||||
this.visitToken(node.closeParenToken),
|
||||
<IStatementSyntax>this.visitNodeOrToken(node.statement));
|
||||
}
|
||||
|
||||
public visitPrefixUnaryExpression(node: PrefixUnaryExpressionSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.operatorToken),
|
||||
<IUnaryExpressionSyntax>this.visitNodeOrToken(node.operand));
|
||||
}
|
||||
|
||||
public visitDeleteExpression(node: DeleteExpressionSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.deleteKeyword),
|
||||
<IUnaryExpressionSyntax>this.visitNodeOrToken(node.expression));
|
||||
}
|
||||
|
||||
public visitTypeOfExpression(node: TypeOfExpressionSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.typeOfKeyword),
|
||||
<IUnaryExpressionSyntax>this.visitNodeOrToken(node.expression));
|
||||
}
|
||||
|
||||
public visitVoidExpression(node: VoidExpressionSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.voidKeyword),
|
||||
<IUnaryExpressionSyntax>this.visitNodeOrToken(node.expression));
|
||||
}
|
||||
|
||||
public visitConditionalExpression(node: ConditionalExpressionSyntax): any {
|
||||
return node.update(
|
||||
<IExpressionSyntax>this.visitNodeOrToken(node.condition),
|
||||
this.visitToken(node.questionToken),
|
||||
<IExpressionSyntax>this.visitNodeOrToken(node.whenTrue),
|
||||
this.visitToken(node.colonToken),
|
||||
<IExpressionSyntax>this.visitNodeOrToken(node.whenFalse));
|
||||
}
|
||||
|
||||
public visitBinaryExpression(node: BinaryExpressionSyntax): any {
|
||||
return node.update(
|
||||
<IExpressionSyntax>this.visitNodeOrToken(node.left),
|
||||
this.visitToken(node.operatorToken),
|
||||
<IExpressionSyntax>this.visitNodeOrToken(node.right));
|
||||
}
|
||||
|
||||
public visitPostfixUnaryExpression(node: PostfixUnaryExpressionSyntax): any {
|
||||
return node.update(
|
||||
<ILeftHandSideExpressionSyntax>this.visitNodeOrToken(node.operand),
|
||||
this.visitToken(node.operatorToken));
|
||||
}
|
||||
|
||||
public visitMemberAccessExpression(node: MemberAccessExpressionSyntax): any {
|
||||
return node.update(
|
||||
<ILeftHandSideExpressionSyntax>this.visitNodeOrToken(node.expression),
|
||||
this.visitToken(node.dotToken),
|
||||
this.visitToken(node.name));
|
||||
}
|
||||
|
||||
public visitInvocationExpression(node: InvocationExpressionSyntax): any {
|
||||
return node.update(
|
||||
<ILeftHandSideExpressionSyntax>this.visitNodeOrToken(node.expression),
|
||||
<ArgumentListSyntax>this.visitNode(node.argumentList));
|
||||
}
|
||||
|
||||
public visitArrayLiteralExpression(node: ArrayLiteralExpressionSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.openBracketToken),
|
||||
this.visitSeparatedList(node.expressions),
|
||||
this.visitToken(node.closeBracketToken));
|
||||
}
|
||||
|
||||
public visitObjectLiteralExpression(node: ObjectLiteralExpressionSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.openBraceToken),
|
||||
this.visitSeparatedList(node.propertyAssignments),
|
||||
this.visitToken(node.closeBraceToken));
|
||||
}
|
||||
|
||||
public visitObjectCreationExpression(node: ObjectCreationExpressionSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.newKeyword),
|
||||
<IMemberExpressionSyntax>this.visitNodeOrToken(node.expression),
|
||||
node.argumentList === null ? null : <ArgumentListSyntax>this.visitNode(node.argumentList));
|
||||
}
|
||||
|
||||
public visitParenthesizedExpression(node: ParenthesizedExpressionSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.openParenToken),
|
||||
<IExpressionSyntax>this.visitNodeOrToken(node.expression),
|
||||
this.visitToken(node.closeParenToken));
|
||||
}
|
||||
|
||||
public visitParenthesizedArrowFunctionExpression(node: ParenthesizedArrowFunctionExpressionSyntax): any {
|
||||
return node.update(
|
||||
<CallSignatureSyntax>this.visitNode(node.callSignature),
|
||||
this.visitToken(node.equalsGreaterThanToken),
|
||||
node.block === null ? null : <BlockSyntax>this.visitNode(node.block),
|
||||
node.expression === null ? null : <IExpressionSyntax>this.visitNodeOrToken(node.expression));
|
||||
}
|
||||
|
||||
public visitSimpleArrowFunctionExpression(node: SimpleArrowFunctionExpressionSyntax): any {
|
||||
return node.update(
|
||||
<ParameterSyntax>this.visitNode(node.parameter),
|
||||
this.visitToken(node.equalsGreaterThanToken),
|
||||
node.block === null ? null : <BlockSyntax>this.visitNode(node.block),
|
||||
node.expression === null ? null : <IExpressionSyntax>this.visitNodeOrToken(node.expression));
|
||||
}
|
||||
|
||||
public visitCastExpression(node: CastExpressionSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.lessThanToken),
|
||||
<ITypeSyntax>this.visitNodeOrToken(node.type),
|
||||
this.visitToken(node.greaterThanToken),
|
||||
<IUnaryExpressionSyntax>this.visitNodeOrToken(node.expression));
|
||||
}
|
||||
|
||||
public visitElementAccessExpression(node: ElementAccessExpressionSyntax): any {
|
||||
return node.update(
|
||||
<ILeftHandSideExpressionSyntax>this.visitNodeOrToken(node.expression),
|
||||
this.visitToken(node.openBracketToken),
|
||||
<IExpressionSyntax>this.visitNodeOrToken(node.argumentExpression),
|
||||
this.visitToken(node.closeBracketToken));
|
||||
}
|
||||
|
||||
public visitFunctionExpression(node: FunctionExpressionSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.functionKeyword),
|
||||
node.identifier === null ? null : this.visitToken(node.identifier),
|
||||
<CallSignatureSyntax>this.visitNode(node.callSignature),
|
||||
<BlockSyntax>this.visitNode(node.block));
|
||||
}
|
||||
|
||||
public visitOmittedExpression(node: OmittedExpressionSyntax): any {
|
||||
return node;
|
||||
}
|
||||
|
||||
public visitVariableDeclaration(node: VariableDeclarationSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.varKeyword),
|
||||
this.visitSeparatedList(node.variableDeclarators));
|
||||
}
|
||||
|
||||
public visitVariableDeclarator(node: VariableDeclaratorSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.propertyName),
|
||||
node.typeAnnotation === null ? null : <TypeAnnotationSyntax>this.visitNode(node.typeAnnotation),
|
||||
node.equalsValueClause === null ? null : <EqualsValueClauseSyntax>this.visitNode(node.equalsValueClause));
|
||||
}
|
||||
|
||||
public visitArgumentList(node: ArgumentListSyntax): any {
|
||||
return node.update(
|
||||
node.typeArgumentList === null ? null : <TypeArgumentListSyntax>this.visitNode(node.typeArgumentList),
|
||||
this.visitToken(node.openParenToken),
|
||||
this.visitSeparatedList(node.arguments),
|
||||
this.visitToken(node.closeParenToken));
|
||||
}
|
||||
|
||||
public visitParameterList(node: ParameterListSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.openParenToken),
|
||||
this.visitSeparatedList(node.parameters),
|
||||
this.visitToken(node.closeParenToken));
|
||||
}
|
||||
|
||||
public visitTypeArgumentList(node: TypeArgumentListSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.lessThanToken),
|
||||
this.visitSeparatedList(node.typeArguments),
|
||||
this.visitToken(node.greaterThanToken));
|
||||
}
|
||||
|
||||
public visitTypeParameterList(node: TypeParameterListSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.lessThanToken),
|
||||
this.visitSeparatedList(node.typeParameters),
|
||||
this.visitToken(node.greaterThanToken));
|
||||
}
|
||||
|
||||
public visitHeritageClause(node: HeritageClauseSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.extendsOrImplementsKeyword),
|
||||
this.visitSeparatedList(node.typeNames));
|
||||
}
|
||||
|
||||
public visitEqualsValueClause(node: EqualsValueClauseSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.equalsToken),
|
||||
<IExpressionSyntax>this.visitNodeOrToken(node.value));
|
||||
}
|
||||
|
||||
public visitCaseSwitchClause(node: CaseSwitchClauseSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.caseKeyword),
|
||||
<IExpressionSyntax>this.visitNodeOrToken(node.expression),
|
||||
this.visitToken(node.colonToken),
|
||||
this.visitList(node.statements));
|
||||
}
|
||||
|
||||
public visitDefaultSwitchClause(node: DefaultSwitchClauseSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.defaultKeyword),
|
||||
this.visitToken(node.colonToken),
|
||||
this.visitList(node.statements));
|
||||
}
|
||||
|
||||
public visitElseClause(node: ElseClauseSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.elseKeyword),
|
||||
<IStatementSyntax>this.visitNodeOrToken(node.statement));
|
||||
}
|
||||
|
||||
public visitCatchClause(node: CatchClauseSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.catchKeyword),
|
||||
this.visitToken(node.openParenToken),
|
||||
this.visitToken(node.identifier),
|
||||
node.typeAnnotation === null ? null : <TypeAnnotationSyntax>this.visitNode(node.typeAnnotation),
|
||||
this.visitToken(node.closeParenToken),
|
||||
<BlockSyntax>this.visitNode(node.block));
|
||||
}
|
||||
|
||||
public visitFinallyClause(node: FinallyClauseSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.finallyKeyword),
|
||||
<BlockSyntax>this.visitNode(node.block));
|
||||
}
|
||||
|
||||
public visitTypeParameter(node: TypeParameterSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.identifier),
|
||||
node.constraint === null ? null : <ConstraintSyntax>this.visitNode(node.constraint));
|
||||
}
|
||||
|
||||
public visitConstraint(node: ConstraintSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.extendsKeyword),
|
||||
<ISyntaxNodeOrToken>this.visitNodeOrToken(node.typeOrExpression));
|
||||
}
|
||||
|
||||
public visitSimplePropertyAssignment(node: SimplePropertyAssignmentSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.propertyName),
|
||||
this.visitToken(node.colonToken),
|
||||
<IExpressionSyntax>this.visitNodeOrToken(node.expression));
|
||||
}
|
||||
|
||||
public visitFunctionPropertyAssignment(node: FunctionPropertyAssignmentSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.propertyName),
|
||||
<CallSignatureSyntax>this.visitNode(node.callSignature),
|
||||
<BlockSyntax>this.visitNode(node.block));
|
||||
}
|
||||
|
||||
public visitParameter(node: ParameterSyntax): any {
|
||||
return node.update(
|
||||
node.dotDotDotToken === null ? null : this.visitToken(node.dotDotDotToken),
|
||||
this.visitList(node.modifiers),
|
||||
this.visitToken(node.identifier),
|
||||
node.questionToken === null ? null : this.visitToken(node.questionToken),
|
||||
node.typeAnnotation === null ? null : <TypeAnnotationSyntax>this.visitNode(node.typeAnnotation),
|
||||
node.equalsValueClause === null ? null : <EqualsValueClauseSyntax>this.visitNode(node.equalsValueClause));
|
||||
}
|
||||
|
||||
public visitEnumElement(node: EnumElementSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.propertyName),
|
||||
node.equalsValueClause === null ? null : <EqualsValueClauseSyntax>this.visitNode(node.equalsValueClause));
|
||||
}
|
||||
|
||||
public visitTypeAnnotation(node: TypeAnnotationSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.colonToken),
|
||||
<ITypeSyntax>this.visitNodeOrToken(node.type));
|
||||
}
|
||||
|
||||
public visitExternalModuleReference(node: ExternalModuleReferenceSyntax): any {
|
||||
return node.update(
|
||||
this.visitToken(node.requireKeyword),
|
||||
this.visitToken(node.openParenToken),
|
||||
this.visitToken(node.stringLiteral),
|
||||
this.visitToken(node.closeParenToken));
|
||||
}
|
||||
|
||||
public visitModuleNameModuleReference(node: ModuleNameModuleReferenceSyntax): any {
|
||||
return node.update(
|
||||
<INameSyntax>this.visitNodeOrToken(node.moduleName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,395 +0,0 @@
|
||||
module TypeScript {
|
||||
function isSeparatedListTypeScriptSpecific(list: ISyntaxNodeOrToken[]): boolean {
|
||||
for (var i = 0, n = childCount(list); i < n; i++) {
|
||||
if (isTypeScriptSpecific(childAt(list, i))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isListTypeScriptSpecific(list: ISyntaxNodeOrToken[]): boolean {
|
||||
for (var i = 0, n = list.length; i < n; i++) {
|
||||
if (isTypeScriptSpecific(list[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isTypeScriptSpecific(element: ISyntaxElement): boolean {
|
||||
if (element === null) { return false; }
|
||||
if (isToken(element)) { return false; }
|
||||
if (isList(element)) { return isListTypeScriptSpecific(<ISyntaxNodeOrToken[]>element); }
|
||||
if (isSeparatedList(element)) { return isSeparatedListTypeScriptSpecific(<ISyntaxNodeOrToken[]>element); }
|
||||
|
||||
switch (element.kind()) {
|
||||
case SyntaxKind.QualifiedName:
|
||||
case SyntaxKind.ObjectType:
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ArrayType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
case SyntaxKind.GenericType:
|
||||
case SyntaxKind.TypeQuery:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
case SyntaxKind.ExportAssignment:
|
||||
case SyntaxKind.MemberFunctionDeclaration:
|
||||
case SyntaxKind.MemberVariableDeclaration:
|
||||
case SyntaxKind.ConstructorDeclaration:
|
||||
case SyntaxKind.IndexMemberDeclaration:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.IndexSignature:
|
||||
case SyntaxKind.ParenthesizedArrowFunctionExpression:
|
||||
case SyntaxKind.SimpleArrowFunctionExpression:
|
||||
case SyntaxKind.CastExpression:
|
||||
case SyntaxKind.TypeArgumentList:
|
||||
case SyntaxKind.TypeParameterList:
|
||||
case SyntaxKind.ExtendsHeritageClause:
|
||||
case SyntaxKind.ImplementsHeritageClause:
|
||||
case SyntaxKind.TypeParameter:
|
||||
case SyntaxKind.Constraint:
|
||||
case SyntaxKind.TypeAnnotation:
|
||||
case SyntaxKind.ExternalModuleReference:
|
||||
case SyntaxKind.ModuleNameModuleReference:
|
||||
return true;
|
||||
case SyntaxKind.BreakStatement:
|
||||
case SyntaxKind.ContinueStatement:
|
||||
case SyntaxKind.EmptyStatement:
|
||||
case SyntaxKind.DebuggerStatement:
|
||||
case SyntaxKind.OmittedExpression:
|
||||
return false;
|
||||
case SyntaxKind.SourceUnit:
|
||||
return isSourceUnitTypeScriptSpecific(<SourceUnitSyntax>element);
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
return isFunctionDeclarationTypeScriptSpecific(<FunctionDeclarationSyntax>element);
|
||||
case SyntaxKind.GetAccessor:
|
||||
return isGetAccessorTypeScriptSpecific(<GetAccessorSyntax>element);
|
||||
case SyntaxKind.CallSignature:
|
||||
return isCallSignatureTypeScriptSpecific(<CallSignatureSyntax>element);
|
||||
case SyntaxKind.MethodSignature:
|
||||
return isMethodSignatureTypeScriptSpecific(<MethodSignatureSyntax>element);
|
||||
case SyntaxKind.Block:
|
||||
return isBlockTypeScriptSpecific(<BlockSyntax>element);
|
||||
case SyntaxKind.IfStatement:
|
||||
return isIfStatementTypeScriptSpecific(<IfStatementSyntax>element);
|
||||
case SyntaxKind.VariableStatement:
|
||||
return isVariableStatementTypeScriptSpecific(<VariableStatementSyntax>element);
|
||||
case SyntaxKind.ExpressionStatement:
|
||||
return isExpressionStatementTypeScriptSpecific(<ExpressionStatementSyntax>element);
|
||||
case SyntaxKind.ReturnStatement:
|
||||
return isReturnStatementTypeScriptSpecific(<ReturnStatementSyntax>element);
|
||||
case SyntaxKind.SwitchStatement:
|
||||
return isSwitchStatementTypeScriptSpecific(<SwitchStatementSyntax>element);
|
||||
case SyntaxKind.ForStatement:
|
||||
return isForStatementTypeScriptSpecific(<ForStatementSyntax>element);
|
||||
case SyntaxKind.ForInStatement:
|
||||
return isForInStatementTypeScriptSpecific(<ForInStatementSyntax>element);
|
||||
case SyntaxKind.ThrowStatement:
|
||||
return isThrowStatementTypeScriptSpecific(<ThrowStatementSyntax>element);
|
||||
case SyntaxKind.WhileStatement:
|
||||
return isWhileStatementTypeScriptSpecific(<WhileStatementSyntax>element);
|
||||
case SyntaxKind.TryStatement:
|
||||
return isTryStatementTypeScriptSpecific(<TryStatementSyntax>element);
|
||||
case SyntaxKind.LabeledStatement:
|
||||
return isLabeledStatementTypeScriptSpecific(<LabeledStatementSyntax>element);
|
||||
case SyntaxKind.DoStatement:
|
||||
return isDoStatementTypeScriptSpecific(<DoStatementSyntax>element);
|
||||
case SyntaxKind.WithStatement:
|
||||
return isWithStatementTypeScriptSpecific(<WithStatementSyntax>element);
|
||||
case SyntaxKind.PreIncrementExpression: case SyntaxKind.PreDecrementExpression: case SyntaxKind.PlusExpression: case SyntaxKind.NegateExpression: case SyntaxKind.BitwiseNotExpression: case SyntaxKind.LogicalNotExpression:
|
||||
return isPrefixUnaryExpressionTypeScriptSpecific(<PrefixUnaryExpressionSyntax>element);
|
||||
case SyntaxKind.DeleteExpression:
|
||||
return isDeleteExpressionTypeScriptSpecific(<DeleteExpressionSyntax>element);
|
||||
case SyntaxKind.TypeOfExpression:
|
||||
return isTypeOfExpressionTypeScriptSpecific(<TypeOfExpressionSyntax>element);
|
||||
case SyntaxKind.VoidExpression:
|
||||
return isVoidExpressionTypeScriptSpecific(<VoidExpressionSyntax>element);
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
return isConditionalExpressionTypeScriptSpecific(<ConditionalExpressionSyntax>element);
|
||||
case SyntaxKind.MultiplyExpression: case SyntaxKind.DivideExpression: case SyntaxKind.ModuloExpression: case SyntaxKind.AddExpression: case SyntaxKind.SubtractExpression: case SyntaxKind.LeftShiftExpression: case SyntaxKind.SignedRightShiftExpression: case SyntaxKind.UnsignedRightShiftExpression: case SyntaxKind.LessThanExpression: case SyntaxKind.GreaterThanExpression: case SyntaxKind.LessThanOrEqualExpression: case SyntaxKind.GreaterThanOrEqualExpression: case SyntaxKind.InstanceOfExpression: case SyntaxKind.InExpression: case SyntaxKind.EqualsWithTypeConversionExpression: case SyntaxKind.NotEqualsWithTypeConversionExpression: case SyntaxKind.EqualsExpression: case SyntaxKind.NotEqualsExpression: case SyntaxKind.BitwiseAndExpression: case SyntaxKind.BitwiseExclusiveOrExpression: case SyntaxKind.BitwiseOrExpression: case SyntaxKind.LogicalAndExpression: case SyntaxKind.LogicalOrExpression: case SyntaxKind.OrAssignmentExpression: case SyntaxKind.AndAssignmentExpression: case SyntaxKind.ExclusiveOrAssignmentExpression: case SyntaxKind.LeftShiftAssignmentExpression: case SyntaxKind.SignedRightShiftAssignmentExpression: case SyntaxKind.UnsignedRightShiftAssignmentExpression: case SyntaxKind.AddAssignmentExpression: case SyntaxKind.SubtractAssignmentExpression: case SyntaxKind.MultiplyAssignmentExpression: case SyntaxKind.DivideAssignmentExpression: case SyntaxKind.ModuloAssignmentExpression: case SyntaxKind.AssignmentExpression: case SyntaxKind.CommaExpression:
|
||||
return isBinaryExpressionTypeScriptSpecific(<BinaryExpressionSyntax>element);
|
||||
case SyntaxKind.PostIncrementExpression: case SyntaxKind.PostDecrementExpression:
|
||||
return isPostfixUnaryExpressionTypeScriptSpecific(<PostfixUnaryExpressionSyntax>element);
|
||||
case SyntaxKind.MemberAccessExpression:
|
||||
return isMemberAccessExpressionTypeScriptSpecific(<MemberAccessExpressionSyntax>element);
|
||||
case SyntaxKind.InvocationExpression:
|
||||
return isInvocationExpressionTypeScriptSpecific(<InvocationExpressionSyntax>element);
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
return isArrayLiteralExpressionTypeScriptSpecific(<ArrayLiteralExpressionSyntax>element);
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
return isObjectLiteralExpressionTypeScriptSpecific(<ObjectLiteralExpressionSyntax>element);
|
||||
case SyntaxKind.ObjectCreationExpression:
|
||||
return isObjectCreationExpressionTypeScriptSpecific(<ObjectCreationExpressionSyntax>element);
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
return isParenthesizedExpressionTypeScriptSpecific(<ParenthesizedExpressionSyntax>element);
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
return isElementAccessExpressionTypeScriptSpecific(<ElementAccessExpressionSyntax>element);
|
||||
case SyntaxKind.FunctionExpression:
|
||||
return isFunctionExpressionTypeScriptSpecific(<FunctionExpressionSyntax>element);
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return isVariableDeclarationTypeScriptSpecific(<VariableDeclarationSyntax>element);
|
||||
case SyntaxKind.VariableDeclarator:
|
||||
return isVariableDeclaratorTypeScriptSpecific(<VariableDeclaratorSyntax>element);
|
||||
case SyntaxKind.ArgumentList:
|
||||
return isArgumentListTypeScriptSpecific(<ArgumentListSyntax>element);
|
||||
case SyntaxKind.ParameterList:
|
||||
return isParameterListTypeScriptSpecific(<ParameterListSyntax>element);
|
||||
case SyntaxKind.EqualsValueClause:
|
||||
return isEqualsValueClauseTypeScriptSpecific(<EqualsValueClauseSyntax>element);
|
||||
case SyntaxKind.CaseSwitchClause:
|
||||
return isCaseSwitchClauseTypeScriptSpecific(<CaseSwitchClauseSyntax>element);
|
||||
case SyntaxKind.DefaultSwitchClause:
|
||||
return isDefaultSwitchClauseTypeScriptSpecific(<DefaultSwitchClauseSyntax>element);
|
||||
case SyntaxKind.ElseClause:
|
||||
return isElseClauseTypeScriptSpecific(<ElseClauseSyntax>element);
|
||||
case SyntaxKind.CatchClause:
|
||||
return isCatchClauseTypeScriptSpecific(<CatchClauseSyntax>element);
|
||||
case SyntaxKind.FinallyClause:
|
||||
return isFinallyClauseTypeScriptSpecific(<FinallyClauseSyntax>element);
|
||||
case SyntaxKind.SimplePropertyAssignment:
|
||||
return isSimplePropertyAssignmentTypeScriptSpecific(<SimplePropertyAssignmentSyntax>element);
|
||||
case SyntaxKind.FunctionPropertyAssignment:
|
||||
return isFunctionPropertyAssignmentTypeScriptSpecific(<FunctionPropertyAssignmentSyntax>element);
|
||||
case SyntaxKind.Parameter:
|
||||
return isParameterTypeScriptSpecific(<ParameterSyntax>element);
|
||||
case SyntaxKind.EnumElement:
|
||||
return isEnumElementTypeScriptSpecific(<EnumElementSyntax>element);
|
||||
}
|
||||
}
|
||||
|
||||
function isSourceUnitTypeScriptSpecific(node: SourceUnitSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.moduleElements);
|
||||
}
|
||||
|
||||
function isFunctionDeclarationTypeScriptSpecific(node: FunctionDeclarationSyntax): boolean {
|
||||
return node.modifiers.length > 0 ||
|
||||
isTypeScriptSpecific(node.callSignature) ||
|
||||
isTypeScriptSpecific(node.block);
|
||||
}
|
||||
|
||||
function isGetAccessorTypeScriptSpecific(node: GetAccessorSyntax): boolean {
|
||||
return node.modifiers.length > 0 ||
|
||||
isTypeScriptSpecific(node.callSignature) ||
|
||||
isTypeScriptSpecific(node.block);
|
||||
}
|
||||
|
||||
function isCallSignatureTypeScriptSpecific(node: CallSignatureSyntax): boolean {
|
||||
return node.typeParameterList !== null ||
|
||||
isTypeScriptSpecific(node.parameterList) ||
|
||||
node.typeAnnotation !== null;
|
||||
}
|
||||
|
||||
function isMethodSignatureTypeScriptSpecific(node: MethodSignatureSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.callSignature);
|
||||
}
|
||||
|
||||
function isBlockTypeScriptSpecific(node: BlockSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.statements);
|
||||
}
|
||||
|
||||
function isIfStatementTypeScriptSpecific(node: IfStatementSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.condition) ||
|
||||
isTypeScriptSpecific(node.statement) ||
|
||||
isTypeScriptSpecific(node.elseClause);
|
||||
}
|
||||
|
||||
function isVariableStatementTypeScriptSpecific(node: VariableStatementSyntax): boolean {
|
||||
return node.modifiers.length > 0 ||
|
||||
isTypeScriptSpecific(node.variableDeclaration);
|
||||
}
|
||||
|
||||
function isExpressionStatementTypeScriptSpecific(node: ExpressionStatementSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.expression);
|
||||
}
|
||||
|
||||
function isReturnStatementTypeScriptSpecific(node: ReturnStatementSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.expression);
|
||||
}
|
||||
|
||||
function isSwitchStatementTypeScriptSpecific(node: SwitchStatementSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.expression) ||
|
||||
isTypeScriptSpecific(node.switchClauses);
|
||||
}
|
||||
|
||||
function isForStatementTypeScriptSpecific(node: ForStatementSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.variableDeclaration) ||
|
||||
isTypeScriptSpecific(node.initializer) ||
|
||||
isTypeScriptSpecific(node.condition) ||
|
||||
isTypeScriptSpecific(node.incrementor) ||
|
||||
isTypeScriptSpecific(node.statement);
|
||||
}
|
||||
|
||||
function isForInStatementTypeScriptSpecific(node: ForInStatementSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.variableDeclaration) ||
|
||||
isTypeScriptSpecific(node.left) ||
|
||||
isTypeScriptSpecific(node.expression) ||
|
||||
isTypeScriptSpecific(node.statement);
|
||||
}
|
||||
|
||||
function isThrowStatementTypeScriptSpecific(node: ThrowStatementSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.expression);
|
||||
}
|
||||
|
||||
function isWhileStatementTypeScriptSpecific(node: WhileStatementSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.condition) ||
|
||||
isTypeScriptSpecific(node.statement);
|
||||
}
|
||||
|
||||
function isTryStatementTypeScriptSpecific(node: TryStatementSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.block) ||
|
||||
isTypeScriptSpecific(node.catchClause) ||
|
||||
isTypeScriptSpecific(node.finallyClause);
|
||||
}
|
||||
|
||||
function isLabeledStatementTypeScriptSpecific(node: LabeledStatementSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.statement);
|
||||
}
|
||||
|
||||
function isDoStatementTypeScriptSpecific(node: DoStatementSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.statement) ||
|
||||
isTypeScriptSpecific(node.condition);
|
||||
}
|
||||
|
||||
function isWithStatementTypeScriptSpecific(node: WithStatementSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.condition) ||
|
||||
isTypeScriptSpecific(node.statement);
|
||||
}
|
||||
|
||||
function isPrefixUnaryExpressionTypeScriptSpecific(node: PrefixUnaryExpressionSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.operand);
|
||||
}
|
||||
|
||||
function isDeleteExpressionTypeScriptSpecific(node: DeleteExpressionSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.expression);
|
||||
}
|
||||
|
||||
function isTypeOfExpressionTypeScriptSpecific(node: TypeOfExpressionSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.expression);
|
||||
}
|
||||
|
||||
function isVoidExpressionTypeScriptSpecific(node: VoidExpressionSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.expression);
|
||||
}
|
||||
|
||||
function isConditionalExpressionTypeScriptSpecific(node: ConditionalExpressionSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.condition) ||
|
||||
isTypeScriptSpecific(node.whenTrue) ||
|
||||
isTypeScriptSpecific(node.whenFalse);
|
||||
}
|
||||
|
||||
function isBinaryExpressionTypeScriptSpecific(node: BinaryExpressionSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.left) ||
|
||||
isTypeScriptSpecific(node.right);
|
||||
}
|
||||
|
||||
function isPostfixUnaryExpressionTypeScriptSpecific(node: PostfixUnaryExpressionSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.operand);
|
||||
}
|
||||
|
||||
function isMemberAccessExpressionTypeScriptSpecific(node: MemberAccessExpressionSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.expression);
|
||||
}
|
||||
|
||||
function isInvocationExpressionTypeScriptSpecific(node: InvocationExpressionSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.expression) ||
|
||||
isTypeScriptSpecific(node.argumentList);
|
||||
}
|
||||
|
||||
function isArrayLiteralExpressionTypeScriptSpecific(node: ArrayLiteralExpressionSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.expressions);
|
||||
}
|
||||
|
||||
function isObjectLiteralExpressionTypeScriptSpecific(node: ObjectLiteralExpressionSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.propertyAssignments);
|
||||
}
|
||||
|
||||
function isObjectCreationExpressionTypeScriptSpecific(node: ObjectCreationExpressionSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.expression) ||
|
||||
isTypeScriptSpecific(node.argumentList);
|
||||
}
|
||||
|
||||
function isParenthesizedExpressionTypeScriptSpecific(node: ParenthesizedExpressionSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.expression);
|
||||
}
|
||||
|
||||
function isElementAccessExpressionTypeScriptSpecific(node: ElementAccessExpressionSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.expression) ||
|
||||
isTypeScriptSpecific(node.argumentExpression);
|
||||
}
|
||||
|
||||
function isFunctionExpressionTypeScriptSpecific(node: FunctionExpressionSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.callSignature) ||
|
||||
isTypeScriptSpecific(node.block);
|
||||
}
|
||||
|
||||
function isVariableDeclarationTypeScriptSpecific(node: VariableDeclarationSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.variableDeclarators);
|
||||
}
|
||||
|
||||
function isVariableDeclaratorTypeScriptSpecific(node: VariableDeclaratorSyntax): boolean {
|
||||
return node.typeAnnotation !== null ||
|
||||
isTypeScriptSpecific(node.equalsValueClause);
|
||||
}
|
||||
|
||||
function isArgumentListTypeScriptSpecific(node: ArgumentListSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.typeArgumentList) ||
|
||||
isTypeScriptSpecific(node.arguments);
|
||||
}
|
||||
|
||||
function isParameterListTypeScriptSpecific(node: ParameterListSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.parameters);
|
||||
}
|
||||
|
||||
function isEqualsValueClauseTypeScriptSpecific(node: EqualsValueClauseSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.value);
|
||||
}
|
||||
|
||||
function isCaseSwitchClauseTypeScriptSpecific(node: CaseSwitchClauseSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.expression) ||
|
||||
isTypeScriptSpecific(node.statements);
|
||||
}
|
||||
|
||||
function isDefaultSwitchClauseTypeScriptSpecific(node: DefaultSwitchClauseSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.statements);
|
||||
}
|
||||
|
||||
function isElseClauseTypeScriptSpecific(node: ElseClauseSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.statement);
|
||||
}
|
||||
|
||||
function isCatchClauseTypeScriptSpecific(node: CatchClauseSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.typeAnnotation) ||
|
||||
isTypeScriptSpecific(node.block);
|
||||
}
|
||||
|
||||
function isFinallyClauseTypeScriptSpecific(node: FinallyClauseSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.block);
|
||||
}
|
||||
|
||||
function isSimplePropertyAssignmentTypeScriptSpecific(node: SimplePropertyAssignmentSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.expression);
|
||||
}
|
||||
|
||||
function isFunctionPropertyAssignmentTypeScriptSpecific(node: FunctionPropertyAssignmentSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.callSignature) ||
|
||||
isTypeScriptSpecific(node.block);
|
||||
}
|
||||
|
||||
function isParameterTypeScriptSpecific(node: ParameterSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.modifiers) ||
|
||||
node.typeAnnotation !== null ||
|
||||
node.equalsValueClause !== null;
|
||||
}
|
||||
|
||||
function isEnumElementTypeScriptSpecific(node: EnumElementSyntax): boolean {
|
||||
return isTypeScriptSpecific(node.equalsValueClause);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user