1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +02:00

178601: Add whitespace options to preference UI

This commit is contained in:
Anton Leherbauer 2008-02-21 16:02:42 +00:00
parent d7f3e235cc
commit d236e380c7
30 changed files with 4366 additions and 2326 deletions

View file

@ -32,91 +32,76 @@ import org.eclipse.text.edits.TextEdit;
* @since 4.0
*/
public class Scribe {
public static final String EMPTY_STRING= ""; //$NON-NLS-1$
private static final String EMPTY_STRING= ""; //$NON-NLS-1$
private static final String SPACE= " "; //$NON-NLS-1$
private static final int INITIAL_SIZE= 100;
private boolean checkLineWrapping;
private final DefaultCodeFormatterOptions preferences;
public final Scanner scanner;
/** one-based column */
public int column= 1;
// Most specific alignment.
public Alignment currentAlignment;
public Alignment memberAlignment;
public Token currentToken;
// edits management
private OptimizedReplaceEdit[] edits;
public int editsIndex;
public CodeFormatterVisitor formatter;
public int indentationLevel;
public int lastNumberOfNewLines;
public int line;
private String lineSeparator;
public Alignment memberAlignment;
public boolean needSpace= false;
public int pageWidth;
public boolean pendingSpace= false;
public Scanner scanner;
public int scannerEndPosition;
public int tabLength;
public int numberOfIndentations;
public int indentationSize;
private int textRegionEnd;
private int textRegionStart;
public int tabChar;
public int numberOfIndentations;
private boolean useTabsOnlyForLeadingIndents;
/** indent empty lines */
private final String lineSeparator;
private final boolean indentEmptyLines;
private final int pageWidth;
private boolean preserveNewLines;
private boolean checkLineWrapping;
public int lastNumberOfNewLines;
public int line;
private boolean preserveNewlines;
public boolean needSpace= false;
public boolean pendingSpace= false;
public int tabLength;
public int tabChar;
private final boolean useTabsOnlyForLeadingIndents;
private int textRegionEnd;
private int textRegionStart;
public int scannerEndPosition;
private List<Position> fSkipPositions= Collections.emptyList();
private boolean skipOverInactive;
private int fSkipTokensFrom= Integer.MAX_VALUE;
private int fSkipTokensTo;
private int fSkipStartOffset= Integer.MAX_VALUE;
private int fSkipEndOffset;
private int fSkippedIndentations;
Scribe(CodeFormatterVisitor formatter, int offset, int length) {
scanner= new Scanner();
this.formatter= formatter;
pageWidth= formatter.preferences.page_width;
tabLength= formatter.preferences.tab_size;
preferences= formatter.preferences;
pageWidth= preferences.page_width;
tabLength= preferences.tab_size;
indentationLevel= 0; // initialize properly
numberOfIndentations= 0;
useTabsOnlyForLeadingIndents= formatter.preferences.use_tabs_only_for_leading_indentations;
indentEmptyLines= formatter.preferences.indent_empty_lines;
tabChar= formatter.preferences.tab_char;
useTabsOnlyForLeadingIndents= preferences.use_tabs_only_for_leading_indentations;
indentEmptyLines= preferences.indent_empty_lines;
tabChar= preferences.tab_char;
if (tabChar == DefaultCodeFormatterOptions.MIXED) {
indentationSize= formatter.preferences.indentation_size;
indentationSize= preferences.indentation_size;
} else {
indentationSize= tabLength;
}
lineSeparator= formatter.preferences.line_separator;
indentationLevel= formatter.preferences.initial_indentation_level * indentationSize;
lineSeparator= preferences.line_separator;
indentationLevel= preferences.initial_indentation_level * indentationSize;
textRegionStart= offset;
textRegionEnd= offset + length - 1;
reset();
@ -242,7 +227,7 @@ public class Scribe {
public Alignment createAlignment(String name, int mode, int tieBreakRule, int count, int sourceRestart) {
return createAlignment(name, mode, tieBreakRule, count, sourceRestart,
formatter.preferences.continuation_indentation, false);
preferences.continuation_indentation, false);
}
public Alignment createAlignment(String name, int mode, int count, int sourceRestart, int continuationIndent,
@ -473,13 +458,13 @@ public class Scribe {
private String getPreserveEmptyLines(int count) {
if (count > 0) {
if (formatter.preferences.number_of_empty_lines_to_preserve != 0) {
int linesToPreserve= Math.min(count, formatter.preferences.number_of_empty_lines_to_preserve);
if (preferences.number_of_empty_lines_to_preserve != 0) {
int linesToPreserve= Math.min(count, preferences.number_of_empty_lines_to_preserve);
return getEmptyLines(linesToPreserve);
} else {
return getNewLine();
}
} else if (preserveNewlines) {
} else if (preserveNewLines) {
return getNewLine();
}
return EMPTY_STRING;
@ -604,8 +589,8 @@ public class Scribe {
private void preserveEmptyLines(int count, int insertPosition) {
if (count > 0) {
if (formatter.preferences.number_of_empty_lines_to_preserve != 0) {
int linesToPreserve= Math.min(count, formatter.preferences.number_of_empty_lines_to_preserve);
if (preferences.number_of_empty_lines_to_preserve != 0) {
int linesToPreserve= Math.min(count, preferences.number_of_empty_lines_to_preserve);
printEmptyLines(linesToPreserve, insertPosition);
} else {
printNewLine(insertPosition);
@ -619,29 +604,31 @@ public class Scribe {
if (length <= 0) {
return;
}
if (shouldSkip(scanner.getCurrentPosition())) {
int currentPosition= scanner.getCurrentPosition();
if (shouldSkip(currentPosition)) {
return;
}
if (startOffset > scanner.getCurrentPosition()) {
if (startOffset > currentPosition) {
printComment();
currentPosition= scanner.getCurrentPosition();
}
if (pendingSpace) {
addInsertEdit(scanner.getCurrentPosition(), " "); //$NON-NLS-1$
addInsertEdit(currentPosition, SPACE);
pendingSpace= false;
needSpace= false;
}
if (startOffset + length < scanner.getCurrentPosition()) {
if (startOffset + length < currentPosition) {
// don't move backwards
return;
}
boolean savedPreserveNL= preserveNewlines;
boolean savedPreserveNL= preserveNewLines;
boolean savedSkipOverInactive= skipOverInactive;
int savedScannerEndPos= scannerEndPosition;
preserveNewlines= true;
preserveNewLines= true;
skipOverInactive= false;
scannerEndPosition= startOffset + length;
try {
scanner.resetTo(Math.max(startOffset, scanner.getCurrentPosition()), startOffset + length - 1);
scanner.resetTo(Math.max(startOffset, currentPosition), startOffset + length - 1);
int parenLevel= 0;
boolean lastTokenWasGT= false;
while (true) {
@ -655,36 +642,32 @@ public class Scribe {
break;
}
if (pendingSpace) {
addInsertEdit(scanner.getCurrentTokenStartPosition(), " "); //$NON-NLS-1$
addInsertEdit(scanner.getCurrentTokenStartPosition(), SPACE);
pendingSpace= false;
needSpace= false;
}
switch (currentToken.type) {
case Token.tLBRACE: {
// int currentPosition= scanner.getCurrentPosition();
scanner.resetTo(scanner.getCurrentTokenStartPosition(), scannerEndPosition-1);
formatOpeningBrace(formatter.preferences.brace_position_for_block, formatter.preferences.insert_space_before_opening_brace_in_block);
if (formatter.preferences.indent_statements_compare_to_block) {
formatOpeningBrace(preferences.brace_position_for_block, preferences.insert_space_before_opening_brace_in_block);
if (preferences.indent_statements_compare_to_block) {
indent();
}
// scanner.resetTo(currentPosition, scannerEndPosition-1);
break;
}
case Token.tRBRACE: {
// int currentPosition= scanner.getCurrentPosition();
scanner.resetTo(scanner.getCurrentTokenStartPosition(), scannerEndPosition-1);
if (formatter.preferences.indent_statements_compare_to_block) {
if (preferences.indent_statements_compare_to_block) {
unIndent();
}
formatClosingBrace(formatter.preferences.brace_position_for_block);
// scanner.resetTo(currentPosition, scannerEndPosition-1);
formatClosingBrace(preferences.brace_position_for_block);
break;
}
case Token.tLPAREN:
++parenLevel;
print(currentToken.getLength(), hasWhitespace);
if (parenLevel > 0) {
for (int i= 0; i < formatter.preferences.continuation_indentation; i++) {
for (int i= 0; i < preferences.continuation_indentation; i++) {
indent();
}
// HACK: avoid indent in same line
@ -694,7 +677,7 @@ public class Scribe {
case Token.tRPAREN:
--parenLevel;
if (parenLevel >= 0) {
for (int i= 0; i < formatter.preferences.continuation_indentation; i++) {
for (int i= 0; i < preferences.continuation_indentation; i++) {
unIndent();
}
}
@ -707,11 +690,11 @@ public class Scribe {
isGT= true;
break;
case Token.tSEMI:
print(currentToken.getLength(), formatter.preferences.insert_space_before_semicolon);
print(currentToken.getLength(), preferences.insert_space_before_semicolon);
break;
case Token.t_else:
case Token.t_catch:
if (formatter.preferences.insert_new_line_before_else_in_if_statement) {
case Token.t_else:
if (preferences.insert_new_line_before_else_in_if_statement) {
printNewLine(currentToken.offset);
} else {
hasWhitespace= true;
@ -720,7 +703,7 @@ public class Scribe {
break;
default:
if (currentToken.isVisibilityModifier()
&& !formatter.preferences.indent_access_specifier_compare_to_type_header) {
&& !preferences.indent_access_specifier_compare_to_type_header) {
int indentLevel= indentationLevel;
if (indentationLevel > 0)
unIndent();
@ -739,11 +722,11 @@ public class Scribe {
scannerEndPosition= savedScannerEndPos;
scanner.resetTo(startOffset + length, scannerEndPosition - 1);
skipOverInactive= savedSkipOverInactive;
preserveNewlines= savedPreserveNL;
preserveNewLines= savedPreserveNL;
}
}
private void formatOpeningBrace(String bracePosition, boolean insertSpaceBeforeBrace) {
public void formatOpeningBrace(String bracePosition, boolean insertSpaceBeforeBrace) {
if (DefaultCodeFormatterConstants.NEXT_LINE.equals(bracePosition)) {
printNewLine();
} else if (DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(bracePosition)) {
@ -755,7 +738,7 @@ public class Scribe {
printTrailingComment();
}
private void formatClosingBrace(String block_brace_position) {
public void formatClosingBrace(String block_brace_position) {
printNextToken(Token.tRBRACE);
printTrailingComment();
if (DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(block_brace_position)) {
@ -776,7 +759,7 @@ public class Scribe {
space();
}
if (pendingSpace) {
addInsertEdit(scanner.getCurrentTokenStartPosition(), " "); //$NON-NLS-1$
addInsertEdit(scanner.getCurrentTokenStartPosition(), SPACE);
}
pendingSpace= false;
column+= length;
@ -794,7 +777,7 @@ public class Scribe {
int nextCharacterStart= currentTokenStartPosition;
printIndentationIfNecessary();
if (pendingSpace) {
addInsertEdit(currentTokenStartPosition, " "); //$NON-NLS-1$
addInsertEdit(currentTokenStartPosition, SPACE);
}
needSpace= false;
pendingSpace= false;
@ -978,7 +961,7 @@ public class Scribe {
} else if (hasLineComment) {
preserveEmptyLines(count - 1, scanner.getCurrentTokenStartPosition());
addDeleteEdit(scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition());
} else if (count != 0 && formatter.preferences.number_of_empty_lines_to_preserve != 0) {
} else if (count != 0 && preferences.number_of_empty_lines_to_preserve != 0) {
String preservedEmptyLines= getPreserveEmptyLines(count - 1);
addReplaceEdit(scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition(),
preservedEmptyLines);
@ -1074,7 +1057,7 @@ public class Scribe {
int nextCharacterStart= currentTokenStartPosition;
printIndentationIfNecessary();
if (pendingSpace) {
addInsertEdit(currentTokenStartPosition, " "); //$NON-NLS-1$
addInsertEdit(currentTokenStartPosition, SPACE);
}
needSpace= false;
pendingSpace= false;
@ -1503,10 +1486,10 @@ public class Scribe {
/**
*/
public void printModifiers() {
public boolean printModifiers() {
int currentTokenStartPosition= scanner.getCurrentPosition();
if (shouldSkip(currentTokenStartPosition)) {
return;
return false;
}
boolean isFirstModifier= true;
boolean hasComment= false;
@ -1595,9 +1578,20 @@ public class Scribe {
}
// step back one token
scanner.resetTo(currentTokenStartPosition, scannerEndPosition - 1);
return;
return !isFirstModifier;
}
}
return !isFirstModifier;
}
public boolean preserveNewLine() {
boolean savedPreserveNewLines= preserveNewLines;
try {
preserveNewLines= true;
return printComment();
} finally {
preserveNewLines= savedPreserveNewLines;
}
}
/**
@ -1658,48 +1652,61 @@ public class Scribe {
}
public boolean printCommentPreservingNewLines() {
final boolean savedPreserveNL= this.preserveNewlines;
this.preserveNewlines= true;
final boolean savedPreserveNL= this.preserveNewLines;
this.preserveNewLines= true;
try {
return printComment();
} finally {
this.preserveNewlines= savedPreserveNL;
this.preserveNewLines= savedPreserveNL;
}
}
boolean shouldSkip(int offset) {
return offset >= fSkipTokensFrom && offset <= fSkipTokensTo;
return offset >= fSkipStartOffset && offset <= fSkipEndOffset;
}
void skipRange(int offset, int endOffset) {
if (offset == fSkipTokensFrom) {
if (offset == fSkipStartOffset) {
return;
}
final int currentPosition= scanner.getCurrentPosition();
if (currentPosition >= offset && currentPosition < endOffset) {
printRaw(offset, endOffset - offset);
}
fSkipTokensFrom= offset;
fSkipTokensTo= endOffset;
fSkipStartOffset= offset;
fSkipEndOffset= endOffset;
}
boolean skipRange() {
return fSkipEndOffset > 0;
}
void restartAtOffset(int offset) {
if (fSkipTokensTo > 0) {
fSkipTokensFrom= Integer.MAX_VALUE;
fSkipTokensTo= 0;
final int currentPosition= scanner.getCurrentPosition();
if (fSkipEndOffset > 0) {
fSkipStartOffset= Integer.MAX_VALUE;
fSkipEndOffset= 0;
while (fSkippedIndentations < 0) {
unIndent();
fSkippedIndentations++;
}
if (offset > scanner.getCurrentPosition()) {
printRaw(scanner.getCurrentPosition(), offset - scanner.getCurrentPosition());
if (offset > currentPosition) {
printRaw(currentPosition, offset - currentPosition);
scanner.resetTo(offset, scannerEndPosition - 1);
}
while (fSkippedIndentations > 0) {
indent();
fSkippedIndentations--;
}
} else if (offset > currentPosition) {
printComment();
final int nextPosition= scanner.getCurrentPosition();
if (offset > nextPosition) {
printRaw(nextPosition, offset - nextPosition);
scanner.resetTo(offset, scannerEndPosition - 1);
}
}
}
}

View file

@ -4,28 +4,28 @@ struct x {
struct x getX() {
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=171520
int bug=sizeof(int);
int bug = sizeof(int);
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=173837
class ABaseClass {
protected:
ABaseClass(int x);
};
class AClass : public ABaseClass {
class AClass: public ABaseClass {
AClass(int x) throw(int);
void test1() const throw(int);
void test2() throw();
};
AClass::AClass(int x) throw(int) :
ABaseClass(x) {
for (int i=0; i < 12; i++) {
for (int i = 0; i < 12; i++) {
}
}
// keep space between decl spec and declarator
int main(int argc, char **argv) {
}
// handling of string concat
char* s1= "this " "is " "one " "string.";
char* s2= "this " "is "
char* s1 = "this " "is " "one " "string.";
char* s2 = "this " "is "
"one " "string.";
// macro definition with line comment
#define ID(x) x // identity
@ -34,7 +34,7 @@ int main() {
}
// semicolons inside for
void g() {
for (int i=0; i<10; ++i) {
for (int i = 0; i < 10; ++i) {
}
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=183220
@ -43,18 +43,17 @@ void bug183220() {
rtc_s2000_src_pending, rtc_s2000_cr_sync_pending,
rtc_hdw_cr_sync_next, rtc_hdw_current_clock;
int rtc_s2000_clock_source_state, RTC_CLOCK_PLL;
if (( ( rtc_hdw_cr_sync_next != rtc_hdw_cr_sync )
|| rtc_hdw_cr_resync_enable )&& !rtc_s2000_src_pending
&& !rtc_s2000_cr_sync_pending) {
if (((rtc_hdw_cr_sync_next != rtc_hdw_cr_sync) || rtc_hdw_cr_resync_enable)
&& !rtc_s2000_src_pending && !rtc_s2000_cr_sync_pending) {
if (!identify_hdw_fvr_master() || !rtc_hdw_current_clock->external
|| !rtc_hdw_cr_sync_next ||( ( rtc_hdw_current_clock->external
|| !rtc_hdw_cr_sync_next || ((rtc_hdw_current_clock->external
&& rtc_hdw_cr_sync_next && rtc_s2000_clock_source_state
!= RTC_CLOCK_PLL ) )) {
!= RTC_CLOCK_PLL))) {
}
}
}
// declaration with array initializer
long dummy[]= { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
long dummy[] = { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,

View file

@ -9,16 +9,16 @@ class AClass : public ABaseClass {AClass(int x) throw(int); void test1() const t
AClass::AClass(int x)throw(int):ABaseClass(x){for (int i=0;i < 12;i++) {}}
// keep space between decl spec and declarator
int
main(int argc, char **argv) {}
main(int argc,char **argv) {}
// handling of string concat
char* s1= "this " "is " "one ""string.";
char* s2= "this " "is "
"one " "string.";
// macro definition with line comment
#define ID(x) x // identity
int main() {return ID(0);}
int main(){return ID(0);}
// semicolons inside for
void g() {for(int i=0;i<10;++i){}}
void g(){for(int i=0;i<10;++i){}}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=183220
void bug183220()
{

View file

@ -44,11 +44,11 @@ int foo(int bar) const {
/*
* Line Wrapping
*/
int array[]= { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1000,
2000, 3000, 4000, 5000 };
int compare(int argument, int otherArgument) {
return argument+otherArgument > argument*otherArgument+1000000 ? 100000
+50000 : 200000-30000;
int array[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1000, 2000, 3000, 4000, 5000 };
int compare(int argument, int otherArg) {
return argument + otherArg > argument * otherArg + 1000000 ? 100000 + 50000
: 200000 - 30000;
}
class Other {
static void bar(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6,
@ -59,3 +59,21 @@ void foo() {
Other::bar(100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000,
900000);
}
enum EEEE {
ONE,
TWO,
THREE,
FOUR,
FIVE,
SIX,
SEVEN = 7,
EIGHT,
NINE,
TEN,
HUNDRED,
THOUSAND,
AMILLION
};
template<typename T1, typename T2> class map {
};
map<int, int> m;

View file

@ -7,6 +7,8 @@ class Point {public:Point(double xc, double yc) : x(xc), y(yc) {}double distance
* Line Wrapping
*/
int array[]= {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1000, 2000, 3000, 4000, 5000};
int compare(int argument, int otherArgument) {return argument+otherArgument > argument*otherArgument+1000000 ? 100000+50000 : 200000-30000;}
int compare(int argument, int otherArg) {return argument+otherArg > argument*otherArg+1000000 ? 100000+50000 : 200000-30000;}
class Other {static void bar(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9) {}};
void foo() {Other::bar(100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000);}
enum EEEE{ONE,TWO,THREE,FOUR,FIVE,SIX,SEVEN=7,EIGHT,NINE,TEN,HUNDRED,THOUSAND,AMILLION};
template<typename T1,typename T2> class map {};map<int,int> m;

View file

@ -4,7 +4,7 @@
struct SimpleStruct {
int num;
char name[ ];
char name[];
float floatNum;
};

View file

@ -5,7 +5,7 @@
struct SimpleStruct
{
int num;
char name[ ];
char name [ ];
float floatNum;
};

View file

@ -11,7 +11,8 @@ class Foo {
};
// TEMPLATE_STRUCT
template<class Key, class Value, class SortAlgorithm=DefaultSort> struct Map {
template<class Key, class Value, class SortAlgorithm=DefaultSort>
struct Map {
Key* keys;
Value* values;
SortAlgorithm* sortAlgorithm;
@ -25,7 +26,7 @@ private:
public:
nonVector() {
head =new T();
head = new T();
}
int length() {
return 1;
@ -34,7 +35,8 @@ public:
};
// TEMPLATE_UNION
template<class X, class Y, int size=16> union ArrayOverlay {
template<class X, class Y, int size=16>
union ArrayOverlay {
public:
X x[size];
Y y[size];
@ -46,7 +48,8 @@ public:
class TemplateContainer {
// these are in an enclosing class
template<class Bar> void fum(int i);
template<int> void scrum(void) {
template<int>
void scrum(void) {
}
;
};
@ -62,12 +65,11 @@ template<class Bar> void Foo::fum(int i) {
}
// TEMPLATE_VARIABLES
template <bool threads, int inst> char
template<bool threads, int inst> char
* default_alloc_template<threads, inst>::S_start_free = 0;
// an instantiation, not a template:
complex
<float> cf(0, 0);
complex<float> cf(0, 0);
//template<class Language, class CharacterSet, class SortAlgorithm<CharacterSet> >
//Dictionary* TheSpellCheckDictionary;

View file

@ -25,7 +25,7 @@ template<class T> class nonVector {
private: T* head;
public:
nonVector() {head =new T();}
nonVector() {head=new T();}
int length() {return 1;}
const T& first() const;
};

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others.
* Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -56,7 +56,7 @@ public class CHeuristicScannerTest extends TestCase {
final String indentOnColumn= DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.INDENT_ON_COLUMN);
options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, indentOnColumn);
options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, indentOnColumn);
options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_INITIALIZER_LIST, indentOnColumn);
options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, "1");
CCorePlugin.setOptions(options);
}

View file

@ -104,7 +104,7 @@ public class CodeFormatterTest extends BaseUITestCase {
// switch (confusefomatter) {
//
// case START_CONFUSION:
// SomeFunctionCallWithTypecast(( castConfusion_t)myvar1,
// SomeFunctionCallWithTypecast((castConfusion_t) myvar1,
// (castNoAdditionalConfusion_t) myvar2);
// break;
//
@ -171,7 +171,7 @@ public class CodeFormatterTest extends BaseUITestCase {
//void foo() {
// for (;;) {
// int a=0;
// int a = 0;
// switch (a) {
// case 0:
// ++a;
@ -380,7 +380,7 @@ public class CodeFormatterTest extends BaseUITestCase {
// indentation_remains();
// }
//
// if (b>a)
// if (b > a)
// indentation_vanishes();
//
// break_end();
@ -391,4 +391,76 @@ public class CodeFormatterTest extends BaseUITestCase {
public void testBracesInMacros_Bug217435() throws Exception {
assertFormatterResult();
}
//int a=1+2;
//int b= - a;
//int c =b ++/-- b;
//int a = 1 + 2;
//int b = -a;
//int c = b++ / --b;
public void testWhitespaceSurroundingOperators() throws Exception {
assertFormatterResult();
}
//void f() {
//int *px= :: new int( 0 );
//int py [] = new int [5 ] (0, 1,2,3, 4);
//int *pz[ ] =new ( px)int(0);
//delete [] py;
//:: delete px;}
//void f() {
// int *px = ::new int(0);
// int py[] = new int[5](0, 1, 2, 3, 4);
// int *pz[] = new(px) int(0);
// delete[] py;
// ::delete px;
//}
public void testNewAndDeleteExpressions() throws Exception {
assertFormatterResult();
}
//namespace X=
// Y ::
// Z ;
//namespace X = Y::Z;
public void testNamespaceAlias() throws Exception {
assertFormatterResult();
}
//using
// typename:: T
//;
//using X::
// T ;
//using typename ::T;
//using X::T;
public void testUsingDeclaration() throws Exception {
assertFormatterResult();
}
//using
// namespace
// X ;
//using namespace X;
public void testUsingDirective() throws Exception {
assertFormatterResult();
}
//static void *f(){}
//static void * g();
//static void* h();
//static void *f() {
//}
//static void * g();
//static void* h();
public void testSpaceBetweenDeclSpecAndDeclarator() throws Exception {
assertFormatterResult();
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others.
* Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -21,7 +21,7 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
public class BracesTabPage extends ModifyDialogTabPage {
public class BracesTabPage extends FormatterTabPage {
/**
* Constant array for boolean selection
@ -134,8 +134,8 @@ public class BracesTabPage extends ModifyDialogTabPage {
createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_blocks_in_case, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE);
createBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_switch_case, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH);
ComboPreference arrayInitOption= createBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_array_initializer, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER);
final CheckboxPreference arrayInitCheckBox= createIndentedCheckboxPref(group, numColumns, FormatterMessages.BracesTabPage_option_keep_empty_array_initializer_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, FALSE_TRUE);
ComboPreference arrayInitOption= createBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_initializer_list, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST);
final CheckboxPreference arrayInitCheckBox= createIndentedCheckboxPref(group, numColumns, FormatterMessages.BracesTabPage_option_keep_empty_initializer_list_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_INITIALIZER_LIST_ON_ONE_LINE, FALSE_TRUE);
arrayInitOption.addObserver(new Observer() {
public void update(Observable o, Object arg) {

View file

@ -42,7 +42,6 @@ import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.ui.text.ICPartitions;
import org.eclipse.cdt.internal.ui.editor.CSourceViewer;
import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
import org.eclipse.cdt.internal.ui.text.CTextTools;
import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration;
@ -90,7 +89,7 @@ public abstract class CPreview {
}
}
protected final CSourceViewerConfiguration fViewerConfiguration;
protected final SimpleCSourceViewerConfiguration fViewerConfiguration;
protected final Document fPreviewDocument;
protected final SourceViewer fSourceViewer;
protected final IPreferenceStore fPreferenceStore;
@ -100,7 +99,7 @@ public abstract class CPreview {
protected Map fWorkingValues;
private int fTabSize= 0;
private WhitespaceCharacterPainter fWhitespacePainter;
private WhitespaceCharacterPainter fWhitespaceCharacterPainter;
/**
* Create a new C preview
@ -127,8 +126,6 @@ public abstract class CPreview {
fMarginPainter.setMarginRulerColor(tools.getColorManager().getColor(rgb));
fSourceViewer.addPainter(fMarginPainter);
fWhitespacePainter= new WhitespaceCharacterPainter(fSourceViewer);
new CSourcePreviewerUpdater();
fSourceViewer.setDocument(fPreviewDocument);
}
@ -193,24 +190,26 @@ public abstract class CPreview {
return defaultValue;
}
public final Map getWorkingValues() {
public Map getWorkingValues() {
return fWorkingValues;
}
public final void setWorkingValues(Map workingValues) {
public void setWorkingValues(Map workingValues) {
fWorkingValues= workingValues;
}
/**
* Enable/disable display of whitespace characters.
*
* @param show flag, whether to display whitespace
*/
public void showWhitespace(boolean show) {
if (show) {
fSourceViewer.addPainter(fWhitespacePainter);
public void showInvisibleCharacters(boolean enable) {
if (enable) {
if (fWhitespaceCharacterPainter == null) {
fWhitespaceCharacterPainter= new WhitespaceCharacterPainter(fSourceViewer);
fSourceViewer.addPainter(fWhitespaceCharacterPainter);
}
} else {
fSourceViewer.removePainter(fWhitespacePainter);
fSourceViewer.removePainter(fWhitespaceCharacterPainter);
fWhitespaceCharacterPainter= null;
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others.
* Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -25,6 +25,7 @@ final class FormatterMessages extends NLS {
// Do not instantiate
}
public static String FormatterTabPage_ShowInvisibleCharacters_label;
public static String ModifyDialog_BuiltIn_Status;
public static String ModifyDialog_Duplicate_Status;
public static String ModifyDialog_EmptyName_Status;
@ -33,245 +34,187 @@ final class FormatterMessages extends NLS {
public static String ModifyDialog_ProfileName_Label;
public static String ModifyDialog_Shared_Status;
public static String ProfileConfigurationBlock_load_profile_wrong_profile_message;
// public static String WhiteSpaceTabPage_assignments;
// public static String WhiteSpaceTabPage_assignments_before_assignment_operator;
// public static String WhiteSpaceTabPage_assignments_after_assignment_operator;
// public static String WhiteSpaceTabPage_operators;
// public static String WhiteSpaceTabPage_operators_before_binary_operators;
// public static String WhiteSpaceTabPage_operators_after_binary_operators;
// public static String WhiteSpaceTabPage_operators_before_unary_operators;
// public static String WhiteSpaceTabPage_operators_after_unary_operators;
// public static String WhiteSpaceTabPage_operators_before_prefix_operators;
// public static String WhiteSpaceTabPage_operators_after_prefix_operators;
// public static String WhiteSpaceTabPage_operators_before_postfix_operators;
// public static String WhiteSpaceTabPage_operators_after_postfix_operators;
// public static String WhiteSpaceTabPage_classes;
// public static String WhiteSpaceTabPage_classes_before_opening_brace_of_a_class;
// public static String WhiteSpaceTabPage_classes_before_opening_brace_of_anon_class;
// public static String WhiteSpaceTabPage_classes_before_comma_implements;
// public static String WhiteSpaceTabPage_classes_after_comma_implements;
// public static String WhiteSpaceTabPage_methods;
// public static String WhiteSpaceTabPage_constructors;
// public static String WhiteSpaceTabPage_fields;
// public static String WhiteSpaceTabPage_fields_before_comma;
// public static String WhiteSpaceTabPage_fields_after_comma;
// public static String WhiteSpaceTabPage_localvars;
// public static String WhiteSpaceTabPage_localvars_before_comma;
// public static String WhiteSpaceTabPage_localvars_after_comma;
// public static String WhiteSpaceTabPage_arrayinit;
// public static String WhiteSpaceTabPage_arraydecls;
// public static String WhiteSpaceTabPage_arrayelem;
// public static String WhiteSpaceTabPage_arrayalloc;
// public static String WhiteSpaceTabPage_calls;
// public static String WhiteSpaceTabPage_calls_before_comma_in_method_args;
// public static String WhiteSpaceTabPage_calls_after_comma_in_method_args;
public static String WhiteSpaceTabPage_assignments;
public static String WhiteSpaceTabPage_assignments_before_assignment_operator;
public static String WhiteSpaceTabPage_assignments_after_assignment_operator;
public static String WhiteSpaceTabPage_operators;
public static String WhiteSpaceTabPage_operators_before_binary_operators;
public static String WhiteSpaceTabPage_operators_after_binary_operators;
public static String WhiteSpaceTabPage_operators_before_unary_operators;
public static String WhiteSpaceTabPage_operators_after_unary_operators;
public static String WhiteSpaceTabPage_operators_before_prefix_operators;
public static String WhiteSpaceTabPage_operators_after_prefix_operators;
public static String WhiteSpaceTabPage_operators_before_postfix_operators;
public static String WhiteSpaceTabPage_operators_after_postfix_operators;
public static String WhiteSpaceTabPage_classes;
public static String WhiteSpaceTabPage_classes_before_opening_brace_of_a_class;
public static String WhiteSpaceTabPage_classes_before_colon_of_base_clause;
public static String WhiteSpaceTabPage_classes_after_colon_of_base_clause;
public static String WhiteSpaceTabPage_classes_before_comma_base_types;
public static String WhiteSpaceTabPage_classes_after_comma_base_types;
public static String WhiteSpaceTabPage_methods;
public static String WhiteSpaceTabPage_constructors;
public static String WhiteSpaceTabPage_declarator_list;
public static String WhiteSpaceTabPage_declarator_list_before_comma;
public static String WhiteSpaceTabPage_declarator_list_after_comma;
public static String WhiteSpaceTabPage_expression_list;
public static String WhiteSpaceTabPage_expression_list_before_comma;
public static String WhiteSpaceTabPage_expression_list_after_comma;
public static String WhiteSpaceTabPage_initializer_list;
public static String WhiteSpaceTabPage_calls;
public static String WhiteSpaceTabPage_calls_before_comma_in_method_args;
public static String WhiteSpaceTabPage_calls_after_comma_in_method_args;
// public static String WhiteSpaceTabPage_calls_before_comma_in_alloc;
// public static String WhiteSpaceTabPage_calls_after_comma_in_alloc;
// public static String WhiteSpaceTabPage_calls_before_comma_in_qalloc;
// public static String WhiteSpaceTabPage_calls_after_comma_in_qalloc;
// public static String WhiteSpaceTabPage_statements;
// public static String WhiteSpaceTabPage_blocks;
// public static String WhiteSpaceTabPage_switch;
// public static String WhiteSpaceTabPage_switch_before_case_colon;
// public static String WhiteSpaceTabPage_switch_before_default_colon;
// public static String WhiteSpaceTabPage_do;
// public static String WhiteSpaceTabPage_synchronized;
// public static String WhiteSpaceTabPage_try;
// public static String WhiteSpaceTabPage_if;
// public static String WhiteSpaceTabPage_assert;
// public static String WhiteSpaceTabPage_for;
// public static String WhiteSpaceTabPage_for_before_comma_init;
// public static String WhiteSpaceTabPage_for_after_comma_init;
// public static String WhiteSpaceTabPage_for_before_comma_inc;
// public static String WhiteSpaceTabPage_for_after_comma_inc;
// public static String WhiteSpaceTabPage_labels;
// public static String WhiteSpaceTabPage_annotations;
// public static String WhiteSpaceTabPage_annotation_types;
// public static String WhiteSpaceTabPage_enums;
// public static String WhiteSpaceTabPage_wildcardtype;
// public static String WhiteSpaceTabPage_param_type_ref;
// public static String WhiteSpaceTabPage_type_arguments;
// public static String WhiteSpaceTabPage_type_parameters;
// public static String WhiteSpaceTabPage_conditionals;
// public static String WhiteSpaceTabPage_typecasts;
// public static String WhiteSpaceTabPage_parenexpr;
// public static String WhiteSpaceTabPage_declarations;
// public static String WhiteSpaceTabPage_expressions;
// public static String WhiteSpaceTabPage_arrays;
// public static String WhiteSpaceTabPage_parameterized_types;
// public static String WhiteSpaceTabPage_after_opening_brace;
// public static String WhiteSpaceTabPage_after_closing_brace;
// public static String WhiteSpaceTabPage_before_opening_brace;
// public static String WhiteSpaceTabPage_before_closing_brace;
// public static String WhiteSpaceTabPage_between_empty_braces;
// public static String WhiteSpaceTabPage_after_opening_paren;
// public static String WhiteSpaceTabPage_after_closing_paren;
// public static String WhiteSpaceTabPage_before_opening_paren;
// public static String WhiteSpaceTabPage_before_closing_paren;
// public static String WhiteSpaceTabPage_between_empty_parens;
// public static String WhiteSpaceTabPage_after_opening_bracket;
// public static String WhiteSpaceTabPage_before_opening_bracket;
// public static String WhiteSpaceTabPage_before_closing_bracket;
// public static String WhiteSpaceTabPage_between_empty_brackets;
// public static String WhiteSpaceTabPage_before_comma_in_params;
// public static String WhiteSpaceTabPage_after_comma_in_params;
// public static String WhiteSpaceTabPage_before_comma_in_throws;
// public static String WhiteSpaceTabPage_after_comma_in_throws;
// public static String WhiteSpaceTabPage_before_ellipsis;
// public static String WhiteSpaceTabPage_after_ellipsis;
// public static String WhiteSpaceTabPage_before_comma;
// public static String WhiteSpaceTabPage_after_comma;
// public static String WhiteSpaceTabPage_after_semicolon;
// public static String WhiteSpaceTabPage_before_semicolon;
// public static String WhiteSpaceTabPage_before_colon;
// public static String WhiteSpaceTabPage_after_colon;
// public static String WhiteSpaceTabPage_before_question;
// public static String WhiteSpaceTabPage_after_question;
// public static String WhiteSpaceTabPage_before_at;
// public static String WhiteSpaceTabPage_after_at;
// public static String WhiteSpaceTabPage_after_opening_angle_bracket;
// public static String WhiteSpaceTabPage_after_closing_angle_bracket;
// public static String WhiteSpaceTabPage_before_opening_angle_bracket;
// public static String WhiteSpaceTabPage_before_closing_angle_bracket;
// public static String WhiteSpaceTabPage_before_and_list;
// public static String WhiteSpaceTabPage_after_and_list;
// public static String WhiteSpaceTabPage_enum_decl_before_opening_brace;
// public static String WhiteSpaceTabPage_enum_decl_before_comma;
// public static String WhiteSpaceTabPage_enum_decl_after_comma;
// public static String WhiteSpaceTabPage_enum_const_arg_before_opening_paren;
// public static String WhiteSpaceTabPage_enum_const_arg_after_opening_paren;
// public static String WhiteSpaceTabPage_enum_const_arg_between_empty_parens;
// public static String WhiteSpaceTabPage_enum_const_arg_before_comma;
// public static String WhiteSpaceTabPage_enum_const_arg_after_comma;
// public static String WhiteSpaceTabPage_enum_const_arg_before_closing_paren;
// public static String WhiteSpaceTabPage_enum_const_before_opening_brace;
// public static String WhiteSpaceTabPage_annot_type_method_before_opening_paren;
// public static String WhiteSpaceTabPage_annot_type_method_between_empty_parens;
// public static String WhiteSpaceTabPage_before_parenthesized_expressions;
// public static String WhiteSpaceTabPage_insert_space;
// public static String WhiteSpaceTabPage_sort_by_c_element;
// public static String WhiteSpaceTabPage_sort_by_syntax_element;
// public static String WhiteSpaceOptions_return;
// public static String WhiteSpaceOptions_before;
// public static String WhiteSpaceOptions_after;
// public static String WhiteSpaceOptions_operator;
// public static String WhiteSpaceOptions_assignment_operator;
// public static String WhiteSpaceOptions_binary_operator;
// public static String WhiteSpaceOptions_unary_operator;
// public static String WhiteSpaceOptions_prefix_operator;
// public static String WhiteSpaceOptions_postfix_operator;
// public static String WhiteSpaceOptions_opening_paren;
// public static String WhiteSpaceOptions_catch;
// public static String WhiteSpaceOptions_for;
// public static String WhiteSpaceOptions_if;
// public static String WhiteSpaceOptions_switch;
// public static String WhiteSpaceOptions_synchronized;
// public static String WhiteSpaceOptions_while;
// public static String WhiteSpaceOptions_assert;
// public static String WhiteSpaceOptions_member_function_declaration;
// public static String WhiteSpaceOptions_constructor;
// public static String WhiteSpaceOptions_method;
// public static String WhiteSpaceOptions_method_call;
// public static String WhiteSpaceOptions_paren_expr;
// public static String WhiteSpaceOptions_enum_constant_body;
// public static String WhiteSpaceOptions_enum_constant_arguments;
// public static String WhiteSpaceOptions_enum_declaration;
// public static String WhiteSpaceOptions_annotation_modifier;
// public static String WhiteSpaceOptions_annotation_modifier_args;
// public static String WhiteSpaceOptions_annotation_type_member;
// public static String WhiteSpaceOptions_annotation_type;
// public static String WhiteSpaceOptions_type_cast;
// public static String WhiteSpaceOptions_parameterized_type;
// public static String WhiteSpaceOptions_type_arguments;
// public static String WhiteSpaceOptions_type_parameters;
// public static String WhiteSpaceOptions_vararg_parameter;
// public static String WhiteSpaceOptions_closing_paren;
// public static String WhiteSpaceOptions_opening_brace;
// public static String WhiteSpaceOptions_closing_brace;
// public static String WhiteSpaceOptions_opening_bracket;
// public static String WhiteSpaceOptions_closing_bracket;
// public static String WhiteSpaceOptions_class_decl;
// public static String WhiteSpaceOptions_anon_class_decl;
// public static String WhiteSpaceOptions_initializer;
// public static String WhiteSpaceOptions_block;
// public static String WhiteSpaceOptions_array_decl;
// public static String WhiteSpaceOptions_array_element_access;
// public static String WhiteSpaceOptions_array_alloc;
// public static String WhiteSpaceOptions_array_init;
// public static String WhiteSpaceOptions_arguments;
// public static String WhiteSpaceOptions_initialization;
// public static String WhiteSpaceOptions_incrementation;
// public static String WhiteSpaceOptions_parameters;
// public static String WhiteSpaceOptions_explicit_constructor_call;
public static String WhiteSpaceTabPage_statements;
public static String WhiteSpaceTabPage_blocks;
public static String WhiteSpaceTabPage_switch;
public static String WhiteSpaceTabPage_switch_before_case_colon;
public static String WhiteSpaceTabPage_switch_before_default_colon;
public static String WhiteSpaceTabPage_do;
public static String WhiteSpaceTabPage_try;
public static String WhiteSpaceTabPage_if;
public static String WhiteSpaceTabPage_for;
public static String WhiteSpaceTabPage_labels;
public static String WhiteSpaceTabPage_template_arguments;
public static String WhiteSpaceTabPage_template_parameters;
public static String WhiteSpaceTabPage_conditionals;
public static String WhiteSpaceTabPage_typecasts;
public static String WhiteSpaceTabPage_parenexpr;
public static String WhiteSpaceTabPage_declarations;
public static String WhiteSpaceTabPage_expressions;
public static String WhiteSpaceTabPage_arrays;
public static String WhiteSpaceTabPage_templates;
public static String WhiteSpaceTabPage_after_opening_brace;
public static String WhiteSpaceTabPage_after_closing_brace;
public static String WhiteSpaceTabPage_before_opening_brace;
public static String WhiteSpaceTabPage_before_closing_brace;
public static String WhiteSpaceTabPage_between_empty_braces;
public static String WhiteSpaceTabPage_after_opening_paren;
public static String WhiteSpaceTabPage_after_closing_paren;
public static String WhiteSpaceTabPage_before_opening_paren;
public static String WhiteSpaceTabPage_before_closing_paren;
public static String WhiteSpaceTabPage_between_empty_parens;
public static String WhiteSpaceTabPage_after_opening_bracket;
public static String WhiteSpaceTabPage_before_opening_bracket;
public static String WhiteSpaceTabPage_before_closing_bracket;
public static String WhiteSpaceTabPage_between_empty_brackets;
public static String WhiteSpaceTabPage_before_comma_in_params;
public static String WhiteSpaceTabPage_after_comma_in_params;
public static String WhiteSpaceTabPage_before_comma_in_throws;
public static String WhiteSpaceTabPage_after_comma_in_throws;
public static String WhiteSpaceTabPage_before_ellipsis;
public static String WhiteSpaceTabPage_after_ellipsis;
public static String WhiteSpaceTabPage_before_comma;
public static String WhiteSpaceTabPage_after_comma;
public static String WhiteSpaceTabPage_after_semicolon;
public static String WhiteSpaceTabPage_before_semicolon;
public static String WhiteSpaceTabPage_before_colon;
public static String WhiteSpaceTabPage_after_colon;
public static String WhiteSpaceTabPage_before_question;
public static String WhiteSpaceTabPage_after_question;
public static String WhiteSpaceTabPage_after_opening_angle_bracket;
public static String WhiteSpaceTabPage_after_closing_angle_bracket;
public static String WhiteSpaceTabPage_before_opening_angle_bracket;
public static String WhiteSpaceTabPage_before_closing_angle_bracket;
public static String WhiteSpaceTabPage_before_parenthesized_expressions;
public static String WhiteSpaceTabPage_insert_space;
public static String WhiteSpaceTabPage_sort_by_c_element;
public static String WhiteSpaceTabPage_sort_by_syntax_element;
public static String WhiteSpaceOptions_return;
public static String WhiteSpaceOptions_throw;
public static String WhiteSpaceOptions_base_clause;
public static String WhiteSpaceOptions_before;
public static String WhiteSpaceOptions_after;
public static String WhiteSpaceOptions_operator;
public static String WhiteSpaceOptions_assignment_operator;
public static String WhiteSpaceOptions_binary_operator;
public static String WhiteSpaceOptions_unary_operator;
public static String WhiteSpaceOptions_prefix_operator;
public static String WhiteSpaceOptions_postfix_operator;
public static String WhiteSpaceOptions_opening_paren;
public static String WhiteSpaceOptions_catch;
public static String WhiteSpaceOptions_for;
public static String WhiteSpaceOptions_if;
public static String WhiteSpaceOptions_switch;
public static String WhiteSpaceOptions_while;
public static String WhiteSpaceOptions_member_function_declaration;
public static String WhiteSpaceOptions_constructor;
public static String WhiteSpaceOptions_method;
public static String WhiteSpaceOptions_method_call;
public static String WhiteSpaceOptions_paren_expr;
public static String WhiteSpaceOptions_type_cast;
public static String WhiteSpaceOptions_parameterized_type;
public static String WhiteSpaceOptions_template_arguments;
public static String WhiteSpaceOptions_template_parameters;
public static String WhiteSpaceOptions_vararg_parameter;
public static String WhiteSpaceOptions_closing_paren;
public static String WhiteSpaceOptions_opening_brace;
public static String WhiteSpaceOptions_closing_brace;
public static String WhiteSpaceOptions_opening_bracket;
public static String WhiteSpaceOptions_closing_bracket;
public static String WhiteSpaceOptions_class_decl;
public static String WhiteSpaceOptions_initializer_list;
public static String WhiteSpaceOptions_block;
public static String WhiteSpaceOptions_arrays;
public static String WhiteSpaceOptions_arguments;
public static String WhiteSpaceOptions_parameters;
// public static String WhiteSpaceOptions_alloc_expr;
// public static String WhiteSpaceOptions_throws;
// public static String WhiteSpaceOptions_mult_decls;
// public static String WhiteSpaceOptions_local_vars;
// public static String WhiteSpaceOptions_fields;
// public static String WhiteSpaceOptions_implements_clause;
// public static String WhiteSpaceOptions_colon;
// public static String WhiteSpaceOptions_conditional;
// public static String WhiteSpaceOptions_wildcard;
// public static String WhiteSpaceOptions_label;
// public static String WhiteSpaceOptions_comma;
// public static String WhiteSpaceOptions_semicolon;
// public static String WhiteSpaceOptions_question_mark;
// public static String WhiteSpaceOptions_between_empty_parens;
// public static String WhiteSpaceOptions_between_empty_braces;
// public static String WhiteSpaceOptions_between_empty_brackets;
// public static String WhiteSpaceOptions_constructor_decl;
// public static String WhiteSpaceOptions_method_decl;
// public static String WhiteSpaceOptions_case;
// public static String WhiteSpaceOptions_default;
// public static String WhiteSpaceOptions_statements;
// public static String WhiteSpaceOptions_before_opening_paren;
// public static String WhiteSpaceOptions_after_opening_paren;
// public static String WhiteSpaceOptions_before_closing_paren;
// public static String WhiteSpaceOptions_after_closing_paren;
// public static String WhiteSpaceOptions_before_opening_brace;
// public static String WhiteSpaceOptions_after_opening_brace;
// public static String WhiteSpaceOptions_after_closing_brace;
// public static String WhiteSpaceOptions_before_closing_brace;
// public static String WhiteSpaceOptions_before_opening_bracket;
// public static String WhiteSpaceOptions_after_opening_bracket;
// public static String WhiteSpaceOptions_before_closing_bracket;
// public static String WhiteSpaceOptions_before_opening_angle_bracket;
// public static String WhiteSpaceOptions_after_opening_angle_bracket;
// public static String WhiteSpaceOptions_before_closing_angle_bracket;
// public static String WhiteSpaceOptions_after_closing_angle_bracket;
// public static String WhiteSpaceOptions_before_operator;
// public static String WhiteSpaceOptions_after_operator;
// public static String WhiteSpaceOptions_before_comma;
// public static String WhiteSpaceOptions_after_comma;
// public static String WhiteSpaceOptions_after_colon;
// public static String WhiteSpaceOptions_before_colon;
// public static String WhiteSpaceOptions_before_semicolon;
// public static String WhiteSpaceOptions_after_semicolon;
// public static String WhiteSpaceOptions_before_question_mark;
// public static String WhiteSpaceOptions_after_question_mark;
// public static String WhiteSpaceOptions_before_at;
// public static String WhiteSpaceOptions_after_at;
// public static String WhiteSpaceOptions_before_and;
// public static String WhiteSpaceOptions_after_and;
// public static String WhiteSpaceOptions_before_ellipsis;
// public static String WhiteSpaceOptions_after_ellipsis;
// public static String WhiteSpaceOptions_return_with_parenthesized_expression;
public static String WhiteSpaceOptions_throws;
public static String WhiteSpaceOptions_lists;
public static String WhiteSpaceOptions_expression_list;
public static String WhiteSpaceOptions_declarator_list;
public static String WhiteSpaceOptions_colon;
public static String WhiteSpaceOptions_conditional;
public static String WhiteSpaceOptions_label;
public static String WhiteSpaceOptions_comma;
public static String WhiteSpaceOptions_semicolon;
public static String WhiteSpaceOptions_question_mark;
public static String WhiteSpaceOptions_between_empty_parens;
public static String WhiteSpaceOptions_between_empty_braces;
public static String WhiteSpaceOptions_between_empty_brackets;
public static String WhiteSpaceOptions_constructor_decl;
public static String WhiteSpaceOptions_method_decl;
public static String WhiteSpaceOptions_case;
public static String WhiteSpaceOptions_default;
public static String WhiteSpaceOptions_statements;
public static String WhiteSpaceOptions_before_opening_paren;
public static String WhiteSpaceOptions_after_opening_paren;
public static String WhiteSpaceOptions_before_closing_paren;
public static String WhiteSpaceOptions_after_closing_paren;
public static String WhiteSpaceOptions_before_opening_brace;
public static String WhiteSpaceOptions_after_opening_brace;
public static String WhiteSpaceOptions_after_closing_brace;
public static String WhiteSpaceOptions_before_closing_brace;
public static String WhiteSpaceOptions_before_opening_bracket;
public static String WhiteSpaceOptions_after_opening_bracket;
public static String WhiteSpaceOptions_before_closing_bracket;
public static String WhiteSpaceOptions_before_opening_angle_bracket;
public static String WhiteSpaceOptions_after_opening_angle_bracket;
public static String WhiteSpaceOptions_before_closing_angle_bracket;
public static String WhiteSpaceOptions_after_closing_angle_bracket;
public static String WhiteSpaceOptions_before_operator;
public static String WhiteSpaceOptions_after_operator;
public static String WhiteSpaceOptions_before_comma;
public static String WhiteSpaceOptions_after_comma;
public static String WhiteSpaceOptions_after_colon;
public static String WhiteSpaceOptions_before_colon;
public static String WhiteSpaceOptions_before_semicolon;
public static String WhiteSpaceOptions_after_semicolon;
public static String WhiteSpaceOptions_before_question_mark;
public static String WhiteSpaceOptions_after_question_mark;
public static String WhiteSpaceOptions_before_ellipsis;
public static String WhiteSpaceOptions_after_ellipsis;
public static String WhiteSpaceOptions_return_with_parenthesized_expression;
public static String WhiteSpaceOptions_throw_with_parenthesized_expression;
// public static String LineWrappingTabPage_compact_if_else;
// public static String LineWrappingTabPage_extends_clause;
// public static String LineWrappingTabPage_enum_constant_arguments;
// public static String LineWrappingTabPage_enum_constants;
// public static String LineWrappingTabPage_implements_clause;
public static String LineWrappingTabPage_parameters;
public static String LineWrappingTabPage_parameters_description;
public static String LineWrappingTabPage_arguments;
public static String LineWrappingTabPage_arguments_description;
// public static String LineWrappingTabPage_qualified_invocations;
// public static String LineWrappingTabPage_throws_clause;
// public static String LineWrappingTabPage_object_allocation;
// public static String LineWrappingTabPage_qualified_object_allocation;
public static String LineWrappingTabPage_array_init;
public static String LineWrappingTabPage_array_init_description;
// public static String LineWrappingTabPage_explicit_constructor_invocations;
public static String LineWrappingTabPage_initializer_list;
public static String LineWrappingTabPage_initializer_list_description;
public static String LineWrappingTabPage_conditionals;
public static String LineWrappingTabPage_conditionals_description;
// public static String LineWrappingTabPage_binary_exprs;
@ -287,7 +230,6 @@ final class FormatterMessages extends NLS {
public static String LineWrappingTabPage_expressions;
public static String LineWrappingTabPage_expressions_description;
// public static String LineWrappingTabPage_statements;
// public static String LineWrappingTabPage_enum_decls;
public static String LineWrappingTabPage_wrapping_policy_label_text;
public static String LineWrappingTabPage_indentation_policy_label_text;
public static String LineWrappingTabPage_force_split_checkbox_text;
@ -308,7 +250,6 @@ final class FormatterMessages extends NLS {
public static String LineWrappingTabPage_width_indent_option_default_indent_wrapped;
public static String LineWrappingTabPage_width_indent_option_default_indent_array;
public static String LineWrappingTabPage_error_invalid_value;
// public static String LineWrappingTabPage_enum_superinterfaces;
// public static String LineWrappingTabPage_assignment_alignment;
public static String AlreadyExistsDialog_message_profile_already_exists;
public static String AlreadyExistsDialog_message_profile_name_empty;
@ -345,11 +286,8 @@ final class FormatterMessages extends NLS {
public static String BracesTabPage_option_blocks;
public static String BracesTabPage_option_blocks_in_case;
public static String BracesTabPage_option_switch_case;
public static String BracesTabPage_option_array_initializer;
public static String BracesTabPage_option_keep_empty_array_initializer_on_one_line;
// public static String BracesTabPage_option_enum_declaration;
// public static String BracesTabPage_option_enumconst_declaration;
// public static String BracesTabPage_option_annotation_type_declaration;
public static String BracesTabPage_option_initializer_list;
public static String BracesTabPage_option_keep_empty_initializer_list_on_one_line;
public static String CodingStyleConfigurationBlock_save_profile_dialog_title;
public static String CodingStyleConfigurationBlock_save_profile_error_title;
public static String CodingStyleConfigurationBlock_save_profile_error_message;
@ -419,8 +357,6 @@ final class FormatterMessages extends NLS {
public static String IndentationTabPage_indent_group_title;
public static String IndentationTabPage_class_group_option_indent_access_specifiers_within_class_body;
public static String IndentationTabPage_class_group_option_indent_declarations_compare_to_access_specifiers;
// public static String IndentationTabPage_class_group_option_indent_declarations_within_enum_const;
// public static String IndentationTabPage_class_group_option_indent_declarations_within_enum_decl;
public static String IndentationTabPage_block_group_option_indent_statements_compare_to_body;
public static String IndentationTabPage_block_group_option_indent_statements_compare_to_block;
public static String IndentationTabPage_switch_group_option_indent_statements_within_switch_body;
@ -429,12 +365,11 @@ final class FormatterMessages extends NLS {
public static String IndentationTabPage_namespace_group_option_indent_declarations_within_namespace;
public static String IndentationTabPage_indent_empty_lines;
public static String IndentationTabPage_use_tabs_only_for_leading_indentations;
public static String IndentationTabPage_show_whitespace_in_preview_label_text;
public static String ModifyDialog_dialog_title;
public static String ModifyDialog_apply_button;
public static String ModifyDialog_tabpage_braces_title;
public static String ModifyDialog_tabpage_indentation_title;
// public static String ModifyDialog_tabpage_whitespace_title;
public static String ModifyDialog_tabpage_whitespace_title;
// public static String ModifyDialog_tabpage_blank_lines_title;
// public static String ModifyDialog_tabpage_new_lines_title;
// public static String ModifyDialog_tabpage_control_statements_title;
@ -448,10 +383,6 @@ final class FormatterMessages extends NLS {
// public static String NewLinesTabPage_preview_header;
// public static String NewLinesTabPage_newlines_group_title;
// public static String NewLinesTabPage_newlines_group_option_empty_class_body;
// public static String NewLinesTabPage_newlines_group_option_empty_annotation_decl_body;
// public static String NewLinesTabPage_newlines_group_option_empty_anonymous_class_body;
// public static String NewLinesTabPage_newlines_group_option_empty_enum_declaration;
// public static String NewLinesTabPage_newlines_group_option_empty_enum_constant;
// public static String NewLinesTabPage_newlines_group_option_empty_method_body;
// public static String NewLinesTabPage_newlines_group_option_empty_block;
// public static String NewLinesTabPage_newlines_group_option_empty_end_of_file;

View file

@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2000, 2007 IBM Corporation and others.
# Copyright (c) 2000, 2008 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@ -13,307 +13,239 @@
# Anton Leherbauer (Wind River Systems)
###############################################################################
WhiteSpaceTabPage_assignments=Assignments
WhiteSpaceTabPage_assignments_before_assignment_operator=before assignment operator
WhiteSpaceTabPage_assignments_after_assignment_operator=after assignment operator
#WhiteSpaceTabPage_assignments=Assignments
#WhiteSpaceTabPage_assignments_before_assignment_operator=before assignment operator
#WhiteSpaceTabPage_assignments_after_assignment_operator=after assignment operator
WhiteSpaceTabPage_operators=Operators
WhiteSpaceTabPage_operators_before_binary_operators=before binary operators
WhiteSpaceTabPage_operators_after_binary_operators=after binary operators
WhiteSpaceTabPage_operators_before_unary_operators=before unary operators
WhiteSpaceTabPage_operators_after_unary_operators=after unary operators
WhiteSpaceTabPage_operators_before_prefix_operators=before prefix operators
WhiteSpaceTabPage_operators_after_prefix_operators=after prefix operators
WhiteSpaceTabPage_operators_before_postfix_operators=before postfix operators
WhiteSpaceTabPage_operators_after_postfix_operators=after postfix operators
#WhiteSpaceTabPage_operators=Operators
#WhiteSpaceTabPage_operators_before_binary_operators=before binary operators
#WhiteSpaceTabPage_operators_after_binary_operators=after binary operators
#WhiteSpaceTabPage_operators_before_unary_operators=before unary operators
#WhiteSpaceTabPage_operators_after_unary_operators=after unary operators
#WhiteSpaceTabPage_operators_before_prefix_operators=before prefix operators
#WhiteSpaceTabPage_operators_after_prefix_operators=after prefix operators
#WhiteSpaceTabPage_operators_before_postfix_operators=before postfix operators
#WhiteSpaceTabPage_operators_after_postfix_operators=after postfix operators
WhiteSpaceTabPage_classes=Types
WhiteSpaceTabPage_classes_before_opening_brace_of_a_class=before opening brace of a class
WhiteSpaceTabPage_classes_before_colon_of_base_clause=before colon of base clause
WhiteSpaceTabPage_classes_after_colon_of_base_clause=after colon of base clause
WhiteSpaceTabPage_classes_before_comma_base_types=before comma in base clause
WhiteSpaceTabPage_classes_after_comma_base_types=after comma in base clause
WhiteSpaceTabPage_methods=Methods
WhiteSpaceTabPage_constructors=Constructors
#WhiteSpaceTabPage_classes=Classes
#WhiteSpaceTabPage_classes_before_opening_brace_of_a_class=before opening brace of a class
#WhiteSpaceTabPage_classes_before_opening_brace_of_anon_class=before opening brace of an anonymous class
#WhiteSpaceTabPage_classes_before_comma_implements=before comma in implements clause
#WhiteSpaceTabPage_classes_after_comma_implements=after comma in implements clause
WhiteSpaceTabPage_declarator_list=Declarator list
WhiteSpaceTabPage_declarator_list_before_comma=before comma in declarator list
WhiteSpaceTabPage_declarator_list_after_comma=after comma in declarator list
WhiteSpaceTabPage_expression_list=Expression list
WhiteSpaceTabPage_expression_list_before_comma=before comma in expression list
WhiteSpaceTabPage_expression_list_after_comma=after comma in expression list
WhiteSpaceTabPage_initializer_list=Initializer list
#WhiteSpaceTabPage_methods=Methods
#WhiteSpaceTabPage_constructors=Constructors
WhiteSpaceTabPage_calls=Function invocations
#WhiteSpaceTabPage_fields=Fields
#WhiteSpaceTabPage_fields_before_comma=before comma in multiple field declarations
#WhiteSpaceTabPage_fields_after_comma=after comma in multiple field declarations
#WhiteSpaceTabPage_localvars=Local variables
#WhiteSpaceTabPage_localvars_before_comma=before comma in multiple local declarations
#WhiteSpaceTabPage_localvars_after_comma=after comma in multiple local declarations
#WhiteSpaceTabPage_arrayinit=Initializer lists
#WhiteSpaceTabPage_arraydecls=Array declarations
#WhiteSpaceTabPage_arrayelem=Array element access
#WhiteSpaceTabPage_arrayalloc=Array allocation
#WhiteSpaceTabPage_calls=Function invocations
#WhiteSpaceTabPage_calls_before_comma_in_method_args=before comma in method arguments
#WhiteSpaceTabPage_calls_after_comma_in_method_args=after comma in method arguments
WhiteSpaceTabPage_calls_before_comma_in_method_args=before comma in method arguments
WhiteSpaceTabPage_calls_after_comma_in_method_args=after comma in method arguments
#WhiteSpaceTabPage_calls_before_comma_in_alloc=before comma in object allocation arguments
#WhiteSpaceTabPage_calls_after_comma_in_alloc=after comma in object allocation arguments
#WhiteSpaceTabPage_calls_before_comma_in_qalloc=before comma in explicit constructor call
#WhiteSpaceTabPage_calls_after_comma_in_qalloc=after comma in explicit constructor call
#WhiteSpaceTabPage_statements=Control statements
WhiteSpaceTabPage_statements=Control statements
#WhiteSpaceTabPage_blocks=Blocks
WhiteSpaceTabPage_blocks=Blocks
#WhiteSpaceTabPage_switch='switch'
#WhiteSpaceTabPage_switch_before_case_colon=before colon in case
#WhiteSpaceTabPage_switch_before_default_colon=before colon in default
WhiteSpaceTabPage_switch='switch'
WhiteSpaceTabPage_switch_before_case_colon=before colon in case
WhiteSpaceTabPage_switch_before_default_colon=before colon in default
#WhiteSpaceTabPage_do='while' & 'do while'
WhiteSpaceTabPage_do='while' & 'do while'
#WhiteSpaceTabPage_synchronized='synchronized'
WhiteSpaceTabPage_try='catch'
#WhiteSpaceTabPage_try='catch'
WhiteSpaceTabPage_if='if else'
#WhiteSpaceTabPage_if='if else'
#WhiteSpaceTabPage_assert='assert'
#WhiteSpaceTabPage_for='for'
WhiteSpaceTabPage_for='for'
#WhiteSpaceTabPage_for_before_comma_init=before comma in initialization
#WhiteSpaceTabPage_for_after_comma_init=after comma in initialization
#WhiteSpaceTabPage_for_before_comma_inc=before comma in increments
#WhiteSpaceTabPage_for_after_comma_inc=after comma in increments
#WhiteSpaceTabPage_labels=Labels
#WhiteSpaceTabPage_annotations=Annotations
#WhiteSpaceTabPage_annotation_types=Annotation types
#WhiteSpaceTabPage_enums=Enum types
#WhiteSpaceTabPage_wildcardtype=Wildcard type
#WhiteSpaceTabPage_param_type_ref=Type reference
#WhiteSpaceTabPage_type_arguments=Type arguments
#WhiteSpaceTabPage_type_parameters=Type parameters
WhiteSpaceTabPage_labels=Labels
WhiteSpaceTabPage_template_arguments=Template arguments
WhiteSpaceTabPage_template_parameters=Template parameters
#WhiteSpaceTabPage_conditionals=Conditionals
WhiteSpaceTabPage_conditionals=Conditionals
#WhiteSpaceTabPage_typecasts=Type casts
WhiteSpaceTabPage_typecasts=Type casts
#WhiteSpaceTabPage_parenexpr=Parenthesized expressions
#WhiteSpaceTabPage_declarations=Declarations
#WhiteSpaceTabPage_expressions=Expressions
#WhiteSpaceTabPage_arrays=Arrays
#WhiteSpaceTabPage_parameterized_types=Parameterized types
WhiteSpaceTabPage_parenexpr=Parenthesized expressions
WhiteSpaceTabPage_declarations=Declarations
WhiteSpaceTabPage_expressions=Expressions
WhiteSpaceTabPage_arrays=Arrays
WhiteSpaceTabPage_templates=Templates
WhiteSpaceTabPage_after_opening_brace=after opening brace
WhiteSpaceTabPage_after_closing_brace=after closing brace
WhiteSpaceTabPage_before_opening_brace=before opening brace
WhiteSpaceTabPage_before_closing_brace=before closing brace
WhiteSpaceTabPage_between_empty_braces=between empty braces
#WhiteSpaceTabPage_after_opening_brace=after opening brace
#WhiteSpaceTabPage_after_closing_brace=after closing brace
#WhiteSpaceTabPage_before_opening_brace=before opening brace
#WhiteSpaceTabPage_before_closing_brace=before closing brace
#WhiteSpaceTabPage_between_empty_braces=between empty braces
WhiteSpaceTabPage_after_opening_paren=after opening parenthesis
WhiteSpaceTabPage_after_closing_paren=after closing parenthesis
WhiteSpaceTabPage_before_opening_paren=before opening parenthesis
WhiteSpaceTabPage_before_closing_paren=before closing parenthesis
WhiteSpaceTabPage_between_empty_parens=between empty parenthesis
WhiteSpaceTabPage_after_opening_bracket=after opening bracket
WhiteSpaceTabPage_before_opening_bracket=before opening bracket
WhiteSpaceTabPage_before_closing_bracket=before closing bracket
WhiteSpaceTabPage_between_empty_brackets=between empty brackets
#WhiteSpaceTabPage_after_opening_paren=after opening parenthesis
#WhiteSpaceTabPage_after_closing_paren=after closing parenthesis
#WhiteSpaceTabPage_before_opening_paren=before opening parenthesis
#WhiteSpaceTabPage_before_closing_paren=before closing parenthesis
#WhiteSpaceTabPage_between_empty_parens=between empty parenthesis
WhiteSpaceTabPage_before_comma_in_params=before comma in parameters
WhiteSpaceTabPage_after_comma_in_params=after comma in parameters
WhiteSpaceTabPage_before_comma_in_throws=before comma in 'throws' clause
WhiteSpaceTabPage_after_comma_in_throws=after comma in 'throws' clause
#WhiteSpaceTabPage_after_opening_bracket=after opening bracket
#WhiteSpaceTabPage_before_opening_bracket=before opening bracket
#WhiteSpaceTabPage_before_closing_bracket=before closing bracket
#WhiteSpaceTabPage_between_empty_brackets=between empty brackets
WhiteSpaceTabPage_before_ellipsis=before ellipsis in vararg parameters
WhiteSpaceTabPage_after_ellipsis=after ellipsis in vararg parameters
#WhiteSpaceTabPage_before_comma_in_params=before comma in parameters
#WhiteSpaceTabPage_after_comma_in_params=after comma in parameters
#WhiteSpaceTabPage_before_comma_in_throws=before comma in 'throws' clause
#WhiteSpaceTabPage_after_comma_in_throws=after comma in 'throws' clause
WhiteSpaceTabPage_before_comma=before comma
WhiteSpaceTabPage_after_comma=after comma
#WhiteSpaceTabPage_before_ellipsis=before ellipsis in vararg parameters
#WhiteSpaceTabPage_after_ellipsis=after ellipsis in vararg parameters
WhiteSpaceTabPage_after_semicolon=after semicolon
WhiteSpaceTabPage_before_semicolon=before semicolon
#WhiteSpaceTabPage_before_comma=before comma
#WhiteSpaceTabPage_after_comma=after comma
WhiteSpaceTabPage_before_colon=before colon
WhiteSpaceTabPage_after_colon=after colon
#WhiteSpaceTabPage_after_semicolon=after semicolon
#WhiteSpaceTabPage_before_semicolon=before semicolon
WhiteSpaceTabPage_before_question=before question mark
WhiteSpaceTabPage_after_question=after question mark
#WhiteSpaceTabPage_before_colon=before colon
#WhiteSpaceTabPage_after_colon=after colon
WhiteSpaceTabPage_after_opening_angle_bracket=after opening angle bracket
WhiteSpaceTabPage_after_closing_angle_bracket=after closing angle bracket
WhiteSpaceTabPage_before_opening_angle_bracket=before opening angle bracket
WhiteSpaceTabPage_before_closing_angle_bracket=before closing angle bracket
WhiteSpaceTabPage_before_parenthesized_expressions=before parenthesized expressions
#WhiteSpaceTabPage_before_question=before question mark
#WhiteSpaceTabPage_after_question=after question mark
WhiteSpaceTabPage_sort_by_c_element=Sort options by C/C++ element
WhiteSpaceTabPage_sort_by_syntax_element=Sort options by Syntax element
#WhiteSpaceTabPage_before_at=before @
#WhiteSpaceTabPage_after_at=after @
WhiteSpaceOptions_base_clause=Base clause
WhiteSpaceOptions_before=Before
WhiteSpaceOptions_after=After
#WhiteSpaceTabPage_after_opening_angle_bracket=after opening angle bracket
#WhiteSpaceTabPage_after_closing_angle_bracket=after closing angle bracket
#WhiteSpaceTabPage_before_opening_angle_bracket=before opening angle bracket
#WhiteSpaceTabPage_before_closing_angle_bracket=before closing angle bracket
#WhiteSpaceTabPage_before_parenthesized_expressions=before parenthesized expressions
WhiteSpaceOptions_operator=Operator
WhiteSpaceOptions_assignment_operator=Assignment operator
WhiteSpaceOptions_binary_operator=Binary operator
WhiteSpaceOptions_unary_operator=Unary operator
WhiteSpaceOptions_prefix_operator=Prefix operator
WhiteSpaceOptions_postfix_operator=Postfix operator
#WhiteSpaceTabPage_before_and_list=before '&' in type bounds
#WhiteSpaceTabPage_after_and_list=after '&' in type bounds
WhiteSpaceOptions_opening_paren=Opening parenthesis
WhiteSpaceOptions_catch='catch'
WhiteSpaceOptions_for='for'
WhiteSpaceOptions_if='if'
WhiteSpaceOptions_switch='switch'
WhiteSpaceOptions_while='while'
WhiteSpaceOptions_member_function_declaration=Member function declaration
WhiteSpaceOptions_constructor=Constructor
WhiteSpaceOptions_method=Method
WhiteSpaceOptions_method_call=Method call
WhiteSpaceOptions_paren_expr=Parenthesized expression
#WhiteSpaceTabPage_enum_decl_before_opening_brace=before opening brace in declaration
#WhiteSpaceTabPage_enum_decl_before_comma=before comma between constants
#WhiteSpaceTabPage_enum_decl_after_comma=after comma between constants
WhiteSpaceOptions_type_cast=Type cast
WhiteSpaceOptions_parameterized_type=Parameterized type
WhiteSpaceOptions_template_arguments=Template arguments
WhiteSpaceOptions_template_parameters=Template parameters
WhiteSpaceOptions_vararg_parameter=Vararg parameters
#WhiteSpaceTabPage_enum_const_arg_before_opening_paren=before opening parenthesis in constant arguments
#WhiteSpaceTabPage_enum_const_arg_after_opening_paren=after opening parenthesis in constant arguments
#WhiteSpaceTabPage_enum_const_arg_between_empty_parens=between empty parenthesis in constant arguments
#WhiteSpaceTabPage_enum_const_arg_before_comma=before comma in constant arguments
#WhiteSpaceTabPage_enum_const_arg_after_comma=after comma in constant arguments
#WhiteSpaceTabPage_enum_const_arg_before_closing_paren=before closing parenthesis in constant arguments
WhiteSpaceOptions_closing_paren=Closing parenthesis
#WhiteSpaceTabPage_enum_const_before_opening_brace=before opening brace of constant body
WhiteSpaceOptions_opening_brace=Opening brace
WhiteSpaceOptions_closing_brace=Closing brace
WhiteSpaceOptions_opening_bracket=Opening bracket
WhiteSpaceOptions_closing_bracket=Closing bracket
WhiteSpaceOptions_class_decl=Type declaration
WhiteSpaceOptions_initializer_list=Initializer list
WhiteSpaceOptions_block=Block
#WhiteSpaceTabPage_annot_type_method_before_opening_paren=before opening parenthesis in annotation type members
#WhiteSpaceTabPage_annot_type_method_between_empty_parens=between parenthesis in annotation type members
#WhiteSpaceTabPage_sort_by_c_element=Sort options by C element
#WhiteSpaceTabPage_sort_by_syntax_element=Sort options by Syntax element
#WhiteSpaceOptions_before=Before
#WhiteSpaceOptions_after=After
#WhiteSpaceOptions_operator=Operator
#WhiteSpaceOptions_assignment_operator=Assignment operator
#WhiteSpaceOptions_binary_operator=Binary operator
#WhiteSpaceOptions_unary_operator=Unary operator
#WhiteSpaceOptions_prefix_operator=Prefix operator
#WhiteSpaceOptions_postfix_operator=Postfix operator
#WhiteSpaceOptions_opening_paren=Opening parenthesis
#WhiteSpaceOptions_catch='catch'
#WhiteSpaceOptions_for='for'
#WhiteSpaceOptions_if='if'
#WhiteSpaceOptions_switch='switch'
#WhiteSpaceOptions_synchronized='synchronized'
#WhiteSpaceOptions_while='while'
#WhiteSpaceOptions_assert='assert'
#WhiteSpaceOptions_member_function_declaration=Member function declaration
#WhiteSpaceOptions_constructor=Constructor
#WhiteSpaceOptions_method=Method
#WhiteSpaceOptions_method_call=Method call
#WhiteSpaceOptions_paren_expr=Parenthesized expression
#WhiteSpaceOptions_enum_constant_body=Enum constant body
#WhiteSpaceOptions_enum_constant_arguments=Enum constant arguments
#WhiteSpaceOptions_enum_declaration=Enum declaration
#WhiteSpaceOptions_annotation_modifier=Annotation
#WhiteSpaceOptions_annotation_modifier_args=Annotation arguments
#WhiteSpaceOptions_annotation_type_member=Annotation type member
#WhiteSpaceOptions_annotation_type=Annotation type
#WhiteSpaceOptions_type_cast=Type cast
#WhiteSpaceOptions_parameterized_type=Parameterized type
#WhiteSpaceOptions_type_arguments=Type arguments
#WhiteSpaceOptions_type_parameters=Type parameters
#WhiteSpaceOptions_vararg_parameter=Vararg parameters
#WhiteSpaceOptions_closing_paren=Closing parenthesis
#WhiteSpaceOptions_opening_brace=Opening brace
#WhiteSpaceOptions_closing_brace=Closing brace
#WhiteSpaceOptions_opening_bracket=Opening bracket
#WhiteSpaceOptions_closing_bracket=Closing bracket
#WhiteSpaceOptions_class_decl=Type declaration
#WhiteSpaceOptions_anon_class_decl=Anonymous type declaration
#WhiteSpaceOptions_initializer=Initializer lists
#WhiteSpaceOptions_block=Block
#WhiteSpaceOptions_array_decl=Array declaration
#WhiteSpaceOptions_array_element_access=Array element access
#WhiteSpaceOptions_array_alloc=Array allocation
#WhiteSpaceOptions_array_init=Initializer list
#WhiteSpaceOptions_arguments=Arguments
WhiteSpaceOptions_arrays=Arrays
WhiteSpaceOptions_initializer_list=Initializer list
WhiteSpaceOptions_arguments=Arguments
#WhiteSpaceOptions_initialization=Initialization
#WhiteSpaceOptions_incrementation=Increment
#WhiteSpaceOptions_parameters=Parameters
WhiteSpaceOptions_parameters=Parameters
#WhiteSpaceOptions_explicit_constructor_call=Explicit constructor call
#WhiteSpaceOptions_alloc_expr=Allocation expression
#WhiteSpaceOptions_throws='throws' clause
#WhiteSpaceOptions_mult_decls=Multiple declarations
#WhiteSpaceOptions_local_vars=Local variables
#WhiteSpaceOptions_fields=Fields
#WhiteSpaceOptions_return='return'
#WhiteSpaceOptions_implements_clause='extends'/'implements' clause
#WhiteSpaceOptions_colon=Colon
#WhiteSpaceOptions_conditional=Conditional
#WhiteSpaceOptions_wildcard=Wildcard type
#WhiteSpaceOptions_label=Label
#WhiteSpaceOptions_comma=Comma
WhiteSpaceOptions_throws='throws' clause
WhiteSpaceOptions_lists=Lists
WhiteSpaceOptions_expression_list=Expression list
WhiteSpaceOptions_declarator_list=Declarator list
WhiteSpaceOptions_return='return'
WhiteSpaceOptions_throw='throw'
WhiteSpaceOptions_colon=Colon
WhiteSpaceOptions_conditional=Conditional
WhiteSpaceOptions_label=Label
WhiteSpaceOptions_comma=Comma
#WhiteSpaceOptions_semicolon=Semicolon
#WhiteSpaceOptions_question_mark=Question mark
#WhiteSpaceOptions_between_empty_parens=Between empty parenthesis
#WhiteSpaceOptions_between_empty_braces=Between empty braces
#WhiteSpaceOptions_between_empty_brackets=Between empty brackets
#WhiteSpaceOptions_constructor_decl=Constructor declaration
#WhiteSpaceOptions_method_decl=Method declaration
#WhiteSpaceOptions_case='case'
#WhiteSpaceOptions_default='default'
#WhiteSpaceOptions_statements=Statements
WhiteSpaceOptions_semicolon=Semicolon
WhiteSpaceOptions_question_mark=Question mark
WhiteSpaceOptions_between_empty_parens=Between empty parenthesis
WhiteSpaceOptions_between_empty_braces=Between empty braces
WhiteSpaceOptions_between_empty_brackets=Between empty brackets
WhiteSpaceOptions_constructor_decl=Constructor declaration
WhiteSpaceOptions_method_decl=Method declaration
WhiteSpaceOptions_case='case'
WhiteSpaceOptions_default='default'
WhiteSpaceOptions_statements=Statements
WhiteSpaceOptions_before_opening_paren=Before opening parenthesis
WhiteSpaceOptions_after_opening_paren=After opening parenthesis
WhiteSpaceOptions_before_closing_paren=Before closing parenthesis
WhiteSpaceOptions_after_closing_paren=After closing parenthesis
WhiteSpaceOptions_before_opening_brace=Before opening brace
WhiteSpaceOptions_after_opening_brace=After opening brace
WhiteSpaceOptions_after_closing_brace=After closing brace
WhiteSpaceOptions_before_closing_brace=Before closing brace
WhiteSpaceOptions_before_opening_bracket=Before opening bracket
WhiteSpaceOptions_after_opening_bracket=After opening bracket
WhiteSpaceOptions_before_closing_bracket=Before closing bracket
#WhiteSpaceOptions_before_opening_paren=Before opening parenthesis
#WhiteSpaceOptions_after_opening_paren=After opening parenthesis
#WhiteSpaceOptions_before_closing_paren=Before closing parenthesis
WhiteSpaceOptions_before_opening_angle_bracket=Before opening angle bracket
WhiteSpaceOptions_after_opening_angle_bracket=After opening angle bracket
WhiteSpaceOptions_before_closing_angle_bracket=Before closing angle bracket
WhiteSpaceOptions_return_with_parenthesized_expression='return' with parenthesized expression
WhiteSpaceOptions_throw_with_parenthesized_expression='throws' with parenthesized expression
WhiteSpaceOptions_after_closing_angle_bracket=After closing angle bracket
#WhiteSpaceOptions_after_closing_paren=After closing parenthesis
#WhiteSpaceOptions_before_opening_brace=Before opening brace
#WhiteSpaceOptions_after_opening_brace=After opening brace
#WhiteSpaceOptions_after_closing_brace=After closing brace
#WhiteSpaceOptions_before_closing_brace=Before closing brace
#WhiteSpaceOptions_before_opening_bracket=Before opening bracket
#WhiteSpaceOptions_after_opening_bracket=After opening bracket
#WhiteSpaceOptions_before_closing_bracket=Before closing bracket
WhiteSpaceOptions_before_operator=Before operator
WhiteSpaceOptions_after_operator=After operator
WhiteSpaceOptions_before_comma=Before comma
WhiteSpaceOptions_after_comma=After comma
WhiteSpaceOptions_after_colon=After colon
WhiteSpaceOptions_before_colon=Before colon
WhiteSpaceOptions_before_semicolon=Before semicolon
WhiteSpaceOptions_after_semicolon=After semicolon
WhiteSpaceOptions_before_question_mark=Before question mark
WhiteSpaceOptions_after_question_mark=After question mark
#WhiteSpaceOptions_before_opening_angle_bracket=Before opening angle bracket
#WhiteSpaceOptions_after_opening_angle_bracket=After opening angle bracket
#WhiteSpaceOptions_before_closing_angle_bracket=Before closing angle bracket
#WhiteSpaceOptions_return_with_parenthesized_expression=parenthesized expression
#WhiteSpaceOptions_after_closing_angle_bracket=After closing angle bracket
WhiteSpaceOptions_before_ellipsis=Before Ellipsis
WhiteSpaceOptions_after_ellipsis=After Ellipsis
#WhiteSpaceOptions_before_operator=Before operator
#WhiteSpaceOptions_after_operator=After operator
#WhiteSpaceOptions_before_comma=Before comma
#WhiteSpaceOptions_after_comma=After comma
#WhiteSpaceOptions_after_colon=After colon
#WhiteSpaceOptions_before_colon=Before colon
#WhiteSpaceOptions_before_semicolon=Before semicolon
#WhiteSpaceOptions_after_semicolon=After semicolon
#WhiteSpaceOptions_before_question_mark=Before question mark
#WhiteSpaceOptions_after_question_mark=After question mark
#WhiteSpaceOptions_before_at=Before @
#WhiteSpaceOptions_after_at=After @
#WhiteSpaceOptions_before_and=Before & list
#WhiteSpaceOptions_after_and=After & list
#WhiteSpaceOptions_before_ellipsis=Before Ellipsis
#WhiteSpaceOptions_after_ellipsis=After Ellipsis
#WhiteSpaceTabPage_insert_space=&Insert space:
WhiteSpaceTabPage_insert_space=&Insert space:
#LineWrappingTabPage_compact_if_else=Compact 'if else'
#LineWrappingTabPage_extends_clause='extends' clause
#LineWrappingTabPage_enum_constant_arguments=Constant arguments
#LineWrappingTabPage_enum_constants=Constants
#LineWrappingTabPage_implements_clause='implements' clause
LineWrappingTabPage_parameters=Parameters
LineWrappingTabPage_parameters_description=parameters
LineWrappingTabPage_arguments=Arguments
LineWrappingTabPage_arguments_description=arguments
#LineWrappingTabPage_qualified_invocations=Qualified invocations
#LineWrappingTabPage_throws_clause='throws' clause
#LineWrappingTabPage_object_allocation=Object allocation arguments
#LineWrappingTabPage_qualified_object_allocation=Qualified object allocation arguments
LineWrappingTabPage_array_init=Initializer Lists
LineWrappingTabPage_array_init_description=initializer lists
#LineWrappingTabPage_explicit_constructor_invocations=Explicit constructor invocations
LineWrappingTabPage_initializer_list=Initializer List
LineWrappingTabPage_initializer_list_description=initializer list
LineWrappingTabPage_conditionals=Conditionals
LineWrappingTabPage_conditionals_description=conditionals
#LineWrappingTabPage_binary_exprs=Binary expressions
@ -329,7 +261,6 @@ LineWrappingTabPage_function_calls_description=function calls
LineWrappingTabPage_expressions=Expressions
LineWrappingTabPage_expressions_description=expressions
#LineWrappingTabPage_statements=Statements
#LineWrappingTabPage_enum_decls='enum' declaration
LineWrappingTabPage_wrapping_policy_label_text=Lin&e wrapping policy:
LineWrappingTabPage_indentation_policy_label_text=Indent&ation policy:
LineWrappingTabPage_force_split_checkbox_text=&Force split
@ -350,7 +281,6 @@ LineWrappingTabPage_width_indent_option_max_line_width=Ma&ximum line width:
LineWrappingTabPage_width_indent_option_default_indent_wrapped=Defa&ult indentation for wrapped lines:
LineWrappingTabPage_width_indent_option_default_indent_array=Default indentation for initializer lists:
LineWrappingTabPage_error_invalid_value=The key ''{0}'' contained an invalid value; resetting to defaults.
#LineWrappingTabPage_enum_superinterfaces='implements' clause
#LineWrappingTabPage_assignment_alignment=Assignments
@ -395,12 +325,8 @@ BracesTabPage_option_method_declaration=Met&hod declaration:
BracesTabPage_option_blocks=&Blocks:
BracesTabPage_option_blocks_in_case=Bloc&ks in case statement:
BracesTabPage_option_switch_case='&switch' statement:
BracesTabPage_option_array_initializer=Initiali&zer list:
BracesTabPage_option_keep_empty_array_initializer_on_one_line=Keep empty &initializer list on one line
#BracesTabPage_option_enum_declaration=&Enum declaration:
#BracesTabPage_option_enumconst_declaration=Enum c&onstant body:
#BracesTabPage_option_annotation_type_declaration=&Annotation type declaration:
BracesTabPage_option_initializer_list=Initiali&zer list:
BracesTabPage_option_keep_empty_initializer_list_on_one_line=Keep empty &initializer list on one line
CodingStyleConfigurationBlock_save_profile_dialog_title=Export Profile
CodingStyleConfigurationBlock_save_profile_error_title=Export Profile
CodingStyleConfigurationBlock_save_profile_error_message=Could not export the profiles.
@ -491,8 +417,6 @@ IndentationTabPage_indent_group_title=Indent
IndentationTabPage_class_group_option_indent_access_specifiers_within_class_body='public', 'protected', 'private' within class &body
IndentationTabPage_class_group_option_indent_declarations_compare_to_access_specifiers=De&clarations relative to 'public', 'protected', 'private'
#IndentationTabPage_class_group_option_indent_declarations_within_enum_const=Declarations within en&um constants
#IndentationTabPage_class_group_option_indent_declarations_within_enum_decl=Declarations within enum declaration
IndentationTabPage_block_group_option_indent_statements_compare_to_body=Stat&ements within method/constructor body
IndentationTabPage_block_group_option_indent_statements_compare_to_block=Statements within bl&ocks
IndentationTabPage_namespace_group_option_indent_declarations_within_namespace=Declarations within '&namespace' definition
@ -503,13 +427,12 @@ IndentationTabPage_switch_group_option_indent_statements_within_case_body=Statem
IndentationTabPage_switch_group_option_indent_break_statements='brea&k' statements
IndentationTabPage_use_tabs_only_for_leading_indentations=Use tabs only for leading indentations
IndentationTabPage_show_whitespace_in_preview_label_text=Show whitespace
ModifyDialog_tabpage_braces_title=B&races
ModifyDialog_ProfileName_Label=&Profile name:
ModifyDialog_NewCreated_Status=A new profile will be created.
ModifyDialog_tabpage_indentation_title=In&dentation
#ModifyDialog_tabpage_whitespace_title=&White Space
ModifyDialog_tabpage_whitespace_title=&White Space
#ModifyDialog_tabpage_blank_lines_title=Bla&nk Lines
#ModifyDialog_tabpage_new_lines_title=New &Lines
#ModifyDialog_tabpage_control_statements_title=Con&trol Statements
@ -534,23 +457,16 @@ ModifyDialogTabPage_NumberPreference_error_invalid_value=Invalid value: Please e
#NewLinesTabPage_newlines_group_title=Insert new line
#NewLinesTabPage_newlines_group_option_empty_class_body=in empty &class body
#NewLinesTabPage_newlines_group_option_empty_annotation_decl_body=in empty annotation body
#NewLinesTabPage_newlines_group_option_empty_anonymous_class_body=in empty &anonymous class body
#NewLinesTabPage_newlines_group_option_empty_enum_declaration=in empty &enum declaration
#NewLinesTabPage_newlines_group_option_empty_enum_constant=in empty enum c&onstant body
#NewLinesTabPage_newlines_group_option_empty_method_body=in empt&y method body
#NewLinesTabPage_newlines_group_option_empty_block=in empty &block
#NewLinesTabPage_newlines_group_option_empty_end_of_file=at end of &file
#NewLinesTabPage_empty_statement_group_title=Empty statements
#NewLinesTabPage_emtpy_statement_group_option_empty_statement_on_new_line=Put empty &statement on new line
#NewLinesTabPage_arrayInitializer_group_title=Initializer lists
#NewLinesTabPage_arrayInitializer_group_title=Initializer list
#NewLinesTabPage_array_group_option_after_opening_brace_of_array_initializer=Insert new line after openin&g brace of initializer list
#NewLinesTabPage_array_group_option_before_closing_brace_of_array_initializer=Insert new line before closing brace of initiali&zer list
#NewLinesTabPage_annotations_group_title=Annotations
#NewLinesTabPage_annotations_group_option_after_annotation=&Insert new line after annotations
ProfileManager_kandr_profile_name=K&R [built-in]
ProfileManager_allman_profile_name=BSD/Allman [built-in]
@ -563,3 +479,4 @@ ProfileManager_unmanaged_profile_with_name=Unmanaged profile "{0}"
CPreview_formatter_exception=The formatter threw an unhandled exception while formatting the preview.
ProfileConfigurationBlock_load_profile_wrong_profile_message=Import failed. This is not a valid profile: Expected ''{0}'' but encountered ''{1}''.
FormatterTabPage_ShowInvisibleCharacters_label=Show &invisible characters

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2006 IBM Corporation and others.
* Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -26,7 +26,7 @@ public class FormatterModifyDialog extends ModifyDialog {
protected void addPages(Map values) {
addTabPage(FormatterMessages.ModifyDialog_tabpage_indentation_title, new IndentationTabPage(this, values));
addTabPage(FormatterMessages.ModifyDialog_tabpage_braces_title, new BracesTabPage(this, values));
// addTabPage(FormatterMessages.ModifyDialog_tabpage_whitespace_title, new WhiteSpaceTabPage(this, values));
addTabPage(FormatterMessages.ModifyDialog_tabpage_whitespace_title, new WhiteSpaceTabPage(this, values));
// addTabPage(FormatterMessages.ModifyDialog_tabpage_blank_lines_title, new BlankLinesTabPage(this, values));
// addTabPage(FormatterMessages.ModifyDialog_tabpage_new_lines_title, new NewLinesTabPage(this, values));
// addTabPage(FormatterMessages.ModifyDialog_tabpage_control_statements_title, new ControlStatementsTabPage(this, values));

View file

@ -0,0 +1,78 @@
/*******************************************************************************
* Copyright (c) 2005, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences.formatter;
import java.util.Map;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.cdt.ui.CUIPlugin;
public abstract class FormatterTabPage extends ModifyDialogTabPage {
private final static String SHOW_INVISIBLE_PREFERENCE_KEY= CUIPlugin.PLUGIN_ID + ".formatter_page.show_invisible_characters"; //$NON-NLS-1$
private CPreview fPreview;
private final IDialogSettings fDialogSettings;
private Button fShowInvisibleButton;
public FormatterTabPage(IModifyDialogTabPage.IModificationListener modifyListener, Map workingValues) {
super(modifyListener, workingValues);
fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
}
protected Composite doCreatePreviewPane(Composite composite, int numColumns) {
createLabel(numColumns - 1, composite, FormatterMessages.ModifyDialogTabPage_preview_label_text);
fShowInvisibleButton= new Button(composite, SWT.CHECK);
fShowInvisibleButton.setText(FormatterMessages.FormatterTabPage_ShowInvisibleCharacters_label);
fShowInvisibleButton.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, false));
fShowInvisibleButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
fPreview.showInvisibleCharacters(fShowInvisibleButton.getSelection());
fDialogSettings.put(SHOW_INVISIBLE_PREFERENCE_KEY, fShowInvisibleButton.getSelection());
doUpdatePreview();
}
});
fShowInvisibleButton.setSelection(isShowInvisible());
fPreview= doCreateCPreview(composite);
fDefaultFocusManager.add(fPreview.getControl());
fPreview.showInvisibleCharacters(fShowInvisibleButton.getSelection());
final GridData gd= createGridData(numColumns, GridData.FILL_BOTH, 0);
gd.widthHint= 0;
gd.heightHint=0;
fPreview.getControl().setLayoutData(gd);
return composite;
}
private boolean isShowInvisible() {
return fDialogSettings.getBoolean(SHOW_INVISIBLE_PREFERENCE_KEY);
}
protected void doUpdatePreview() {
boolean showInvisible= isShowInvisible();
fPreview.showInvisibleCharacters(showInvisible);
fShowInvisibleButton.setSelection(showInvisible);
}
}

View file

@ -0,0 +1,76 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences.formatter;
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.widgets.Composite;
/**
* @since 5.0
*/
public interface IModifyDialogTabPage {
public interface IModificationListener {
void updateStatus(IStatus status);
void valuesModified();
}
/**
* A map containing key value pairs this tab page
* is must modify.
*
* @param workingValues the values to work with
*/
public void setWorkingValues(Map workingValues);
/**
* A modify listener which must be informed whenever
* a value in the map passed to {@link #setWorkingValues(Map)}
* changes. The listener can also be informed about status
* changes.
*
* @param modifyListener the listener to inform
*/
public void setModifyListener(IModificationListener modifyListener);
/**
* Create the contents of this tab page.
*
* @param parent the parent composite
* @return created content control
*/
public Composite createContents(Composite parent);
/**
* This is called when the page becomes visible.
* Common tasks to do include:
* <ul><li>Updating the preview.</li>
* <li>Setting the focus</li>
* </ul>
*/
public void makeVisible();
/**
* Each tab page should remember where its last focus was, and reset it
* correctly within this method. This method is only called after
* initialization on the first tab page to be displayed in order to restore
* the focus of the last session.
*/
public void setInitialFocus();
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others.
* Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences.formatter;
import java.util.HashMap;
import java.util.Map;
import java.util.Observable;
import java.util.Observer;
@ -26,7 +25,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
public class IndentationTabPage extends ModifyDialogTabPage {
public class IndentationTabPage extends FormatterTabPage {
/**
* Constant array for boolean selection
@ -85,8 +84,6 @@ public class IndentationTabPage extends ModifyDialogTabPage {
"}"+ //$NON-NLS-1$
"} // end namespace FOO"; //$NON-NLS-1$
private static final String SHOW_WHITESPACE = "showWhitespace"; //$NON-NLS-1$
private TranslationUnitPreview fPreview;
private String fOldTabChar= null;
@ -151,25 +148,6 @@ public class IndentationTabPage extends ModifyDialogTabPage {
fPreview.setPreviewText(PREVIEW);
}
/*
* @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreatePreviewPane(org.eclipse.swt.widgets.Composite, int)
*/
protected Composite doCreatePreviewPane(Composite composite, int numColumns) {
super.doCreatePreviewPane(composite, numColumns);
final Map previewPrefs= new HashMap();
final CheckboxPreference previewShowWhitespace= new CheckboxPreference(composite, numColumns / 2, previewPrefs, SHOW_WHITESPACE, FALSE_TRUE,
FormatterMessages.IndentationTabPage_show_whitespace_in_preview_label_text);
fDefaultFocusManager.add(previewShowWhitespace);
previewShowWhitespace.addObserver(new Observer() {
public void update(Observable o, Object arg) {
fPreview.showWhitespace(FALSE_TRUE[1] == previewPrefs.get(SHOW_WHITESPACE));
}
});
return composite;
}
/*
* @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateCPreview(org.eclipse.swt.widgets.Composite)
*/

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others.
* Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -53,7 +53,7 @@ import org.eclipse.cdt.internal.corext.util.Messages;
/**
* The line wrapping tab page.
*/
public class LineWrappingTabPage extends ModifyDialogTabPage {
public class LineWrappingTabPage extends FormatterTabPage {
/**
* Represents a line wrapping category. All members are final.
@ -437,10 +437,10 @@ public class LineWrappingTabPage extends ModifyDialogTabPage {
// );
private final Category fArrayInitializerExpressionsCategory= new Category(
DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER,
DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_INITIALIZER_LIST,
"int array[]= {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};", //$NON-NLS-1$
FormatterMessages.LineWrappingTabPage_array_init,
FormatterMessages.LineWrappingTabPage_array_init_description
FormatterMessages.LineWrappingTabPage_initializer_list,
FormatterMessages.LineWrappingTabPage_initializer_list_description
);
// private final Category fExplicitConstructorArgumentsCategory= new Category(
@ -636,7 +636,7 @@ public class LineWrappingTabPage extends ModifyDialogTabPage {
createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_max_line_width, DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, 0, 9999);
createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_default_indent_wrapped, DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, 0, 9999);
createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_default_indent_array, DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, 0, 9999);
createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_default_indent_array, DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_INITIALIZER_LIST, 0, 9999);
fCategoriesViewer= new TreeViewer(composite /*categoryGroup*/, SWT.MULTI | SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL );
fCategoriesViewer.setContentProvider(new ITreeContentProvider() {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others.
* Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -48,7 +48,6 @@ import org.eclipse.swt.widgets.TabItem;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage.IModificationListener;
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
@ -57,7 +56,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
public abstract class ModifyDialog extends StatusDialog implements IModificationListener {
public abstract class ModifyDialog extends StatusDialog implements IModifyDialogTabPage.IModificationListener {
/**
* The keys to retrieve the preferred area from the dialog settings.
@ -134,7 +133,7 @@ public abstract class ModifyDialog extends StatusDialog implements IModification
if (!fNewProfile) {
fTabFolder.setSelection(lastFocusNr);
((ModifyDialogTabPage)fTabFolder.getSelection()[0].getData()).setInitialFocus();
((IModifyDialogTabPage)fTabFolder.getSelection()[0].getData()).setInitialFocus();
}
}
@ -171,7 +170,7 @@ public abstract class ModifyDialog extends StatusDialog implements IModification
public void widgetDefaultSelected(SelectionEvent e) {}
public void widgetSelected(SelectionEvent e) {
final TabItem tabItem= (TabItem)e.item;
final ModifyDialogTabPage page= (ModifyDialogTabPage)tabItem.getData();
final IModifyDialogTabPage page= (IModifyDialogTabPage)tabItem.getData();
// page.fSashForm.setWeights();
fDialogSettings.put(fKeyLastFocus, fTabPages.indexOf(page));
page.makeVisible();
@ -202,7 +201,7 @@ public abstract class ModifyDialog extends StatusDialog implements IModification
lastWidth= initialSize.x;
int lastHeight= fDialogSettings.getInt(fKeyPreferredHight);
if (initialSize.y > lastHeight)
lastHeight= initialSize.x;
lastHeight= initialSize.y;
return new Point(lastWidth, lastHeight);
} catch (NumberFormatException ex) {
}
@ -309,7 +308,7 @@ public abstract class ModifyDialog extends StatusDialog implements IModification
super.createButtonsForButtonBar(parent);
}
protected final void addTabPage(String title, ModifyDialogTabPage tabPage) {
protected final void addTabPage(String title, IModifyDialogTabPage tabPage) {
final TabItem tabItem= new TabItem(fTabFolder, SWT.NONE);
applyDialogFont(tabItem.getControl());
tabItem.setText(title);
@ -333,13 +332,18 @@ public abstract class ModifyDialog extends StatusDialog implements IModification
}
private void doValidate() {
String name= fProfileNameField.getText().trim();
if (name.equals(fProfile.getName()) && fProfile.hasEqualSettings(fWorkingValues, fWorkingValues.keySet())) {
updateStatus(StatusInfo.OK_STATUS);
return;
}
IStatus status= validateProfileName();
if (status.matches(IStatus.ERROR)) {
updateStatus(status);
return;
}
String name= fProfileNameField.getText().trim();
if (!name.equals(fProfile.getName()) && fProfileManager.containsName(name)) {
updateStatus(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, FormatterMessages.ModifyDialog_Duplicate_Status, null));
return;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others.
* Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -25,6 +25,9 @@ import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
@ -32,6 +35,8 @@ import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@ -40,6 +45,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Text;
import org.eclipse.cdt.ui.CUIPlugin;
@ -48,16 +54,7 @@ import org.eclipse.cdt.internal.ui.util.Messages;
import org.eclipse.cdt.internal.ui.util.PixelConverter;
public abstract class ModifyDialogTabPage {
public interface IModificationListener {
void updateStatus(IStatus status);
void valuesModified();
}
public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
/**
* This is the default listener for any of the Preference
* classes. It is added by the respective factory methods and
@ -515,6 +512,68 @@ public abstract class ModifyDialogTabPage {
}
}
/**
* Layout used for the settings part. Makes sure to show scrollbars
* if necessary. The settings part needs to be layouted on resize.
*/
private static class PageLayout extends Layout {
private final ScrolledComposite fContainer;
private final int fMinimalWidth;
private final int fMinimalHight;
private PageLayout(ScrolledComposite container, int minimalWidth, int minimalHight) {
fContainer= container;
fMinimalWidth= minimalWidth;
fMinimalHight= minimalHight;
}
public Point computeSize(Composite composite, int wHint, int hHint, boolean force) {
if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) {
return new Point(wHint, hHint);
}
int x = fMinimalWidth;
int y = fMinimalHight;
Control[] children = composite.getChildren();
for (int i = 0; i < children.length; i++) {
Point size = children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
x = Math.max(x, size.x);
y = Math.max(y, size.y);
}
Rectangle area= fContainer.getClientArea();
if (area.width > x) {
fContainer.setExpandHorizontal(true);
} else {
fContainer.setExpandHorizontal(false);
}
if (area.height > y) {
fContainer.setExpandVertical(true);
} else {
fContainer.setExpandVertical(false);
}
if (wHint != SWT.DEFAULT) {
x = wHint;
}
if (hHint != SWT.DEFAULT) {
y = hHint;
}
return new Point(x, y);
}
public void layout(Composite composite, boolean force) {
Rectangle rect = composite.getClientArea();
Control[] children = composite.getChildren();
for (int i = 0; i < children.length; i++) {
children[i].setSize(rect.width, rect.height);
}
}
}
/**
* The default focus manager. This widget knows all widgets which can have the focus
* and listens for focusGained events, on which it stores the index of the current
@ -536,23 +595,41 @@ public abstract class ModifyDialogTabPage {
/**
* The map where the current settings are stored.
*/
protected final Map fWorkingValues;
protected Map fWorkingValues;
/**
* The modify dialog where we can display status messages.
*/
private final IModificationListener fModifyListener;
private IModifyDialogTabPage.IModificationListener fModifyListener;
/*
* Create a new <code>ModifyDialogTabPage</code>
*/
public ModifyDialogTabPage(IModificationListener modifyListener, Map workingValues) {
public ModifyDialogTabPage(IModifyDialogTabPage.IModificationListener modifyListener, Map workingValues) {
fWorkingValues= workingValues;
fModifyListener= modifyListener;
fDefaultFocusManager= new DefaultFocusManager();
}
public ModifyDialogTabPage() {
fDefaultFocusManager= new DefaultFocusManager();
}
/**
* {@inheritDoc}
*/
public void setWorkingValues(Map workingValues) {
fWorkingValues= workingValues;
}
/**
* {@inheritDoc}
*/
public void setModifyListener(IModifyDialogTabPage.IModificationListener modifyListener) {
fModifyListener= modifyListener;
}
/**
* Create the contents of this tab page. Subclasses cannot override this,
* instead they must implement <code>doCreatePreferences</code>. <code>doCreatePreview</code> may also
@ -567,13 +644,38 @@ public abstract class ModifyDialogTabPage {
fPixelConverter= new PixelConverter(parent);
}
final SashForm fSashForm = new SashForm(parent, SWT.HORIZONTAL);
fSashForm.setFont(parent.getFont());
final SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL);
sashForm.setFont(parent.getFont());
final Composite settingsPane= new Composite(fSashForm, SWT.NONE);
settingsPane.setFont(fSashForm.getFont());
Composite scrollContainer = new Composite(sashForm, SWT.NONE);
final GridLayout layout= new GridLayout(numColumns, false);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
scrollContainer.setLayoutData(gridData);
GridLayout layout= new GridLayout(2, false);
layout.marginHeight= 0;
layout.marginWidth= 0;
layout.horizontalSpacing= 0;
layout.verticalSpacing= 0;
scrollContainer.setLayout(layout);
ScrolledComposite scroll= new ScrolledComposite(scrollContainer, SWT.V_SCROLL | SWT.H_SCROLL);
scroll.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
scroll.setExpandHorizontal(true);
scroll.setExpandVertical(true);
final Composite settingsContainer= new Composite(scroll, SWT.NONE);
settingsContainer.setFont(sashForm.getFont());
scroll.setContent(settingsContainer);
settingsContainer.setLayout(new PageLayout(scroll, 400, 400));
settingsContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Composite settingsPane= new Composite(settingsContainer, SWT.NONE);
settingsPane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
layout= new GridLayout(numColumns, false);
layout.verticalSpacing= (int)(1.5 * fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING));
layout.horizontalSpacing= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
layout.marginHeight= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
@ -581,19 +683,35 @@ public abstract class ModifyDialogTabPage {
settingsPane.setLayout(layout);
doCreatePreferences(settingsPane, numColumns);
final Composite previewPane= new Composite(fSashForm, SWT.NONE);
settingsContainer.setSize(settingsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT));
scroll.addControlListener(new ControlListener() {
public void controlMoved(ControlEvent e) {
}
public void controlResized(ControlEvent e) {
settingsContainer.setSize(settingsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
});
Label sashHandle = new Label(scrollContainer, SWT.SEPARATOR | SWT.VERTICAL);
gridData= new GridData(SWT.RIGHT, SWT.FILL, false, true);
sashHandle.setLayoutData(gridData);
final Composite previewPane= new Composite(sashForm, SWT.NONE);
previewPane.setLayout(createGridLayout(numColumns, true));
previewPane.setFont(fSashForm.getFont());
previewPane.setFont(sashForm.getFont());
doCreatePreviewPane(previewPane, numColumns);
initializePage();
fSashForm.setWeights(new int [] {3, 3});
return fSashForm;
sashForm.setWeights(new int [] {3, 3});
return sashForm;
}
/**
* This method is called after all controls have been alloated, including the preview.
* This method is called after all controls have been allocated, including the preview.
* It can be used to set the preview text and to create listeners.
*
*/
@ -641,11 +759,7 @@ public abstract class ModifyDialogTabPage {
protected abstract CPreview doCreateCPreview(Composite parent);
/**
* This is called when the page becomes visible.
* Common tasks to do include:
* <ul><li>Updating the preview.</li>
* <li>Setting the focus</li>
* </ul>
* {@inheritDoc}
*/
final public void makeVisible() {
fDefaultFocusManager.resetFocus();
@ -661,11 +775,8 @@ public abstract class ModifyDialogTabPage {
fModifyListener.valuesModified();
}
/**
* Each tab page should remember where its last focus was, and reset it
* correctly within this method. This method is only called after
* initialization on the first tab page to be displayed in order to restore
* the focus of the last session.
*/
* {@inheritDoc}
*/
public void setInitialFocus() {
if (fDefaultFocusManager.isUsed()) {
fDefaultFocusManager.restoreFocus();
@ -729,7 +840,9 @@ public abstract class ModifyDialogTabPage {
final Label label= new Label(parent, SWT.WRAP);
label.setFont(parent.getFont());
label.setText(text);
label.setLayoutData(createGridData(numColumns, gridDataStyle, SWT.DEFAULT));
PixelConverter pixelConverter= new PixelConverter(parent);
label.setLayoutData(createGridData(numColumns, gridDataStyle, pixelConverter.convertHorizontalDLUsToPixels(150)));
return label;
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others.
* Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -13,6 +13,7 @@
package org.eclipse.cdt.internal.ui.preferences.formatter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
@ -82,7 +83,7 @@ public abstract class ProfileManager extends Observable {
public abstract int getVersion();
public boolean hasEqualSettings(Map otherMap, List allKeys) {
public boolean hasEqualSettings(Map otherMap, Collection allKeys) {
Map settings= getSettings();
for (Iterator iter= allKeys.iterator(); iter.hasNext(); ){
String key= (String) iter.next();

View file

@ -0,0 +1,108 @@
/*******************************************************************************
* Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences.formatter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.Document;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.text.edits.TextEdit;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
import org.eclipse.cdt.internal.ui.ICStatusConstants;
public class SnippetPreview extends CPreview {
public final static class PreviewSnippet {
public String header;
public final String source;
public final int kind;
public PreviewSnippet(int kind, String source) {
this.kind= kind;
this.source= source;
}
}
private ArrayList fSnippets;
public SnippetPreview(Map workingValues, Composite parent) {
super(workingValues, parent);
fSnippets= new ArrayList();
}
protected void doFormatPreview() {
if (fSnippets.isEmpty()) {
fPreviewDocument.set(""); //$NON-NLS-1$
return;
}
//This delimiter looks best for invisible characters
final String delimiter= "\n"; //$NON-NLS-1$
final StringBuffer buffer= new StringBuffer();
for (final Iterator iter= fSnippets.iterator(); iter.hasNext();) {
final PreviewSnippet snippet= (PreviewSnippet) iter.next();
String formattedSource;
try {
TextEdit edit= CodeFormatterUtil.format(snippet.kind, snippet.source, 0, delimiter, fWorkingValues);
if (edit == null) {
formattedSource= snippet.source;
} else {
Document document= new Document(snippet.source);
edit.apply(document, TextEdit.NONE);
formattedSource= document.get();
}
} catch (Exception e) {
final IStatus status= new Status(IStatus.ERROR, CUIPlugin.getPluginId(), ICStatusConstants.INTERNAL_ERROR,
FormatterMessages.CPreview_formatter_exception, e);
CUIPlugin.getDefault().log(status);
continue;
}
buffer.append(delimiter);
buffer.append(formattedSource);
buffer.append(delimiter);
buffer.append(delimiter);
}
fPreviewDocument.set(buffer.toString());
}
public void add(PreviewSnippet snippet) {
fSnippets.add(snippet);
}
public void remove(PreviewSnippet snippet) {
fSnippets.remove(snippet);
}
public void addAll(Collection snippets) {
fSnippets.addAll(snippets);
}
public void clear() {
fSnippets.clear();
}
}

View file

@ -0,0 +1,479 @@
/*******************************************************************************
* Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences.formatter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
import org.eclipse.ui.part.PageBook;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.preferences.formatter.WhiteSpaceOptions.InnerNode;
import org.eclipse.cdt.internal.ui.preferences.formatter.WhiteSpaceOptions.Node;
import org.eclipse.cdt.internal.ui.preferences.formatter.WhiteSpaceOptions.OptionNode;
public class WhiteSpaceTabPage extends FormatterTabPage {
/**
* Encapsulates a view of the options tree which is structured by
* syntactical element.
*/
private final class SyntaxComponent implements ISelectionChangedListener, ICheckStateListener, IDoubleClickListener {
private final String PREF_NODE_KEY= CUIPlugin.PLUGIN_ID + "formatter_page.white_space_tab_page.node"; //$NON-NLS-1$
private final List fIndexedNodeList;
private final List fTree;
private ContainerCheckedTreeViewer fTreeViewer;
private Composite fComposite;
private Node fLastSelected= null;
public SyntaxComponent() {
fIndexedNodeList= new ArrayList();
fTree= new WhiteSpaceOptions().createAltTree(fWorkingValues);
WhiteSpaceOptions.makeIndexForNodes(fTree, fIndexedNodeList);
}
public void createContents(final int numColumns, final Composite parent) {
fComposite= new Composite(parent, SWT.NONE);
fComposite.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, SWT.DEFAULT));
fComposite.setLayout(createGridLayout(numColumns, false));
createLabel(numColumns, fComposite, FormatterMessages.WhiteSpaceTabPage_insert_space);
fTreeViewer= new ContainerCheckedTreeViewer(fComposite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
fTreeViewer.setContentProvider(new ITreeContentProvider() {
public Object[] getElements(Object inputElement) {
return ((Collection)inputElement).toArray();
}
public Object[] getChildren(Object parentElement) {
return ((Node)parentElement).getChildren().toArray();
}
public Object getParent(Object element) {
return ((Node)element).getParent();
}
public boolean hasChildren(Object element) {
return ((Node)element).hasChildren();
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
public void dispose() {}
});
fTreeViewer.setLabelProvider(new LabelProvider());
fTreeViewer.getControl().setLayoutData(createGridData(numColumns, GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL, SWT.DEFAULT));
fDefaultFocusManager.add(fTreeViewer.getControl());
}
public void initialize() {
fTreeViewer.addCheckStateListener(this);
fTreeViewer.addSelectionChangedListener(this);
fTreeViewer.addDoubleClickListener(this);
fTreeViewer.setInput(fTree);
restoreSelection();
refreshState();
}
public void refreshState() {
final ArrayList checked= new ArrayList(100);
for (Iterator iter= fTree.iterator(); iter.hasNext();)
((Node) iter.next()).getCheckedLeafs(checked);
fTreeViewer.setGrayedElements(new Object[0]);
fTreeViewer.setCheckedElements(checked.toArray());
fPreview.clear();
if (fLastSelected != null) {
fPreview.addAll(fLastSelected.getSnippets());
}
doUpdatePreview();
}
public void selectionChanged(SelectionChangedEvent event) {
final IStructuredSelection selection= (IStructuredSelection)event.getSelection();
if (selection.isEmpty())
return;
final Node node= (Node)selection.getFirstElement();
if (node == fLastSelected)
return;
fDialogSettings.put(PREF_NODE_KEY, node.index);
fPreview.clear();
fPreview.addAll(node.getSnippets());
doUpdatePreview();
fLastSelected= node;
}
public void checkStateChanged(CheckStateChangedEvent event) {
final Node node= (Node)event.getElement();
node.setChecked(event.getChecked());
doUpdatePreview();
notifyValuesModified();
}
public void restoreSelection() {
int index;
try {
index= fDialogSettings.getInt(PREF_NODE_KEY);
} catch (NumberFormatException ex) {
index= -1;
}
if (index < 0 || index > fIndexedNodeList.size() - 1) {
index= 0;
}
final Node node= (Node)fIndexedNodeList.get(index);
if (node != null) {
fTreeViewer.expandToLevel(node, 0);
fTreeViewer.setSelection(new StructuredSelection(new Node [] {node}));
fLastSelected= node;
}
}
public void doubleClick(DoubleClickEvent event) {
final ISelection selection= event.getSelection();
if (selection instanceof IStructuredSelection) {
final Node node= (Node)((IStructuredSelection)selection).getFirstElement();
fTreeViewer.setExpandedState(node, !fTreeViewer.getExpandedState(node));
}
}
public Control getControl() {
return fComposite;
}
}
private final class JavaElementComponent implements ISelectionChangedListener, ICheckStateListener {
private final String PREF_INNER_INDEX= CUIPlugin.PLUGIN_ID + "formatter_page.white_space.java_view.inner"; //$NON-NLS-1$
private final String PREF_OPTION_INDEX= CUIPlugin.PLUGIN_ID + "formatter_page.white_space.java_view.option"; //$NON-NLS-1$
private final ArrayList fIndexedNodeList;
private final ArrayList fTree;
private InnerNode fLastSelected;
private TreeViewer fInnerViewer;
private CheckboxTableViewer fOptionsViewer;
private Composite fComposite;
public JavaElementComponent() {
fIndexedNodeList= new ArrayList();
fTree= new WhiteSpaceOptions().createTreeByJavaElement(fWorkingValues);
WhiteSpaceOptions.makeIndexForNodes(fTree, fIndexedNodeList);
}
public void createContents(int numColumns, Composite parent) {
fComposite= new Composite(parent, SWT.NONE);
fComposite.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, SWT.DEFAULT));
fComposite.setLayout(createGridLayout(numColumns, false));
createLabel(numColumns, fComposite, FormatterMessages.WhiteSpaceTabPage_insert_space, GridData.HORIZONTAL_ALIGN_BEGINNING);
final SashForm sashForm= new SashForm(fComposite, SWT.VERTICAL);
sashForm.setLayoutData(createGridData(numColumns, GridData.FILL_BOTH, SWT.DEFAULT));
fInnerViewer= new TreeViewer(sashForm, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
fInnerViewer.setContentProvider(new ITreeContentProvider() {
public Object[] getElements(Object inputElement) {
return ((Collection)inputElement).toArray();
}
public Object[] getChildren(Object parentElement) {
final List children= ((Node)parentElement).getChildren();
final ArrayList innerChildren= new ArrayList();
for (final Iterator iter= children.iterator(); iter.hasNext();) {
final Object o= iter.next();
if (o instanceof InnerNode) innerChildren.add(o);
}
return innerChildren.toArray();
}
public Object getParent(Object element) {
if (element instanceof InnerNode)
return ((InnerNode)element).getParent();
return null;
}
public boolean hasChildren(Object element) {
final List children= ((Node)element).getChildren();
for (final Iterator iter= children.iterator(); iter.hasNext();)
if (iter.next() instanceof InnerNode) return true;
return false;
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
public void dispose() {}
});
fInnerViewer.setLabelProvider(new LabelProvider());
final GridData innerGd= createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL, SWT.DEFAULT);
innerGd.heightHint= fPixelConverter.convertHeightInCharsToPixels(3);
fInnerViewer.getControl().setLayoutData(innerGd);
fOptionsViewer= CheckboxTableViewer.newCheckList(sashForm, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL);
fOptionsViewer.setContentProvider(new ArrayContentProvider());
fOptionsViewer.setLabelProvider(new LabelProvider());
final GridData optionsGd= createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL, SWT.DEFAULT);
optionsGd.heightHint= fPixelConverter.convertHeightInCharsToPixels(3);
fOptionsViewer.getControl().setLayoutData(optionsGd);
fDefaultFocusManager.add(fInnerViewer.getControl());
fDefaultFocusManager.add(fOptionsViewer.getControl());
fInnerViewer.setInput(fTree);
}
public void refreshState() {
if (fLastSelected != null) {
innerViewerChanged(fLastSelected);
}
}
public void initialize() {
fInnerViewer.addSelectionChangedListener(this);
fOptionsViewer.addSelectionChangedListener(this);
fOptionsViewer.addCheckStateListener(this);
restoreSelections();
refreshState();
}
private void restoreSelections() {
Node node;
final int innerIndex= getValidatedIndex(PREF_INNER_INDEX);
node= (Node)fIndexedNodeList.get(innerIndex);
if (node instanceof InnerNode) {
fInnerViewer.expandToLevel(node, 0);
fInnerViewer.setSelection(new StructuredSelection(new Object[] {node}));
fLastSelected= (InnerNode)node;
}
final int optionIndex= getValidatedIndex(PREF_OPTION_INDEX);
node= (Node)fIndexedNodeList.get(optionIndex);
if (node instanceof OptionNode) {
fOptionsViewer.setSelection(new StructuredSelection(new Object[] {node}));
}
}
private int getValidatedIndex(String key) {
int index;
try {
index= fDialogSettings.getInt(key);
} catch (NumberFormatException ex) {
index= 0;
}
if (index < 0 || index > fIndexedNodeList.size() - 1) {
index= 0;
}
return index;
}
public Control getControl() {
return fComposite;
}
public void selectionChanged(SelectionChangedEvent event) {
final IStructuredSelection selection= (IStructuredSelection)event.getSelection();
if (selection.isEmpty() || !(selection.getFirstElement() instanceof Node))
return;
final Node selected= (Node)selection.getFirstElement();
if (selected == null || selected == fLastSelected)
return;
if (event.getSource() == fInnerViewer && selected instanceof InnerNode) {
fLastSelected= (InnerNode)selected;
fDialogSettings.put(PREF_INNER_INDEX, selected.index);
innerViewerChanged((InnerNode)selected);
}
else if (event.getSource() == fOptionsViewer && selected instanceof OptionNode)
fDialogSettings.put(PREF_OPTION_INDEX, selected.index);
}
private void innerViewerChanged(InnerNode selectedNode) {
final List children= selectedNode.getChildren();
final ArrayList optionsChildren= new ArrayList();
for (final Iterator iter= children.iterator(); iter.hasNext();) {
final Object o= iter.next();
if (o instanceof OptionNode) optionsChildren.add(o);
}
fOptionsViewer.setInput(optionsChildren.toArray());
for (final Iterator iter= optionsChildren.iterator(); iter.hasNext();) {
final OptionNode child= (OptionNode)iter.next();
fOptionsViewer.setChecked(child, child.getChecked());
}
fPreview.clear();
fPreview.addAll(selectedNode.getSnippets());
doUpdatePreview();
}
public void checkStateChanged(CheckStateChangedEvent event) {
final OptionNode option= (OptionNode)event.getElement();
if (option != null)
option.setChecked(event.getChecked());
doUpdatePreview();
notifyValuesModified();
}
}
/**
* This component switches between the two view and is responsible for delegating
* the appropriate update requests.
*/
private final class SwitchComponent extends SelectionAdapter {
private final String PREF_VIEW_KEY= CUIPlugin.PLUGIN_ID + "formatter_page.white_space_tab_page.view"; //$NON-NLS-1$
private final String [] fItems= new String [] {
FormatterMessages.WhiteSpaceTabPage_sort_by_c_element,
FormatterMessages.WhiteSpaceTabPage_sort_by_syntax_element
};
private Combo fSwitchCombo;
private PageBook fPageBook;
private final SyntaxComponent fSyntaxComponent;
private final JavaElementComponent fJavaElementComponent;
public SwitchComponent() {
fSyntaxComponent= new SyntaxComponent();
fJavaElementComponent= new JavaElementComponent();
}
public void widgetSelected(SelectionEvent e) {
final int index= fSwitchCombo.getSelectionIndex();
if (index == 0) {
fDialogSettings.put(PREF_VIEW_KEY, false);
fJavaElementComponent.refreshState();
fPageBook.showPage(fJavaElementComponent.getControl());
}
else if (index == 1) {
fDialogSettings.put(PREF_VIEW_KEY, true);
fSyntaxComponent.refreshState();
fPageBook.showPage(fSyntaxComponent.getControl());
}
}
public void createContents(int numColumns, Composite parent) {
fPageBook= new PageBook(parent, SWT.NONE);
fPageBook.setLayoutData(createGridData(numColumns, GridData.FILL_BOTH, SWT.DEFAULT));
fJavaElementComponent.createContents(numColumns, fPageBook);
fSyntaxComponent.createContents(numColumns, fPageBook);
fSwitchCombo= new Combo(parent, SWT.READ_ONLY);
final GridData gd= createGridData(numColumns, GridData.HORIZONTAL_ALIGN_END, SWT.DEFAULT);
fSwitchCombo.setLayoutData(gd);
fSwitchCombo.setItems(fItems);
}
public void initialize() {
fSwitchCombo.addSelectionListener(this);
fJavaElementComponent.initialize();
fSyntaxComponent.initialize();
restoreSelection();
}
private void restoreSelection() {
final boolean selectSyntax= fDialogSettings.getBoolean(PREF_VIEW_KEY);
if (selectSyntax) {
fSyntaxComponent.refreshState();
fSwitchCombo.setText(fItems[1]);
fPageBook.showPage(fSyntaxComponent.getControl());
} else {
fJavaElementComponent.refreshState();
fSwitchCombo.setText(fItems[0]);
fPageBook.showPage(fJavaElementComponent.getControl());
}
}
}
private final SwitchComponent fSwitchComponent;
protected final IDialogSettings fDialogSettings;
protected SnippetPreview fPreview;
/**
* Create a new white space dialog page.
* @param modifyDialog
* @param workingValues
*/
public WhiteSpaceTabPage(ModifyDialog modifyDialog, Map workingValues) {
super(modifyDialog, workingValues);
fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
fSwitchComponent= new SwitchComponent();
}
protected void doCreatePreferences(Composite composite, int numColumns) {
fSwitchComponent.createContents(numColumns, composite);
}
protected void initializePage() {
fSwitchComponent.initialize();
}
protected CPreview doCreateCPreview(Composite parent) {
fPreview= new SnippetPreview(fWorkingValues, parent);
return fPreview;
}
protected void doUpdatePreview() {
super.doUpdatePreview();
fPreview.update();
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others.
* Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -137,7 +137,7 @@ public final class CIndenter {
}
private int prefArrayIndent() {
String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER);
String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_INITIALIZER_LIST);
try {
if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
return 1;
@ -149,7 +149,7 @@ public final class CIndenter {
}
private boolean prefArrayDeepIndent() {
String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER);
String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_INITIALIZER_LIST);
try {
return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
} catch (IllegalArgumentException e) {
@ -319,7 +319,7 @@ public final class CIndenter {
}
private boolean prefIndentBracesForArrays() {
return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER));
return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST));
}
private boolean prefIndentBracesForMethods() {