List of usage examples for org.eclipse.jdt.core JavaCore COMPILER_SOURCE
String COMPILER_SOURCE
To view the source code for org.eclipse.jdt.core JavaCore COMPILER_SOURCE.
Click Source Link
From source file:JavaSourceViewerConfiguration.java
License:Open Source License
@Override public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) { if (IJavaPartitions.JAVA_DOC.equals(contentType)) return new JavadocDoubleClickStrategy(getConfiguredDocumentPartitioning(sourceViewer)); if (IJavaPartitions.JAVA_SINGLE_LINE_COMMENT.equals(contentType)) return new PartitionDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer), 0, 0); if (IJavaPartitions.JAVA_MULTI_LINE_COMMENT.equals(contentType)) return new PartitionDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer), 0, 0); else if (IJavaPartitions.JAVA_STRING.equals(contentType) || IJavaPartitions.JAVA_CHARACTER.equals(contentType)) return new PartitionDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer), 1, 1); if (fJavaDoubleClickSelector == null) { fJavaDoubleClickSelector = new JavaDoubleClickSelector(); fJavaDoubleClickSelector.setSourceVersion(fPreferenceStore.getString(JavaCore.COMPILER_SOURCE)); }/*from w w w.jav a 2 s .co m*/ return fJavaDoubleClickSelector; }
From source file:JavaSourceViewerConfiguration.java
License:Open Source License
/** * Adapts the behavior of the contained components to the change * encoded in the given event.//www. jav a2 s.c o m * <p> * Clients are not allowed to call this method if the old setup with * text tools is in use. * </p> * * @param event the event to which to adapt * @see JavaSourceViewerConfiguration#JavaSourceViewerConfiguration(IColorManager, IPreferenceStore, ITextEditor, String) * @since 3.0 */ public void handlePropertyChangeEvent(PropertyChangeEvent event) { Assert.isTrue(isNewSetup()); if (fCodeScanner.affectsBehavior(event)) fCodeScanner.adaptToPreferenceChange(event); if (fMultilineCommentScanner.affectsBehavior(event)) fMultilineCommentScanner.adaptToPreferenceChange(event); if (fSinglelineCommentScanner.affectsBehavior(event)) fSinglelineCommentScanner.adaptToPreferenceChange(event); if (fStringScanner.affectsBehavior(event)) fStringScanner.adaptToPreferenceChange(event); if (fJavaDocScanner.affectsBehavior(event)) fJavaDocScanner.adaptToPreferenceChange(event); if (fJavaDoubleClickSelector != null && JavaCore.COMPILER_SOURCE.equals(event.getProperty())) if (event.getNewValue() instanceof String) fJavaDoubleClickSelector.setSourceVersion((String) event.getNewValue()); }
From source file:ar.com.fluxit.jqa.JQAEclipseRunner.java
License:Open Source License
private void run(IResource rulesContextFile, IProject targetProject) throws RulesContextFactoryException, IntrospectionException, FileNotFoundException, TypeFormatException, IOException { final IJavaProject javaProject = JavaCore.create(targetProject); final RulesContextFactory rulesContextFactory = RulesContextFactoryLocator.getRulesContextFactory(); final RulesContext rulesContext = rulesContextFactory .getRulesContext(rulesContextFile.getRawLocation().toOSString()); try {/* w w w. j a va 2 s . c o m*/ Collection<File> classPath = getClassPath(javaProject); Collection<File> classFiles = getClassFiles(javaProject); String sourceJavaVersion = javaProject.getOption(JavaCore.COMPILER_SOURCE, true); File[] sourceDir = Utils.getSourcesDirs(javaProject); final CheckingResult checkResult = RulesContextChecker.INSTANCE.check(targetProject.getName(), classFiles, classPath, rulesContext, sourceDir, sourceJavaVersion, LOGGER); JQAEclipseMarker.INSTANCE.mark(javaProject, checkResult); } catch (JavaModelException e) { throw new IllegalStateException("Can not parse Java project: " + javaProject.getElementName(), e); } }
From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.handler.AbstractAntHandler.java
License:Open Source License
protected BuildConfiguration prepareBuild(IFile f, AntTask task) { final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); BuildConfiguration config = new BuildConfiguration(); config.task = task;// w ww . ja v a2 s .c o m project = JavaCore.create(f.getProject()); IPath[] paths = BuildPathSupport.getFxJarPath(project); if (paths != null) { config.jfxjar = paths[0].toFile().getAbsolutePath(); config.jfxantjar = paths[2].toFile().getAbsolutePath(); } if (task.getBuildDirectory() == null) { DirectoryDialog dialog = new DirectoryDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); dialog.setText("Staging Directory"); String directory = dialog.open(); if (directory == null) { return null; } config.buildDirectory = directory; } else { config.buildDirectory = resolvePath(task.getBuildDirectory(), project.getProject()); } // TODO uncomment // config.builderName = properties.getProperty( "jfx.eclipse.buildername" ); if (task.getDeploy().getApplication().getName() != null) { config.projectName = task.getDeploy().getApplication().getName(); } else { config.projectName = f.getProject().getName(); } config.keyStore = task.getSignjar().getKeystore() != null ? resolvePath(task.getSignjar().getKeystore(), project.getProject()) : null; try { config.projectEncoding = f.getProject().getDefaultCharset(); config.sourceCompliance = project.getOption(JavaCore.COMPILER_SOURCE, true); config.targetCompliance = project.getOption(JavaCore.COMPILER_COMPLIANCE, true); } catch (CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } Set<IPath> listProjectSourceDirs = new HashSet<IPath>(); Set<IPath> listRefProjectSourceDirs = new HashSet<IPath>(); Set<IPath> listRefLibraries = new HashSet<IPath>(); resolveDataProject(project, listProjectSourceDirs, listRefProjectSourceDirs, listRefLibraries); { Set<String> set = new HashSet<String>(); Set<File> set2 = new HashSet<File>(); for (IPath p : listRefLibraries) { set.add(p.lastSegment()); IFile file = root.getFile(p); if (file != null && file.exists()) { p = file.getLocation(); } set2.add(p.toFile()); } config.externalLibs = set; config.origExternalLibs = set2; } { Set<String> set = new HashSet<String>(); Set<SetupDirectory> set2 = new HashSet<SetupDirectory>(); for (IPath p : listProjectSourceDirs) { IFolder t = root.getFolder(p); set.add(t.getProjectRelativePath().toString()); set2.add(new SetupDirectory(t.getProject().getLocation().toFile(), new File(t.getProjectRelativePath().toString()))); } config.projectSourceDirs = set; config.origProjectSourceDirs = set2; } { Set<String> set = new HashSet<String>(); Set<SetupDirectory> set2 = new HashSet<SetupDirectory>(); for (IPath p : listRefProjectSourceDirs) { IFolder t = root.getFolder(p); set.add(t.getProject().getName() + "/" + t.getProjectRelativePath()); set2.add(new SetupDirectory(t.getProject().getLocation().toFile().getParentFile(), new File(t.getProject().getName() + "/" + t.getProjectRelativePath().toString()))); } config.projectRefSourceDirs = set; config.origProjectRefSourceDirs = set2; } return config; }
From source file:br.uff.ic.gems.resources.ast.ASTExtractor.java
public void parser() throws IOException { ASTParser parser = ASTParser.newParser(AST.JLS3); File file = new File(filePath); String stringFile = FileUtils.readFileToString(file); parser.setSource(stringFile.toCharArray()); parser.setKind(ASTParser.K_COMPILATION_UNIT); //Setting options Map options;/*ww w.j a v a2 s . c om*/ options = JavaCore.getOptions(); options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_7); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_7); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_7); parser.setCompilerOptions(options); final CompilationUnit cu = (CompilationUnit) parser.createAST(null); Visitor visitor = new Visitor(cu); cu.accept(visitor); List<Comment> commentList = cu.getCommentList(); for (Comment comment : commentList) { comment.accept(visitor); } languageConstructs = visitor.getLanguageConstructs(); }
From source file:br.uff.ic.mergeguider.javaparser.JavaParser.java
private Storage generateASTs(String path) { ASTParser parser = ASTParser.newParser(AST.JLS8); parser.setResolveBindings(true);/*from w w w .ja va 2 s .c o m*/ parser.setBindingsRecovery(true); Map options = JavaCore.getOptions(); options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8); parser.setCompilerOptions(options); String[] srcDirs = FileUtils.getAllDirs(path); String[] javaFiles = FileUtils.getAllJavaFiles(path); parser.setEnvironment(null, srcDirs, null, true); Storage storage = new Storage(); parser.createASTs(javaFiles, null, new String[0], storage, null); return storage; }
From source file:ch.acanda.eclipse.pmd.java.resolution.ASTQuickFixTestCase.java
License:Open Source License
private CompilationUnit createAST(final org.eclipse.jface.text.Document document, final ASTQuickFix<ASTNode> quickFix) { final ASTParser astParser = ASTParser.newParser(AST.JLS4); astParser.setSource(document.get().toCharArray()); astParser.setKind(ASTParser.K_COMPILATION_UNIT); astParser.setResolveBindings(quickFix.needsTypeResolution()); astParser.setEnvironment(new String[0], new String[0], new String[0], true); final String name = last(params.pmdReferenceId.or("QuickFixTest").split("/")); astParser.setUnitName(format("{0}.java", name)); final String version = last(params.language.or("java 1.7").split("\\s+")); astParser.setCompilerOptions(ImmutableMap.<String, String>builder().put(JavaCore.COMPILER_SOURCE, version) .put(JavaCore.COMPILER_COMPLIANCE, version).put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, version) .build());// ww w . j a va 2 s . c om final CompilationUnit ast = (CompilationUnit) astParser.createAST(null); ast.recordModifications(); return ast; }
From source file:ch.acanda.eclipse.pmd.java.resolution.TextEditQuickFixTestCase.java
License:Open Source License
private CompilationUnit createAST(final org.eclipse.jface.text.Document document) { final ASTParser astParser = ASTParser.newParser(AST.JLS4); astParser.setKind(ASTParser.K_COMPILATION_UNIT); astParser.setSource(document.get().toCharArray()); astParser.setCompilerOptions(/*w ww .j a v a 2 s . c o m*/ ImmutableMap.<String, String>builder().put(JavaCore.COMPILER_SOURCE, "1.7").build()); final CompilationUnit ast = (CompilationUnit) astParser.createAST(null); ast.recordModifications(); return ast; }
From source file:chibi.gumtreediff.gen.jdt.AbstractJdtTreeGenerator.java
License:Open Source License
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) public TreeContext generate(Reader r) throws IOException { ASTParser parser = ASTParser.newParser(AST.JLS8); parser.setKind(ASTParser.K_COMPILATION_UNIT); Map pOptions = JavaCore.getOptions(); pOptions.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8); pOptions.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8); pOptions.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8); pOptions.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); parser.setCompilerOptions(pOptions); parser.setSource(readerToCharArray(r)); AbstractJdtVisitor v = createVisitor(); CompilationUnit c = (CompilationUnit) parser.createAST(null); v.setTreeRoot(c);/*from w w w .j a v a 2s . c o m*/ c.accept(v); return v.getTreeContext(); }
From source file:cideplus.ui.astview.ASTView.java
License:Open Source License
private int getInitialASTLevel(ITypeRoot typeRoot) { String option = typeRoot.getJavaProject().getOption(JavaCore.COMPILER_SOURCE, true); if (option.compareTo(JavaCore.VERSION_1_5) >= 0) { return JLS3; }//from w ww. j a va 2 s.com return fCurrentASTLevel; // use previous level }