diff options
author | Jeffrey Stedfast <fejj@gnome.org> | 2011-03-04 01:03:28 +0300 |
---|---|---|
committer | Jeffrey Stedfast <fejj@gnome.org> | 2011-03-04 01:03:28 +0300 |
commit | 102f31bb7f107436066b4290fab9bcd53f94ae45 (patch) | |
tree | 58fb7b2219a617c124216be968103dfa57f852f9 /main/src/addins/CBinding | |
parent | 10ff10f22170771907b0453ec530e631b1d6fc2c (diff) |
Drop verbatim string support from CBinding
Diffstat (limited to 'main/src/addins/CBinding')
3 files changed, 19 insertions, 83 deletions
diff --git a/main/src/addins/CBinding/Formatting/CIndentEngine.cs b/main/src/addins/CBinding/Formatting/CIndentEngine.cs index d01f4d9dc3..8cf9d96031 100644 --- a/main/src/addins/CBinding/Formatting/CIndentEngine.cs +++ b/main/src/addins/CBinding/Formatting/CIndentEngine.cs @@ -50,7 +50,6 @@ namespace CBinding.Formatting Inside beganInside; bool needsReindent; - bool popVerbatim; bool canBeLabel; bool isEscaped; @@ -106,10 +105,6 @@ namespace CBinding.Formatting get { return stack.Count; } } - public bool IsInsideVerbatimString { - get { return stack.PeekInside (0) == Inside.VerbatimString; } - } - public bool IsInsideMultiLineComment { get { return stack.PeekInside (0) == Inside.MultiLineComment; } } @@ -118,10 +113,6 @@ namespace CBinding.Formatting get { return stack.PeekInside (0) == Inside.DocComment; } } - public bool LineBeganInsideVerbatimString { - get { return beganInside == Inside.VerbatimString; } - } - public bool LineBeganInsideMultiLineComment { get { return beganInside == Inside.MultiLineComment; } } @@ -194,7 +185,6 @@ namespace CBinding.Formatting curIndent = String.Empty; needsReindent = false; - popVerbatim = false; canBeLabel = true; isEscaped = false; @@ -223,7 +213,6 @@ namespace CBinding.Formatting engine.curIndent = curIndent; engine.needsReindent = needsReindent; - engine.popVerbatim = popVerbatim; engine.canBeLabel = canBeLabel; engine.isEscaped = isEscaped; @@ -264,7 +253,6 @@ namespace CBinding.Formatting static bool KeywordIsSpecial (string keyword) { string[] specials = new string [] { - "foreach", "while", "for", "else", @@ -281,7 +269,6 @@ namespace CBinding.Formatting static readonly string[] keywords = new string [] { "namespace", - "interface", "struct", "class", "enum", @@ -321,8 +308,8 @@ namespace CBinding.Formatting return str == "default"; } - //directive keywords that we care about - static string[] directiveKeywords = new string [] {"region", "endregion" }; + // directive keywords that we care about + static string[] directiveKeywords = new string [] { "region", "endregion" }; string GetDirectiveKeyword (char currentChar) { @@ -465,16 +452,7 @@ namespace CBinding.Formatting if ((inside & (Inside.PreProcessor | Inside.Comment | Inside.CharLiteral)) != 0) return; - if (inside == Inside.VerbatimString) { - if (popVerbatim) { - // back in the verbatim-string-literal token - popVerbatim = false; - } else { - /* need to see the next char before we pop the - * verbatim-string-literal */ - popVerbatim = true; - } - } else if (inside == Inside.StringLiteral) { + if (inside == Inside.StringLiteral) { // check that it isn't escaped if (!isEscaped) { keyword = stack.PeekKeyword (0); @@ -482,10 +460,7 @@ namespace CBinding.Formatting } } else { // FoldedStatement, Block, Attribute or ParenList - if (pc == '@') - type = Inside.VerbatimString; - else - type = Inside.StringLiteral; + type = Inside.StringLiteral; // push a new string onto the stack stack.Push (type, keyword, curLineNr, 0); @@ -766,9 +741,6 @@ namespace CBinding.Formatting inside = stack.PeekInside (0); goto top; - case Inside.VerbatimString: - // nothing to do - break; case Inside.StringLiteral: if (isEscaped) { /* I don't think c# allows breaking a @@ -888,16 +860,6 @@ namespace CBinding.Formatting Inside inside, after; inside = stack.PeekInside (0); - - // pop the verbatim-string-literal - if (inside == Inside.VerbatimString && popVerbatim && c != '"') { - keyword = stack.PeekKeyword (0); - popVerbatim = false; - stack.Pop (); - - inside = stack.PeekInside (0); - } - needsReindent = false; if ((inside & (Inside.PreProcessor | Inside.StringOrChar | Inside.Comment)) == 0 && wordStart != -1) { @@ -907,15 +869,14 @@ namespace CBinding.Formatting keyword = tmp; } else if (c == ':' && WordIsDefault ()) { keyword = "default"; - } - //get the keyword for preprocessor directives + } } else if ((inside & (Inside.PreProcessor)) != 0 && stack.PeekKeyword (0) == null) { - //replace the stack item with a keyworded one + // replace the stack item with a keyworded one string preProcessorKeyword = GetDirectiveKeyword (c); int peekLine = stack.PeekLineNr (0); stack.Pop (); stack.Push (Inside.PreProcessor, preProcessorKeyword, peekLine, 0); - //regions need to pop back out + // regions need to pop back out if (preProcessorKeyword == "region" || preProcessorKeyword == "endregion") { curIndent = stack.PeekIndent (0); needsReindent = true; @@ -1059,9 +1020,6 @@ namespace CBinding.Formatting case Inside.LineComment: Console.WriteLine ("\t// comment"); break; - case Inside.VerbatimString: - Console.WriteLine ("\tverbatim string"); - break; case Inside.StringLiteral: Console.WriteLine ("\tstring literal"); break; diff --git a/main/src/addins/CBinding/Formatting/CIndentEngineStack.cs b/main/src/addins/CBinding/Formatting/CIndentEngineStack.cs index 2e0f5da714..7125f1be18 100644 --- a/main/src/addins/CBinding/Formatting/CIndentEngineStack.cs +++ b/main/src/addins/CBinding/Formatting/CIndentEngineStack.cs @@ -41,13 +41,12 @@ namespace CBinding.Formatting MultiLineComment = (1 << 1), LineComment = (1 << 2), - DocComment = (1 << 11), - Comment = (MultiLineComment | LineComment | DocComment), + DocComment = (1 << 3), + Comment = (MultiLineComment | LineComment | DocComment), - VerbatimString = (1 << 3), StringLiteral = (1 << 4), CharLiteral = (1 << 5), - String = (VerbatimString | StringLiteral), + String = StringLiteral, StringOrChar = (String | CharLiteral), Attribute = (1 << 6), diff --git a/main/src/addins/CBinding/Formatting/CTextEditorIndentation.cs b/main/src/addins/CBinding/Formatting/CTextEditorIndentation.cs index 51cedc8e78..e7e4d4cfa7 100644 --- a/main/src/addins/CBinding/Formatting/CTextEditorIndentation.cs +++ b/main/src/addins/CBinding/Formatting/CTextEditorIndentation.cs @@ -206,17 +206,8 @@ namespace CBinding.Formatting if (key == Gdk.Key.Tab && TextEditorProperties.TabIsReindent && !(textEditorData.CurrentMode is TextLinkEditMode) && !DoInsertTemplate () && !isSomethingSelected) { int cursor = textEditorData.Caret.Offset; - - if (TextEditorProperties.TabIsReindent && stateTracker.Engine.IsInsideVerbatimString) { - // insert normal tab inside @" ... " - if (textEditorData.IsSomethingSelected) { - textEditorData.SelectedText = "\t"; - } else { - textEditorData.Insert (cursor, "\t"); - textEditorData.Caret.Offset++; - } - textEditorData.Document.CommitLineUpdate (textEditorData.Caret.Line); - } else if (TextEditorProperties.TabIsReindent && cursor >= 1) { + + if (TextEditorProperties.TabIsReindent && cursor >= 1) { if (textEditorData.Caret.Column > 1) { int delta = cursor - this.cursorPositionBeforeKeyPress; if (delta < 2 && delta > 0) { @@ -299,9 +290,10 @@ namespace CBinding.Formatting // if the line ends with ';' the line end is not the correct place for a new semicolon. if (curLine.EditableLength > 0 && data.Document.GetCharAt (max - 1) == ';') return offset; - - bool isInString = false , isInChar= false , isVerbatimString= false; - bool isInLineComment = false , isInBlockComment= false; + + bool isInLineComment = false, isInBlockComment = false; + bool isInString = false, isInChar = false; + for (int pos = offset; pos < max; pos++) { char ch = data.Document.GetCharAt (pos); switch (ch) { @@ -322,25 +314,12 @@ namespace CBinding.Formatting } break; case '\\': - if (isInChar || (isInString && !isVerbatimString)) + if (isInChar || isInString) pos++; break; - case '@': - if (!(isInString || isInChar || isInLineComment || isInBlockComment) && pos + 1 < max && data.Document.GetCharAt (pos + 1) == '"') { - isInString = true; - isVerbatimString = true; - pos++; - } - break; case '"': - if (!(isInChar || isInLineComment || isInBlockComment)) { - if (isInString && isVerbatimString && pos + 1 < max && data.Document.GetCharAt (pos + 1) == '"') { - pos++; - } else { - isInString = !isInString; - isVerbatimString = false; - } - } + if (!(isInChar || isInLineComment || isInBlockComment)) + isInString = !isInString; break; case '\'': if (!(isInString || isInLineComment || isInBlockComment)) |