mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 11:25:35 +02:00
Fix for 194585: [Indentation] of nested brackets inside an array declaration > inside an array declaration.
This commit is contained in:
parent
a0140348f1
commit
8ecd3b539e
4 changed files with 82 additions and 22 deletions
|
@ -2,9 +2,9 @@
|
|||
|
||||
const SimpleStruct simpleStruct =
|
||||
{
|
||||
1
|
||||
, "mySimple"
|
||||
, 0.1232
|
||||
1,
|
||||
"mySimple",
|
||||
0.1232
|
||||
};
|
||||
|
||||
#define SIZEOF( A, B ) sizeof( A.B )
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
const SimpleStruct simpleStruct =
|
||||
{
|
||||
1
|
||||
, "mySimple"
|
||||
, 0.1232
|
||||
1,
|
||||
"mySimple",
|
||||
0.1232
|
||||
};
|
||||
|
||||
#define SIZEOF( A, B ) sizeof( A.B )
|
||||
|
|
|
@ -230,4 +230,50 @@ public class CIndenterTest extends BaseUITestCase {
|
|||
public void testIndentationOfCaseBlockAfterCharLiteral_Bug194710() throws Exception {
|
||||
assertIndenterResult();
|
||||
}
|
||||
|
||||
//int a[]=
|
||||
//{
|
||||
//1,
|
||||
//2
|
||||
//};
|
||||
|
||||
//int a[]=
|
||||
//{
|
||||
// 1,
|
||||
// 2
|
||||
//};
|
||||
public void testIndentationOfInitializerLists_Bug194585() throws Exception {
|
||||
assertIndenterResult();
|
||||
}
|
||||
|
||||
//struct_t a[]=
|
||||
//{
|
||||
//{
|
||||
//1,
|
||||
//2,
|
||||
//{ 1,2,3 }
|
||||
//},
|
||||
//{
|
||||
//1,
|
||||
//2,
|
||||
//{ 1,2,3 }
|
||||
//}
|
||||
//};
|
||||
|
||||
//struct_t a[]=
|
||||
//{
|
||||
// {
|
||||
// 1,
|
||||
// 2,
|
||||
// { 1,2,3 }
|
||||
// },
|
||||
// {
|
||||
// 1,
|
||||
// 2,
|
||||
// { 1,2,3 }
|
||||
// }
|
||||
//};
|
||||
public void testIndentationOfNestedInitializerLists_Bug194585() throws Exception {
|
||||
assertIndenterResult();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1503,8 +1503,9 @@ public final class CIndenter {
|
|||
case Symbols.TokenLBRACE:
|
||||
pos= fPosition; // store
|
||||
|
||||
final boolean looksLikeArrayInitializerIntro= looksLikeArrayInitializerIntro();
|
||||
// special: array initializer
|
||||
if (looksLikeArrayInitializerIntro()) {
|
||||
if (looksLikeArrayInitializerIntro) {
|
||||
if (fPrefs.prefArrayDeepIndent)
|
||||
return setFirstElementAlignment(pos, bound);
|
||||
else
|
||||
|
@ -1517,8 +1518,7 @@ public final class CIndenter {
|
|||
|
||||
// normal: skip to the statement start before the scope introducer
|
||||
// opening braces are often on differently ending indents than e.g. a method definition
|
||||
if (looksLikeArrayInitializerIntro() && !fPrefs.prefIndentBracesForArrays
|
||||
|| !fPrefs.prefIndentBracesForBlocks) {
|
||||
if (!looksLikeArrayInitializerIntro && !fPrefs.prefIndentBracesForBlocks) {
|
||||
fPosition= pos; // restore
|
||||
return skipToStatementStart(true, true); // set to true to match the first if
|
||||
} else {
|
||||
|
@ -1564,13 +1564,27 @@ public final class CIndenter {
|
|||
|
||||
/**
|
||||
* Returns <code>true</code> if the next token received after calling
|
||||
* <code>nextToken</code> is either an equal sign or an array designator ('[]').
|
||||
* <code>nextToken</code> is either an equal sign, an opening brace,
|
||||
* a comma or an array designator ('[]').
|
||||
*
|
||||
* @return <code>true</code> if the next elements look like the start of an array definition
|
||||
*/
|
||||
private boolean looksLikeArrayInitializerIntro() {
|
||||
int pos= fPosition;
|
||||
nextToken();
|
||||
if (fToken == Symbols.TokenEQUAL || skipBrackets()) {
|
||||
switch (fToken) {
|
||||
case Symbols.TokenEQUAL:
|
||||
return true;
|
||||
case Symbols.TokenRBRACKET:
|
||||
return skipBrackets();
|
||||
case Symbols.TokenLBRACE:
|
||||
if (looksLikeArrayInitializerIntro()) {
|
||||
fPosition= pos;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case Symbols.TokenCOMMA:
|
||||
fPosition= pos;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue