use of org.apache.cxf.tools.corba.idlpreprocessor.DefaultIncludeResolver in project cxf by apache.
the class IDLProcessor method process.
public void process() throws ToolException {
String location = env.get(ToolCorbaConstants.CFG_IDLFILE).toString();
File file = new File(location).getAbsoluteFile();
if (!file.exists()) {
throw new ToolException("IDL file " + file.getName() + " doesn't exist");
}
try {
URL orig = file.toURI().toURL();
DefaultIncludeResolver includeResolver = getDefaultIncludeResolver(file.getParentFile());
DefineState defineState = new DefineState(new HashMap<String, String>());
preprocessor = new IdlPreprocessorReader(orig, location, includeResolver, defineState);
IDLLexer lexer = new IDLLexer(new java.io.LineNumberReader(preprocessor));
lexer.setTokenObjectClass("antlr.CommonHiddenStreamToken");
TokenStreamHiddenTokenFilter filter = new TokenStreamHiddenTokenFilter(lexer);
filter.discard(IDLTokenTypes.WS);
filter.hide(IDLTokenTypes.SL_COMMENT);
filter.hide(IDLTokenTypes.ML_COMMENT);
parser = new IDLParser(filter);
parser.setASTNodeClass("antlr.CommonASTWithHiddenTokens");
parser.specification();
} catch (Exception ex) {
throw new ToolException(ex);
}
}
use of org.apache.cxf.tools.corba.idlpreprocessor.DefaultIncludeResolver in project cxf by apache.
the class IDLProcessor method getDefaultIncludeResolver.
private DefaultIncludeResolver getDefaultIncludeResolver(File currentDir) {
DefaultIncludeResolver includeResolver;
if (env.optionSet(ToolCorbaConstants.CFG_INCLUDEDIR)) {
String[] includedDirs = (String[]) env.get(ToolCorbaConstants.CFG_INCLUDEDIR);
File[] includeDirs = new File[includedDirs.length];
for (int i = 0; i < includedDirs.length; i++) {
includeDirs[i] = new File(includedDirs[i]);
}
includeResolver = new DefaultIncludeResolver(includeDirs);
} else {
includeResolver = new DefaultIncludeResolver(currentDir);
}
return includeResolver;
}
Aggregations