use of com.google.javascript.rhino.SimpleSourceFile in project closure-compiler by google.
the class GlobalTypeInfoCollector method dummyRawTypeForMissingExterns.
private RawNominalType dummyRawTypeForMissingExterns(String name) {
Node defSite = NodeUtil.emptyFunction();
defSite.setStaticSourceFile(new SimpleSourceFile("", true));
return RawNominalType.makeClass(getCommonTypes(), defSite, name, ImmutableList.of(), ObjectKind.UNRESTRICTED, false);
}
use of com.google.javascript.rhino.SimpleSourceFile in project closure-compiler by google.
the class AstValidatorTest method testValidScript.
@Test
public void testValidScript() {
// Since we're building the AST by hand, there won't be any types on it.
typeInfoValidationMode = AstValidator.TypeInfoValidation.NONE;
Node n = new Node(Token.SCRIPT);
expectInvalid(n, Check.SCRIPT);
n.setInputId(new InputId("something_input"));
n.setStaticSourceFile(new SimpleSourceFile("something", SourceKind.STRONG));
expectValid(n, Check.SCRIPT);
expectInvalid(n, Check.STATEMENT);
expectInvalid(n, Check.EXPRESSION);
}
use of com.google.javascript.rhino.SimpleSourceFile in project closure-compiler by google.
the class AstValidatorTest method testValidFeatureInScript.
@Test
public void testValidFeatureInScript() {
// Since we're building the AST by hand, there won't be any types on it.
typeInfoValidationMode = AstValidator.TypeInfoValidation.NONE;
setAcceptedLanguage(LanguageMode.ECMASCRIPT_2015);
Node n = new Node(Token.SCRIPT);
n.setInputId(new InputId("something_input"));
n.setStaticSourceFile(new SimpleSourceFile("something", SourceKind.STRONG));
expectValid(n, Check.SCRIPT);
n.addChildToFront(IR.let(IR.name("a"), IR.number(3)));
n.srcrefTree(n);
expectInvalid(n, Check.SCRIPT);
n.putProp(Node.FEATURE_SET, FeatureSet.BARE_MINIMUM.with(Feature.LET_DECLARATIONS));
expectValid(n, Check.SCRIPT);
}
use of com.google.javascript.rhino.SimpleSourceFile in project closure-compiler by google.
the class ParsingUtilTest method parse.
private static Node parse(String source, String... warnings) {
TestErrorReporter testErrorReporter = new TestErrorReporter().expectAllWarnings(warnings);
Config config = ParserRunner.createConfig(LanguageMode.ES_NEXT, Config.JsDocParsing.INCLUDE_DESCRIPTIONS_NO_WHITESPACE, Config.RunMode.KEEP_GOING, null, true, StrictMode.STRICT);
Node script = ParserRunner.parse(new SimpleSourceFile("input", SourceKind.STRONG), source, config, testErrorReporter).ast;
// verifying that all warnings were seen
testErrorReporter.verifyHasEncounteredAllWarningsAndErrors();
return script;
}
use of com.google.javascript.rhino.SimpleSourceFile in project closure-compiler by google.
the class JsDocInfoParserTest method parseFull.
private Node parseFull(String code, String... warnings) {
TestErrorReporter testErrorReporter = new TestErrorReporter().expectAllWarnings(warnings);
Config config = Config.builder().setExtraAnnotationNames(extraAnnotations).setJsDocParsingMode(JsDocParsing.INCLUDE_DESCRIPTIONS_NO_WHITESPACE).setRunMode(RunMode.KEEP_GOING).setSuppressionNames(extraSuppressions).setLanguageMode(LanguageMode.ECMASCRIPT3).setParseInlineSourceMaps(true).setStrictMode(StrictMode.SLOPPY).build();
ParseResult result = ParserRunner.parse(new SimpleSourceFile("source", SourceKind.STRONG), code, config, testErrorReporter);
testErrorReporter.verifyHasEncounteredAllWarningsAndErrors();
return result.ast;
}
Aggregations