Permalink
Browse files

Some namespace cleanup.

  • Loading branch information...
1 parent bd31569 commit f12ae15bf4db1d25f6db4ec1d88c42e65d904b87 @jmis jmis committed Mar 27, 2011
Showing with 1,619 additions and 1,619 deletions.
  1. +1 −1 ClojureExtension.Deployment/ClojurePackage.cs
  2. +28 −28 ClojureExtension.Editor/ActiveTextBufferStateProvider.cs
  3. +95 −95 ClojureExtension.Editor/AutoFormat/AutoFormatter.cs
  4. +58 −58 ClojureExtension.Editor/AutoIndent/ClojureSmartIndent.cs
  5. +27 −27 ClojureExtension.Editor/AutoIndent/SmartIndentAdapter.cs
  6. +27 −27 ClojureExtension.Editor/BraceMatching/BraceMatchingTaggerProvider.cs
  7. +64 −64 ClojureExtension.Editor/BraceMatching/MatchingBraceFinder.cs
  8. +86 −86 ClojureExtension.Editor/InputHandling/BufferTextChangeHandler.cs
  9. +24 −24 ClojureExtension.Editor/Options/EditorOptionsBuilder.cs
  10. +29 −29 ClojureExtension.Editor/Tagger/ClojureTagProvider.cs
  11. +43 −43 ClojureExtension.Editor/Tagger/ClojureTokenTagger.cs
  12. +29 −29 ClojureExtension.Editor/TokenizedBufferBuilder.cs
  13. +1 −0 ClojureExtension.Project/ClojureProjectNode.cs
  14. +39 −39 ClojureExtension.Project/Hierarchy/ProjectFilesProvider.cs
  15. +31 −31 ClojureExtension.Project/Hierarchy/SelectedFilesProvider.cs
  16. +33 −33 ClojureExtension.Project/Hierarchy/SelectedProjectProvider.cs
  17. +1 −1 ClojureExtension.Project/Launching/LaunchParametersBuilder.cs
  18. +5 −5 ClojureExtension.Project/Launching/ProjectLauncher.cs
  19. +0 −1 ClojureExtension.Repl/History.cs
  20. +0 −1 ClojureExtension.Repl/InputKeyHandler.cs
  21. +1 −1 ClojureExtension.Repl/Operations/ActiveFileProvider.cs
  22. +1 −1 ClojureExtension.Repl/Operations/LoadFilesIntoRepl.cs
  23. +1 −1 ClojureExtension.Repl/Operations/StartReplUsingProjectVersion.cs
  24. +0 −1 ClojureExtension.Repl/ReplFactory.cs
  25. +1 −1 ClojureExtension.Repl/TextBoxWriter.cs
  26. +276 −276 ClojureExtension.Tests/Editor/AutoFormat/AutoFormatterTests.cs
  27. +84 −84 ClojureExtension.Tests/Editor/AutoIndent/ClojureSmartIndentTests.cs
  28. +129 −129 ClojureExtension.Tests/Editor/BraceMatching/MatchingBraceFinderTests.cs
  29. +244 −244 ClojureExtension.Tests/Editor/InputHandling/BufferTextChangeHandlerTests.cs
  30. +117 −117 ClojureExtension.Tests/Parsing/TokenListTests.cs
  31. +6 −6 ClojureExtension.Utilities/Entity.cs
  32. +11 −12 ClojureExtension.Utilities/Guids.cs
  33. +6 −6 ClojureExtension.Utilities/IProvider.cs
  34. +27 −27 ClojureExtension.Utilities/MenuCommandListHider.cs
  35. +31 −31 ClojureExtension.Utilities/MenuCommandListWirer.cs
  36. +39 −36 ClojureExtension.Utilities/Properties/AssemblyInfo.cs
  37. +2 −2 ClojureExtension.Utilities/StreamBuffer.cs
  38. +22 −22 ClojureExtension.Utilities/StringExtensions.cs
@@ -24,6 +24,7 @@
using ClojureExtension.Project.Launching;
using ClojureExtension.Repl;
using ClojureExtension.Repl.Operations;
+using ClojureExtension.Utilities;
using EnvDTE;
using EnvDTE80;
using Microsoft.ClojureExtension;
@@ -32,7 +33,6 @@
using Microsoft.ClojureExtension.Editor.Options;
using Microsoft.ClojureExtension.Project;
using Microsoft.ClojureExtension.Project.Hierarchy;
-using Microsoft.ClojureExtension.Utilities;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Project;
using Microsoft.VisualStudio.Shell;
@@ -1,29 +1,29 @@
-using System.Collections.Generic;
-using ClojureExtension.Parsing;
-using Microsoft.ClojureExtension.Utilities;
-using Microsoft.VisualStudio.Editor;
-using Microsoft.VisualStudio.Text.Editor;
-using Microsoft.VisualStudio.TextManager.Interop;
-
-namespace Microsoft.ClojureExtension.Editor
-{
- public class ActiveTextBufferStateProvider : IProvider<LinkedList<Token>>
- {
- private readonly IVsEditorAdaptersFactoryService _vsEditorAdaptersFactoryService;
- private readonly IVsTextManager _vsTextManager;
-
- public ActiveTextBufferStateProvider(IVsEditorAdaptersFactoryService vsEditorAdaptersFactoryService, IVsTextManager vsTextManager)
- {
- _vsEditorAdaptersFactoryService = vsEditorAdaptersFactoryService;
- _vsTextManager = vsTextManager;
- }
-
- public LinkedList<Token> Get()
- {
- IVsTextView activeView = null;
- _vsTextManager.GetActiveView(0, null, out activeView);
- IWpfTextView wpfTextView = _vsEditorAdaptersFactoryService.GetWpfTextView(activeView);
- return TokenizedBufferBuilder.TokenizedBuffers[wpfTextView.TextBuffer].CurrentState;
- }
- }
+using System.Collections.Generic;
+using ClojureExtension.Parsing;
+using ClojureExtension.Utilities;
+using Microsoft.VisualStudio.Editor;
+using Microsoft.VisualStudio.Text.Editor;
+using Microsoft.VisualStudio.TextManager.Interop;
+
+namespace Microsoft.ClojureExtension.Editor
+{
+ public class ActiveTextBufferStateProvider : IProvider<LinkedList<Token>>
+ {
+ private readonly IVsEditorAdaptersFactoryService _vsEditorAdaptersFactoryService;
+ private readonly IVsTextManager _vsTextManager;
+
+ public ActiveTextBufferStateProvider(IVsEditorAdaptersFactoryService vsEditorAdaptersFactoryService, IVsTextManager vsTextManager)
+ {
+ _vsEditorAdaptersFactoryService = vsEditorAdaptersFactoryService;
+ _vsTextManager = vsTextManager;
+ }
+
+ public LinkedList<Token> Get()
+ {
+ IVsTextView activeView = null;
+ _vsTextManager.GetActiveView(0, null, out activeView);
+ IWpfTextView wpfTextView = _vsEditorAdaptersFactoryService.GetWpfTextView(activeView);
+ return TokenizedBufferBuilder.TokenizedBuffers[wpfTextView.TextBuffer].CurrentState;
+ }
+ }
}
@@ -1,96 +1,96 @@
-using System.Collections.Generic;
-using System.Text;
-using ClojureExtension.Editor.InputHandling;
-using ClojureExtension.Editor.TextBuffer;
-using ClojureExtension.Parsing;
-using Microsoft.ClojureExtension.Editor.Options;
-using Microsoft.ClojureExtension.Utilities;
-
-namespace Microsoft.ClojureExtension.Editor.AutoFormat
-{
- public class AutoFormatter
- {
- private readonly ITextBufferAdapter _textBuffer;
- private readonly Entity<LinkedList<Token>> _tokenizedBuffer;
- private Stack<Token> _dataStructureStack;
- private LinkedListNode<Token> _currentToken;
- private int _currentLineIndex;
- private Stack<int> _indentStack;
-
- public AutoFormatter(ITextBufferAdapter textBuffer, Entity<LinkedList<Token>> tokenizedBuffer)
- {
- _textBuffer = textBuffer;
- _tokenizedBuffer = tokenizedBuffer;
- }
-
- public void Format(EditorOptions editorOptions)
- {
- StringBuilder output = new StringBuilder();
- _currentToken = _tokenizedBuffer.CurrentState.First;
- _dataStructureStack = new Stack<Token>();
- _indentStack = new Stack<int>();
-
- while (_currentToken != null)
- {
- string tokenText = _currentToken.Value.Text;
- if (_currentToken.Value.Type.IsBraceStart()) _dataStructureStack.Push(_currentToken.Value);
- if (_currentToken.Value.Type.IsBraceEnd() && _dataStructureStack.Count > 0 && _dataStructureStack.Peek().Type.MatchingBraceType() == _currentToken.Value.Type) _dataStructureStack.Pop();
-
- if (_currentToken.Value.Type == TokenType.Whitespace)
- {
- bool moreThanOneLineBreak = tokenText.Replace(" ", "").Contains("\r\n\r\n");
- bool hasAtLeastOneLineBreak = tokenText.Replace(" ", "").Contains("\r\n");
-
- if (_currentToken.Previous == null) tokenText = "";
- else if (_currentToken.Next == null) tokenText = "";
- else if (_currentToken.Next.Value.Type == TokenType.Comment && !tokenText.Contains("\r\n")) tokenText = " ";
- else if (_dataStructureStack.Count == 0 && IsPreviousTokenACommentOnTheSameLineAsExpression()) tokenText = "\r\n\r\n";
- else if (_dataStructureStack.Count == 0 && _currentToken.Previous.Value.Type != TokenType.Comment) tokenText = "\r\n\r\n";
- else if (_dataStructureStack.Count == 0) tokenText = moreThanOneLineBreak ? "\r\n\r\n" : hasAtLeastOneLineBreak ? "\r\n" : "";
- else if (_currentToken.Next.Value.Type == TokenType.Comment && !tokenText.EndsWith(" ")) tokenText = "\r\n";
- else if (tokenText.Contains("\r\n")) tokenText = "\r\n" + GetIndent(editorOptions);
- else if (_currentToken.Next.Value.Type.IsBraceEnd()) tokenText = "";
- else if (_currentToken.Previous.Value.Type.IsBraceStart()) tokenText = "";
- else tokenText = " ";
- }
- else if (_currentToken.Next != null && _currentToken.Next.Value.Type != TokenType.Whitespace)
- {
- if (_currentToken.Next.Value.Type == TokenType.Comment) tokenText += " ";
- else if (_dataStructureStack.Count == 0) tokenText += "\r\n\r\n";
- else if (!_currentToken.Value.Type.IsBrace() && !_currentToken.Next.Value.Type.IsBrace()) tokenText += " ";
- }
-
- if (tokenText.Contains("\r\n")) _currentLineIndex = tokenText.Count(' ');
- else _currentLineIndex += tokenText.Length;
-
- if (_currentToken.Value.Type.IsBraceStart()) _indentStack.Push(_currentLineIndex - tokenText.Count(' '));
- else if (_indentStack.Count > _dataStructureStack.Count) _indentStack.Pop();
-
- _currentToken = _currentToken.Next;
- output.Append(tokenText);
- }
-
- _textBuffer.SetText(output.ToString());
- }
-
- private string GetIndent(EditorOptions editorOptions)
- {
- if (_dataStructureStack.Count == 0) return "";
- if (_dataStructureStack.Peek().Type == TokenType.ListStart) return " ".Repeat(editorOptions.IndentSize + _indentStack.Peek() - 1);
- return " ".Repeat(_indentStack.Peek());
- }
-
- private bool IsPreviousTokenACommentOnTheSameLineAsExpression()
- {
- if (_currentToken.Previous.Value.Type == TokenType.Comment)
- {
- LinkedListNode<Token> commentToken = _currentToken.Previous;
- if (commentToken.Previous == null) return false;
- if (commentToken.Previous.Value.Type != TokenType.Whitespace) return true;
- return !commentToken.Previous.Value.Text.Contains("\r\n");
- }
-
- return false;
- }
- }
+using System.Collections.Generic;
+using System.Text;
+using ClojureExtension.Editor.InputHandling;
+using ClojureExtension.Editor.TextBuffer;
+using ClojureExtension.Parsing;
+using ClojureExtension.Utilities;
+using Microsoft.ClojureExtension.Editor.Options;
+
+namespace Microsoft.ClojureExtension.Editor.AutoFormat
+{
+ public class AutoFormatter
+ {
+ private readonly ITextBufferAdapter _textBuffer;
+ private readonly Entity<LinkedList<Token>> _tokenizedBuffer;
+ private Stack<Token> _dataStructureStack;
+ private LinkedListNode<Token> _currentToken;
+ private int _currentLineIndex;
+ private Stack<int> _indentStack;
+
+ public AutoFormatter(ITextBufferAdapter textBuffer, Entity<LinkedList<Token>> tokenizedBuffer)
+ {
+ _textBuffer = textBuffer;
+ _tokenizedBuffer = tokenizedBuffer;
+ }
+
+ public void Format(EditorOptions editorOptions)
+ {
+ StringBuilder output = new StringBuilder();
+ _currentToken = _tokenizedBuffer.CurrentState.First;
+ _dataStructureStack = new Stack<Token>();
+ _indentStack = new Stack<int>();
+
+ while (_currentToken != null)
+ {
+ string tokenText = _currentToken.Value.Text;
+ if (_currentToken.Value.Type.IsBraceStart()) _dataStructureStack.Push(_currentToken.Value);
+ if (_currentToken.Value.Type.IsBraceEnd() && _dataStructureStack.Count > 0 && _dataStructureStack.Peek().Type.MatchingBraceType() == _currentToken.Value.Type) _dataStructureStack.Pop();
+
+ if (_currentToken.Value.Type == TokenType.Whitespace)
+ {
+ bool moreThanOneLineBreak = tokenText.Replace(" ", "").Contains("\r\n\r\n");
+ bool hasAtLeastOneLineBreak = tokenText.Replace(" ", "").Contains("\r\n");
+
+ if (_currentToken.Previous == null) tokenText = "";
+ else if (_currentToken.Next == null) tokenText = "";
+ else if (_currentToken.Next.Value.Type == TokenType.Comment && !tokenText.Contains("\r\n")) tokenText = " ";
+ else if (_dataStructureStack.Count == 0 && IsPreviousTokenACommentOnTheSameLineAsExpression()) tokenText = "\r\n\r\n";
+ else if (_dataStructureStack.Count == 0 && _currentToken.Previous.Value.Type != TokenType.Comment) tokenText = "\r\n\r\n";
+ else if (_dataStructureStack.Count == 0) tokenText = moreThanOneLineBreak ? "\r\n\r\n" : hasAtLeastOneLineBreak ? "\r\n" : "";
+ else if (_currentToken.Next.Value.Type == TokenType.Comment && !tokenText.EndsWith(" ")) tokenText = "\r\n";
+ else if (tokenText.Contains("\r\n")) tokenText = "\r\n" + GetIndent(editorOptions);
+ else if (_currentToken.Next.Value.Type.IsBraceEnd()) tokenText = "";
+ else if (_currentToken.Previous.Value.Type.IsBraceStart()) tokenText = "";
+ else tokenText = " ";
+ }
+ else if (_currentToken.Next != null && _currentToken.Next.Value.Type != TokenType.Whitespace)
+ {
+ if (_currentToken.Next.Value.Type == TokenType.Comment) tokenText += " ";
+ else if (_dataStructureStack.Count == 0) tokenText += "\r\n\r\n";
+ else if (!_currentToken.Value.Type.IsBrace() && !_currentToken.Next.Value.Type.IsBrace()) tokenText += " ";
+ }
+
+ if (tokenText.Contains("\r\n")) _currentLineIndex = tokenText.Count(' ');
+ else _currentLineIndex += tokenText.Length;
+
+ if (_currentToken.Value.Type.IsBraceStart()) _indentStack.Push(_currentLineIndex - tokenText.Count(' '));
+ else if (_indentStack.Count > _dataStructureStack.Count) _indentStack.Pop();
+
+ _currentToken = _currentToken.Next;
+ output.Append(tokenText);
+ }
+
+ _textBuffer.SetText(output.ToString());
+ }
+
+ private string GetIndent(EditorOptions editorOptions)
+ {
+ if (_dataStructureStack.Count == 0) return "";
+ if (_dataStructureStack.Peek().Type == TokenType.ListStart) return " ".Repeat(editorOptions.IndentSize + _indentStack.Peek() - 1);
+ return " ".Repeat(_indentStack.Peek());
+ }
+
+ private bool IsPreviousTokenACommentOnTheSameLineAsExpression()
+ {
+ if (_currentToken.Previous.Value.Type == TokenType.Comment)
+ {
+ LinkedListNode<Token> commentToken = _currentToken.Previous;
+ if (commentToken.Previous == null) return false;
+ if (commentToken.Previous.Value.Type != TokenType.Whitespace) return true;
+ return !commentToken.Previous.Value.Text.Contains("\r\n");
+ }
+
+ return false;
+ }
+ }
}
@@ -1,59 +1,59 @@
-using System;
-using System.Collections.Generic;
-using ClojureExtension.Parsing;
-using Microsoft.ClojureExtension.Editor.Options;
-using Microsoft.ClojureExtension.Utilities;
-
-namespace Microsoft.ClojureExtension.Editor.AutoIndent
-{
- public class ClojureSmartIndent
- {
- private readonly Entity<LinkedList<Token>> _tokenizedBuffer;
-
- public ClojureSmartIndent(Entity<LinkedList<Token>> tokenizedBuffer)
- {
- _tokenizedBuffer = tokenizedBuffer;
- }
-
- public int GetDesiredIndentation(int position, EditorOptions options)
- {
- if (_tokenizedBuffer.CurrentState.Count == 0) return 0;
- IndexTokenNode currentToken = _tokenizedBuffer.CurrentState.FindTokenAtIndex(position);
- currentToken = currentToken.Previous();
- IndexTokenNode firstOpenBrace = null;
- int braceCount = 0;
-
- while (currentToken != null && firstOpenBrace == null)
- {
- if (currentToken.IndexToken.Token.Type.IsBraceEnd()) braceCount--;
- if (currentToken.IndexToken.Token.Type.IsBraceStart()) braceCount++;
- if (braceCount == 1) firstOpenBrace = currentToken;
- else currentToken = currentToken.Previous();
- }
-
- if (firstOpenBrace == null) return 0;
-
- int previousLineLength = 0;
- IndexTokenNode startOfLine = firstOpenBrace.Previous();
-
- while (startOfLine != null && (startOfLine.IndexToken.Token.Type != TokenType.Whitespace || (startOfLine.IndexToken.Token.Type == TokenType.Whitespace && !startOfLine.IndexToken.Token.Text.Contains("\r\n"))))
- {
- previousLineLength += startOfLine.IndexToken.Token.Length;
- startOfLine = startOfLine.Previous();
- }
-
- int previousIndentAmount = 0;
-
- if (startOfLine != null)
- {
- string startOfLineText = startOfLine.Node.Value.Text;
- string lineWhitespaceWithoutIndent = startOfLineText.TrimEnd(new[] {' '});
- previousIndentAmount = startOfLineText.Length - lineWhitespaceWithoutIndent.Length;
- }
-
- if (firstOpenBrace.Node.Value.Type == TokenType.ListStart) return previousIndentAmount + previousLineLength + options.IndentSize;
- return previousIndentAmount + previousLineLength + 1;
- }
- }
-}
+using System;
+using System.Collections.Generic;
+using ClojureExtension.Parsing;
+using ClojureExtension.Utilities;
+using Microsoft.ClojureExtension.Editor.Options;
+
+namespace Microsoft.ClojureExtension.Editor.AutoIndent
+{
+ public class ClojureSmartIndent
+ {
+ private readonly Entity<LinkedList<Token>> _tokenizedBuffer;
+
+ public ClojureSmartIndent(Entity<LinkedList<Token>> tokenizedBuffer)
+ {
+ _tokenizedBuffer = tokenizedBuffer;
+ }
+
+ public int GetDesiredIndentation(int position, EditorOptions options)
+ {
+ if (_tokenizedBuffer.CurrentState.Count == 0) return 0;
+ IndexTokenNode currentToken = _tokenizedBuffer.CurrentState.FindTokenAtIndex(position);
+ currentToken = currentToken.Previous();
+ IndexTokenNode firstOpenBrace = null;
+ int braceCount = 0;
+
+ while (currentToken != null && firstOpenBrace == null)
+ {
+ if (currentToken.IndexToken.Token.Type.IsBraceEnd()) braceCount--;
+ if (currentToken.IndexToken.Token.Type.IsBraceStart()) braceCount++;
+ if (braceCount == 1) firstOpenBrace = currentToken;
+ else currentToken = currentToken.Previous();
+ }
+
+ if (firstOpenBrace == null) return 0;
+
+ int previousLineLength = 0;
+ IndexTokenNode startOfLine = firstOpenBrace.Previous();
+
+ while (startOfLine != null && (startOfLine.IndexToken.Token.Type != TokenType.Whitespace || (startOfLine.IndexToken.Token.Type == TokenType.Whitespace && !startOfLine.IndexToken.Token.Text.Contains("\r\n"))))
+ {
+ previousLineLength += startOfLine.IndexToken.Token.Length;
+ startOfLine = startOfLine.Previous();
+ }
+
+ int previousIndentAmount = 0;
+
+ if (startOfLine != null)
+ {
+ string startOfLineText = startOfLine.Node.Value.Text;
+ string lineWhitespaceWithoutIndent = startOfLineText.TrimEnd(new[] {' '});
+ previousIndentAmount = startOfLineText.Length - lineWhitespaceWithoutIndent.Length;
+ }
+
+ if (firstOpenBrace.Node.Value.Type == TokenType.ListStart) return previousIndentAmount + previousLineLength + options.IndentSize;
+ return previousIndentAmount + previousLineLength + 1;
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit f12ae15

Please sign in to comment.