Skip to content

Commit e72c923

Browse files
committed
More CodeFormatter work...
1 parent f0ec361 commit e72c923

File tree

3 files changed

+600
-142
lines changed

3 files changed

+600
-142
lines changed

External/Plugins/CodeFormatter/Handlers/ASPrettyPrinter.cs

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ public class ASPrettyPrinter
144144
private int mBraceStyleSetting=BraceStyle_Adobe;
145145
private bool mUseGlobalNewlineBeforeBraceSetting=true;
146146
private int mAdvancedNewlineBeforeBraceSettings;
147-
147+
148+
private bool mIndentMultilineComments = true;
148149
private bool mUseLineCommentWrapping=false;
149150
private bool mUseDocCommentWrapping=false;
150151
private bool mUseMLCommentWrapping=false;
@@ -1254,8 +1255,7 @@ public void emit(IToken tok)
12541255
if (isKeepRelativeCommentIndent())
12551256
{
12561257
//find original indent
1257-
String lineData="";
1258-
lineData += t.Text;
1258+
String lineData=t.Text;
12591259
int prevLineEnd=mSourceData.LastIndexOf('\n', ((CommonToken)t).StartIndex);
12601260
if (prevLineEnd<0)
12611261
prevLineEnd=0;
@@ -1283,17 +1283,26 @@ public void emit(IToken tok)
12831283
{
12841284
if (onLastLine && data.StartsWith("*/")) //if we're on the last line and there's more than one line
12851285
{
1286-
indentAmount++;
1286+
if (mIndentMultilineComments) indentAmount += 1;
1287+
else indentAmount += 0;
12871288
}
12881289
else
12891290
{
1290-
//on a middle line, we have 2 cases. If the line starts with an asterisk, then attempt to line the
1291-
//asterisk up with the asterisk on the first line. Otherwise, indent the text to the right of the open asterisk.
1292-
String nextLine=data;
1293-
if (nextLine.Length>0 && nextLine[0]=='*')
1294-
indentAmount+=1;
1295-
else
1296-
indentAmount+=3;
1291+
//on a middle line, we have 2 cases. If the line starts with an asterisk, then attempt to line the
1292+
//asterisk up with the asterisk on the first line. Otherwise, indent the text to the right of the open asterisk.
1293+
//String nextLine=data;
1294+
//if (nextLine.Length>0 && nextLine[0]=='*')
1295+
//indentAmount+=1;
1296+
//else
1297+
//indentAmount+=3;
1298+
// FIXED: Multiline comment indent support added
1299+
String nextLine = data;
1300+
if (nextLine.Length > 0 && nextLine[0] == '*')
1301+
{
1302+
if (mIndentMultilineComments) indentAmount += 1;
1303+
else indentAmount += 0;
1304+
}
1305+
else indentAmount += 3;
12971306
}
12981307
}
12991308
}
@@ -3516,6 +3525,16 @@ public void saveWrapChar(IToken op, int breakType, bool breakBefore, bool indent
35163525
info.addWrapChar(op, mExpressionWrapData.Count, mOutputBuffer.Length-op.Text.Length, breakType, breakBefore, indentToFirstParm, firstParmLocation, getCurrentIndent(), commaContextType);
35173526
}
35183527

3528+
public bool isIndentMultilineComments()
3529+
{
3530+
return mIndentMultilineComments;
3531+
}
3532+
3533+
public void setIndentMultilineComments(bool indentMultilineComments)
3534+
{
3535+
mIndentMultilineComments = indentMultilineComments;
3536+
}
3537+
35193538
public int getHangingIndentTabs() {
35203539
return mHangingIndentTabs;
35213540
}
@@ -3954,6 +3973,7 @@ public bool addOpenBrace(ITokenStream input, int braceCode)
39543973

39553974
private List<StatementBraceInfo> mAddBraceStack;
39563975
private List<StatementBraceInfo> mCompletedBraceInfos;
3976+
39573977
public void addOpenBrace(IToken nextToken, int braceCode)
39583978
{
39593979
// addBracePart(nextToken, braceCode, "{");

0 commit comments

Comments
 (0)