本文整理汇总了Java中org.eclipse.jdt.internal.core.BasicCompilationUnit类的典型用法代码示例。如果您正苦于以下问题:Java BasicCompilationUnit类的具体用法?Java BasicCompilationUnit怎么用?Java BasicCompilationUnit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BasicCompilationUnit类属于org.eclipse.jdt.internal.core包,在下文中一共展示了BasicCompilationUnit类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseSnippeInitializer
import org.eclipse.jdt.internal.core.BasicCompilationUnit; //导入依赖的package包/类
private Initializer parseSnippeInitializer(char[] snippet, int position, char[][] localVariableTypeNames, char[][] localVariableNames, int[] localVariableModifiers, boolean isStatic){
StringBuffer prefix = new StringBuffer();
prefix.append("public class FakeType {\n "); //$NON-NLS-1$
if(isStatic) {
prefix.append("static "); //$NON-NLS-1$
}
prefix.append("{\n"); //$NON-NLS-1$
for (int i = 0; i < localVariableTypeNames.length; i++) {
ASTNode.printModifiers(localVariableModifiers[i], prefix);
prefix.append(' ');
prefix.append(localVariableTypeNames[i]);
prefix.append(' ');
prefix.append(localVariableNames[i]);
prefix.append(';');
}
char[] fakeSource = CharOperation.concat(prefix.toString().toCharArray(), snippet, "}}".toCharArray());//$NON-NLS-1$
this.offset = prefix.length();
String encoding = this.compilerOptions.defaultEncoding;
BasicCompilationUnit fakeUnit = new BasicCompilationUnit(
fakeSource,
null,
"FakeType.java", //$NON-NLS-1$
encoding);
this.actualCompletionPosition = prefix.length() + position - 1;
CompilationResult fakeResult = new CompilationResult(fakeUnit, 1, 1, this.compilerOptions.maxProblemsPerUnit);
CompilationUnitDeclaration fakeAST = this.parser.dietParse(fakeUnit, fakeResult, this.actualCompletionPosition);
parseBlockStatements(fakeAST, this.actualCompletionPosition);
return (Initializer)fakeAST.types[0].fields[0];
}