Browse files

remove VBIndentationStrategy

  • Loading branch information...
1 parent 55de9e4 commit fab0f9f4633924ce18f4a994b34dc7b3049bd0e6 @siegfriedpammer siegfriedpammer committed Mar 6, 2011
View
3,057 src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/Parser.cs
0 additions, 3,057 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
80 src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/PushParser.frame
@@ -1,80 +0,0 @@
-/*----------------------------------------------------------------------
-Compiler Generator Coco/R,
-Copyright (c) 1990, 2004 Hanspeter Moessenboeck, University of Linz
-extended by M. Loeberbauer & A. Woess, Univ. of Linz
-with improvements by Pat Terry, Rhodes University
-
-This program is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License along
-with this program; if not, write to the Free Software Foundation, Inc.,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-As an exception, it is allowed to write an extension of Coco/R that is
-used as a plugin in non-free software.
-
-If not otherwise stated, any source code generated by Coco/R (other than
-Coco/R itself) does not fall under the GNU General Public License.
-----------------------------------------------------------------------*/
--->begin
--->namespace
-
-partial class VBIndentationStrategy {
--->constants
- const bool T = true;
- const bool x = false;
-
--->declarations
- readonly Stack<int> stateStack = new Stack<int>();
- List<Token> errors = new List<Token>();
-
- VBIndentationStrategy()
- {
- stateStack.Push(-1); // required so that we don't crash when leaving the root production
- }
-
- void Expect(int expectedKind, Token la)
- {
- if (la.Kind != expectedKind) {
- Error(la);
- Console.WriteLine("expected: " + expectedKind);
- }
- }
-
- void Error(Token la)
- {
- Console.WriteLine("not expected: " + la);
- errors.Add(la);
- }
-
- Token t;
-
- public void InformToken(Token la)
- {
- -->informToken
- if (la != null)
- t = la;
- }
-
- public void Advance()
- {
- //Console.WriteLine("Advance");
- InformToken(null);
- }
-
- static readonly BitArray[] set = {
--->initialization
- };
-
-} // end Parser
-
-
-$$$
View
298 ...Ins/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBIndentationStrategy.atg
@@ -1,298 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using ICSharpCode.NRefactory.Parser;
-
-PUSHCOMPILER VBIndentationStrategy
-
-$tokenKindFieldName=Kind
-
-/* START AUTOGENERATED TOKENS SECTION */
-TOKENS
- /* ----- terminal classes ----- */
- /* EOF is 0 */
- EOL
- ident
- LiteralString
- LiteralCharacter
- LiteralInteger
- LiteralDouble
- LiteralSingle
- LiteralDecimal
- LiteralDate
- XmlOpenTag
- XmlCloseTag
- XmlStartInlineVB
- XmlEndInlineVB
- XmlCloseTagEmptyElement
- XmlOpenEndTag
- XmlContent
- XmlComment
- XmlCData
- XmlProcessingInstruction
-
- /* ----- special character ----- */
- "="
- ":"
- ","
- "&"
- "/"
- "\\"
- "."
- "..."
- ".@"
- "!"
- "-"
- "+"
- "^"
- "?"
- "*"
- "{"
- "}"
- "("
- ")"
- ">"
- "<"
- "<>"
- ">="
- "<="
- "<<"
- ">>"
- "+="
- "^="
- "-="
- "*="
- "/="
- "\\="
- "<<="
- ">>="
- "&="
- ":="
-
- /* ----- keywords ----- */
- "AddHandler"
- "AddressOf"
- "Aggregate"
- "Alias"
- "And"
- "AndAlso"
- "Ansi"
- "As"
- "Ascending"
- "Assembly"
- "Auto"
- "Binary"
- "Boolean"
- "ByRef"
- "By"
- "Byte"
- "ByVal"
- "Call"
- "Case"
- "Catch"
- "CBool"
- "CByte"
- "CChar"
- "CDate"
- "CDbl"
- "CDec"
- "Char"
- "CInt"
- "Class"
- "CLng"
- "CObj"
- "Compare"
- "Const"
- "Continue"
- "CSByte"
- "CShort"
- "CSng"
- "CStr"
- "CType"
- "CUInt"
- "CULng"
- "CUShort"
- "Custom"
- "Date"
- "Decimal"
- "Declare"
- "Default"
- "Delegate"
- "Descending"
- "Dim"
- "DirectCast"
- "Distinct"
- "Do"
- "Double"
- "Each"
- "Else"
- "ElseIf"
- "End"
- "EndIf"
- "Enum"
- "Equals"
- "Erase"
- "Error"
- "Event"
- "Exit"
- "Explicit"
- "False"
- "Finally"
- "For"
- "Friend"
- "From"
- "Function"
- "Get"
- "GetType"
- "Global"
- "GoSub"
- "GoTo"
- "Group"
- "Handles"
- "If"
- "Implements"
- "Imports"
- "In"
- "Infer"
- "Inherits"
- "Integer"
- "Interface"
- "Into"
- "Is"
- "IsNot"
- "Join"
- "Key"
- "Let"
- "Lib"
- "Like"
- "Long"
- "Loop"
- "Me"
- "Mod"
- "Module"
- "MustInherit"
- "MustOverride"
- "MyBase"
- "MyClass"
- "Namespace"
- "Narrowing"
- "New"
- "Next"
- "Not"
- "Nothing"
- "NotInheritable"
- "NotOverridable"
- "Object"
- "Of"
- "Off"
- "On"
- "Operator"
- "Option"
- "Optional"
- "Or"
- "Order"
- "OrElse"
- "Out"
- "Overloads"
- "Overridable"
- "Overrides"
- "ParamArray"
- "Partial"
- "Preserve"
- "Private"
- "Property"
- "Protected"
- "Public"
- "RaiseEvent"
- "ReadOnly"
- "ReDim"
- "Rem"
- "RemoveHandler"
- "Resume"
- "Return"
- "SByte"
- "Select"
- "Set"
- "Shadows"
- "Shared"
- "Short"
- "Single"
- "Skip"
- "Static"
- "Step"
- "Stop"
- "Strict"
- "String"
- "Structure"
- "Sub"
- "SyncLock"
- "Take"
- "Text"
- "Then"
- "Throw"
- "To"
- "True"
- "Try"
- "TryCast"
- "TypeOf"
- "UInteger"
- "ULong"
- "Unicode"
- "Until"
- "UShort"
- "Using"
- "Variant"
- "Wend"
- "When"
- "Where"
- "While"
- "Widening"
- "With"
- "WithEvents"
- "WriteOnly"
- "Xor"
- "GetXmlNamespace"
-/* END AUTOGENERATED TOKENS SECTION */
-
-PRODUCTIONS
-/*------------------------------------------------------------------------*/
-VBIndentationStrategy =
- { ANY }
- { NamespaceMemberDeclaration { ANY } }
-.
-
-StatementTerminator =
- EOL | ":"
-.
-
-NamespaceMemberDeclaration =
- NamespaceDeclaration
- | TypeDeclaration
-.
-
-NamespaceDeclaration =
- "Namespace" { ANY } StatementTerminator
- (. Indent(la); .)
- { NamespaceMemberDeclaration { ANY } }
- (. Unindent(la); .)
- "End" "Namespace" StatementTerminator
-.
-
-TypeDeclaration =
- ClassOrModuleOrStructureTypeDeclaration |
- DelegateTypeDeclaration |
- EnumTypeDeclaration |
- InterfaceDeclaration
-.
-
-DelegateTypeDeclaration = "Delegate" { ANY } StatementTerminator .
-
-EnumTypeDeclaration =
- "Enum" { ANY } StatementTerminator
- (. Indent(la); .)
- { ANY } StatementTerminator
- (. Unindent(la); .)
- "End" "Enum" StatementTerminator
-.
-
-END VBIndentationStrategy.
View
76 ...dIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBIndentationStrategy.cs
@@ -1,76 +0,0 @@
-// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
-// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
-
-using System;
-using System.Collections.Generic;
-using ICSharpCode.NRefactory.Parser;
-using ICSharpCode.SharpDevelop.Editor;
-
-namespace ICSharpCode.VBNetBinding
-{
- /// <summary>
- /// Description of VBIndentationStrategy.
- /// </summary>
- public partial class VBIndentationStrategy
- {
- Stack<Block> indentationStack = new Stack<Block>();
- ITextEditor editor;
- IDocumentLine startLine, endLine;
-
- public string CurrentIndent {
- get { return (indentationStack.PeekOrDefault() ?? Block.Empty).Indentation; }
- }
-
- class Block {
- public static readonly Block Empty = new Block {
- Indentation = "",
- StartLine = 1
- };
-
- public string Indentation;
- public int StartLine;
- }
-
- public VBIndentationStrategy(ITextEditor editor, int start, int end)
- : this()
- {
- this.editor = editor;
-
- startLine = editor.Document.GetLine(start);
- endLine = editor.Document.GetLine(end);
- }
-
- void Indent(Token la)
- {
- ApplyIndent(la);
- Block parent = indentationStack.PeekOrDefault() ?? Block.Empty;
- indentationStack.Push(new Block() { Indentation = parent.Indentation + editor.Options.IndentationString, StartLine = t.Location.Line + 1 } );
- }
-
- void Unindent(Token la)
- {
- ApplyIndent(la);
- indentationStack.PopOrDefault();
- }
-
- void ApplyIndent(Token la)
- {
- Block current = indentationStack.PeekOrDefault() ?? Block.Empty;
-
- if (t.Location.Line < startLine.LineNumber)
- return;
-
- IDocumentLine firstLine = startLine.LineNumber > current.StartLine ? startLine : editor.Document.GetLine(current.StartLine);
- IDocumentLine currentLine = firstLine;
-
- while (currentLine.LineNumber < la.Location.Line) {
- editor.Document.SmartReplaceLine(currentLine, current.Indentation + currentLine.Text.Trim());
-
- if (currentLine.LineNumber == endLine.LineNumber)
- break;
-
- currentLine = editor.Document.GetLine(currentLine.LineNumber + 1);
- }
- }
- }
-}
View
2 ...ns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs
@@ -23,6 +23,7 @@ namespace ICSharpCode.VBNetBinding
/// </summary>
public class VBNetFormattingStrategy : DefaultFormattingStrategy
{
+ #region VB Statements
static readonly List<VBStatement> statements;
internal static List<VBStatement> Statements {
@@ -85,6 +86,7 @@ public class VBNetFormattingStrategy : DefaultFormattingStrategy
Tokens.If, Tokens.For, Tokens.Do, Tokens.While, Tokens.With, Tokens.Select, Tokens.Try,
Tokens.Property, Tokens.Get, Tokens.Set
});
+ #endregion
bool doCasing;
bool doInsertion;
View
11 src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj
@@ -63,10 +63,6 @@
<LogicalName>Resources.BuildOptions.xfrm</LogicalName>
</EmbeddedResource>
<Compile Include="Src\Extensions.cs" />
- <Compile Include="Src\FormattingStrategy\Parser.cs">
- <DependentUpon>VBIndentationStrategy.atg</DependentUpon>
- </Compile>
- <Compile Include="Src\FormattingStrategy\VBIndentationStrategy.cs" />
<Compile Include="Src\FormattingStrategy\VBStatement.cs" />
<Compile Include="Src\LanguageUtils.cs" />
<Compile Include="Src\OptionPanels\ProjectImportsOptions.xaml.cs">
@@ -88,13 +84,6 @@
</Compile>
<Compile Include="Src\Parser\Parser.cs" />
<Compile Include="Src\Project\VBNetProject.cs" />
- <None Include="Src\FormattingStrategy\PushParser.frame">
- <DependentUpon>VBIndentationStrategy.atg</DependentUpon>
- </None>
- <None Include="Src\FormattingStrategy\VBIndentationStrategy.atg">
- <Generator>CocoParserGenerator</Generator>
- <CustomToolNamespace>ICSharpCode.VBNetBinding</CustomToolNamespace>
- </None>
<None Include="VBNetBinding.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
View
16 src/AddIns/BackendBindings/VBNetBinding/Test/FormattingStrategy/IndentationTests.cs
@@ -75,12 +75,12 @@ End Sub
End Class";
string code = @"Public Class Test
- Private Sub Tester()
- B = New Burger With {Cheese = True, _
- Lettuce = True, _
- Tomato = True, _
- CookLevel = MeatCookLevel.WellDone}
- End Sub
+Private Sub Tester()
+B = New Burger With {Cheese = True, _
+Lettuce = True, _
+Tomato = True, _
+CookLevel = MeatCookLevel.WellDone}
+End Sub
End Class";
RunFormatTest(code, expected);
@@ -94,7 +94,7 @@ public void Simple()
' User: Siegfried
' Date: 25.02.2011
' Time: 14:41
-'
+'
' To change this template use Tools | Options | Coding | Edit Standard Headers.
'
Imports Microsoft.VisualBasic.ApplicationServices
@@ -121,7 +121,7 @@ End Class
' User: Siegfried
' Date: 25.02.2011
' Time: 14:41
-'
+'
' To change this template use Tools | Options | Coding | Edit Standard Headers.
'
Imports Microsoft.VisualBasic.ApplicationServices

0 comments on commit fab0f9f

Please sign in to comment.