本文整理汇总了Java中org.eclipse.jdt.core.JavaCore.getOptions方法的典型用法代码示例。如果您正苦于以下问题:Java JavaCore.getOptions方法的具体用法?Java JavaCore.getOptions怎么用?Java JavaCore.getOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.JavaCore
的用法示例。
在下文中一共展示了JavaCore.getOptions方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.eclipse.jdt.core.JavaCore; //导入方法依赖的package包/类
public void parse() throws ParseException {
ASTParser parser = ASTParser.newParser(AST.JLS8);
parser.setSource(source.toCharArray());
Map<String, String> options = JavaCore.getOptions();
options.put("org.eclipse.jdt.core.compiler.source", "1.8");
parser.setCompilerOptions(options);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setUnitName("Program.java");
parser.setEnvironment(new String[] { classpath != null? classpath : "" },
new String[] { "" }, new String[] { "UTF-8" }, true);
parser.setResolveBindings(true);
cu = (CompilationUnit) parser.createAST(null);
List<IProblem> problems = Arrays.stream(cu.getProblems()).filter(p ->
p.isError() &&
p.getID() != IProblem.PublicClassMustMatchFileName && // we use "Program.java"
p.getID() != IProblem.ParameterMismatch // Evidence varargs
).collect(Collectors.toList());
if (problems.size() > 0)
throw new ParseException(problems);
}
示例2: createCompilationUnitParser
import org.eclipse.jdt.core.JavaCore; //导入方法依赖的package包/类
private static ASTParser createCompilationUnitParser() {
ASTParser parser = ASTParser.newParser(AST.JLS8);
Map options = JavaCore.getOptions();
JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options);
parser.setCompilerOptions(options);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
return parser;
}
示例3: createProject
import org.eclipse.jdt.core.JavaCore; //导入方法依赖的package包/类
private synchronized IProject createProject(String projectName) {
final IProject project = this.workspace.getRoot().getProject(projectName);
Object cmpl = JavaCore.getOption(CompilerOptions.OPTION_Compliance);
Object src = JavaCore.getOption(CompilerOptions.OPTION_Source);
Object tgt = JavaCore.getOption(CompilerOptions.OPTION_TargetPlatform);
try {
IWorkspaceRunnable create = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
project.create(null, null);
project.open(null);
}
};
this.workspace.run(create, null);
this.projects.put(projectName, project);
addBuilderSpecs(projectName);
} catch (CoreException e) {
handle(e);
} finally {
// restore workspace settings
Hashtable options = JavaCore.getOptions();
options.put(CompilerOptions.OPTION_Compliance,cmpl);
options.put(CompilerOptions.OPTION_Source,src);
options.put(CompilerOptions.OPTION_TargetPlatform,tgt);
JavaCore.setOptions(options);
}
return project;
}
示例4: buildAstParser
import org.eclipse.jdt.core.JavaCore; //导入方法依赖的package包/类
private static ASTParser buildAstParser(String[] sourceFolders) {
ASTParser parser = ASTParser.newParser(AST.JLS8);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
Map options = JavaCore.getOptions();
JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options);
parser.setCompilerOptions(options);
parser.setResolveBindings(true);
parser.setBindingsRecovery(true);
parser.setEnvironment(new String[0], sourceFolders, null, true);
// parser.setEnvironment(new String[0], new String[]{"tmp\\refactoring-toy-example\\src"}, null, false);
return parser;
}
示例5: buildAstParser
import org.eclipse.jdt.core.JavaCore; //导入方法依赖的package包/类
private static ASTParser buildAstParser(String[] sourceFolders) {
ASTParser parser = ASTParser.newParser(AST.JLS8);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
Map options = JavaCore.getOptions();
JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options);
parser.setCompilerOptions(options);
parser.setResolveBindings(true);
parser.setBindingsRecovery(true);
parser.setEnvironment(new String[0], sourceFolders, null, true);
//parser.setEnvironment(new String[0], new String[]{"tmp\\refactoring-toy-example\\src"}, null, false);
return parser;
}
示例6: JavaSourceParser
import org.eclipse.jdt.core.JavaCore; //导入方法依赖的package包/类
private JavaSourceParser(String source, String className) {
this.source = source.toCharArray();
parser = ASTParser.newParser(AST.JLS8);
parser.setResolveBindings(true);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setEnvironment(null, new String[] {}, new String[] {}, true);
parser.setUnitName(className);
parser.setSource(this.source);
Map<String, String> options = JavaCore.getOptions();
options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED);
parser.setCompilerOptions(options);
}
示例7: parse
import org.eclipse.jdt.core.JavaCore; //导入方法依赖的package包/类
/**
* Parse the code and generate the JSON in outJ
*
* @param source String to parses
* @return CompilationUnit of the AST
* @throws IOException if anything related to I/O or Json generation failed
*/
public CompilationUnit parse(final String source) throws IOException {
parser.setSource(source.toCharArray());
Map options = JavaCore.getOptions();
JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options);
parser.setCompilerOptions(options);
return (CompilationUnit) parser.createAST(null);
}