Java Code Examples for org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#INDENT_BY_ONE

The following examples show how to use org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#INDENT_BY_ONE . 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: JavaStringAutoIndentStrategy.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns extra indentation string for strings that are broken by a newline
 * based on the value of the formatter preferences for tabs vs. spaces.
 *
 * @return two tabs or equivalent number of spaces
 */
private String getExtraIndentAfterNewLine() {
	// read settings
	int formatterContinuationIndentationSize= getContinuationIndentationSize();
	int binaryAlignmentValue= getBinaryOperatorAlignmentStyle();
	
	// work out indent
	int indentSize= formatterContinuationIndentationSize;
	if (binaryAlignmentValue == DefaultCodeFormatterConstants.INDENT_BY_ONE) {
		indentSize= 1;
	} else if (binaryAlignmentValue == DefaultCodeFormatterConstants.INDENT_ON_COLUMN) {
		// there is no obvious way to work out the current column indent
	}
	
	// generate indentation string with correct size
	return CodeFormatterUtil.createIndentString(indentSize, fProject);
}
 
Example 2
Source File: JavaIndenter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private int prefArrayIndent() {
	String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER);
	try {
		if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
			return 1;
	} catch (IllegalArgumentException e) {
		// ignore and return default
	}

	return prefContinuationIndent(); // default
}
 
Example 3
Source File: JavaIndenter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private int prefTernaryIndent() {
	String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION);
	try {
		if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
			return 1;
		else
			return prefContinuationIndent();
	} catch (IllegalArgumentException e) {
		// ignore and return default
	}

	return prefContinuationIndent();
}
 
Example 4
Source File: JavaIndenter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private int prefMethodDeclIndent() {
	String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
	try {
		if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
			return 1;
		else
			return prefContinuationIndent();
	} catch (IllegalArgumentException e) {
		// ignore and return default
	}
	return 1;
}
 
Example 5
Source File: JavaIndenter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private int prefMethodCallIndent() {
	String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
	try {
		if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
			return 1;
		else
			return prefContinuationIndent();
	} catch (IllegalArgumentException e) {
		// ignore and return default
	}

	return 1; // sensible default
}