updated code style, added tests, fixed regex bug, merged to latest branch
This commit is contained in:
Родитель
6184c15d9c
Коммит
9974526101
|
@ -44,3 +44,4 @@ scripts/ior.js
|
|||
scripts/*.js.map
|
||||
coverage/
|
||||
internal/
|
||||
**/.DS_Store
|
||||
|
|
|
@ -3916,7 +3916,7 @@ module ts {
|
|||
emitLiteral(<LiteralExpression>getExternalModuleImportDeclarationExpression(imp));
|
||||
});
|
||||
forEach(node.amdDependencies, amdDependency => {
|
||||
var text = "\"" + amdDependency + "\"";
|
||||
var text = "\"" + amdDependency.path + "\"";
|
||||
write(", ");
|
||||
write(text);
|
||||
});
|
||||
|
@ -3925,6 +3925,12 @@ module ts {
|
|||
write(", ");
|
||||
emit(imp.name);
|
||||
});
|
||||
forEach(node.amdDependencies, amdDependency => {
|
||||
if (amdDependency.name) {
|
||||
write(", ");
|
||||
write(amdDependency.name);
|
||||
}
|
||||
});
|
||||
write(") {");
|
||||
increaseIndent();
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
|
|
|
@ -4670,7 +4670,7 @@ module ts {
|
|||
function processReferenceComments(sourceFile: SourceFile): void {
|
||||
var triviaScanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/false, sourceText);
|
||||
var referencedFiles: FileReference[] = [];
|
||||
var amdDependencies: string[] = [];
|
||||
var amdDependencies: {path: string; name: string}[] = [];
|
||||
var amdModuleName: string;
|
||||
|
||||
// Keep scanning all the leading trivia in the file until we get to something that
|
||||
|
@ -4710,10 +4710,16 @@ module ts {
|
|||
amdModuleName = amdModuleNameMatchResult[2];
|
||||
}
|
||||
|
||||
var amdDependencyRegEx = /^\/\/\/\s*<amd-dependency\s+path\s*=\s*('|")(.+?)\1/gim;
|
||||
var amdDependencyRegEx = /^\/\/\/\s*<amd-dependency\s/gim;
|
||||
var pathRegex = /\spath\s*=\s*('|")(.+?)\1/gim;
|
||||
var nameRegex = /\sname\s*=\s*('|")(.+?)\1/gim;
|
||||
var amdDependencyMatchResult = amdDependencyRegEx.exec(comment);
|
||||
if (amdDependencyMatchResult) {
|
||||
amdDependencies.push(amdDependencyMatchResult[2]);
|
||||
var pathMatchResult = pathRegex.exec(comment);
|
||||
var nameMatchResult = nameRegex.exec(comment);
|
||||
if (pathMatchResult) {
|
||||
amdDependencies.push({path: pathMatchResult[2], name: nameMatchResult ? nameMatchResult[2] : undefined });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -887,7 +887,7 @@ module ts {
|
|||
fileName: string;
|
||||
text: string;
|
||||
|
||||
amdDependencies: string[];
|
||||
amdDependencies: {path: string; name: string}[];
|
||||
amdModuleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
|
||||
|
|
|
@ -726,7 +726,7 @@ module ts {
|
|||
public statements: NodeArray<Statement>;
|
||||
public endOfFileToken: Node;
|
||||
|
||||
public amdDependencies: string[];
|
||||
public amdDependencies: {name: string; path: string}[];
|
||||
public amdModuleName: string;
|
||||
public referencedFiles: FileReference[];
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
tests/cases/compiler/amdDependencyCommentName1.ts(3,21): error TS2307: Cannot find external module 'm2'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/amdDependencyCommentName1.ts (1 errors) ====
|
||||
///<amd-dependency path='bar' name='b'/>
|
||||
|
||||
import m1 = require("m2")
|
||||
~~~~
|
||||
!!! error TS2307: Cannot find external module 'm2'.
|
||||
m1.f();
|
|
@ -0,0 +1,10 @@
|
|||
//// [amdDependencyCommentName1.ts]
|
||||
///<amd-dependency path='bar' name='b'/>
|
||||
|
||||
import m1 = require("m2")
|
||||
m1.f();
|
||||
|
||||
//// [amdDependencyCommentName1.js]
|
||||
///<amd-dependency path='bar' name='b'/>
|
||||
var m1 = require("m2");
|
||||
m1.f();
|
|
@ -0,0 +1,10 @@
|
|||
tests/cases/compiler/amdDependencyCommentName2.ts(3,21): error TS2307: Cannot find external module 'm2'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/amdDependencyCommentName2.ts (1 errors) ====
|
||||
///<amd-dependency path='bar' name='b'/>
|
||||
|
||||
import m1 = require("m2")
|
||||
~~~~
|
||||
!!! error TS2307: Cannot find external module 'm2'.
|
||||
m1.f();
|
|
@ -0,0 +1,11 @@
|
|||
//// [amdDependencyCommentName2.ts]
|
||||
///<amd-dependency path='bar' name='b'/>
|
||||
|
||||
import m1 = require("m2")
|
||||
m1.f();
|
||||
|
||||
//// [amdDependencyCommentName2.js]
|
||||
///<amd-dependency path='bar' name='b'/>
|
||||
define(["require", "exports", "m2", "bar"], function (require, exports, m1, b) {
|
||||
m1.f();
|
||||
});
|
|
@ -0,0 +1,5 @@
|
|||
//@module: commonjs
|
||||
///<amd-dependency path='bar' name='b'/>
|
||||
|
||||
import m1 = require("m2")
|
||||
m1.f();
|
|
@ -0,0 +1,5 @@
|
|||
//@module: amd
|
||||
///<amd-dependency path='bar' name='b'/>
|
||||
|
||||
import m1 = require("m2")
|
||||
m1.f();
|
Загрузка…
Ссылка в новой задаче