当前位置: 首页>>代码示例>>Java>>正文


Java BasicCompilationUnit类代码示例

本文整理汇总了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];
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:36,代码来源:CompletionEngine.java


注:本文中的org.eclipse.jdt.internal.core.BasicCompilationUnit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。