本文整理汇总了Java中org.stringtemplate.v4.misc.ErrorType类的典型用法代码示例。如果您正苦于以下问题:Java ErrorType类的具体用法?Java ErrorType怎么用?Java ErrorType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ErrorType类属于org.stringtemplate.v4.misc包,在下文中一共展示了ErrorType类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: defineRegion
import org.stringtemplate.v4.misc.ErrorType; //导入依赖的package包/类
public CompiledST defineRegion(String enclosingTemplateName, Token regionT, String template, Token templateToken) {
String name = regionT.getText();
template = Misc.trimOneStartingNewline(template);
template = Misc.trimOneTrailingNewline(template);
CompiledST code = compile(getFileName(), enclosingTemplateName, null, template, templateToken);
String mangled = getMangledRegionName(enclosingTemplateName, name);
if ( lookupTemplate(mangled)==null ) {
errMgr.compileTimeError(ErrorType.NO_SUCH_REGION,
templateToken,
regionT,
enclosingTemplateName,
name);
return new CompiledST();
}
code.name = mangled;
code.isRegion = true;
code.regionDefType = ST.RegionType.EXPLICIT;
code.templateDefStartToken = regionT;
rawDefineTemplate(mangled, code, regionT);
code.defineArgDefaultValueTemplates(this);
code.defineImplicitlyDefinedTemplates(this);
return code;
}
示例2: rawDefineTemplate
import org.stringtemplate.v4.misc.ErrorType; //导入依赖的package包/类
public void rawDefineTemplate(String name, CompiledST code, Token defT) {
CompiledST prev = rawGetTemplate(name);
if ( prev!=null ) {
if ( !prev.isRegion ) {
errMgr.compileTimeError(ErrorType.TEMPLATE_REDEFINITION, null, defT);
return;
}
else {
if ( code.regionDefType!= ST.RegionType.IMPLICIT && prev.regionDefType==ST.RegionType.EMBEDDED ) {
errMgr.compileTimeError(ErrorType.EMBEDDED_REGION_REDEFINITION, null, defT, getUnMangledTemplateName(name));
return;
}
else if ( code.regionDefType==ST.RegionType.IMPLICIT || prev.regionDefType==ST.RegionType.EXPLICIT ) {
errMgr.compileTimeError(ErrorType.REGION_REDEFINITION,
null,
defT,
getUnMangledTemplateName(name));
return;
}
}
}
code.nativeGroup = this;
code.templateDefStartToken = defT;
templates.put(name, code);
}
示例3: loadTemplateFile
import org.stringtemplate.v4.misc.ErrorType; //导入依赖的package包/类
/** Load template stream into this group. {@code unqualifiedFileName} is
* {@code "a.st"}. The {@code prefix} is path from group root to
* {@code unqualifiedFileName} like {@code "/subdir"} if file is in
* {@code /subdir/a.st}.
*/
public CompiledST loadTemplateFile(String prefix, String unqualifiedFileName, CharStream templateStream) {
GroupLexer lexer = new GroupLexer(templateStream);
CommonTokenStream tokens = new CommonTokenStream(lexer);
GroupParser parser = new GroupParser(tokens);
parser.group = this;
lexer.group = this;
try {
parser.templateDef(prefix);
}
catch (RecognitionException re) {
errMgr.groupSyntaxError(ErrorType.SYNTAX_ERROR, unqualifiedFileName, re, re.getMessage());
}
String templateName = Misc.getFileNameNoSuffix(unqualifiedFileName);
if ( prefix!=null && prefix.length()>0 ) templateName = prefix+templateName;
CompiledST impl = rawGetTemplate(templateName);
impl.prefix = prefix;
return impl;
}
示例4: getRootDirURL
import org.stringtemplate.v4.misc.ErrorType; //导入依赖的package包/类
@Override
public URL getRootDirURL() {
// System.out.println("url of "+fileName+" is "+url.toString());
String parent = Misc.stripLastPathElement(url.toString());
if ( parent.endsWith(".jar!") ) {
parent = parent+"/."; // whooops. at the root so add "current dir" after jar spec
}
try {
URL parentURL = new URL(parent);
// System.out.println("parent URL "+parentURL.toString());
return parentURL;
}
catch (MalformedURLException mue) {
errMgr.runTimeError(null, null, ErrorType.INVALID_TEMPLATE_NAME, mue, parent);
}
return null;
}
示例5: defineRegion
import org.stringtemplate.v4.misc.ErrorType; //导入依赖的package包/类
public CompiledST defineRegion(String enclosingTemplateName, Token regionT, String template, Token templateToken) {
String name = regionT.getText();
template = Misc.trimOneStartingNewline(template);
template = Misc.trimOneTrailingNewline(template);
CompiledST code = compile(getFileName(), enclosingTemplateName, null, template, templateToken);
String mangled = getMangledRegionName(enclosingTemplateName, name);
if ( lookupTemplate(mangled)==null ) {
errMgr.compileTimeError(ErrorType.NO_SUCH_REGION, templateToken, regionT, enclosingTemplateName, name);
return new CompiledST();
}
code.name = mangled;
code.isRegion = true;
code.regionDefType = ST.RegionType.EXPLICIT;
code.templateDefStartToken = regionT;
rawDefineTemplate(mangled, code, regionT);
code.defineArgDefaultValueTemplates(this);
code.defineImplicitlyDefinedTemplates(this);
return code;
}
示例6: rawDefineTemplate
import org.stringtemplate.v4.misc.ErrorType; //导入依赖的package包/类
public void rawDefineTemplate(String name, CompiledST code, Token defT) {
CompiledST prev = rawGetTemplate(name);
if ( prev!=null ) {
if ( !prev.isRegion ) {
errMgr.compileTimeError(ErrorType.TEMPLATE_REDEFINITION, null, defT);
return;
}
else {
if ( code.regionDefType!= ST.RegionType.IMPLICIT && prev.regionDefType==ST.RegionType.EMBEDDED ) {
errMgr.compileTimeError(ErrorType.EMBEDDED_REGION_REDEFINITION, null, defT, getUnMangledTemplateName(name));
return;
}
else if ( code.regionDefType==ST.RegionType.IMPLICIT || prev.regionDefType==ST.RegionType.EXPLICIT ) {
errMgr.compileTimeError(ErrorType.REGION_REDEFINITION, null, defT, getUnMangledTemplateName(name));
return;
}
}
}
code.nativeGroup = this;
code.templateDefStartToken = defT;
templates.put(name, code);
}
示例7: defineRegion
import org.stringtemplate.v4.misc.ErrorType; //导入依赖的package包/类
public CompiledST defineRegion(String enclosingTemplateName, Token regionT, String template, Token templateToken) {
String name = regionT.getText();
template = Misc.trimOneStartingNewline(template);
template = Misc.trimOneTrailingNewline(template);
CompiledST code = compile(getFileName(), enclosingTemplateName, null, template, templateToken);
String mangled = getMangledRegionName(enclosingTemplateName, name);
if ( lookupTemplate(mangled) ==null ) {
errMgr.compileTimeError(ErrorType.NO_SUCH_REGION,
templateToken,
regionT,
enclosingTemplateName,
name);
return new CompiledST();
}
code.name = mangled;
code.isRegion = true;
code.regionDefType = ST.RegionType.EXPLICIT;
code.templateDefStartToken = regionT;
rawDefineTemplate(mangled, code, regionT);
code.defineArgDefaultValueTemplates(this);
code.defineImplicitlyDefinedTemplates(this);
return code;
}
示例8: rawDefineTemplate
import org.stringtemplate.v4.misc.ErrorType; //导入依赖的package包/类
public void rawDefineTemplate(String name, CompiledST code, Token defT) {
CompiledST prev = rawGetTemplate(name);
if ( prev!=null ) {
if ( !prev.isRegion ) {
errMgr.compileTimeError(ErrorType.TEMPLATE_REDEFINITION, null, defT);
return;
}
else {
if ( code.regionDefType!= ST.RegionType.IMPLICIT && prev.regionDefType== ST.RegionType.EMBEDDED ) {
errMgr.compileTimeError(ErrorType.EMBEDDED_REGION_REDEFINITION, null, defT, getUnMangledTemplateName(name));
return;
}
else if ( code.regionDefType== ST.RegionType.IMPLICIT || prev.regionDefType== ST.RegionType.EXPLICIT ) {
errMgr.compileTimeError(ErrorType.REGION_REDEFINITION,
null,
defT,
getUnMangledTemplateName(name));
return;
}
}
}
code.nativeGroup = this;
code.templateDefStartToken = defT;
templates.put(name, code);
}
示例9: loadTemplateFile
import org.stringtemplate.v4.misc.ErrorType; //导入依赖的package包/类
/** Load template stream into this group. {@code unqualifiedFileName} is
* {@code "a.st"}. The {@code prefix} is path from group root to
* {@code unqualifiedFileName} like {@code "/subdir"} if file is in
* {@code /subdir/a.st}.
*/
public CompiledST loadTemplateFile(String prefix, String unqualifiedFileName, CharStream templateStream) {
GroupLexer lexer = new GroupLexer(templateStream);
CommonTokenStream tokens = new CommonTokenStream(lexer);
GroupParser parser = new GroupParser(tokens);
parser.group = this;
lexer.group = this;
try {
parser.templateDef(prefix);
}
catch (RecognitionException re) {
errMgr.groupSyntaxError(ErrorType.SYNTAX_ERROR, unqualifiedFileName, re, re.getMessage());
}
String templateName = Misc.getFileNameNoSuffix(unqualifiedFileName);
if ( prefix !=null && prefix.length()>0 ) templateName = prefix+templateName;
CompiledST impl = rawGetTemplate(templateName);
impl.prefix = prefix;
return impl;
}