Java Code Examples for org.eclipse.jdt.core.JavaCore#getDefaultOptions()

The following examples show how to use org.eclipse.jdt.core.JavaCore#getDefaultOptions() . 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: TestOptions.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
public static Hashtable<String, String> getDefaultOptions() {
	Hashtable<String, String> result = JavaCore.getDefaultOptions();
	result.put(JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING, JavaCore.IGNORE);
	result.put(JavaCore.COMPILER_PB_FIELD_HIDING, JavaCore.IGNORE);
	result.put(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER, JavaCore.IGNORE);
	result.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.IGNORE);
	result.put(JavaCore.COMPILER_PB_RAW_TYPE_REFERENCE, JavaCore.IGNORE);
	result.put(JavaCore.COMPILER_PB_UNUSED_WARNING_TOKEN, JavaCore.IGNORE);
	result.put(JavaCore.COMPILER_PB_DEAD_CODE, JavaCore.IGNORE);
	result.put(JavaCore.COMPILER_PB_UNUSED_IMPORT, JavaCore.ERROR);

	result.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
	result.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");

	JavaCore.setComplianceOptions("1.8", result);

	return result;
}
 
Example 2
Source File: UnresolvedElementsSubProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static void addNullityAnnotationTypesProposals(ICompilationUnit cu, Name node, Collection<ICommandAccess> proposals) throws CoreException {
	ASTNode parent= node.getParent();
	boolean isAnnotationName= parent instanceof Annotation && ((Annotation) parent).getTypeNameProperty() == node.getLocationInParent();
	if (!isAnnotationName) {
		boolean isImportName= parent instanceof ImportDeclaration && ImportDeclaration.NAME_PROPERTY == node.getLocationInParent();
		if (!isImportName)
			return;
	}
	
	final IJavaProject javaProject= cu.getJavaProject();
	String name= node.getFullyQualifiedName();
	
	String nullityAnnotation= null;
	String[] annotationNameOptions= { JavaCore.COMPILER_NULLABLE_ANNOTATION_NAME, JavaCore.COMPILER_NONNULL_ANNOTATION_NAME, JavaCore.COMPILER_NONNULL_BY_DEFAULT_ANNOTATION_NAME };
	Hashtable<String, String> defaultOptions= JavaCore.getDefaultOptions();
	for (String annotationNameOption : annotationNameOptions) {
		String annotationName= javaProject.getOption(annotationNameOption, true);
		if (! annotationName.equals(defaultOptions.get(annotationNameOption)))
			return;
		if (JavaModelUtil.isMatchingName(name, annotationName)) {
			nullityAnnotation= annotationName;
		}
	}
	if (nullityAnnotation == null)
		return;
	if (javaProject.findType(defaultOptions.get(annotationNameOptions[0])) != null)
		return;
	String version= JavaModelUtil.is18OrHigher(javaProject) ? "2" : "[1.1.0,2.0.0)"; //$NON-NLS-1$ //$NON-NLS-2$
	Bundle[] annotationsBundles= JavaPlugin.getDefault().getBundles("org.eclipse.jdt.annotation", version); //$NON-NLS-1$
	if (annotationsBundles == null)
		return;
	
	if (! cu.getJavaProject().getProject().hasNature("org.eclipse.pde.PluginNature")) //$NON-NLS-1$
		addCopyAnnotationsJarProposal(cu, node, nullityAnnotation, annotationsBundles[0], proposals);
}
 
Example 3
Source File: ComplianceConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Tells whether the compliance option is the same as the original default.
 * 
 * @return <code>true</code> if the compliance is the same as the original default
 * @since 3.6
 */
private static final boolean isOriginalDefaultCompliance() {
	Hashtable<String, String> options= JavaCore.getDefaultOptions();
	Preferences bundleDefaults= BundleDefaultsScope.INSTANCE.getNode(JavaCore.PLUGIN_ID);

	return equals(JavaCore.COMPILER_COMPLIANCE, bundleDefaults, options)
			&& equals(JavaCore.COMPILER_SOURCE, bundleDefaults, options)
			&& equals(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, bundleDefaults, options)
			&& equals(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, bundleDefaults, options)
			&& equals(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, bundleDefaults, options);
}
 
Example 4
Source File: CleanUpPreview.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public CleanUpPreview(Composite parent, ICleanUpConfigurationUI page) {
	super(JavaCore.getDefaultOptions(), parent);
	fPage= page;
	fFormat= false;
}
 
Example 5
Source File: AST.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Creates a new, empty abstract syntax tree using default options.
 *
 * @see JavaCore#getDefaultOptions()
 * @deprecated Clients should port their code to use the new JLS4 AST API and call
 *    {@link #newAST(int) AST.newAST(AST.JLS4)} instead of using this constructor.
 */
public AST() {
	this(JavaCore.getDefaultOptions());
}