Browse Source

NRefactory: use Location structure instead of System.Drawing.Point for source positions.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1581 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
835c7dedbd
  1. 2
      src/AddIns/BackendBindings/Boo/Boo.InterpreterAddIn/Project/Boo.InterpreterAddIn.booproj
  2. 55
      src/AddIns/BackendBindings/Boo/Boo.InterpreterAddIn/Project/ContextEntry.boo
  3. 61
      src/AddIns/BackendBindings/Boo/Boo.InterpreterAddIn/Project/DefaultBooInterpreterContext.boo
  4. 21
      src/AddIns/BackendBindings/Boo/Boo.InterpreterAddIn/Project/InteractiveInterpreterControl.boo
  5. 25
      src/AddIns/BackendBindings/Boo/Boo.InterpreterAddIn/Project/InterpreterContext.boo
  6. 80
      src/AddIns/BackendBindings/Boo/Boo.InterpreterAddIn/Project/InterpreterPad.boo
  7. 2
      src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/BooPrinterVisitorWithComments.cs
  8. 4
      src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitor.cs
  9. 2
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/NRefactoryDesignerLoader.cs
  10. 2
      src/Libraries/NRefactory/Project/NRefactory.csproj
  11. 19
      src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs
  12. 1
      src/Libraries/NRefactory/Project/Src/Lexer/LookupTable.cs
  13. 3
      src/Libraries/NRefactory/Project/Src/Lexer/Special/BlankLine.cs
  14. 3
      src/Libraries/NRefactory/Project/Src/Lexer/Special/Comment.cs
  15. 15
      src/Libraries/NRefactory/Project/Src/Lexer/Special/ISpecial.cs
  16. 3
      src/Libraries/NRefactory/Project/Src/Lexer/Special/PreProcessingDirective.cs
  17. 11
      src/Libraries/NRefactory/Project/Src/Lexer/Special/SpecialTracker.cs
  18. 3
      src/Libraries/NRefactory/Project/Src/Lexer/Special/TagComment.cs
  19. 9
      src/Libraries/NRefactory/Project/Src/Lexer/Token.cs
  20. 13
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs
  21. 5
      src/Libraries/NRefactory/Project/Src/Output/SpecialNodesInserter.cs
  22. 9
      src/Libraries/NRefactory/Project/Src/Parser/AST/AbstractNode.cs
  23. 51
      src/Libraries/NRefactory/Project/Src/Parser/AST/Generated.cs
  24. 5
      src/Libraries/NRefactory/Project/Src/Parser/AST/INode.cs
  25. 2111
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs
  26. 3
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG
  27. 51
      src/Libraries/NRefactory/Project/Src/Parser/Location.cs
  28. 9
      src/Libraries/NRefactory/Project/Src/Parser/Modifiers.cs
  29. 2139
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  30. 1
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  31. 15
      src/Libraries/NRefactory/Project/Src/Parser/Visitors/LookupTableVisitor.cs
  32. 13
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs
  33. 9
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs
  34. 11
      src/Main/Base/Project/Src/Dom/Region.cs

2
src/AddIns/BackendBindings/Boo/Boo.InterpreterAddIn/Project/Boo.InterpreterAddIn.booproj

@ -39,6 +39,8 @@
<Compile Include="InteractiveInterpreterControl.boo" /> <Compile Include="InteractiveInterpreterControl.boo" />
<Compile Include="InterpreterPad.boo" /> <Compile Include="InterpreterPad.boo" />
<Compile Include="InterpreterContext.boo" /> <Compile Include="InterpreterContext.boo" />
<Compile Include="ContextEntry.boo" />
<Compile Include="DefaultBooInterpreterContext.boo" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj"> <ProjectReference Include="..\..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj">

55
src/AddIns/BackendBindings/Boo/Boo.InterpreterAddIn/Project/ContextEntry.boo

@ -0,0 +1,55 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
namespace Boo.InterpreterAddIn
import System
import System.Windows.Forms
import ICSharpCode.Core
import ICSharpCode.SharpDevelop.Gui
class ContextEntry:
[getter(InterpreterControl)]
_ctl as InteractiveInterpreterControl
[getter(Context)]
_context as InterpreterContext
[getter(ToolBarItem)]
_item as ToolStripButton
_parentPad as InterpreterPad
def constructor([required] context as InterpreterContext, [required] parentPad as InterpreterPad):
_context = context
_parentPad = parentPad
_ctl = InteractiveInterpreterControl(context)
_ctl.Dock = DockStyle.Fill
_item = ToolStripButton(StringParser.Parse(context.Title), context.Image)
_item.ToolTipText = context.ToolTipText
_item.Visible = context.Visible
_item.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText
context.ImageChanged += AutoInvoke() do:
_item.Image = _context.Image
context.TitleChanged += AutoInvoke() do:
_item.Text = StringParser.Parse(_context.Title)
context.ToolTipTextChanged += AutoInvoke() do:
_item.ToolTipText = StringParser.Parse(_context.ToolTipText)
context.VisibleChanged += AutoInvoke() do:
_item.Visible = _context.Visible
_parentPad.UpdateToolBarVisible()
if _parentPad.CurrentContext is self and _context.Visible == false:
_parentPad.ActivateFirstVisibleContext()
_item.Click += def:
_parentPad.CurrentContext = self
private static def AutoInvoke(what as callable()) as EventHandler:
return def(sender as object, e as EventArgs):
WorkbenchSingleton.SafeThreadAsyncCall(what)

61
src/AddIns/BackendBindings/Boo/Boo.InterpreterAddIn/Project/DefaultBooInterpreterContext.boo

@ -0,0 +1,61 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
namespace Boo.InterpreterAddIn
import System
import System.Reflection
class DefaultBooInterpreterContext(InterpreterContext):
_interpreter as Boo.Lang.Interpreter.InteractiveInterpreter
_isAdditionalTab as bool
def constructor():
self.Image = ICSharpCode.Core.ResourceService.GetBitmap("Boo.ProjectIcon")
def constructor(isAdditionalTab as bool):
self()
if isAdditionalTab:
self.Title = "New " + self.Title
_isAdditionalTab = true
private def AddAssemblies(main as Assembly):
_interpreter.References.Add(main)
for reference in main.GetReferencedAssemblies():
_interpreter.References.Add(Assembly.Load(reference.FullName))
private def InitInterpreter():
_interpreter = Boo.Lang.Interpreter.InteractiveInterpreter(
RememberLastValue: true,
Print: self.PrintLine)
AddAssemblies(typeof(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton).Assembly)
_interpreter.SetValue("cls", RaiseClear)
_interpreter.SetValue("newTab") do():
InterpreterPad.Instance.AddInterpreterContext(c = DefaultBooInterpreterContext(true))
return c
if _isAdditionalTab:
_interpreter.SetValue("thisTab", self)
_interpreter.LoopEval("""
import System
import System.IO
import System.Text
""")
def RunCommand(code as string):
InitInterpreter() if _interpreter is null
try:
_interpreter.LoopEval(code)
except x as System.Reflection.TargetInvocationException:
PrintLine(x.InnerException.ToString())
def GetGlobals():
InitInterpreter() if _interpreter is null
return _interpreter.globals()
def CloseTab():
InterpreterPad.Instance.RemoveInterpreterContext(self)

21
src/AddIns/BackendBindings/Boo/Boo.InterpreterAddIn/Project/InteractiveInterpreterControl.boo

@ -14,6 +14,7 @@ import System
import System.Drawing import System.Drawing
import System.IO import System.IO
import System.Windows.Forms import System.Windows.Forms
import ICSharpCode.SharpDevelop.Gui
import ICSharpCode.TextEditor import ICSharpCode.TextEditor
import ICSharpCode.TextEditor.Document import ICSharpCode.TextEditor.Document
import ICSharpCode.TextEditor.Actions import ICSharpCode.TextEditor.Actions
@ -75,8 +76,16 @@ class InteractiveInterpreterControl(TextEditorControl):
def constructor([required] interpreter as InterpreterContext): def constructor([required] interpreter as InterpreterContext):
self._interpreter = interpreter self._interpreter = interpreter
self._interpreter.LinePrinted += self.print self._interpreter.LinePrinted += def(line as string):
self._interpreter.Cleared += self.cls if WorkbenchSingleton.InvokeRequired:
WorkbenchSingleton.SafeThreadAsyncCall(self.print, (line,))
else:
self.print(line)
self._interpreter.Cleared += def():
if WorkbenchSingleton.InvokeRequired:
WorkbenchSingleton.SafeThreadAsyncCall(self.cls)
else:
self.cls()
self._lineHistory = LineHistory(CurrentLineChanged: _lineHistory_CurrentLineChanged) self._lineHistory = LineHistory(CurrentLineChanged: _lineHistory_CurrentLineChanged)
self.Document.HighlightingStrategy = GetBooHighlighting() self.Document.HighlightingStrategy = GetBooHighlighting()
self.EnableFolding = false self.EnableFolding = false
@ -132,8 +141,8 @@ class InteractiveInterpreterControl(TextEditorControl):
else: else:
_block.WriteLine(code) _block.WriteLine(code)
def print(msg): def print(msg as string):
AppendText("${msg}\r\n") AppendText(msg + "\r\n")
def prompt(): def prompt():
AppendText((">>> ", "... ")[_state]) AppendText((">>> ", "... ")[_state])
@ -196,10 +205,8 @@ class InteractiveInterpreterControl(TextEditorControl):
if key == Keys.Enter: if key == Keys.Enter:
try: try:
(SingleLineInputState, BlockInputState)[_state]() (SingleLineInputState, BlockInputState)[_state]()
except x as System.Reflection.TargetInvocationException:
print(x.InnerException)
except x: except x:
print(x) print(x.ToString())
prompt() prompt()
return true return true

25
src/AddIns/BackendBindings/Boo/Boo.InterpreterAddIn/Project/InterpreterContext.boo

@ -49,28 +49,3 @@ abstract class InterpreterContext:
virtual def SuggestCodeCompletion(code as string) as (string): virtual def SuggestCodeCompletion(code as string) as (string):
"""Gets list of available members for completion on the passed expression. Used for '.' completion""" """Gets list of available members for completion on the passed expression. Used for '.' completion"""
return null return null
class DefaultBooInterpreterContext(InterpreterContext):
_interpreter as Boo.Lang.Interpreter.InteractiveInterpreter
def constructor():
self.Image = ICSharpCode.Core.ResourceService.GetBitmap("Boo.ProjectIcon")
private def InitInterpreter():
_interpreter = Boo.Lang.Interpreter.InteractiveInterpreter(
RememberLastValue: true,
Print: self.PrintLine)
_interpreter.SetValue("cls", RaiseClear)
_interpreter.LoopEval("""
import System
import System.IO
import System.Text
""")
def RunCommand(code as string):
InitInterpreter() if _interpreter is null
_interpreter.LoopEval(code)
def GetGlobals():
InitInterpreter() if _interpreter is null
return _interpreter.globals()

80
src/AddIns/BackendBindings/Boo/Boo.InterpreterAddIn/Project/InterpreterPad.boo

@ -12,81 +12,65 @@ import System.Windows.Forms
import ICSharpCode.Core import ICSharpCode.Core
import ICSharpCode.SharpDevelop.Gui import ICSharpCode.SharpDevelop.Gui
class ContextEntry:
[getter(InterpreterControl)]
_ctl as InteractiveInterpreterControl
[getter(Context)]
_context as InterpreterContext
[getter(ToolBarItem)]
_item as ToolStripButton
_parentPad as InterpreterPad
def constructor([required] context as InterpreterContext, [required] parentPad as InterpreterPad):
_context = context
_parentPad = parentPad
_ctl = InteractiveInterpreterControl(context)
_ctl.Dock = DockStyle.Fill
_item = ToolStripButton(StringParser.Parse(context.Title), context.Image)
_item.ToolTipText = context.ToolTipText
_item.Visible = context.Visible
_item.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText
context.ImageChanged += AutoInvoke() do:
_item.Image = _context.Image
context.TitleChanged += AutoInvoke() do:
_item.Text = StringParser.Parse(_context.Title)
context.ToolTipTextChanged += AutoInvoke() do:
_item.ToolTipText = StringParser.Parse(_context.ToolTipText)
context.VisibleChanged += AutoInvoke() do:
_item.Visible = _context.Visible
_parentPad.UpdateToolBarVisible()
if _parentPad.CurrentContext is self and _context.Visible == false:
_parentPad.ActivateFirstVisibleContext()
_item.Click += def:
_parentPad.CurrentContext = self
private static def AutoInvoke(what as callable()) as EventHandler:
return def(sender as object, e as EventArgs):
WorkbenchSingleton.SafeThreadAsyncCall(what)
class InterpreterPad(AbstractPadContent, IClipboardHandler): class InterpreterPad(AbstractPadContent, IClipboardHandler):
[getter(Contexts)] public static Instance as InterpreterPad:
_contexts = [] get:
return WorkbenchSingleton.Workbench.GetPad(InterpreterPad).PadContent
_contexts = []
_currentContext as ContextEntry _currentContext as ContextEntry
_toolStrip = ToolStrip(GripStyle: ToolStripGripStyle.Hidden) _toolStrip = ToolStrip(GripStyle: ToolStripGripStyle.Hidden)
_panel = Panel() _panel = Panel()
_initDone
def constructor(): def constructor():
_panel.Controls.Add(_toolStrip) _panel.Controls.Add(_toolStrip)
for context as InterpreterContext in AddInTree.GetTreeNode("/AddIns/InterpreterAddIn/InterpreterContexts").BuildChildItemsArrayList(self): for context as InterpreterContext in AddInTree.GetTreeNode("/AddIns/InterpreterAddIn/InterpreterContexts").BuildChildItemsArrayList(self):
AddInterpreterContext(context)
ActivateFirstVisibleContext()
UpdateToolBarVisible()
_initDone = true
def AddInterpreterContext([required] context as InterpreterContext):
newContext = ContextEntry(context, self) newContext = ContextEntry(context, self)
_toolStrip.Items.Add(newContext.ToolBarItem) _toolStrip.Items.Add(newContext.ToolBarItem)
_contexts.Add(newContext) _contexts.Add(newContext)
ActivateFirstVisibleContext() UpdateToolBarVisible() if _initDone
return newContext
def RemoveInterpreterContext([required] context as InterpreterContext):
for c as ContextEntry in _contexts:
if c.Context is context:
RemoveInterpreterContext(c)
return
def RemoveInterpreterContext([required] context as ContextEntry):
_contexts.Remove(context)
_toolStrip.Items.Remove(context.ToolBarItem)
ActivateFirstVisibleContext() if self.CurrentContext is context
UpdateToolBarVisible() UpdateToolBarVisible()
def UpdateToolBarVisible(): def UpdateToolBarVisible():
count = 0 count = 0
for c as ContextEntry in self.Contexts: for c as ContextEntry in _contexts:
count += 1 if c.Context.Visible count += 1 if c.Context.Visible
_toolStrip.Visible = (count > 1) _toolStrip.Visible = (count > 1)
def ActivateFirstVisibleContext(): def ActivateFirstVisibleContext():
for c as ContextEntry in self.Contexts: for c as ContextEntry in _contexts:
if c.Context.Visible: if c.Context.Visible:
self.CurrentContext = c self.CurrentContext = c
return return
self.CurrentContext = null
Control as Control: Control as Control:
get: get:
return _panel return _panel
public Contexts:
get:
return System.Collections.ArrayList.ReadOnly(_contexts)
CurrentContext: CurrentContext:
get: get:
return _currentContext return _currentContext
@ -98,7 +82,7 @@ class InterpreterPad(AbstractPadContent, IClipboardHandler):
_panel.Controls.Add(value.InterpreterControl) _panel.Controls.Add(value.InterpreterControl)
_panel.Controls.SetChildIndex(_toolStrip, 1) _panel.Controls.SetChildIndex(_toolStrip, 1)
_currentContext = value _currentContext = value
for c as ContextEntry in self.Contexts: for c as ContextEntry in _contexts:
c.ToolBarItem.Checked = c is value c.ToolBarItem.Checked = c is value
CurrentTextArea: CurrentTextArea:

2
src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/BooPrinterVisitorWithComments.cs

@ -49,7 +49,7 @@ namespace NRefactoryToBooConverter
void AcceptPoint(int line, int column) void AcceptPoint(int line, int column)
{ {
while (available) { while (available) {
Point b = enumerator.Current.StartPosition; Location b = enumerator.Current.StartPosition;
if (b.Y < line || (b.Y == line && b.X <= column)) { if (b.Y < line || (b.Y == line && b.X <= column)) {
WriteCurrent(); WriteCurrent();
} else { } else {

4
src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitor.cs

@ -47,7 +47,7 @@ namespace NRefactoryToBooConverter
{ {
if (node == null) if (node == null)
return new B.LexicalInfo(fileName); return new B.LexicalInfo(fileName);
Point point = node.StartLocation; Location point = node.StartLocation;
if (!point.IsEmpty) { if (!point.IsEmpty) {
lastLexicalInfo = new B.LexicalInfo(fileName, point.Y, point.X); lastLexicalInfo = new B.LexicalInfo(fileName, point.Y, point.X);
} }
@ -82,7 +82,7 @@ namespace NRefactoryToBooConverter
return GetLocation(node.EndLocation); return GetLocation(node.EndLocation);
} }
B.SourceLocation GetLocation(Point point) B.SourceLocation GetLocation(Location point)
{ {
return new B.SourceLocation(point.Y, point.X); return new B.SourceLocation(point.Y, point.X);
} }

2
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/NRefactoryDesignerLoader.cs

@ -299,7 +299,7 @@ namespace ICSharpCode.FormsDesigner
} }
} }
void FixTypeReference(TypeReference type, Point location, ICSharpCode.SharpDevelop.Dom.ICompilationUnit domCu) void FixTypeReference(TypeReference type, Location location, ICSharpCode.SharpDevelop.Dom.ICompilationUnit domCu)
{ {
if (type == null) if (type == null)
return; return;

2
src/Libraries/NRefactory/Project/NRefactory.csproj

@ -49,7 +49,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Drawing" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Resources\ICSharpCode.NRefactory.snk" /> <None Include="Resources\ICSharpCode.NRefactory.snk" />
@ -127,6 +126,7 @@
<Compile Include="..\..\..\Main\GlobalAssemblyInfo.cs"> <Compile Include="..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>Configuration\GlobalAssemblyInfo.cs</Link> <Link>Configuration\GlobalAssemblyInfo.cs</Link>
</Compile> </Compile>
<Compile Include="Src\Parser\Location.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Src\Lexer\CSharp\KeywordList.txt" /> <Content Include="Src\Lexer\CSharp\KeywordList.txt" />

19
src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs

@ -8,7 +8,6 @@
using System; using System;
using System.IO; using System.IO;
using System.Collections; using System.Collections;
using System.Drawing;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.Text; using System.Text;
@ -24,10 +23,10 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
void ReadPreProcessingDirective() void ReadPreProcessingDirective()
{ {
Point start = new Point(Col - 1, Line); Location start = new Location(Col - 1, Line);
string directive = ReadIdent('#'); string directive = ReadIdent('#');
string argument = ReadToEOL(); string argument = ReadToEOL();
this.specialTracker.AddPreProcessingDirective(directive, argument.Trim(), start, new Point(start.X + directive.Length + argument.Length, start.Y)); this.specialTracker.AddPreProcessingDirective(directive, argument.Trim(), start, new Location(start.X + directive.Length + argument.Length, start.Y));
} }
protected override Token Next() protected override Token Next()
@ -727,9 +726,9 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
string tag = curWord.ToString(); string tag = curWord.ToString();
curWord.Length = 0; curWord.Length = 0;
if (specialCommentHash.ContainsKey(tag)) { if (specialCommentHash.ContainsKey(tag)) {
Point p = new Point(Col, Line); Location p = new Location(Col, Line);
string comment = ch + ReadToEOL(); string comment = ch + ReadToEOL();
tagComments.Add(new TagComment(tag, comment, p, new Point(Col, Line))); tagComments.Add(new TagComment(tag, comment, p, new Location(Col, Line)));
sb.Append(comment); sb.Append(comment);
break; break;
} }
@ -743,9 +742,9 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
if (skipAllComments) { if (skipAllComments) {
SkipToEOL(); SkipToEOL();
} else { } else {
specialTracker.StartComment(commentType, new Point(Col, Line)); specialTracker.StartComment(commentType, new Location(Col, Line));
specialTracker.AddString(ReadCommentToEOL()); specialTracker.AddString(ReadCommentToEOL());
specialTracker.FinishComment(new Point(Col, Line)); specialTracker.FinishComment(new Location(Col, Line));
} }
} }
@ -761,7 +760,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
} }
} }
} else { } else {
specialTracker.StartComment(CommentType.Block, new Point(Col, Line)); specialTracker.StartComment(CommentType.Block, new Location(Col, Line));
while ((nextChar = ReaderRead()) != -1) { while ((nextChar = ReaderRead()) != -1) {
char ch = (char)nextChar; char ch = (char)nextChar;
@ -773,12 +772,12 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
// End of multiline comment reached ? // End of multiline comment reached ?
if (ch == '*' && ReaderPeek() == '/') { if (ch == '*' && ReaderPeek() == '/') {
ReaderRead(); ReaderRead();
specialTracker.FinishComment(new Point(Col, Line)); specialTracker.FinishComment(new Location(Col, Line));
return; return;
} }
specialTracker.AddChar(ch); specialTracker.AddChar(ch);
} }
specialTracker.FinishComment(new Point(Col, Line)); specialTracker.FinishComment(new Location(Col, Line));
} }
// Reached EOF before end of multiline comment. // Reached EOF before end of multiline comment.
errors.Error(Line, Col, String.Format("Reached EOF before the end of a multiline comment")); errors.Error(Line, Col, String.Format("Reached EOF before the end of a multiline comment"));

1
src/Libraries/NRefactory/Project/Src/Lexer/LookupTable.cs

@ -7,7 +7,6 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Drawing;
using System.Globalization; using System.Globalization;
namespace ICSharpCode.NRefactory.Parser namespace ICSharpCode.NRefactory.Parser

3
src/Libraries/NRefactory/Project/Src/Lexer/Special/BlankLine.cs

@ -6,13 +6,12 @@
// </file> // </file>
using System; using System;
using System.Drawing;
namespace ICSharpCode.NRefactory.Parser namespace ICSharpCode.NRefactory.Parser
{ {
public class BlankLine : AbstractSpecial public class BlankLine : AbstractSpecial
{ {
public BlankLine(Point point) : base(point) public BlankLine(Location point) : base(point)
{ {
} }

3
src/Libraries/NRefactory/Project/Src/Lexer/Special/Comment.cs

@ -9,7 +9,6 @@ using System;
using System.Text; using System.Text;
using System.CodeDom; using System.CodeDom;
using System.Collections; using System.Collections;
using System.Drawing;
namespace ICSharpCode.NRefactory.Parser namespace ICSharpCode.NRefactory.Parser
{ {
@ -36,7 +35,7 @@ namespace ICSharpCode.NRefactory.Parser
} }
} }
public Comment(CommentType commentType, string comment, Point startPosition, Point endPosition) public Comment(CommentType commentType, string comment, Location startPosition, Location endPosition)
: base(startPosition, endPosition) : base(startPosition, endPosition)
{ {
this.commentType = commentType; this.commentType = commentType;

15
src/Libraries/NRefactory/Project/Src/Lexer/Special/ISpecial.cs

@ -6,7 +6,6 @@
// </file> // </file>
using System; using System;
using System.Drawing;
namespace ICSharpCode.NRefactory.Parser namespace ICSharpCode.NRefactory.Parser
{ {
@ -15,8 +14,8 @@ namespace ICSharpCode.NRefactory.Parser
/// </summary> /// </summary>
public interface ISpecial public interface ISpecial
{ {
Point StartPosition { get; } Location StartPosition { get; }
Point EndPosition { get; } Location EndPosition { get; }
object AcceptVisitor(ISpecialVisitor visitor, object data); object AcceptVisitor(ISpecialVisitor visitor, object data);
} }
@ -33,21 +32,21 @@ namespace ICSharpCode.NRefactory.Parser
{ {
public abstract object AcceptVisitor(ISpecialVisitor visitor, object data); public abstract object AcceptVisitor(ISpecialVisitor visitor, object data);
Point startPosition, endPosition; Location startPosition, endPosition;
public AbstractSpecial(Point position) public AbstractSpecial(Location position)
{ {
this.startPosition = position; this.startPosition = position;
this.endPosition = position; this.endPosition = position;
} }
public AbstractSpecial(Point startPosition, Point endPosition) public AbstractSpecial(Location startPosition, Location endPosition)
{ {
this.startPosition = startPosition; this.startPosition = startPosition;
this.endPosition = endPosition; this.endPosition = endPosition;
} }
public Point StartPosition { public Location StartPosition {
get { get {
return startPosition; return startPosition;
} }
@ -56,7 +55,7 @@ namespace ICSharpCode.NRefactory.Parser
} }
} }
public Point EndPosition { public Location EndPosition {
get { get {
return endPosition; return endPosition;
} }

3
src/Libraries/NRefactory/Project/Src/Lexer/Special/PreProcessingDirective.cs

@ -6,7 +6,6 @@
// </file> // </file>
using System; using System;
using System.Drawing;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
@ -108,7 +107,7 @@ namespace ICSharpCode.NRefactory.Parser
Arg); Arg);
} }
public PreProcessingDirective(string cmd, string arg, Point start, Point end) public PreProcessingDirective(string cmd, string arg, Location start, Location end)
: base(start, end) : base(start, end)
{ {
this.cmd = cmd; this.cmd = cmd;

11
src/Libraries/NRefactory/Project/Src/Lexer/Special/SpecialTracker.cs

@ -9,7 +9,6 @@ using System;
using System.Text; using System.Text;
using System.CodeDom; using System.CodeDom;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
namespace ICSharpCode.NRefactory.Parser namespace ICSharpCode.NRefactory.Parser
{ {
@ -19,7 +18,7 @@ namespace ICSharpCode.NRefactory.Parser
CommentType currentCommentType; CommentType currentCommentType;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
Point startPosition; Location startPosition;
public List<ISpecial> CurrentSpecials { public List<ISpecial> CurrentSpecials {
get { get {
@ -42,18 +41,18 @@ namespace ICSharpCode.NRefactory.Parser
return tmp; return tmp;
} }
public void AddEndOfLine(Point point) public void AddEndOfLine(Location point)
{ {
currentSpecials.Add(new BlankLine(point)); currentSpecials.Add(new BlankLine(point));
} }
public void AddPreProcessingDirective(string cmd, string arg, Point start, Point end) public void AddPreProcessingDirective(string cmd, string arg, Location start, Location end)
{ {
currentSpecials.Add(new PreProcessingDirective(cmd, arg, start, end)); currentSpecials.Add(new PreProcessingDirective(cmd, arg, start, end));
} }
// used for comment tracking // used for comment tracking
public void StartComment(CommentType commentType, Point startPosition) public void StartComment(CommentType commentType, Location startPosition)
{ {
this.currentCommentType = commentType; this.currentCommentType = commentType;
this.startPosition = startPosition; this.startPosition = startPosition;
@ -70,7 +69,7 @@ namespace ICSharpCode.NRefactory.Parser
sb.Append(s); sb.Append(s);
} }
public void FinishComment(Point endPosition) public void FinishComment(Location endPosition)
{ {
currentSpecials.Add(new Comment(currentCommentType, sb.ToString(), startPosition, endPosition)); currentSpecials.Add(new Comment(currentCommentType, sb.ToString(), startPosition, endPosition));
} }

3
src/Libraries/NRefactory/Project/Src/Lexer/Special/TagComment.cs

@ -9,7 +9,6 @@ using System;
using System.Text; using System.Text;
using System.CodeDom; using System.CodeDom;
using System.Collections; using System.Collections;
using System.Drawing;
namespace ICSharpCode.NRefactory.Parser namespace ICSharpCode.NRefactory.Parser
{ {
@ -29,7 +28,7 @@ namespace ICSharpCode.NRefactory.Parser
} }
} }
public TagComment(string tag, string comment, Point startPosition, Point endPosition) : base(CommentType.SingleLine, comment, startPosition, endPosition) public TagComment(string tag, string comment, Location startPosition, Location endPosition) : base(CommentType.SingleLine, comment, startPosition, endPosition)
{ {
this.tag = tag; this.tag = tag;
} }

9
src/Libraries/NRefactory/Project/Src/Lexer/Token.cs

@ -6,7 +6,6 @@
// </file> // </file>
using System; using System;
using System.Drawing;
namespace ICSharpCode.NRefactory.Parser namespace ICSharpCode.NRefactory.Parser
{ {
@ -21,14 +20,14 @@ namespace ICSharpCode.NRefactory.Parser
public string val; public string val;
public Token next; public Token next;
public Point EndLocation { public Location EndLocation {
get { get {
return new Point(val == null ? col + 1 : col + val.Length, line); return new Location(val == null ? col + 1 : col + val.Length, line);
} }
} }
public Point Location { public Location Location {
get { get {
return new Point(col, line); return new Location(col, line);
} }
} }

13
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs

@ -8,7 +8,6 @@
using System; using System;
using System.IO; using System.IO;
using System.Collections; using System.Collections;
using System.Drawing;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.Text; using System.Text;
@ -469,10 +468,10 @@ namespace ICSharpCode.NRefactory.Parser.VB
void ReadPreprocessorDirective() void ReadPreprocessorDirective()
{ {
Point start = new Point(Col - 1, Line); Location start = new Location(Col - 1, Line);
string directive = ReadIdent('#'); string directive = ReadIdent('#');
string argument = ReadToEOL(); string argument = ReadToEOL();
this.specialTracker.AddPreProcessingDirective(directive, argument.Trim(), start, new Point(start.X + directive.Length + argument.Length, start.Y)); this.specialTracker.AddPreProcessingDirective(directive, argument.Trim(), start, new Location(start.X + directive.Length + argument.Length, start.Y));
} }
string ReadDate() string ReadDate()
@ -524,7 +523,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
void ReadComment() void ReadComment()
{ {
Point startPos = new Point(Col, Line); Location startPos = new Location(Col, Line);
sb.Length = 0; sb.Length = 0;
StringBuilder curWord = specialCommentHash != null ? new StringBuilder() : null; StringBuilder curWord = specialCommentHash != null ? new StringBuilder() : null;
int missingApostrophes = 2; // no. of ' missing until it is a documentation comment int missingApostrophes = 2; // no. of ' missing until it is a documentation comment
@ -559,9 +558,9 @@ namespace ICSharpCode.NRefactory.Parser.VB
string tag = curWord.ToString(); string tag = curWord.ToString();
curWord.Length = 0; curWord.Length = 0;
if (specialCommentHash.ContainsKey(tag)) { if (specialCommentHash.ContainsKey(tag)) {
Point p = new Point(Col, Line); Location p = new Location(Col, Line);
string comment = ch + ReadToEOL(); string comment = ch + ReadToEOL();
tagComments.Add(new TagComment(tag, comment, p, new Point(Col, Line))); tagComments.Add(new TagComment(tag, comment, p, new Location(Col, Line)));
sb.Append(comment); sb.Append(comment);
break; break;
} }
@ -572,7 +571,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
specialTracker.StartComment(CommentType.SingleLine, startPos); specialTracker.StartComment(CommentType.SingleLine, startPos);
} }
specialTracker.AddString(sb.ToString()); specialTracker.AddString(sb.ToString());
specialTracker.FinishComment(new Point(Col, Line)); specialTracker.FinishComment(new Location(Col, Line));
} }
Token ReadOperator(char ch) Token ReadOperator(char ch)

5
src/Libraries/NRefactory/Project/Src/Output/SpecialNodesInserter.cs

@ -6,7 +6,6 @@
// </file> // </file>
using System; using System;
using System.Drawing;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.NRefactory.Parser; using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST; using ICSharpCode.NRefactory.Parser.AST;
@ -94,10 +93,10 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
/// <summary> /// <summary>
/// Writes all specials up to the specified location. /// Writes all specials up to the specified location.
/// </summary> /// </summary>
public void AcceptPoint(Point a) public void AcceptPoint(Location a)
{ {
while (available) { while (available) {
Point b = enumerator.Current.StartPosition; Location b = enumerator.Current.StartPosition;
if (b.Y < a.Y || (b.Y == a.Y && b.X <= a.X)) { if (b.Y < a.Y || (b.Y == a.Y && b.X <= a.X)) {
WriteCurrent(); WriteCurrent();
} else { } else {

9
src/Libraries/NRefactory/Project/Src/Parser/AST/AbstractNode.cs

@ -7,7 +7,6 @@
using System; using System;
using System.Text; using System.Text;
using System.Drawing;
using System.Diagnostics; using System.Diagnostics;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@ -19,8 +18,8 @@ namespace ICSharpCode.NRefactory.Parser.AST
INode parent; INode parent;
List<INode> children = new List<INode>(); List<INode> children = new List<INode>();
Point startLocation; Location startLocation;
Point endLocation; Location endLocation;
public INode Parent { public INode Parent {
get { get {
@ -31,7 +30,7 @@ namespace ICSharpCode.NRefactory.Parser.AST
} }
} }
public Point StartLocation { public Location StartLocation {
get { get {
return startLocation; return startLocation;
} }
@ -40,7 +39,7 @@ namespace ICSharpCode.NRefactory.Parser.AST
} }
} }
public Point EndLocation { public Location EndLocation {
get { get {
return endLocation; return endLocation;
} }

51
src/Libraries/NRefactory/Project/Src/Parser/AST/Generated.cs

@ -12,7 +12,6 @@ namespace ICSharpCode.NRefactory.Parser.AST {
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing;
public class AddHandlerStatement : Statement { public class AddHandlerStatement : Statement {
@ -1459,9 +1458,9 @@ namespace ICSharpCode.NRefactory.Parser.AST {
EventRaiseRegion raiseRegion; EventRaiseRegion raiseRegion;
Point bodyStart; Location bodyStart;
Point bodyEnd; Location bodyEnd;
public TypeReference TypeReference { public TypeReference TypeReference {
get { get {
@ -1508,7 +1507,7 @@ namespace ICSharpCode.NRefactory.Parser.AST {
} }
} }
public Point BodyStart { public Location BodyStart {
get { get {
return bodyStart; return bodyStart;
} }
@ -1517,7 +1516,7 @@ namespace ICSharpCode.NRefactory.Parser.AST {
} }
} }
public Point BodyEnd { public Location BodyEnd {
get { get {
return bodyEnd; return bodyEnd;
} }
@ -1533,8 +1532,8 @@ namespace ICSharpCode.NRefactory.Parser.AST {
addRegion = EventAddRegion.Null; addRegion = EventAddRegion.Null;
removeRegion = EventRemoveRegion.Null; removeRegion = EventRemoveRegion.Null;
raiseRegion = EventRaiseRegion.Null; raiseRegion = EventRaiseRegion.Null;
bodyStart = new Point(-1, -1); bodyStart = new Location(-1, -1);
bodyEnd = new Point(-1, -1); bodyEnd = new Location(-1, -1);
} }
public EventDeclaration(TypeReference typeReference, Modifier modifier, List<ParameterDeclarationExpression> parameters, List<AttributeSection> attributes, string name, List<InterfaceImplementation> interfaceImplementations) : public EventDeclaration(TypeReference typeReference, Modifier modifier, List<ParameterDeclarationExpression> parameters, List<AttributeSection> attributes, string name, List<InterfaceImplementation> interfaceImplementations) :
@ -1544,8 +1543,8 @@ namespace ICSharpCode.NRefactory.Parser.AST {
addRegion = EventAddRegion.Null; addRegion = EventAddRegion.Null;
removeRegion = EventRemoveRegion.Null; removeRegion = EventRemoveRegion.Null;
raiseRegion = EventRaiseRegion.Null; raiseRegion = EventRaiseRegion.Null;
bodyStart = new Point(-1, -1); bodyStart = new Location(-1, -1);
bodyEnd = new Point(-1, -1); bodyEnd = new Location(-1, -1);
} }
public bool HasAddRegion { public bool HasAddRegion {
@ -2243,9 +2242,9 @@ namespace ICSharpCode.NRefactory.Parser.AST {
TypeReference typeReference; TypeReference typeReference;
Point bodyStart; Location bodyStart;
Point bodyEnd; Location bodyEnd;
PropertyGetRegion getRegion; PropertyGetRegion getRegion;
@ -2278,7 +2277,7 @@ namespace ICSharpCode.NRefactory.Parser.AST {
} }
} }
public Point BodyStart { public Location BodyStart {
get { get {
return bodyStart; return bodyStart;
} }
@ -2287,7 +2286,7 @@ namespace ICSharpCode.NRefactory.Parser.AST {
} }
} }
public Point BodyEnd { public Location BodyEnd {
get { get {
return bodyEnd; return bodyEnd;
} }
@ -2320,8 +2319,8 @@ namespace ICSharpCode.NRefactory.Parser.AST {
Parameters = parameters; Parameters = parameters;
interfaceImplementations = new List<InterfaceImplementation>(); interfaceImplementations = new List<InterfaceImplementation>();
typeReference = TypeReference.Null; typeReference = TypeReference.Null;
bodyStart = new Point(-1, -1); bodyStart = new Location(-1, -1);
bodyEnd = new Point(-1, -1); bodyEnd = new Location(-1, -1);
getRegion = PropertyGetRegion.Null; getRegion = PropertyGetRegion.Null;
setRegion = PropertySetRegion.Null; setRegion = PropertySetRegion.Null;
} }
@ -2332,8 +2331,8 @@ namespace ICSharpCode.NRefactory.Parser.AST {
Parameters = parameters; Parameters = parameters;
Modifier = modifier; Modifier = modifier;
interfaceImplementations = new List<InterfaceImplementation>(); interfaceImplementations = new List<InterfaceImplementation>();
bodyStart = new Point(-1, -1); bodyStart = new Location(-1, -1);
bodyEnd = new Point(-1, -1); bodyEnd = new Location(-1, -1);
getRegion = PropertyGetRegion.Null; getRegion = PropertyGetRegion.Null;
setRegion = PropertySetRegion.Null; setRegion = PropertySetRegion.Null;
} }
@ -3058,9 +3057,9 @@ namespace ICSharpCode.NRefactory.Parser.AST {
TypeReference typeReference; TypeReference typeReference;
Point bodyStart; Location bodyStart;
Point bodyEnd; Location bodyEnd;
PropertyGetRegion getRegion; PropertyGetRegion getRegion;
@ -3084,7 +3083,7 @@ namespace ICSharpCode.NRefactory.Parser.AST {
} }
} }
public Point BodyStart { public Location BodyStart {
get { get {
return bodyStart; return bodyStart;
} }
@ -3093,7 +3092,7 @@ namespace ICSharpCode.NRefactory.Parser.AST {
} }
} }
public Point BodyEnd { public Location BodyEnd {
get { get {
return bodyEnd; return bodyEnd;
} }
@ -3124,8 +3123,8 @@ namespace ICSharpCode.NRefactory.Parser.AST {
base(modifier, attributes, name, parameters) { base(modifier, attributes, name, parameters) {
interfaceImplementations = new List<InterfaceImplementation>(); interfaceImplementations = new List<InterfaceImplementation>();
typeReference = TypeReference.Null; typeReference = TypeReference.Null;
bodyStart = new Point(-1, -1); bodyStart = new Location(-1, -1);
bodyEnd = new Point(-1, -1); bodyEnd = new Location(-1, -1);
getRegion = PropertyGetRegion.Null; getRegion = PropertyGetRegion.Null;
setRegion = PropertySetRegion.Null; setRegion = PropertySetRegion.Null;
} }
@ -3806,7 +3805,7 @@ namespace ICSharpCode.NRefactory.Parser.AST {
List<TemplateDefinition> templates; List<TemplateDefinition> templates;
Point bodyStartLocation; Location bodyStartLocation;
public string Name { public string Name {
get { get {
@ -3844,7 +3843,7 @@ namespace ICSharpCode.NRefactory.Parser.AST {
} }
} }
public Point BodyStartLocation { public Location BodyStartLocation {
get { get {
return bodyStartLocation; return bodyStartLocation;
} }
@ -3859,7 +3858,7 @@ namespace ICSharpCode.NRefactory.Parser.AST {
name = ""; name = "";
baseTypes = new List<TypeReference>(); baseTypes = new List<TypeReference>();
templates = new List<TemplateDefinition>(); templates = new List<TemplateDefinition>();
bodyStartLocation = new Point(-1, -1); bodyStartLocation = new Location(-1, -1);
} }
public override object AcceptVisitor(IAstVisitor visitor, object data) { public override object AcceptVisitor(IAstVisitor visitor, object data) {

5
src/Libraries/NRefactory/Project/Src/Parser/AST/INode.cs

@ -6,7 +6,6 @@
// </file> // </file>
using System; using System;
using System.Drawing;
using System.Collections.Generic; using System.Collections.Generic;
namespace ICSharpCode.NRefactory.Parser.AST namespace ICSharpCode.NRefactory.Parser.AST
@ -22,12 +21,12 @@ namespace ICSharpCode.NRefactory.Parser.AST
get; get;
} }
Point StartLocation { Location StartLocation {
get; get;
set; set;
} }
Point EndLocation { Location EndLocation {
get; get;
set; set;
} }

2111
src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs

File diff suppressed because it is too large Load Diff

3
src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG

@ -1,4 +1,3 @@
using System.Drawing;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
@ -1093,7 +1092,7 @@ FixedParameter<out ParameterDeclarationExpression p>
(. (.
TypeReference type; TypeReference type;
ParamModifier mod = ParamModifier.In; ParamModifier mod = ParamModifier.In;
System.Drawing.Point start = t.Location; Location start = t.Location;
.) .)
= =
[ [

51
src/Libraries/NRefactory/Project/Src/Parser/Location.cs

@ -0,0 +1,51 @@
/*
* Created by SharpDevelop.
* User: Daniel Grunwald
* Date: 15.07.2006
* Time: 19:49
*/
using System;
namespace ICSharpCode.NRefactory.Parser
{
/// <summary>
/// Description of Position.
/// </summary>
public struct Location
{
public static readonly Location Empty = new Location(0, 0);
public Location(int column, int line)
{
x = column;
y = line;
}
int x, y;
public int X {
get {
return x;
}
set {
x = value;
}
}
public int Y {
get {
return y;
}
set {
y = value;
}
}
public bool IsEmpty {
get {
return x <= 0 && y <= 0;
}
}
}
}

9
src/Libraries/NRefactory/Project/Src/Parser/Modifiers.cs

@ -6,14 +6,13 @@
// </file> // </file>
using ICSharpCode.NRefactory.Parser.AST; using ICSharpCode.NRefactory.Parser.AST;
using System.Drawing;
namespace ICSharpCode.NRefactory.Parser namespace ICSharpCode.NRefactory.Parser
{ {
internal class Modifiers internal class Modifiers
{ {
Modifier cur; Modifier cur;
Point location = new Point(-1, -1); Location location = new Location(-1, -1);
public Modifier Modifier { public Modifier Modifier {
get { get {
@ -21,7 +20,7 @@ namespace ICSharpCode.NRefactory.Parser
} }
} }
public Point GetDeclarationLocation(Point keywordLocation) public Location GetDeclarationLocation(Location keywordLocation)
{ {
if(location.X == -1 && location.Y == -1) { if(location.X == -1 && location.Y == -1) {
return keywordLocation; return keywordLocation;
@ -29,7 +28,7 @@ namespace ICSharpCode.NRefactory.Parser
return location; return location;
} }
public Point Location { public Location Location {
get { get {
return location; return location;
} }
@ -45,7 +44,7 @@ namespace ICSharpCode.NRefactory.Parser
return ((cur & m) != 0); return ((cur & m) != 0);
} }
public void Add(Modifier m, Point tokenLocation) public void Add(Modifier m, Location tokenLocation)
{ {
if(location.X == -1 && location.Y == -1) { if(location.X == -1 && location.Y == -1) {
location = tokenLocation; location = tokenLocation;

2139
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs

File diff suppressed because it is too large Load Diff

1
src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

@ -1,4 +1,3 @@
using System.Drawing;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;

15
src/Libraries/NRefactory/Project/Src/Parser/Visitors/LookupTableVisitor.cs

@ -6,7 +6,6 @@
// </file> // </file>
using System; using System;
using System.Drawing;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.NRefactory.Parser.AST; using ICSharpCode.NRefactory.Parser.AST;
@ -16,8 +15,8 @@ namespace ICSharpCode.NRefactory.Parser
public class LocalLookupVariable public class LocalLookupVariable
{ {
TypeReference typeRef; TypeReference typeRef;
Point startPos; Location startPos;
Point endPos; Location endPos;
bool isConst; bool isConst;
public TypeReference TypeRef { public TypeReference TypeRef {
@ -25,12 +24,12 @@ namespace ICSharpCode.NRefactory.Parser
return typeRef; return typeRef;
} }
} }
public Point StartPos { public Location StartPos {
get { get {
return startPos; return startPos;
} }
} }
public Point EndPos { public Location EndPos {
get { get {
return endPos; return endPos;
} }
@ -42,7 +41,7 @@ namespace ICSharpCode.NRefactory.Parser
} }
} }
public LocalLookupVariable(TypeReference typeRef, Point startPos, Point endPos, bool isConst) public LocalLookupVariable(TypeReference typeRef, Location startPos, Location endPos, bool isConst)
{ {
this.typeRef = typeRef; this.typeRef = typeRef;
this.startPos = startPos; this.startPos = startPos;
@ -74,7 +73,7 @@ namespace ICSharpCode.NRefactory.Parser
variables = new Dictionary<string, List<LocalLookupVariable>>(nameComparer); variables = new Dictionary<string, List<LocalLookupVariable>>(nameComparer);
} }
public void AddVariable(TypeReference typeRef, string name, Point startPos, Point endPos, bool isConst) public void AddVariable(TypeReference typeRef, string name, Location startPos, Location endPos, bool isConst)
{ {
if (name == null || name.Length == 0) { if (name == null || name.Length == 0) {
return; return;
@ -112,7 +111,7 @@ namespace ICSharpCode.NRefactory.Parser
AddVariable(localVariableDeclaration.GetTypeForVariable(i), AddVariable(localVariableDeclaration.GetTypeForVariable(i),
varDecl.Name, varDecl.Name,
localVariableDeclaration.StartLocation, localVariableDeclaration.StartLocation,
(blockStack.Count == 0) ? new Point(-1, -1) : blockStack.Peek().EndLocation, (blockStack.Count == 0) ? new Location(-1, -1) : blockStack.Peek().EndLocation,
(localVariableDeclaration.Modifier & Modifier.Const) == Modifier.Const); (localVariableDeclaration.Modifier & Modifier.Const) == Modifier.Const);
} }
return base.Visit(localVariableDeclaration, data); return base.Visit(localVariableDeclaration, data);

13
src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs

@ -8,7 +8,6 @@
// created on 04.08.2003 at 17:49 // created on 04.08.2003 at 17:49
using System; using System;
using System.Text; using System.Text;
using System.Drawing;
using System.Diagnostics; using System.Diagnostics;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@ -271,7 +270,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
} }
} }
DomRegion GetRegion(Point start, Point end) static DomRegion GetRegion(RefParser.Location start, RefParser.Location end)
{ {
return new DomRegion(start, end); return new DomRegion(start, end);
} }
@ -420,7 +419,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
internal static IParameter CreateParameter(AST.ParameterDeclarationExpression par, IMethod method, IClass currentClass, ICompilationUnit cu) internal static IParameter CreateParameter(AST.ParameterDeclarationExpression par, IMethod method, IClass currentClass, ICompilationUnit cu)
{ {
IReturnType parType = CreateReturnType(par.TypeReference, method, currentClass, cu); IReturnType parType = CreateReturnType(par.TypeReference, method, currentClass, cu);
DefaultParameter p = new DefaultParameter(par.ParameterName, parType, new DomRegion(par.StartLocation, par.EndLocation)); DefaultParameter p = new DefaultParameter(par.ParameterName, parType, GetRegion(par.StartLocation, par.EndLocation));
p.Modifiers = (ParameterModifiers)par.ParamModifier; p.Modifiers = (ParameterModifiers)par.ParamModifier;
return p; return p;
} }
@ -428,7 +427,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public override object Visit(AST.MethodDeclaration methodDeclaration, object data) public override object Visit(AST.MethodDeclaration methodDeclaration, object data)
{ {
DomRegion region = GetRegion(methodDeclaration.StartLocation, methodDeclaration.EndLocation); DomRegion region = GetRegion(methodDeclaration.StartLocation, methodDeclaration.EndLocation);
DomRegion bodyRegion = GetRegion(methodDeclaration.EndLocation, methodDeclaration.Body != null ? methodDeclaration.Body.EndLocation : new Point(-1, -1)); DomRegion bodyRegion = GetRegion(methodDeclaration.EndLocation, methodDeclaration.Body != null ? methodDeclaration.Body.EndLocation : RefParser.Location.Empty);
DefaultClass c = GetCurrentClass(); DefaultClass c = GetCurrentClass();
DefaultMethod method = new DefaultMethod(methodDeclaration.Name, null, ConvertModifier(methodDeclaration.Modifier), region, bodyRegion, GetCurrentClass()); DefaultMethod method = new DefaultMethod(methodDeclaration.Name, null, ConvertModifier(methodDeclaration.Modifier), region, bodyRegion, GetCurrentClass());
@ -451,7 +450,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
{ {
DefaultClass c = GetCurrentClass(); DefaultClass c = GetCurrentClass();
DomRegion region = GetRegion(operatorDeclaration.StartLocation, operatorDeclaration.EndLocation); DomRegion region = GetRegion(operatorDeclaration.StartLocation, operatorDeclaration.EndLocation);
DomRegion bodyRegion = GetRegion(operatorDeclaration.EndLocation, operatorDeclaration.Body != null ? operatorDeclaration.Body.EndLocation : new Point(-1, -1)); DomRegion bodyRegion = GetRegion(operatorDeclaration.EndLocation, operatorDeclaration.Body != null ? operatorDeclaration.Body.EndLocation : RefParser.Location.Empty);
DefaultMethod method = new DefaultMethod(operatorDeclaration.Name, CreateReturnType(operatorDeclaration.TypeReference), ConvertModifier(operatorDeclaration.Modifier), region, bodyRegion, c); DefaultMethod method = new DefaultMethod(operatorDeclaration.Name, CreateReturnType(operatorDeclaration.TypeReference), ConvertModifier(operatorDeclaration.Modifier), region, bodyRegion, c);
ConvertAttributes(operatorDeclaration, method); ConvertAttributes(operatorDeclaration, method);
@ -468,7 +467,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public override object Visit(AST.ConstructorDeclaration constructorDeclaration, object data) public override object Visit(AST.ConstructorDeclaration constructorDeclaration, object data)
{ {
DomRegion region = GetRegion(constructorDeclaration.StartLocation, constructorDeclaration.EndLocation); DomRegion region = GetRegion(constructorDeclaration.StartLocation, constructorDeclaration.EndLocation);
DomRegion bodyRegion = GetRegion(constructorDeclaration.EndLocation, constructorDeclaration.Body != null ? constructorDeclaration.Body.EndLocation : new Point(-1, -1)); DomRegion bodyRegion = GetRegion(constructorDeclaration.EndLocation, constructorDeclaration.Body != null ? constructorDeclaration.Body.EndLocation : RefParser.Location.Empty);
DefaultClass c = GetCurrentClass(); DefaultClass c = GetCurrentClass();
Constructor constructor = new Constructor(ConvertModifier(constructorDeclaration.Modifier), region, bodyRegion, GetCurrentClass()); Constructor constructor = new Constructor(ConvertModifier(constructorDeclaration.Modifier), region, bodyRegion, GetCurrentClass());
@ -486,7 +485,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public override object Visit(AST.DestructorDeclaration destructorDeclaration, object data) public override object Visit(AST.DestructorDeclaration destructorDeclaration, object data)
{ {
DomRegion region = GetRegion(destructorDeclaration.StartLocation, destructorDeclaration.EndLocation); DomRegion region = GetRegion(destructorDeclaration.StartLocation, destructorDeclaration.EndLocation);
DomRegion bodyRegion = GetRegion(destructorDeclaration.EndLocation, destructorDeclaration.Body != null ? destructorDeclaration.Body.EndLocation : new Point(-1, -1)); DomRegion bodyRegion = GetRegion(destructorDeclaration.EndLocation, destructorDeclaration.Body != null ? destructorDeclaration.Body.EndLocation : RefParser.Location.Empty);
DefaultClass c = GetCurrentClass(); DefaultClass c = GetCurrentClass();

9
src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs

@ -8,7 +8,6 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.NRefactory.Parser; using ICSharpCode.NRefactory.Parser;
@ -213,7 +212,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
WithStatement innermost = null; WithStatement innermost = null;
if (lookupTableVisitor.WithStatements != null) { if (lookupTableVisitor.WithStatements != null) {
foreach (WithStatement with in lookupTableVisitor.WithStatements) { foreach (WithStatement with in lookupTableVisitor.WithStatements) {
if (IsInside(new Point(caretColumn, caretLine), with.StartLocation, with.EndLocation)) { if (IsInside(new Location(caretColumn, caretLine), with.StartLocation, with.EndLocation)) {
innermost = with; innermost = with;
} }
} }
@ -721,7 +720,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
return languageProperties.NameComparer.Equals(name1, name2); return languageProperties.NameComparer.Equals(name1, name2);
} }
bool IsInside(Point between, Point start, Point end) bool IsInside(Location between, Location start, Location end)
{ {
if (between.Y < start.Y || between.Y > end.Y) { if (between.Y < start.Y || between.Y > end.Y) {
return false; return false;
@ -940,7 +939,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
} }
foreach (LocalLookupVariable v in variables) { foreach (LocalLookupVariable v in variables) {
if (IsInside(new Point(caretColumn, caretLine), v.StartPos, v.EndPos)) { if (IsInside(new Location(caretColumn, caretLine), v.StartPos, v.EndPos)) {
return v; return v;
} }
} }
@ -1012,7 +1011,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
foreach (KeyValuePair<string, List<LocalLookupVariable>> pair in lookupTableVisitor.Variables) { foreach (KeyValuePair<string, List<LocalLookupVariable>> pair in lookupTableVisitor.Variables) {
if (pair.Value != null && pair.Value.Count > 0) { if (pair.Value != null && pair.Value.Count > 0) {
foreach (LocalLookupVariable v in pair.Value) { foreach (LocalLookupVariable v in pair.Value) {
if (IsInside(new Point(caretColumn, caretLine), v.StartPos, v.EndPos)) { if (IsInside(new Location(caretColumn, caretLine), v.StartPos, v.EndPos)) {
// convert to a field for display // convert to a field for display
result.Add(CreateLocalVariableField(v, pair.Key)); result.Add(CreateLocalVariableField(v, pair.Key));
break; break;

11
src/Main/Base/Project/Src/Dom/Region.cs

@ -6,7 +6,7 @@
// </file> // </file>
using System; using System;
using System.Drawing; using Location = ICSharpCode.NRefactory.Parser.Location;
namespace ICSharpCode.SharpDevelop.Dom namespace ICSharpCode.SharpDevelop.Dom
{ {
@ -50,7 +50,7 @@ namespace ICSharpCode.SharpDevelop.Dom
/// <value> /// <value>
/// if the end column is == -1 the end line is -1 too /// if the end column is == -1 the end line is -1 too
/// this stands for an unknwon end /// this stands for an unknown end
/// </value> /// </value>
public int EndColumn { public int EndColumn {
get { get {
@ -58,16 +58,11 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
public DomRegion(Point start, Point end) public DomRegion(Location start, Location end)
: this(start.Y, start.X, end.Y, end.X) : this(start.Y, start.X, end.Y, end.X)
{ {
} }
public DomRegion(Point start)
: this(start.Y, start.X)
{
}
public DomRegion(int beginLine, int beginColumn, int endLine, int endColumn) public DomRegion(int beginLine, int beginColumn, int endLine, int endColumn)
{ {
this.beginLine = beginLine; this.beginLine = beginLine;

Loading…
Cancel
Save