List of usage examples for org.eclipse.jdt.core IJavaProject getOptions
Map<String, String> getOptions(boolean inheritJavaCoreOptions);
From source file:org.eclipse.wb.internal.core.utils.jdt.core.ProjectUtils.java
License:Open Source License
/** * @return the {@link IJavaProject} options {@link Map}. *//*from ww w . j a va 2 s .com*/ @SuppressWarnings("unchecked") public static Map<String, String> getOptions(IJavaProject project) { return project.getOptions(true); }
From source file:org.eclipse.xtend.ide.javaconverter.EclipseASTParserFactory.java
License:Open Source License
public void tweakOptions(final ASTParser parser, final IJavaProject project) { if ((project != null)) { final Map options = project.getOptions(true); options.remove(JavaCore.COMPILER_TASK_TAGS); options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); parser.setCompilerOptions(options); }//www. ja v a2 s. c om }
From source file:org.eclipse.xtend.ide.tests.WorkbenchTestHelper.java
License:Open Source License
public static void makeCompliantFor(IJavaProject javaProject, JavaVersion javaVersion) { @SuppressWarnings("unchecked") Map<String, String> options = javaProject.getOptions(false); String jreLevel = javaVersion.getQualifier(); options.put(JavaCore.COMPILER_COMPLIANCE, jreLevel); options.put(JavaCore.COMPILER_SOURCE, jreLevel); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, jreLevel); options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); options.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_LINE_NUMBER_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_SOURCE_FILE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL, JavaCore.PRESERVE); javaProject.setOptions(options);//w ww .j a v a2 s . co m }
From source file:org.eclipse.xtend.performance.tests.PerformanceTestProjectSetup.java
License:Open Source License
public static void makeJava5Compliant(IJavaProject javaProject) { @SuppressWarnings("unchecked") Map<String, String> options = javaProject.getOptions(false); options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); options.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_LINE_NUMBER_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_SOURCE_FILE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL, JavaCore.PRESERVE); javaProject.setOptions(options);/* w w w . j a va 2 s . c o m*/ }
From source file:org.eclipse.xtext.common.types.access.jdt.JdtBasedTypeFactory.java
License:Open Source License
@SuppressWarnings("unchecked") private IBinding resolveBindings(IType jdtType, IJavaProject javaProject) { ThreadLocal<Boolean> abortOnMissingSource = JavaModelManager.getJavaModelManager().abortOnMissingSource; Boolean wasAbortOnMissingSource = abortOnMissingSource.get(); try {//from www . jav a 2 s . c o m abortOnMissingSource.set(Boolean.TRUE); resolveBinding.start(); parser.setWorkingCopyOwner(workingCopyOwner); parser.setIgnoreMethodBodies(true); parser.setProject(javaProject); Map<String, String> options = javaProject.getOptions(true); options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.DISABLED); parser.setCompilerOptions(options); IBinding[] bindings = parser.createBindings(new IJavaElement[] { jdtType }, null); resolveBinding.stop(); return bindings[0]; } finally { abortOnMissingSource.set(wasAbortOnMissingSource); } }
From source file:org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.java
License:Open Source License
public static void makeJava5Compliant(IJavaProject javaProject) { Map<String, String> options = javaProject.getOptions(false); options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); options.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_LINE_NUMBER_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_SOURCE_FILE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL, JavaCore.PRESERVE); javaProject.setOptions(options);/*from ww w .j av a2s . c o m*/ }
From source file:org.eclipse.xtext.xbase.ui.hover.XbaseHoverDocumentationProvider.java
License:Open Source License
public Javadoc getJavaDoc() { if (context == null || context.eResource() == null || context.eResource().getResourceSet() == null) return null; Object classpathURIContext = ((XtextResourceSet) context.eResource().getResourceSet()) .getClasspathURIContext();/* w ww . j a v a 2s . c om*/ if (classpathURIContext instanceof IJavaProject) { IJavaProject javaProject = (IJavaProject) classpathURIContext; @SuppressWarnings("all") ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setProject(javaProject); @SuppressWarnings("unchecked") Map<String, String> options = javaProject.getOptions(true); options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=212207 parser.setCompilerOptions(options); String source = rawJavaDoc + "class C{}"; //$NON-NLS-1$ parser.setSource(source.toCharArray()); CompilationUnit root = (CompilationUnit) parser.createAST(null); if (root == null) return null; @SuppressWarnings("unchecked") List<AbstractTypeDeclaration> types = root.types(); if (types.size() != 1) return null; AbstractTypeDeclaration type = types.get(0); return type.getJavadoc(); } return null; }
From source file:org.eclipselabs.nullness.equinox.JavaProjectAnnotationSet.java
License:Open Source License
public JavaProjectAnnotationSet(IJavaProject project) { Map<?, ?> options = project.getOptions(true); defaultNonNullAnnotation = getOption(options, JavaCore.COMPILER_NONNULL_BY_DEFAULT_ANNOTATION_NAME); nonNullAnnotation = getOption(options, JavaCore.COMPILER_NONNULL_ANNOTATION_NAME); nullableAnnotation = getOption(options, JavaCore.COMPILER_NULLABLE_ANNOTATION_NAME); }
From source file:org.entirej.ide.ui.editors.form.builder.EJFormConstBuilder.java
License:Apache License
static void buildPropertiesConstant(IJavaProject project, EJPluginEntireJProperties entireJProperties, IFile file, IProgressMonitor monitor) { String propID = "EJ_PROPERTIES"; try {//w w w. j a va 2 s. com IFile javaFile = getPropertiesJavaSource(file, monitor, propID); StringBuilder builder = new StringBuilder(); builder.append("package "); builder.append(javaFile.getParent().getProjectRelativePath().toString().replaceFirst("src/", "") .replaceAll("/", ".")); builder.append(";"); builder.append("\n"); builder.append("\n"); builder.append("/* AUTO-GENERATED FILE. DO NOT MODIFY. \n"); builder.append("*\n"); builder.append("* This class was automatically generated by the\n"); builder.append("* entirej plugin from the EntireJProperties. It\n"); builder.append("* should not be modified by hand.\n"); builder.append(" */"); builder.append("\n"); builder.append("public class "); builder.append(propID); builder.append("\n"); builder.append("{"); builder.append("\n"); Set<String> actions = new TreeSet<String>(); // adding menu id's parameters for (EJPluginMenuProperties menuProperties : entireJProperties.getPluginMenuContainer() .getAllMenuProperties()) { if (menuProperties.getName() != null && menuProperties.getName().trim().length() > 0) { builder.append(" public static final String M_"); builder.append(toVAR(menuProperties.getName()).toUpperCase().replaceAll(" ", "_")); builder.append(" = "); builder.append("\""); builder.append(menuProperties.getName()); builder.append("\""); builder.append(";"); builder.append("\n"); } addActionsFromMenuProperties(menuProperties, actions); } builder.append("\n"); // adding form parameters Collection<EJPluginApplicationParameter> formParameters = entireJProperties .getAllApplicationLevelParameters(); for (EJPluginApplicationParameter parameter : formParameters) { if (parameter.getName() != null && parameter.getName().trim().length() > 0) { builder.append(" public static final String P_"); builder.append(toVAR(parameter.getName()).toUpperCase().replaceAll(" ", "_")); builder.append(" = "); builder.append("\""); builder.append(parameter.getName()); builder.append("\""); builder.append(";"); builder.append("\n"); } } builder.append("\n"); // adding VA Collection<String> visualAttributeNames = entireJProperties.getVisualAttributesContainer() .getVisualAttributeNames(); for (String va : visualAttributeNames) { if (va != null && va.trim().length() > 0) { builder.append(" public static final String VA_"); builder.append(toVAR(va).toUpperCase().replaceAll(" ", "_")); builder.append(" = "); builder.append("\""); builder.append(va); builder.append("\""); builder.append(";"); builder.append("\n"); } } builder.append("\n"); // adding Actions for (String action : actions) { builder.append(" public static final String AC_"); builder.append(toVAR(action).toUpperCase().replaceAll(" ", "_")); builder.append(" = "); builder.append("\""); builder.append(action); builder.append("\""); builder.append(";"); builder.append("\n"); } builder.append("\n"); builder.append("}"); String classContent = builder.toString(); CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(project.getOptions(true)); IDocument doc = new Document(classContent); TextEdit edit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT, doc.get(), 0, doc.get().length(), 0, null); if (edit != null) { edit.apply(doc); classContent = doc.get(); } if (javaFile.exists()) { try { if (classContent.equals(getStringFromInputStream(javaFile.getContents(true)))) return; } catch (Exception e) { // ignore } javaFile.setContents(new ByteArrayInputStream(classContent.toString().getBytes("UTF-8")), IResource.FORCE, monitor); } else { javaFile.create(new ByteArrayInputStream(classContent.toString().getBytes("UTF-8")), IResource.FORCE, monitor); } } catch (Exception e) { EJCoreLog.logException(e); } }
From source file:org.entirej.ide.ui.editors.form.builder.EJFormConstBuilder.java
License:Apache License
static void buildFormConstant(IJavaProject project, EJPluginFormProperties formProperties, IFile file, IProgressMonitor monitor) {/*from ww w .ja v a 2 s. c o m*/ String formID = getFormId(formProperties); try { IFile javaFile = getFormJavaSource(file, monitor, formID); StringBuilder builder = new StringBuilder(); builder.append("package "); builder.append(javaFile.getParent().getProjectRelativePath().toString().replaceFirst("src/", "") .replaceAll("/", ".")); builder.append(";"); builder.append("\n"); builder.append("\n"); builder.append("/* AUTO-GENERATED FILE. DO NOT MODIFY. \n"); builder.append("*\n"); builder.append("* This class was automatically generated by the\n"); builder.append("* entirej plugin from the form. It\n"); builder.append("* should not be modified by hand.\n"); builder.append(" */"); builder.append("\n"); builder.append("public class "); builder.append(formID); builder.append("\n"); builder.append("{"); builder.append("\n"); // add Form ID builder.append(" public static final String ID = "); builder.append("\""); builder.append(formProperties.getFormName()); builder.append("\""); builder.append(";"); Set<String> actions = new TreeSet<String>(); // process Form renderer Properties String renderer = formProperties.getFormRendererName(); if (renderer != null && renderer.trim().length() > 0) { EJRendererAssignment assignment = formProperties.getEntireJProperties() .getApplicationAssignedFormRenderer(renderer); if (assignment != null) { EJDevFormRendererDefinition rendererDefinition = ExtensionsPropertiesFactory .loadFormRendererDefinition(formProperties.getEntireJProperties(), formProperties.getFormRendererName()); EJFrameworkExtensionProperties rendererProperties = formProperties.getFormRendererProperties(); if (rendererDefinition != null && rendererProperties != null) { addActionsFromRendererProperties(formProperties, null, rendererDefinition.getFormPropertyDefinitionGroup(), rendererProperties, actions); } } } // / // build Block List<EJPluginBlockProperties> allBlockProperties = formProperties.getBlockContainer() .getAllBlockProperties(); for (EJPluginBlockProperties blockProp : allBlockProperties) { if (blockProp.getName() != null && blockProp.getName().length() > 0) { createBlockCode(blockProp, builder); EJDevBlockRendererDefinition rendererDefinition = blockProp.getBlockRendererDefinition(); EJFrameworkExtensionProperties rendererProperties = blockProp.getBlockRendererProperties(); if (rendererDefinition != null && rendererProperties != null) { addActionsFromRendererProperties(formProperties, blockProp, rendererDefinition.getBlockPropertyDefinitionGroup(), rendererProperties, actions); List<EJPluginItemGroupProperties> itemGroups = blockProp .getMainScreenItemGroupDisplayContainer().getItemGroups(); EJPropertyDefinitionGroup propertyDefinitionGroup = rendererDefinition .getItemPropertiesDefinitionGroup(); for (EJPluginItemGroupProperties groupProperties : itemGroups) { addActionsFromItemGroupProperties(formProperties, rendererDefinition.getItemGroupPropertiesDefinitionGroup(), propertyDefinitionGroup, groupProperties, actions); } } rendererDefinition = null; if (blockProp.isInsertAllowed()) { EJDevInsertScreenRendererDefinition insertRendererDefinition = blockProp .getInsertScreenRendererDefinition(); rendererProperties = blockProp.getInsertScreenRendererProperties(); if (insertRendererDefinition != null && rendererProperties != null) { addActionsFromRendererProperties(formProperties, blockProp, insertRendererDefinition.getInsertScreenPropertyDefinitionGroup(), rendererProperties, actions); List<EJPluginItemGroupProperties> itemGroups = blockProp .getInsertScreenItemGroupDisplayContainer().getItemGroups(); EJPropertyDefinitionGroup propertyDefinitionGroup = insertRendererDefinition .getItemPropertyDefinitionGroup(); for (EJPluginItemGroupProperties groupProperties : itemGroups) { addActionsFromItemGroupProperties(formProperties, insertRendererDefinition.getItemGroupPropertiesDefinitionGroup(), propertyDefinitionGroup, groupProperties, actions); } } insertRendererDefinition = null; } if (blockProp.isUpdateAllowed()) { EJDevUpdateScreenRendererDefinition updateRendererDefinition = blockProp .getUpdateScreenRendererDefinition(); rendererProperties = blockProp.getUpdateScreenRendererProperties(); if (updateRendererDefinition != null && rendererProperties != null) { addActionsFromRendererProperties(formProperties, blockProp, updateRendererDefinition.getUpdateScreenPropertyDefinitionGroup(), rendererProperties, actions); List<EJPluginItemGroupProperties> itemGroups = blockProp .getUpdateScreenItemGroupDisplayContainer().getItemGroups(); EJPropertyDefinitionGroup propertyDefinitionGroup = updateRendererDefinition .getItemPropertyDefinitionGroup(); for (EJPluginItemGroupProperties groupProperties : itemGroups) { addActionsFromItemGroupProperties(formProperties, updateRendererDefinition.getItemGroupPropertiesDefinitionGroup(), propertyDefinitionGroup, groupProperties, actions); } } updateRendererDefinition = null; } if (blockProp.isQueryAllowed()) { EJDevQueryScreenRendererDefinition queryRendererDefinition = blockProp .getQueryScreenRendererDefinition(); rendererProperties = blockProp.getQueryScreenRendererProperties(); if (queryRendererDefinition != null && rendererProperties != null) { addActionsFromRendererProperties(formProperties, blockProp, queryRendererDefinition.getQueryScreenPropertyDefinitionGroup(), rendererProperties, actions); List<EJPluginItemGroupProperties> itemGroups = blockProp .getQueryScreenItemGroupDisplayContainer().getItemGroups(); EJPropertyDefinitionGroup propertyDefinitionGroup = queryRendererDefinition .getItemPropertyDefinitionGroup(); for (EJPluginItemGroupProperties groupProperties : itemGroups) { addActionsFromItemGroupProperties(formProperties, queryRendererDefinition.getItemGroupPropertiesDefinitionGroup(), propertyDefinitionGroup, groupProperties, actions); } } queryRendererDefinition = null; } } List<EJPluginBlockItemProperties> allItemProperties = blockProp.getItemContainer() .getAllItemProperties(); for (EJPluginBlockItemProperties itemProp : allItemProperties) { String itemRenderer = itemProp.getItemRendererName(); if (itemRenderer == null || itemRenderer.trim().length() == 0) { continue; } EJRendererAssignment assignment = formProperties.getEntireJProperties() .getApplicationAssignedItemRenderer(itemRenderer); if (assignment == null) { continue; } EJDevItemRendererDefinition rendererDefinition = itemProp.getItemRendererDefinition(); EJFrameworkExtensionProperties rendererProperties = itemProp.getItemRendererProperties(); if (rendererDefinition != null && rendererProperties != null) { addActionsFromRendererProperties(formProperties, blockProp, rendererDefinition.getItemPropertyDefinitionGroup(), rendererProperties, actions); } } for (EJScreenType screenType : EJScreenType.values()) { for (String itemName : blockProp.getScreenItemNames(screenType)) { EJScreenItemProperties itemProperties = blockProp.getScreenItemProperties(screenType, itemName); if (itemProperties != null && itemProperties.getActionCommand() != null && itemProperties.getActionCommand().trim().length() > 0) { actions.add(itemProperties.getActionCommand()); } } } } // build LOV // build Block List<EJPluginLovDefinitionProperties> lovDefinitionProperties = formProperties .getLovDefinitionContainer().getAllLovDefinitionProperties(); for (EJPluginLovDefinitionProperties definitionProperties : lovDefinitionProperties) { if (definitionProperties.getName() != null && definitionProperties.getName().length() > 0) { createLovCode(definitionProperties, builder); } } // read canvas Collection<EJCanvasProperties> allCanvasProperties = EJPluginCanvasRetriever .retriveAllCanvases(formProperties); for (EJCanvasProperties canvasProperties : allCanvasProperties) { if (canvasProperties.getName() != null && canvasProperties.getName().length() > 0) { builder.append(" public static final String C_"); builder.append(toVAR(canvasProperties.getName()).toUpperCase().replaceAll(" ", "_")); builder.append(" = "); builder.append("\""); builder.append(canvasProperties.getName()); builder.append("\""); builder.append(";"); builder.append("\n"); switch (canvasProperties.getType()) { case TAB: Collection<EJTabPageProperties> allTabPageProperties = canvasProperties .getTabPageContainer().getAllTabPageProperties(); builder.append("\n"); builder.append("public static class "); builder.append("C_"); builder.append(toVAR(canvasProperties.getName()).toUpperCase().replaceAll(" ", "_")); builder.append("_PAGES"); builder.append("\n"); builder.append("{"); builder.append("\n"); for (EJTabPageProperties page : allTabPageProperties) { if (page.getName() != null && page.getName().length() > 0) { builder.append(" public static final String "); builder.append(toVAR(page.getName()).toUpperCase().replaceAll(" ", "_")); builder.append(" = "); builder.append("\""); builder.append(page.getName()); builder.append("\""); builder.append(";"); builder.append("\n"); } } builder.append("\n"); builder.append("}"); builder.append("\n"); break; case STACKED: Collection<EJStackedPageProperties> allStackedPageProperties = canvasProperties .getStackedPageContainer().getAllStackedPageProperties(); builder.append("\n"); builder.append("public static class "); builder.append("C_"); builder.append(toVAR(canvasProperties.getName()).toUpperCase().replaceAll(" ", "_")); builder.append("_PAGES"); builder.append("\n"); builder.append("{"); builder.append("\n"); for (EJStackedPageProperties page : allStackedPageProperties) { if (page.getName() != null && page.getName().length() > 0) { builder.append(" public static final String "); builder.append(toVAR(page.getName()).toUpperCase().replaceAll(" ", "_")); builder.append(" = "); builder.append("\""); builder.append(page.getName()); builder.append("\""); builder.append(";"); builder.append("\n"); } } builder.append("\n"); builder.append("}"); builder.append("\n"); break; default: break; } } } builder.append("\n"); // adding Actions for (String action : actions) { builder.append(" public static final String AC_"); builder.append(toVAR(action).toUpperCase().replaceAll(" ", "_")); builder.append(" = "); builder.append("\""); builder.append(action); builder.append("\""); builder.append(";"); builder.append("\n"); } builder.append("\n"); // adding form parameters Collection<EJPluginApplicationParameter> formParameters = formProperties.getAllFormParameters(); for (EJPluginApplicationParameter parameter : formParameters) { if (parameter.getName() != null && parameter.getName().trim().length() > 0) { builder.append(" public static final String P_"); builder.append(toVAR(parameter.getName()).toUpperCase().replaceAll(" ", "_")); builder.append(" = "); builder.append("\""); builder.append(parameter.getName()); builder.append("\""); builder.append(";"); builder.append("\n"); } } builder.append("\n"); builder.append("}"); String classContent = builder.toString(); CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(project.getOptions(true)); IDocument doc = new Document(classContent); TextEdit edit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT, doc.get(), 0, doc.get().length(), 0, null); if (edit != null) { edit.apply(doc); classContent = doc.get(); } if (javaFile.exists()) { try { if (classContent.equals(getStringFromInputStream(javaFile.getContents(true)))) return; } catch (Exception e) { // ignore } javaFile.setContents(new ByteArrayInputStream(classContent.toString().getBytes("UTF-8")), IResource.FORCE, monitor); } else { javaFile.create(new ByteArrayInputStream(classContent.toString().getBytes("UTF-8")), IResource.FORCE, monitor); } } catch (Exception e) { EJCoreLog.logException(e); } }