Java Code Examples for org.eclipse.jdt.core.JavaCore#getOption()
The following examples show how to use
org.eclipse.jdt.core.JavaCore#getOption() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaSourceViewerConfiguration.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) { IJavaProject project= getProject(); final int tabWidth= CodeFormatterUtil.getTabWidth(project); final int indentWidth= CodeFormatterUtil.getIndentWidth(project); boolean allowTabs= tabWidth <= indentWidth; String indentMode; if (project == null) indentMode= JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR); else indentMode= project.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, true); boolean useSpaces= JavaCore.SPACE.equals(indentMode) || DefaultCodeFormatterConstants.MIXED.equals(indentMode); Assert.isLegal(allowTabs || useSpaces); if (!allowTabs) { char[] spaces= new char[indentWidth]; Arrays.fill(spaces, ' '); return new String[] { new String(spaces), "" }; //$NON-NLS-1$ } else if (!useSpaces) return getIndentPrefixesForTab(tabWidth); else return getIndentPrefixesForSpaces(tabWidth); }
Example 2
Source File: StubUtility.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static String getTodoTaskTag(IJavaProject project) { String markers= null; if (project == null) { markers= JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS); } else { markers= project.getOption(JavaCore.COMPILER_TASK_TAGS, true); } if (markers != null && markers.length() > 0) { int idx= markers.indexOf(','); if (idx == -1) { return markers; } else { return markers.substring(0, idx); } } return null; }
Example 3
Source File: ModuleUtils.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
/** * Validates a simple module name. The name should be a camel-cased valid Java identifier. * * @param simpleName the simple module name * @return a status object with code <code>IStatus.OK</code> if the given name is valid, otherwise * a status object indicating what is wrong with the name */ public static IStatus validateSimpleModuleName(String simpleName) { String complianceLevel = JavaCore.getOption("org.eclipse.jdt.core.compiler.compliance"); String sourceLevel = JavaCore.getOption("org.eclipse.jdt.core.compiler.source"); // Make sure that the simple name does not have any dots in it. We need // to do this validation before passing the simpleName to JavaConventions, // because validateTypeName accepts both simple and fully-qualified type // names. if (simpleName.indexOf('.') != -1) { return Util.newErrorStatus("Module name should not contain dots."); } // Validate the module name according to Java type name conventions IStatus nameStatus = JavaConventions.validateJavaTypeName(simpleName, complianceLevel, sourceLevel); if (nameStatus.matches(IStatus.ERROR)) { return Util.newErrorStatus("The module name is invalid"); } return Status.OK_STATUS; }
Example 4
Source File: JavaConventionsUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * @param context an {@link IJavaElement} or <code>null</code> * @return a <code>String[]</code> whose <code>[0]</code> is the * {@link JavaCore#COMPILER_SOURCE} and whose <code>[1]</code> is * the {@link JavaCore#COMPILER_COMPLIANCE} level at the given * <code>context</code>. */ public static String[] getSourceComplianceLevels(IJavaElement context) { if (context != null) { IJavaProject javaProject= context.getJavaProject(); if (javaProject != null) { return new String[] { javaProject.getOption(JavaCore.COMPILER_SOURCE, true), javaProject.getOption(JavaCore.COMPILER_COMPLIANCE, true) }; } } return new String[] { JavaCore.getOption(JavaCore.COMPILER_SOURCE), JavaCore.getOption(JavaCore.COMPILER_COMPLIANCE) }; }
Example 5
Source File: XbaseValidationConfigurationBlock.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected String javaValue(final String javaIssueCode) { String delegatedValue; String decodedDelegateKey = XbaseSeverityConverter.decodeDelegationKey(javaIssueCode).getFirst(); IJavaProject javaProject = JavaCore.create(getProject()); if (javaProject != null && javaProject.exists() && javaProject.getProject().isAccessible()) { delegatedValue = javaProject.getOption(decodedDelegateKey, true); } else { delegatedValue = JavaCore.getOption(decodedDelegateKey); } return delegatedValue; }
Example 6
Source File: CompilationUnitEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected boolean isTabsToSpacesConversionEnabled() { IJavaElement element= getInputJavaElement(); IJavaProject project= element == null ? null : element.getJavaProject(); String option; if (project == null) option= JavaCore.getOption(SPACES_FOR_TABS); else option= project.getOption(SPACES_FOR_TABS, true); return JavaCore.SPACE.equals(option); }
Example 7
Source File: XbaseBuilderConfigurationBlock.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected String javaValue(final String javaPreference) { IJavaProject javaProject = JavaCore.create(getProject()); if (javaProject != null && javaProject.exists() && javaProject.getProject().isAccessible()) { return javaProject.getOption(javaPreference, true); } else { return JavaCore.getOption(javaPreference); } }
Example 8
Source File: Util.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
public static boolean isValidMethodName(String methodName) { String complianceLevel = JavaCore.getOption("org.eclipse.jdt.core.compiler.compliance"); String sourceLevel = JavaCore.getOption("org.eclipse.jdt.core.compiler.source"); return JavaConventions.validateMethodName(methodName, sourceLevel, complianceLevel).isOK(); }
Example 9
Source File: Util.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
public static boolean isValidTypeName(String typeName) { String complianceLevel = JavaCore.getOption("org.eclipse.jdt.core.compiler.compliance"); String sourceLevel = JavaCore.getOption("org.eclipse.jdt.core.compiler.source"); return JavaConventions.validateJavaTypeName(typeName, sourceLevel, complianceLevel).isOK(); }
Example 10
Source File: TestingEnvironment.java From dacapobench with Apache License 2.0 | 5 votes |
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; }
Example 11
Source File: MainProjectWizardPage.java From sarl with Apache License 2.0 | 4 votes |
@SuppressWarnings("synthetic-access") public void handlePossibleJVMChange() { if (JavaRuntime.getDefaultVMInstall() == null) { this.fHintText.setText(NewWizardMessages.NewJavaProjectWizardPageOne_NoJREFound_link); this.fHintText.setVisible(true); this.icon.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING)); this.icon.setVisible(true); return; } String selectedCompliance = MainProjectWizardPage.this.jreGroup.getSelectedCompilerCompliance(); if (selectedCompliance != null) { final String defaultCompliance = JavaCore.getOption(JavaCore.COMPILER_COMPLIANCE); if (selectedCompliance.equals(defaultCompliance)) { this.fHintText.setVisible(false); this.icon.setVisible(false); } else { this.fHintText.setText(MessageFormat.format( NewWizardMessages.NewJavaProjectWizardPageOne_DetectGroup_differendWorkspaceCC_message, TextProcessor.process(defaultCompliance), TextProcessor.process(selectedCompliance))); this.fHintText.setVisible(true); this.icon.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_INFO)); this.icon.setVisible(true); } return; } selectedCompliance = JavaCore.getOption(JavaCore.COMPILER_COMPLIANCE); IVMInstall selectedJVM = MainProjectWizardPage.this.jreGroup.getSelectedJVM(); if (selectedJVM == null) { selectedJVM = JavaRuntime.getDefaultVMInstall(); } String jvmCompliance = SARLVersion.MINIMAL_JDK_VERSION_IN_SARL_PROJECT_CLASSPATH; if (selectedJVM instanceof IVMInstall2) { jvmCompliance = JavaModelUtil.getCompilerCompliance((IVMInstall2) selectedJVM, SARLVersion.MINIMAL_JDK_VERSION_IN_SARL_PROJECT_CLASSPATH); } if (!selectedCompliance.equals(jvmCompliance) && (JavaModelUtil.is50OrHigher(selectedCompliance) || JavaModelUtil.is50OrHigher(jvmCompliance))) { this.fHintText.setText(MessageFormat.format( NewWizardMessages.NewJavaProjectWizardPageOne_DetectGroup_jre_message, TextProcessor.process(selectedCompliance), TextProcessor.process(jvmCompliance))); this.fHintText.setVisible(true); this.icon.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING)); this.icon.setVisible(true); } else { this.fHintText.setVisible(false); this.icon.setVisible(false); } }
Example 12
Source File: NewJavaProjectWizardPageOne.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public void handlePossibleJVMChange() { if (JavaRuntime.getDefaultVMInstall() == null) { fHintText.setText(NewWizardMessages.NewJavaProjectWizardPageOne_NoJREFound_link); fHintText.setVisible(true); fIcon.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING)); fIcon.setVisible(true); return; } String selectedCompliance= fJREGroup.getSelectedCompilerCompliance(); if (selectedCompliance != null) { String defaultCompliance= JavaCore.getOption(JavaCore.COMPILER_COMPLIANCE); if (selectedCompliance.equals(defaultCompliance)) { fHintText.setVisible(false); fIcon.setVisible(false); } else { fHintText.setText(Messages.format(NewWizardMessages.NewJavaProjectWizardPageOne_DetectGroup_differendWorkspaceCC_message, new String[] { BasicElementLabels.getVersionName(defaultCompliance), BasicElementLabels.getVersionName(selectedCompliance)})); fHintText.setVisible(true); fIcon.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_INFO)); fIcon.setVisible(true); } return; } selectedCompliance= JavaCore.getOption(JavaCore.COMPILER_COMPLIANCE); IVMInstall selectedJVM= fJREGroup.getSelectedJVM(); if (selectedJVM == null) { selectedJVM= JavaRuntime.getDefaultVMInstall(); } String jvmCompliance= JavaCore.VERSION_1_4; if (selectedJVM instanceof IVMInstall2) { jvmCompliance= JavaModelUtil.getCompilerCompliance((IVMInstall2) selectedJVM, JavaCore.VERSION_1_4); } if (!selectedCompliance.equals(jvmCompliance) && (JavaModelUtil.is50OrHigher(selectedCompliance) || JavaModelUtil.is50OrHigher(jvmCompliance))) { fHintText.setText(Messages.format(NewWizardMessages.NewJavaProjectWizardPageOne_DetectGroup_jre_message, new String[] {BasicElementLabels.getVersionName(selectedCompliance), BasicElementLabels.getVersionName(jvmCompliance)})); fHintText.setVisible(true); fIcon.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING)); fIcon.setVisible(true); } else { fHintText.setVisible(false); fIcon.setVisible(false); } }
Example 13
Source File: JavaModelUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private static String getSourceCompliance(IJavaProject project) { return project != null ? project.getOption(JavaCore.COMPILER_SOURCE, true) : JavaCore.getOption(JavaCore.COMPILER_SOURCE); }
Example 14
Source File: TypeFilterPreferencePage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private boolean getJDTCoreOption(String option, boolean fromDefault) { Object value= fromDefault ? JavaCore.getDefaultOptions().get(option) : JavaCore.getOption(option); return JavaCore.ENABLED.equals(value); }
Example 15
Source File: FillArgumentNamesCompletionProposalCollector.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 3 votes |
/** * Returns <code>true</code> if generic proposals should be allowed, * <code>false</code> if not. Note that even though code (in a library) * may be referenced that uses generics, it is still possible that the * current source does not allow generics. * * @param project the Java project * @return <code>true</code> if the generic proposals should be allowed, * <code>false</code> if not */ private final boolean shouldProposeGenerics(IJavaProject project) { String sourceVersion; if (project != null) sourceVersion= project.getOption(JavaCore.COMPILER_SOURCE, true); else sourceVersion= JavaCore.getOption(JavaCore.COMPILER_SOURCE); return JavaModelUtil.is50OrHigher(sourceVersion); }
Example 16
Source File: CodeFormatterUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Returns the possibly <code>project</code>-specific core preference defined under <code>key</code>. * * @param project * the project to get the preference from, * or <code>null</code> to get the global preference * @param key * the key of the preference * @return the value of the preference * @since 3.1 */ private static String getCoreOption(IJavaProject project, String key) { if (project == null) return JavaCore.getOption(key); return project.getOption(key, true); }
Example 17
Source File: AbstractJavaCompletionProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Returns true if camel case matching is enabled. * * @return <code>true</code> if camel case matching is enabled * @since 3.2 */ protected boolean isCamelCaseMatching() { String value= JavaCore.getOption(JavaCore.CODEASSIST_CAMEL_CASE_MATCH); return JavaCore.ENABLED.equals(value); }
Example 18
Source File: JavaAutoIndentStrategy.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Returns the possibly <code>project</code>-specific core preference defined under * <code>key</code>. * * @param project the project to get the preference from, or <code>null</code> to get the global * preference * @param key the key of the preference * @return the value of the preference * @since 3.5 */ private static String getCoreOption(IJavaProject project, String key) { if (project == null) return JavaCore.getOption(key); return project.getOption(key, true); }
Example 19
Source File: JavaIndenter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Returns the possibly project-specific core preference defined under <code>key</code>. * * @param key the key of the preference * @return the value of the preference * @since 3.1 */ private String getCoreFormatterOption(String key) { if (fProject == null) return JavaCore.getOption(key); return fProject.getOption(key, true); }
Example 20
Source File: IndentAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Returns the possibly project-specific core preference defined under <code>key</code>. * * @param key the key of the preference * @param project the project to retrieve the indentation settings from, <b>null</b> for workspace settings * @return the value of the preference * @since 3.1 */ private static String getCoreFormatterOption(String key, IJavaProject project) { if (project == null) return JavaCore.getOption(key); return project.getOption(key, true); }