Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions PoorMansTSqlFormatterLibShared/Formatters/TSqlStandardFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ You should have received a copy of the GNU Affero General Public License
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using PoorMansTSqlFormatterLib.Interfaces;
using PoorMansTSqlFormatterLib.ParseStructure;
Expand Down Expand Up @@ -159,7 +160,7 @@ private void ProcessSqlNodeList(IEnumerable<Node> rootList, TSqlStandardFormatti
private void ProcessSqlNode(Node contentElement, TSqlStandardFormattingState state)
{
int initialIndent = state.IndentLevel;

if (contentElement.GetAttributeValue(SqlStructureConstants.ANAME_HASERROR) == "1")
state.OpenClass(SqlHtmlConstants.CLASS_ERRORHIGHLIGHT);
bool addOutputSpace = true; // New
Expand Down Expand Up @@ -562,6 +563,9 @@ private void ProcessSqlNode(Node contentElement, TSqlStandardFormattingState sta
break;
}
break;
case SqlStructureConstants.ENAME_FUNCTION_PARENS: // This stops the inline functions from getting a line break
// Dump out here so the default logic below does not execute
break;
default:
state.AddOutputLineBreak();
state.Indent(state.IndentLevel);
Expand Down Expand Up @@ -615,11 +619,6 @@ private void ProcessSqlNode(Node contentElement, TSqlStandardFormattingState sta

// Close parenthesis
state.AddOutputContent(FormatOperator(")"), SqlHtmlConstants.CLASS_OPERATOR);
// if (recentKey == "WITH")
//{
// state.AddOutputLineBreak();
// state.Indent(state.IndentLevel);
//}
state.WordSeparatorExpected = true;
if (indentAfter && initialIndent != state.IndentLevel) // New
{
Expand Down Expand Up @@ -756,13 +755,11 @@ private void ProcessSqlNode(Node contentElement, TSqlStandardFormattingState sta

if (state.SpecialRegionActive == null && contentElement.TextValue.ToUpperInvariant().Contains("[NOFORMAT]"))
{
//state.AddOutputLineBreak();
state.SpecialRegionActive = SpecialRegionType.NoFormat;
state.RegionStartNode = contentElement;
}
else if (state.SpecialRegionActive == null && contentElement.TextValue.ToUpperInvariant().Contains("[MINIFY]"))
{
//state.AddOutputLineBreak();
state.SpecialRegionActive = SpecialRegionType.Minify;
state.RegionStartNode = contentElement;
}
Expand Down Expand Up @@ -825,14 +822,11 @@ private void ProcessSqlNode(Node contentElement, TSqlStandardFormattingState sta
break;
default:
state.AddOutputContent(formattedOutput, SqlHtmlConstants.CLASS_COMMENT);
state.BreakExpected = true;
state.SourceBreakPending = true;
break;
}
break;
default:
state.AddOutputContent(formattedOutput, SqlHtmlConstants.CLASS_COMMENT);
state.BreakExpected = true;
state.SourceBreakPending = true;
break;
} // New end
Expand Down Expand Up @@ -1068,7 +1062,10 @@ private void ProcessSqlNode(Node contentElement, TSqlStandardFormattingState sta
{
if (contentElement.PreviousSibling().Name.Equals(SqlStructureConstants.ENAME_COMMENT_SINGLELINE) && state.SourceBreakPending)
{
// TODO: If this is a single line comment not at position zero - we get 2 line breaks
state.AddOutputLineBreak();
state.SourceBreakPending = false;
state.Indent(state.IndentLevel);
}
}
break;
Expand Down