本文整理汇总了Java中org.eclipse.jdt.internal.compiler.parser.Parser.dietParse方法的典型用法代码示例。如果您正苦于以下问题:Java Parser.dietParse方法的具体用法?Java Parser.dietParse怎么用?Java Parser.dietParse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.parser.Parser
的用法示例。
在下文中一共展示了Parser.dietParse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installStubs
import org.eclipse.jdt.internal.compiler.parser.Parser; //导入方法依赖的package包/类
public void installStubs(final Resource resource) {
boolean _isInfoFile = this.isInfoFile(resource);
if (_isInfoFile) {
return;
}
final CompilationUnit compilationUnit = this.getCompilationUnit(resource);
IErrorHandlingPolicy _proceedWithAllProblems = DefaultErrorHandlingPolicies.proceedWithAllProblems();
CompilerOptions _compilerOptions = this.getCompilerOptions(resource);
DefaultProblemFactory _defaultProblemFactory = new DefaultProblemFactory();
ProblemReporter _problemReporter = new ProblemReporter(_proceedWithAllProblems, _compilerOptions, _defaultProblemFactory);
final Parser parser = new Parser(_problemReporter, true);
final CompilationResult compilationResult = new CompilationResult(compilationUnit, 0, 1, (-1));
final CompilationUnitDeclaration result = parser.dietParse(compilationUnit, compilationResult);
if ((result.types != null)) {
for (final TypeDeclaration type : result.types) {
{
ImportReference _currentPackage = result.currentPackage;
char[][] _importName = null;
if (_currentPackage!=null) {
_importName=_currentPackage.getImportName();
}
List<String> _map = null;
if (((List<char[]>)Conversions.doWrapArray(_importName))!=null) {
final Function1<char[], String> _function = (char[] it) -> {
return String.valueOf(it);
};
_map=ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(_importName)), _function);
}
String _join = null;
if (_map!=null) {
_join=IterableExtensions.join(_map, ".");
}
final String packageName = _join;
final JvmDeclaredType jvmType = this.createType(type, packageName);
resource.getContents().add(jvmType);
}
}
}
}
示例2: parse
import org.eclipse.jdt.internal.compiler.parser.Parser; //导入方法依赖的package包/类
public static void parse(ICompilationUnit[] compilationUnits, ASTRequestor astRequestor, int apiLevel, Map options, int flags, IProgressMonitor monitor) {
try {
CompilerOptions compilerOptions = new CompilerOptions(options);
compilerOptions.ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
Parser parser = new CommentRecorderParser(
new ProblemReporter(
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
compilerOptions,
new DefaultProblemFactory()),
false);
int unitLength = compilationUnits.length;
if (monitor != null) monitor.beginTask("", unitLength); //$NON-NLS-1$
for (int i = 0; i < unitLength; i++) {
org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) compilationUnits[i];
CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit);
CompilationUnitDeclaration compilationUnitDeclaration = parser.dietParse(sourceUnit, compilationResult);
if (compilationUnitDeclaration.ignoreMethodBodies) {
compilationUnitDeclaration.ignoreFurtherInvestigation = true;
// if initial diet parse did not work, no need to dig into method bodies.
continue;
}
//fill the methods bodies in order for the code to be generated
//real parse of the method....
org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types;
if (types != null) {
for (int j = 0, typeLength = types.length; j < typeLength; j++) {
types[j].parseMethods(parser, compilationUnitDeclaration);
}
}
// convert AST
CompilationUnit node = convert(compilationUnitDeclaration, parser.scanner.getSource(), apiLevel, options, false/*don't resolve binding*/, null/*no owner needed*/, null/*no binding table needed*/, flags /* flags */, monitor, true);
node.setTypeRoot(compilationUnits[i]);
// accept AST
astRequestor.acceptAST(compilationUnits[i], node);
if (monitor != null) monitor.worked(1);
}
} finally {
if (monitor != null) monitor.done();
}
}