mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into getRenameInfo
Conflicts: src/services/services.ts
This commit is contained in:
+12
-14
@@ -2968,10 +2968,12 @@ module ts {
|
||||
}
|
||||
|
||||
if (getDeclarationFlagsFromSymbol(sourceProp) & NodeFlags.Private || getDeclarationFlagsFromSymbol(targetProp) & NodeFlags.Private) {
|
||||
if (reportErrors) {
|
||||
reportError(Diagnostics.Private_property_0_cannot_be_reimplemented, symbolToString(targetProp));
|
||||
if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) {
|
||||
if (reportErrors) {
|
||||
reportError(Diagnostics.Private_property_0_cannot_be_reimplemented, symbolToString(targetProp));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors)) {
|
||||
if (reportErrors) {
|
||||
@@ -5212,8 +5214,7 @@ module ts {
|
||||
var otherKind = node.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor;
|
||||
var otherAccessor = <AccessorDeclaration>getDeclarationOfKind(node.symbol, otherKind);
|
||||
if (otherAccessor) {
|
||||
var visibilityFlags = NodeFlags.Private | NodeFlags.Public;
|
||||
if (((node.flags & visibilityFlags) !== (otherAccessor.flags & visibilityFlags))) {
|
||||
if (((node.flags & NodeFlags.AccessibilityModifier) !== (otherAccessor.flags & NodeFlags.AccessibilityModifier))) {
|
||||
error(node.name, Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility);
|
||||
}
|
||||
|
||||
@@ -7240,12 +7241,9 @@ module ts {
|
||||
return target !== unknownSymbol && ((target.flags & SymbolFlags.Value) !== 0);
|
||||
}
|
||||
|
||||
function shouldEmitDeclarations() {
|
||||
// If the declaration emit and there are no errors being reported in program or by checker
|
||||
// declarations can be emitted
|
||||
return compilerOptions.declaration &&
|
||||
!program.getDiagnostics().length &&
|
||||
!getDiagnostics().length;
|
||||
function hasSemanticErrors() {
|
||||
// Return true if there is any semantic error in a file or globally
|
||||
return getDiagnostics().length > 0 || getGlobalDiagnostics().length > 0;
|
||||
}
|
||||
|
||||
function isReferencedImportDeclaration(node: ImportDeclaration): boolean {
|
||||
@@ -7306,7 +7304,7 @@ module ts {
|
||||
writeTypeToTextWriter(getReturnTypeOfSignature(signature), enclosingDeclaration, flags , writer);
|
||||
}
|
||||
|
||||
function invokeEmitter() {
|
||||
function invokeEmitter(targetSourceFile?: SourceFile) {
|
||||
var resolver: EmitResolver = {
|
||||
getProgram: () => program,
|
||||
getLocalNameOfContainer: getLocalNameOfContainer,
|
||||
@@ -7317,7 +7315,7 @@ module ts {
|
||||
getNodeCheckFlags: getNodeCheckFlags,
|
||||
getEnumMemberValue: getEnumMemberValue,
|
||||
isTopLevelValueImportedViaEntityName: isTopLevelValueImportedViaEntityName,
|
||||
shouldEmitDeclarations: shouldEmitDeclarations,
|
||||
hasSemanticErrors: hasSemanticErrors,
|
||||
isDeclarationVisible: isDeclarationVisible,
|
||||
isImplementationOfOverload: isImplementationOfOverload,
|
||||
writeTypeAtLocation: writeTypeAtLocation,
|
||||
@@ -7327,7 +7325,7 @@ module ts {
|
||||
isImportDeclarationEntityNameReferenceDeclarationVisibile: isImportDeclarationEntityNameReferenceDeclarationVisibile
|
||||
};
|
||||
checkProgram();
|
||||
return emitFiles(resolver);
|
||||
return emitFiles(resolver, targetSourceFile);
|
||||
}
|
||||
|
||||
function initializeTypeChecker() {
|
||||
|
||||
@@ -407,7 +407,7 @@ module ts {
|
||||
return normalizedPathComponents(path, rootLength);
|
||||
}
|
||||
|
||||
export function getNormalizedPathFromPathCompoments(pathComponents: string[]) {
|
||||
export function getNormalizedPathFromPathComponents(pathComponents: string[]) {
|
||||
if (pathComponents && pathComponents.length) {
|
||||
return pathComponents[0] + pathComponents.slice(1).join(directorySeparator);
|
||||
}
|
||||
@@ -468,7 +468,7 @@ module ts {
|
||||
var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory);
|
||||
var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory);
|
||||
if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") {
|
||||
// If the directory path given was of type test/cases/ then we really need components of directry to be only till its name
|
||||
// If the directory path given was of type test/cases/ then we really need components of directory to be only till its name
|
||||
// that is ["test", "cases", ""] needs to be actually ["test", "cases"]
|
||||
directoryComponents.length--;
|
||||
}
|
||||
@@ -494,7 +494,7 @@ module ts {
|
||||
}
|
||||
|
||||
// Cant find the relative path, get the absolute path
|
||||
var absolutePath = getNormalizedPathFromPathCompoments(pathComponents);
|
||||
var absolutePath = getNormalizedPathFromPathComponents(pathComponents);
|
||||
if (isAbsolutePathAnUrl && isRootedDiskPath(absolutePath)) {
|
||||
absolutePath = "file:///" + absolutePath;
|
||||
}
|
||||
|
||||
+57
-29
@@ -25,7 +25,22 @@ module ts {
|
||||
return indentStrings[1].length;
|
||||
}
|
||||
|
||||
export function emitFiles(resolver: EmitResolver): EmitResult {
|
||||
export function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean {
|
||||
if (!(sourceFile.flags & NodeFlags.DeclarationFile)) {
|
||||
if ((isExternalModule(sourceFile) || !compilerOptions.out) && !fileExtensionIs(sourceFile.filename, ".js")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isExternalModuleOrDeclarationFile(sourceFile: SourceFile) {
|
||||
return isExternalModule(sourceFile) || (sourceFile.flags & NodeFlags.DeclarationFile) !== 0;
|
||||
}
|
||||
|
||||
// targetSourceFile is when users only want one file in entire project to be emitted. This is used in compilerOnSave feature
|
||||
export function emitFiles(resolver: EmitResolver, targetSourceFile?: SourceFile): EmitResult {
|
||||
var program = resolver.getProgram();
|
||||
var compilerHost = program.getCompilerHost();
|
||||
var compilerOptions = program.getCompilerOptions();
|
||||
@@ -34,22 +49,14 @@ module ts {
|
||||
var newLine = program.getCompilerHost().getNewLine();
|
||||
|
||||
function getSourceFilePathInNewDir(newDirPath: string, sourceFile: SourceFile) {
|
||||
var sourceFilePath = getNormalizedPathFromPathCompoments(getNormalizedPathComponents(sourceFile.filename, compilerHost.getCurrentDirectory()));
|
||||
var sourceFilePath = getNormalizedPathFromPathComponents(getNormalizedPathComponents(sourceFile.filename, compilerHost.getCurrentDirectory()));
|
||||
sourceFilePath = sourceFilePath.replace(program.getCommonSourceDirectory(), "");
|
||||
return combinePaths(newDirPath, sourceFilePath);
|
||||
}
|
||||
|
||||
function shouldEmitToOwnFile(sourceFile: SourceFile) {
|
||||
if (!(sourceFile.flags & NodeFlags.DeclarationFile)) {
|
||||
if ((isExternalModule(sourceFile) || !compilerOptions.out) && !fileExtensionIs(sourceFile.filename, ".js")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getOwnEmitOutputFilePath(sourceFile: SourceFile, extension: string) {
|
||||
if (program.getCompilerOptions().outDir) {
|
||||
var emitOutputFilePathWithoutExtension = getModuleNameFromFilename(getSourceFilePathInNewDir(program.getCompilerOptions().outDir, sourceFile));
|
||||
if (compilerOptions.outDir) {
|
||||
var emitOutputFilePathWithoutExtension = getModuleNameFromFilename(getSourceFilePathInNewDir(compilerOptions.outDir, sourceFile));
|
||||
}
|
||||
else {
|
||||
var emitOutputFilePathWithoutExtension = getModuleNameFromFilename(sourceFile.filename);
|
||||
@@ -58,10 +65,6 @@ module ts {
|
||||
return emitOutputFilePathWithoutExtension + extension;
|
||||
}
|
||||
|
||||
function isExternalModuleOrDeclarationFile(sourceFile: SourceFile) {
|
||||
return isExternalModule(sourceFile) || (sourceFile.flags & NodeFlags.DeclarationFile) !== 0;
|
||||
}
|
||||
|
||||
function getFirstConstructorWithBody(node: ClassDeclaration): ConstructorDeclaration {
|
||||
return forEach(node.members, member => {
|
||||
if (member.kind === SyntaxKind.Constructor && (<ConstructorDeclaration>member).body) {
|
||||
@@ -1431,7 +1434,7 @@ module ts {
|
||||
|
||||
function emitParameterPropertyAssignments(node: ConstructorDeclaration) {
|
||||
forEach(node.parameters, param => {
|
||||
if (param.flags & (NodeFlags.Public | NodeFlags.Private)) {
|
||||
if (param.flags & NodeFlags.AccessibilityModifier) {
|
||||
writeLine();
|
||||
emitStart(param);
|
||||
emitStart(param.name);
|
||||
@@ -2630,7 +2633,7 @@ module ts {
|
||||
function emitParameterProperties(constructorDeclaration: ConstructorDeclaration) {
|
||||
if (constructorDeclaration) {
|
||||
forEach(constructorDeclaration.parameters, param => {
|
||||
if (param.flags & (NodeFlags.Public | NodeFlags.Private)) {
|
||||
if (param.flags & NodeFlags.AccessibilityModifier) {
|
||||
emitPropertyDeclaration(param);
|
||||
}
|
||||
});
|
||||
@@ -3082,7 +3085,7 @@ module ts {
|
||||
function writeReferencePath(referencedFile: SourceFile) {
|
||||
var declFileName = referencedFile.flags & NodeFlags.DeclarationFile
|
||||
? referencedFile.filename // Declaration file, use declaration file name
|
||||
: shouldEmitToOwnFile(referencedFile)
|
||||
: shouldEmitToOwnFile(referencedFile, compilerOptions)
|
||||
? getOwnEmitOutputFilePath(referencedFile, ".d.ts") // Own output file so get the .d.ts file
|
||||
: getModuleNameFromFilename(compilerOptions.out) + ".d.ts";// Global out file
|
||||
|
||||
@@ -3104,7 +3107,7 @@ module ts {
|
||||
|
||||
// All the references that are not going to be part of same file
|
||||
if ((referencedFile.flags & NodeFlags.DeclarationFile) || // This is a declare file reference
|
||||
shouldEmitToOwnFile(referencedFile) || // This is referenced file is emitting its own js file
|
||||
shouldEmitToOwnFile(referencedFile, compilerOptions) || // This is referenced file is emitting its own js file
|
||||
!addedGlobalFileReference) { // Or the global out file corresponding to this reference was not added
|
||||
|
||||
writeReferencePath(referencedFile);
|
||||
@@ -3161,29 +3164,54 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
var shouldEmitDeclarations = resolver.shouldEmitDeclarations();
|
||||
var hasSemanticErrors = resolver.hasSemanticErrors();
|
||||
|
||||
function emitFile(jsFilePath: string, sourceFile?: SourceFile) {
|
||||
emitJavaScript(jsFilePath, sourceFile);
|
||||
if (shouldEmitDeclarations) {
|
||||
if (!hasSemanticErrors && compilerOptions.declaration) {
|
||||
emitDeclarations(jsFilePath, sourceFile);
|
||||
}
|
||||
}
|
||||
|
||||
forEach(program.getSourceFiles(), sourceFile => {
|
||||
if (shouldEmitToOwnFile(sourceFile)) {
|
||||
var jsFilePath = getOwnEmitOutputFilePath(sourceFile, ".js");
|
||||
emitFile(jsFilePath, sourceFile);
|
||||
}
|
||||
});
|
||||
if (targetSourceFile === undefined) {
|
||||
forEach(program.getSourceFiles(), sourceFile => {
|
||||
if (shouldEmitToOwnFile(sourceFile, compilerOptions)) {
|
||||
var jsFilePath = getOwnEmitOutputFilePath(sourceFile, ".js");
|
||||
emitFile(jsFilePath, sourceFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
// Emit only one file specified in targetFilename. This is mainly used in compilerOnSave feature
|
||||
var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, ".js");
|
||||
emitFile(jsFilePath, targetSourceFile);
|
||||
}
|
||||
|
||||
if (compilerOptions.out) {
|
||||
emitFile(compilerOptions.out);
|
||||
}
|
||||
|
||||
|
||||
// Sort and make the unique list of diagnostics
|
||||
diagnostics.sort(compareDiagnostics);
|
||||
diagnostics = deduplicateSortedDiagnostics(diagnostics);
|
||||
|
||||
// Update returnCode if there is any EmitterError
|
||||
var hasEmitterError = forEach(diagnostics, diagnostic => diagnostic.category === DiagnosticCategory.Error);
|
||||
|
||||
// Check and update returnCode for syntactic and semantic
|
||||
var returnCode: EmitReturnStatus;
|
||||
if (hasEmitterError) {
|
||||
returnCode = EmitReturnStatus.EmitErrorsEncountered;
|
||||
} else if (hasSemanticErrors && compilerOptions.declaration) {
|
||||
returnCode = EmitReturnStatus.DeclarationGenerationSkipped;
|
||||
} else if (hasSemanticErrors && !compilerOptions.declaration) {
|
||||
returnCode = EmitReturnStatus.JSGeneratedWithSemanticErrors;
|
||||
} else {
|
||||
returnCode = EmitReturnStatus.Succeeded;
|
||||
}
|
||||
|
||||
return {
|
||||
emitResultStatus: returnCode,
|
||||
errors: diagnostics,
|
||||
sourceMaps: sourceMapDataList
|
||||
};
|
||||
|
||||
+48
-26
@@ -1400,14 +1400,25 @@ module ts {
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseSignature(kind: SyntaxKind, returnToken: SyntaxKind): ParsedSignature {
|
||||
function parseSignature(kind: SyntaxKind, returnToken: SyntaxKind, returnTokenRequired: boolean): ParsedSignature {
|
||||
if (kind === SyntaxKind.ConstructSignature) {
|
||||
parseExpected(SyntaxKind.NewKeyword);
|
||||
}
|
||||
var typeParameters = parseTypeParameters();
|
||||
var parameters = parseParameterList(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken);
|
||||
checkParameterList(parameters);
|
||||
var type = parseOptional(returnToken) ? parseType() : undefined;
|
||||
|
||||
var type: TypeNode;
|
||||
|
||||
if (returnTokenRequired) {
|
||||
parseExpected(returnToken);
|
||||
type = parseType();
|
||||
}
|
||||
else if (parseOptional(returnToken))
|
||||
{
|
||||
type = parseType();
|
||||
}
|
||||
|
||||
return {
|
||||
typeParameters: typeParameters,
|
||||
parameters: parameters,
|
||||
@@ -1471,7 +1482,7 @@ module ts {
|
||||
|
||||
function parseSignatureMember(kind: SyntaxKind, returnToken: SyntaxKind): SignatureDeclaration {
|
||||
var node = <SignatureDeclaration>createNode(kind);
|
||||
var sig = parseSignature(kind, returnToken);
|
||||
var sig = parseSignature(kind, returnToken, /* returnTokenRequired */ false);
|
||||
node.typeParameters = sig.typeParameters;
|
||||
node.parameters = sig.parameters;
|
||||
node.type = sig.type;
|
||||
@@ -1544,7 +1555,7 @@ module ts {
|
||||
}
|
||||
if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) {
|
||||
node.kind = SyntaxKind.Method;
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||
(<MethodDeclaration>node).typeParameters = sig.typeParameters;
|
||||
(<MethodDeclaration>node).parameters = sig.parameters;
|
||||
(<MethodDeclaration>node).type = sig.type;
|
||||
@@ -1616,7 +1627,7 @@ module ts {
|
||||
function parseFunctionType(signatureKind: SyntaxKind): TypeLiteralNode {
|
||||
var node = <TypeLiteralNode>createNode(SyntaxKind.TypeLiteral);
|
||||
var member = <SignatureDeclaration>createNode(signatureKind);
|
||||
var sig = parseSignature(signatureKind, SyntaxKind.EqualsGreaterThanToken);
|
||||
var sig = parseSignature(signatureKind, SyntaxKind.EqualsGreaterThanToken, /* returnTokenRequired */ true);
|
||||
member.typeParameters = sig.typeParameters;
|
||||
member.parameters = sig.parameters;
|
||||
member.type = sig.type;
|
||||
@@ -1875,7 +1886,7 @@ module ts {
|
||||
var pos = getNodePos();
|
||||
|
||||
if (triState === Tristate.True) {
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||
|
||||
// If we have an arrow, then try to parse the body.
|
||||
// Even if not, try to parse if we have an opening brace, just in case we're in an error state.
|
||||
@@ -1978,7 +1989,7 @@ module ts {
|
||||
|
||||
function tryParseSignatureIfArrowOrBraceFollows(): ParsedSignature {
|
||||
return tryParse(() => {
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||
|
||||
// Parsing a signature isn't enough.
|
||||
// Parenthesized arrow signatures often look like other valid expressions.
|
||||
@@ -2320,7 +2331,7 @@ module ts {
|
||||
var node = <PropertyDeclaration>createNode(SyntaxKind.PropertyAssignment);
|
||||
node.name = parsePropertyName();
|
||||
if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) {
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||
var body = parseBody(/* ignoreMissingOpenBrace */ false);
|
||||
// do not propagate property name as name for function expression
|
||||
// for scenarios like
|
||||
@@ -2420,7 +2431,7 @@ module ts {
|
||||
var pos = getNodePos();
|
||||
parseExpected(SyntaxKind.FunctionKeyword);
|
||||
var name = isIdentifier() ? parseIdentifier() : undefined;
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||
var body = parseBody(/* ignoreMissingOpenBrace */ false);
|
||||
if (name && isInStrictMode && isEvalOrArgumentsIdentifier(name)) {
|
||||
// It is a SyntaxError to use within strict mode code the identifiers eval or arguments as the
|
||||
@@ -3035,7 +3046,7 @@ module ts {
|
||||
if (flags) node.flags = flags;
|
||||
parseExpected(SyntaxKind.FunctionKeyword);
|
||||
node.name = parseIdentifier();
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||
node.typeParameters = sig.typeParameters;
|
||||
node.parameters = sig.parameters;
|
||||
node.type = sig.type;
|
||||
@@ -3052,7 +3063,7 @@ module ts {
|
||||
var node = <ConstructorDeclaration>createNode(SyntaxKind.Constructor, pos);
|
||||
node.flags = flags;
|
||||
parseExpected(SyntaxKind.ConstructorKeyword);
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||
node.typeParameters = sig.typeParameters;
|
||||
node.parameters = sig.parameters;
|
||||
node.type = sig.type;
|
||||
@@ -3079,7 +3090,7 @@ module ts {
|
||||
var method = <MethodDeclaration>createNode(SyntaxKind.Method, pos);
|
||||
method.flags = flags;
|
||||
method.name = name;
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||
method.typeParameters = sig.typeParameters;
|
||||
method.parameters = sig.parameters;
|
||||
method.type = sig.type;
|
||||
@@ -3152,7 +3163,7 @@ module ts {
|
||||
var node = <MethodDeclaration>createNode(kind, pos);
|
||||
node.flags = flags;
|
||||
node.name = parsePropertyName();
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||
node.typeParameters = sig.typeParameters;
|
||||
node.parameters = sig.parameters;
|
||||
node.type = sig.type;
|
||||
@@ -3239,7 +3250,7 @@ module ts {
|
||||
|
||||
switch (modifierToken) {
|
||||
case SyntaxKind.PublicKeyword:
|
||||
if (flags & NodeFlags.Private || flags & NodeFlags.Public) {
|
||||
if (flags & NodeFlags.AccessibilityModifier) {
|
||||
grammarErrorAtPos(modifierStart, modifierLength, Diagnostics.Accessibility_modifier_already_seen);
|
||||
}
|
||||
else if (flags & NodeFlags.Static) {
|
||||
@@ -3252,7 +3263,7 @@ module ts {
|
||||
break;
|
||||
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
if (flags & NodeFlags.Private || flags & NodeFlags.Public) {
|
||||
if (flags & NodeFlags.AccessibilityModifier) {
|
||||
grammarErrorAtPos(modifierStart, modifierLength, Diagnostics.Accessibility_modifier_already_seen);
|
||||
}
|
||||
else if (flags & NodeFlags.Static) {
|
||||
@@ -3822,17 +3833,28 @@ module ts {
|
||||
var start = refPos;
|
||||
var length = refEnd - refPos;
|
||||
}
|
||||
var diagnostic: DiagnosticMessage;
|
||||
if (hasExtension(filename)) {
|
||||
if (!fileExtensionIs(filename, ".ts")) {
|
||||
errors.push(createFileDiagnostic(refFile, start, length, Diagnostics.File_0_must_have_extension_ts_or_d_ts, filename));
|
||||
diagnostic = Diagnostics.File_0_must_have_extension_ts_or_d_ts;
|
||||
}
|
||||
else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) {
|
||||
errors.push(createFileDiagnostic(refFile, start, length, Diagnostics.File_0_not_found, filename));
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!(findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) || findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd))) {
|
||||
errors.push(createFileDiagnostic(refFile, start, length, Diagnostics.File_0_not_found, filename + ".ts"));
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
filename += ".ts";
|
||||
}
|
||||
}
|
||||
|
||||
if (diagnostic) {
|
||||
if (refFile) {
|
||||
errors.push(createFileDiagnostic(refFile, start, length, diagnostic, filename));
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(diagnostic, filename));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3965,11 +3987,11 @@ module ts {
|
||||
// Each file contributes into common source file path
|
||||
if (!(sourceFile.flags & NodeFlags.DeclarationFile)
|
||||
&& !fileExtensionIs(sourceFile.filename, ".js")) {
|
||||
var sourcePathCompoments = getNormalizedPathComponents(sourceFile.filename, host.getCurrentDirectory());
|
||||
sourcePathCompoments.pop(); // FileName is not part of directory
|
||||
var sourcePathComponents = getNormalizedPathComponents(sourceFile.filename, host.getCurrentDirectory());
|
||||
sourcePathComponents.pop(); // FileName is not part of directory
|
||||
if (commonPathComponents) {
|
||||
for (var i = 0; i < Math.min(commonPathComponents.length, sourcePathCompoments.length); i++) {
|
||||
if (commonPathComponents[i] !== sourcePathCompoments[i]) {
|
||||
for (var i = 0; i < Math.min(commonPathComponents.length, sourcePathComponents.length); i++) {
|
||||
if (commonPathComponents[i] !== sourcePathComponents[i]) {
|
||||
if (i === 0) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
|
||||
return;
|
||||
@@ -3982,18 +4004,18 @@ module ts {
|
||||
}
|
||||
|
||||
// If the fileComponent path completely matched and less than already found update the length
|
||||
if (sourcePathCompoments.length < commonPathComponents.length) {
|
||||
commonPathComponents.length = sourcePathCompoments.length;
|
||||
if (sourcePathComponents.length < commonPathComponents.length) {
|
||||
commonPathComponents.length = sourcePathComponents.length;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// first file
|
||||
commonPathComponents = sourcePathCompoments;
|
||||
commonPathComponents = sourcePathComponents;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
commonSourceDirectory = getNormalizedPathFromPathCompoments(commonPathComponents);
|
||||
commonSourceDirectory = getNormalizedPathFromPathComponents(commonPathComponents);
|
||||
if (commonSourceDirectory) {
|
||||
// Make sure directory path ends with directory separator so this string can directly
|
||||
// used to replace with "" to get the relative path of the source file and the relative path doesn't
|
||||
|
||||
+15
-4
@@ -239,7 +239,8 @@ module ts {
|
||||
Synthetic = 0x00000100, // Synthetic node (for full fidelity)
|
||||
DeclarationFile = 0x00000200, // Node is a .d.ts file
|
||||
|
||||
Modifier = Export | Ambient | Public | Private | Static
|
||||
Modifier = Export | Ambient | Public | Private | Static,
|
||||
AccessibilityModifier = Public | Private
|
||||
}
|
||||
|
||||
export interface Node extends TextRange {
|
||||
@@ -576,7 +577,7 @@ module ts {
|
||||
export interface SourceMapData {
|
||||
/** Where the sourcemap file is written */
|
||||
sourceMapFilePath: string;
|
||||
/** source map url written in the js file */
|
||||
/** source map URL written in the js file */
|
||||
jsSourceMappingURL: string;
|
||||
/** Source map's file field - js file name*/
|
||||
sourceMapFile: string;
|
||||
@@ -595,7 +596,17 @@ module ts {
|
||||
sourceMapDecodedMappings: SourceMapSpan[];
|
||||
}
|
||||
|
||||
// Return code used by getEmitOutput function to indicate status of the function
|
||||
export enum EmitReturnStatus {
|
||||
Succeeded = 0, // All outputs generated as requested (.js, .map, .d.ts), no errors reported
|
||||
AllOutputGenerationSkipped = 1, // No .js generated because of syntax errors, or compiler options errors, nothing generated
|
||||
JSGeneratedWithSemanticErrors = 2, // .js and .map generated with semantic errors
|
||||
DeclarationGenerationSkipped = 3, // .d.ts generation skipped because of semantic errors or declaration emitter specific errors; Output .js with semantic errors
|
||||
EmitErrorsEncountered = 4 // Emitter errors occurred during emitting process
|
||||
}
|
||||
|
||||
export interface EmitResult {
|
||||
emitResultStatus: EmitReturnStatus;
|
||||
errors: Diagnostic[];
|
||||
sourceMaps: SourceMapData[]; // Array of sourceMapData if compiler emitted sourcemaps
|
||||
}
|
||||
@@ -609,7 +620,7 @@ module ts {
|
||||
getSymbolCount(): number;
|
||||
getTypeCount(): number;
|
||||
checkProgram(): void;
|
||||
emitFiles(): EmitResult;
|
||||
emitFiles(targetSourceFile?: SourceFile): EmitResult;
|
||||
getParentOfSymbol(symbol: Symbol): Symbol;
|
||||
getTypeOfSymbol(symbol: Symbol): Type;
|
||||
getPropertiesOfType(type: Type): Symbol[];
|
||||
@@ -668,7 +679,7 @@ module ts {
|
||||
isTopLevelValueImportedViaEntityName(node: ImportDeclaration): boolean;
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
getEnumMemberValue(node: EnumMember): number;
|
||||
shouldEmitDeclarations(): boolean;
|
||||
hasSemanticErrors(): boolean;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
isImplementationOfOverload(node: FunctionDeclaration): boolean;
|
||||
writeTypeAtLocation(location: Node, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: TextWriter): void;
|
||||
|
||||
Reference in New Issue
Block a user