Java Code Examples for org.eclipse.jdt.core.JavaCore#VERSION_1_7

The following examples show how to use org.eclipse.jdt.core.JavaCore#VERSION_1_7 . 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: JavaModelUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static String getCompilerCompliance(IVMInstall2 vMInstall, String defaultCompliance) {
	String version= vMInstall.getJavaVersion();
	if (version == null) {
		return defaultCompliance;
	} else if (version.startsWith(JavaCore.VERSION_1_8)) {
		return JavaCore.VERSION_1_8;
	} else if (version.startsWith(JavaCore.VERSION_1_7)) {
		return JavaCore.VERSION_1_7;
	} else if (version.startsWith(JavaCore.VERSION_1_6)) {
		return JavaCore.VERSION_1_6;
	} else if (version.startsWith(JavaCore.VERSION_1_5)) {
		return JavaCore.VERSION_1_5;
	} else if (version.startsWith(JavaCore.VERSION_1_4)) {
		return JavaCore.VERSION_1_4;
	} else if (version.startsWith(JavaCore.VERSION_1_3)) {
		return JavaCore.VERSION_1_3;
	} else if (version.startsWith(JavaCore.VERSION_1_2)) {
		return JavaCore.VERSION_1_3;
	} else if (version.startsWith(JavaCore.VERSION_1_1)) {
		return JavaCore.VERSION_1_3;
	}
	return defaultCompliance;
}
 
Example 2
Source File: JavaModelUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static String getExecutionEnvironmentCompliance(IExecutionEnvironment executionEnvironment) {
	Map<String, String> complianceOptions= executionEnvironment.getComplianceOptions();
	if (complianceOptions != null) {
		Object compliance= complianceOptions.get(JavaCore.COMPILER_COMPLIANCE);
		if (compliance instanceof String)
			return (String)compliance;
	}
	
	// fallback:
	String desc= executionEnvironment.getId();
	if (desc.indexOf(JavaCore.VERSION_1_8) != -1) {
		return JavaCore.VERSION_1_8;
	} else if (desc.indexOf(JavaCore.VERSION_1_7) != -1) {
		return JavaCore.VERSION_1_7;
	} else if (desc.indexOf(JavaCore.VERSION_1_6) != -1) {
		return JavaCore.VERSION_1_6;
	} else if (desc.indexOf(JavaCore.VERSION_1_5) != -1) {
		return JavaCore.VERSION_1_5;
	} else if (desc.indexOf(JavaCore.VERSION_1_4) != -1) {
		return JavaCore.VERSION_1_4;
	}
	return JavaCore.VERSION_1_3;
}
 
Example 3
Source File: JavaASTUtil.java    From compiler with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
public static ASTParser buildParser(FileKind fileKind) {
	int astLevel = -1;
	String compliance = null;
	switch (fileKind) {
	case SOURCE_JAVA_JLS2:
		astLevel = AST.JLS2;
		compliance = JavaCore.VERSION_1_4;
		break;
	case SOURCE_JAVA_JLS3:
		astLevel = AST.JLS3;
		compliance = JavaCore.VERSION_1_5;
		break;
	case SOURCE_JAVA_JLS4:
		astLevel = AST.JLS4;
		compliance = JavaCore.VERSION_1_7;
		break;
	case SOURCE_JAVA_JLS8:
		astLevel = AST.JLS8;
		compliance = JavaCore.VERSION_1_8;
		break;
	default:
		break;
	}
	if (compliance != null) {
		ASTParser parser = ASTParser.newParser(astLevel);
		parser.setKind(ASTParser.K_COMPILATION_UNIT);

		final Map<?, ?> options = JavaCore.getOptions();
		JavaCore.setComplianceOptions(compliance, options);
		parser.setCompilerOptions(options);
		return parser;
	}
	return null;
}
 
Example 4
Source File: WorkbenchTestHelper.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Make the given project compliant for the given version.
 *
 * @param javaProject the project.
 * @param javaVersion the Java version.
 */
public static void makeCompliantFor(IJavaProject javaProject, JavaVersion javaVersion) {
	Map<String, String> options = javaProject.getOptions(false);
	String jreLevel;
	switch (javaVersion) {
	case JAVA8:
		jreLevel = JavaCore.VERSION_1_8;
		break;
	case JAVA6:
		jreLevel = JavaCore.VERSION_1_6;
		break;
	case JAVA5:
		jreLevel = JavaCore.VERSION_1_5;
		break;
	case JAVA7:
	default:
		jreLevel = JavaCore.VERSION_1_7;
	}
	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);
}
 
Example 5
Source File: JavadocSpecificsWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private void createExtraOptionsGroup(Composite composite) {
	Composite c= new Composite(composite, SWT.NONE);
	c.setLayout(createGridLayout(3));
	c.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 3, 0));
	((GridLayout) c.getLayout()).marginWidth= 0;

	fOverViewButton= createButton(c, SWT.CHECK, JavadocExportMessages.JavadocSpecificsWizardPage_overviewbutton_label, createGridData(1));
	fOverViewText= createText(c, SWT.SINGLE | SWT.BORDER, null, createGridData(GridData.FILL_HORIZONTAL, 1, 0));
	SWTUtil.setAccessibilityText(fOverViewText, JavadocExportMessages.JavadocSpecificsWizardPage_overviewbutton_description);
	//there really aught to be a way to specify this
	 ((GridData) fOverViewText.getLayoutData()).widthHint= 200;
	fOverViewBrowseButton= createButton(c, SWT.PUSH, JavadocExportMessages.JavadocSpecificsWizardPage_overviewbrowse_label, createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 0));
	SWTUtil.setButtonDimensionHint(fOverViewBrowseButton);

	String str= fStore.getOverview();
	if (str.length() == 0) {
		//default
		fOverViewText.setEnabled(false);
		fOverViewBrowseButton.setEnabled(false);
	} else {
		fOverViewButton.setSelection(true);
		fOverViewText.setText(str);
	}

	createLabel(composite, SWT.NONE, JavadocExportMessages.JavadocSpecificsWizardPage_vmoptionsfield_label, createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 3, 0));
	fVMOptionsText= createText(composite, SWT.SINGLE | SWT.BORDER, null, createGridData(GridData.HORIZONTAL_ALIGN_FILL, 3, 0));
	fVMOptionsText.setText(fStore.getVMParams());


	createLabel(composite, SWT.NONE, JavadocExportMessages.JavadocSpecificsWizardPage_extraoptionsfield_label, createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 3, 0));
	fExtraOptionsText= createText(composite, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL, null, createGridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL, 3, 0));
	//fExtraOptionsText.setSize(convertWidthInCharsToPixels(60), convertHeightInCharsToPixels(10));

	fExtraOptionsText.setText(fStore.getAdditionalParams());

	Composite inner= new Composite(composite, SWT.NONE);
	inner.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 3, 1));
	GridLayout layout= new GridLayout(2, false);
	layout.marginHeight= 0;
	layout.marginWidth= 0;
	inner.setLayout(layout);

	createLabel(inner, SWT.NONE, JavadocExportMessages.JavadocSpecificsWizardPage_sourcecompatibility_label, createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 0));

	fSourceCombo= createCombo(inner, SWT.NONE, fStore.getSource(), createGridData(1));
	String[] versions= { "-", //$NON-NLS-1$
			JavaCore.VERSION_1_3, JavaCore.VERSION_1_4, JavaCore.VERSION_1_5, JavaCore.VERSION_1_6, JavaCore.VERSION_1_7, JavaCore.VERSION_1_8 };
	fSourceCombo.setItems(versions);
	fSourceCombo.setText(fStore.getSource());


	//Listeners
	fOverViewButton.addSelectionListener(new ToggleSelectionAdapter(new Control[] { fOverViewBrowseButton, fOverViewText }) {
		@Override
		public void validate() {
			doValidation(OVERVIEWSTATUS);
		}
	});

	fOverViewText.addModifyListener(new ModifyListener() {
		public void modifyText(ModifyEvent e) {
			doValidation(OVERVIEWSTATUS);
		}
	});

	fOverViewBrowseButton.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent event) {
			handleFileBrowseButtonPressed(fOverViewText, new String[] { "*.html" }, JavadocExportMessages.JavadocSpecificsWizardPage_overviewbrowsedialog_title);  //$NON-NLS-1$
		}
	});

}