365 changed files with 17531 additions and 10683 deletions
@ -0,0 +1,308 @@
@@ -0,0 +1,308 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<ReportModel> |
||||
<ReportSettings> |
||||
<ReportSettings> |
||||
<ReportName>DependencyReport</ReportName> |
||||
<ReportType>FormSheet</ReportType> |
||||
<BottomMargin>50</BottomMargin> |
||||
<TopMargin>50</TopMargin> |
||||
<LeftMargin>50</LeftMargin> |
||||
<RightMargin>50</RightMargin> |
||||
<PageSize>827, 1169</PageSize> |
||||
<Landscape>False</Landscape> |
||||
<GraphicsUnit>Millimeter</GraphicsUnit> |
||||
<Padding>5, 5, 5, 5</Padding> |
||||
<AvailableFieldsCollection /> |
||||
<SortColumnsCollection /> |
||||
<GroupColumnsCollection> |
||||
<GroupColumn> |
||||
<SortDirection>Ascending</SortDirection> |
||||
<CaseSensitive>False</CaseSensitive> |
||||
<ColumnName>Name</ColumnName> |
||||
<DataTypeName>System.String</DataTypeName> |
||||
</GroupColumn> |
||||
</GroupColumnsCollection> |
||||
<ParameterCollection /> |
||||
<SqlParameters /> |
||||
<ConnectionString /> |
||||
<CommandText /> |
||||
<CommandType>Text</CommandType> |
||||
<DataModel>FormSheet</DataModel> |
||||
<NoDataMessage>No Data for this Report</NoDataMessage> |
||||
<DefaultFont>Microsoft Sans Serif, 10pt</DefaultFont> |
||||
<UseStandardPrinter>True</UseStandardPrinter> |
||||
</ReportSettings> |
||||
</ReportSettings> |
||||
<SectionCollection> |
||||
<BaseSection> |
||||
<Location>50, 50</Location> |
||||
<Size>727, 60</Size> |
||||
<BackColor>White</BackColor> |
||||
<SectionOffset>0</SectionOffset> |
||||
<SectionMargin>0</SectionMargin> |
||||
<DrawBorder>False</DrawBorder> |
||||
<PageBreakAfter>False</PageBreakAfter> |
||||
<Items> |
||||
<BaseTextItem> |
||||
<Location>157, 3</Location> |
||||
<Size>414, 40</Size> |
||||
<BackColor>White</BackColor> |
||||
<Font>Segoe UI, 18pt, style=Bold</Font> |
||||
<StringTrimming>None</StringTrimming> |
||||
<ContentAlignment>TopLeft</ContentAlignment> |
||||
<CanGrow>False</CanGrow> |
||||
<CanShrink>False</CanShrink> |
||||
<RTL>No</RTL> |
||||
<Text>SharpDevelop CodeQuality Analysis</Text> |
||||
<DrawBorder>False</DrawBorder> |
||||
<FrameColor>Black</FrameColor> |
||||
<ForeColor>Black</ForeColor> |
||||
<Name>BaseTextItem2147483637</Name> |
||||
</BaseTextItem> |
||||
</Items> |
||||
<FrameColor>Black</FrameColor> |
||||
<Name>ReportHeader</Name> |
||||
</BaseSection> |
||||
<BaseSection> |
||||
<Location>50, 125</Location> |
||||
<Size>727, 69</Size> |
||||
<BackColor>White</BackColor> |
||||
<SectionOffset>0</SectionOffset> |
||||
<SectionMargin>0</SectionMargin> |
||||
<DrawBorder>False</DrawBorder> |
||||
<PageBreakAfter>False</PageBreakAfter> |
||||
<Items> |
||||
<BaseLineItem> |
||||
<Location>22, 47</Location> |
||||
<Size>660, 10</Size> |
||||
<BackColor>White</BackColor> |
||||
<ForeColor>Black</ForeColor> |
||||
<FromPoint>10, 5</FromPoint> |
||||
<ToPoint>647, 5</ToPoint> |
||||
<StartLineCap>Flat</StartLineCap> |
||||
<EndLineCap>Flat</EndLineCap> |
||||
<DashLineCap>Flat</DashLineCap> |
||||
<DashStyle>Solid</DashStyle> |
||||
<Thickness>4</Thickness> |
||||
<Name>BaseLineItem1</Name> |
||||
</BaseLineItem> |
||||
<BaseTextItem> |
||||
<Location>222, 3</Location> |
||||
<Size>257, 26</Size> |
||||
<BackColor>White</BackColor> |
||||
<Font>Microsoft Sans Serif, 15.75pt</Font> |
||||
<StringTrimming>None</StringTrimming> |
||||
<ContentAlignment>TopLeft</ContentAlignment> |
||||
<CanGrow>False</CanGrow> |
||||
<CanShrink>False</CanShrink> |
||||
<DataType>System.String</DataType> |
||||
<RTL>No</RTL> |
||||
<Text>Analysis Overview Report</Text> |
||||
<DrawBorder>False</DrawBorder> |
||||
<FrameColor>Black</FrameColor> |
||||
<ForeColor>Black</ForeColor> |
||||
<Name>Overview</Name> |
||||
</BaseTextItem> |
||||
<BaseTextItem> |
||||
<Location>563, 3</Location> |
||||
<Size>100, 26</Size> |
||||
<BackColor>White</BackColor> |
||||
<Font>Segoe UI, 15.75pt</Font> |
||||
<StringTrimming>None</StringTrimming> |
||||
<ContentAlignment>TopLeft</ContentAlignment> |
||||
<CanGrow>False</CanGrow> |
||||
<CanShrink>False</CanShrink> |
||||
<RTL>No</RTL> |
||||
<Text>=Today()</Text> |
||||
<DrawBorder>False</DrawBorder> |
||||
<FrameColor>Black</FrameColor> |
||||
<ForeColor>ControlText</ForeColor> |
||||
<Name>BaseTextItem2147483638</Name> |
||||
</BaseTextItem> |
||||
</Items> |
||||
<FrameColor>Black</FrameColor> |
||||
<Name>ReportPageHeader</Name> |
||||
</BaseSection> |
||||
<BaseSection> |
||||
<Location>50, 209</Location> |
||||
<Size>727, 115</Size> |
||||
<BackColor>White</BackColor> |
||||
<SectionOffset>0</SectionOffset> |
||||
<SectionMargin>0</SectionMargin> |
||||
<DrawBorder>False</DrawBorder> |
||||
<PageBreakAfter>False</PageBreakAfter> |
||||
<Items> |
||||
<BaseRowItem> |
||||
<Location>31, 72</Location> |
||||
<Size>641, 30</Size> |
||||
<BackColor>White</BackColor> |
||||
<DrawBorder>False</DrawBorder> |
||||
<ForeColor>Black</ForeColor> |
||||
<FrameColor>Black</FrameColor> |
||||
<Items> |
||||
<BaseDataItem> |
||||
<Location>443, 4</Location> |
||||
<Size>71, 20</Size> |
||||
<BackColor>White</BackColor> |
||||
<Font>Segoe UI, 9pt</Font> |
||||
<StringTrimming>None</StringTrimming> |
||||
<ContentAlignment>MiddleRight</ContentAlignment> |
||||
<CanGrow>False</CanGrow> |
||||
<CanShrink>False</CanShrink> |
||||
<RTL>No</RTL> |
||||
<Text>BaseDataItem2147483646</Text> |
||||
<DrawBorder>False</DrawBorder> |
||||
<FrameColor>Black</FrameColor> |
||||
<ForeColor>Black</ForeColor> |
||||
<ColumnName>ReferenceCount</ColumnName> |
||||
<Name>BaseDataItem2147483646</Name> |
||||
</BaseDataItem> |
||||
<BaseDataItem> |
||||
<Location>254, 4</Location> |
||||
<Size>156, 20</Size> |
||||
<BackColor>White</BackColor> |
||||
<Font>Microsoft Sans Serif, 10pt</Font> |
||||
<StringTrimming>None</StringTrimming> |
||||
<ContentAlignment>TopLeft</ContentAlignment> |
||||
<CanGrow>False</CanGrow> |
||||
<CanShrink>False</CanShrink> |
||||
<RTL>No</RTL> |
||||
<Text>References</Text> |
||||
<DrawBorder>False</DrawBorder> |
||||
<FrameColor>Black</FrameColor> |
||||
<ForeColor>Black</ForeColor> |
||||
<ColumnName>References</ColumnName> |
||||
<Name>BaseDataItem2</Name> |
||||
</BaseDataItem> |
||||
</Items> |
||||
<AlternateBackColor /> |
||||
<ChangeBackColorEveryNRow>0</ChangeBackColorEveryNRow> |
||||
<Name>BaseRowItem1</Name> |
||||
</BaseRowItem> |
||||
<GroupHeader> |
||||
<Location>31, 22</Location> |
||||
<Size>641, 30</Size> |
||||
<BackColor>LightGray</BackColor> |
||||
<DrawBorder>False</DrawBorder> |
||||
<ForeColor>Black</ForeColor> |
||||
<FrameColor>Black</FrameColor> |
||||
<Items> |
||||
<BaseTextItem> |
||||
<Location>414, 7</Location> |
||||
<Size>100, 20</Size> |
||||
<BackColor>White</BackColor> |
||||
<Font>Segoe UI, 9.75pt</Font> |
||||
<StringTrimming>None</StringTrimming> |
||||
<ContentAlignment>MiddleRight</ContentAlignment> |
||||
<CanGrow>False</CanGrow> |
||||
<CanShrink>False</CanShrink> |
||||
<RTL>No</RTL> |
||||
<Text># of References</Text> |
||||
<DrawBorder>False</DrawBorder> |
||||
<FrameColor>Black</FrameColor> |
||||
<ForeColor>Black</ForeColor> |
||||
<Name>BaseTextItem2147483646</Name> |
||||
</BaseTextItem> |
||||
<BaseTextItem> |
||||
<Location>254, 2</Location> |
||||
<Size>100, 20</Size> |
||||
<BackColor>White</BackColor> |
||||
<Font>Microsoft Sans Serif, 10pt</Font> |
||||
<StringTrimming>None</StringTrimming> |
||||
<ContentAlignment>TopLeft</ContentAlignment> |
||||
<CanGrow>False</CanGrow> |
||||
<CanShrink>False</CanShrink> |
||||
<RTL>No</RTL> |
||||
<Text>References</Text> |
||||
<DrawBorder>False</DrawBorder> |
||||
<FrameColor>Black</FrameColor> |
||||
<ForeColor>Black</ForeColor> |
||||
<Name>BaseTextItem2147483636</Name> |
||||
</BaseTextItem> |
||||
<BaseDataItem> |
||||
<Location>12, 3</Location> |
||||
<Size>211, 20</Size> |
||||
<BackColor>White</BackColor> |
||||
<Font>Microsoft Sans Serif, 10pt</Font> |
||||
<StringTrimming>None</StringTrimming> |
||||
<ContentAlignment>TopLeft</ContentAlignment> |
||||
<CanGrow>False</CanGrow> |
||||
<CanShrink>False</CanShrink> |
||||
<RTL>No</RTL> |
||||
<Text>BaseDataItem1</Text> |
||||
<DrawBorder>False</DrawBorder> |
||||
<FrameColor>Black</FrameColor> |
||||
<ForeColor>Black</ForeColor> |
||||
<ColumnName>Name</ColumnName> |
||||
<Name>BaseDataItem1</Name> |
||||
</BaseDataItem> |
||||
</Items> |
||||
<AlternateBackColor /> |
||||
<ChangeBackColorEveryNRow>0</ChangeBackColorEveryNRow> |
||||
<PageBreakOnGroupChange>False</PageBreakOnGroupChange> |
||||
<Name>GroupHeader1</Name> |
||||
</GroupHeader> |
||||
</Items> |
||||
<FrameColor>Black</FrameColor> |
||||
<Name>ReportDetail</Name> |
||||
</BaseSection> |
||||
<BaseSection> |
||||
<Location>50, 339</Location> |
||||
<Size>727, 36</Size> |
||||
<BackColor>White</BackColor> |
||||
<SectionOffset>0</SectionOffset> |
||||
<SectionMargin>0</SectionMargin> |
||||
<DrawBorder>False</DrawBorder> |
||||
<PageBreakAfter>False</PageBreakAfter> |
||||
<Items> |
||||
<BaseTextItem> |
||||
<Location>31, 5</Location> |
||||
<Size>555, 20</Size> |
||||
<BackColor>White</BackColor> |
||||
<Font>Segoe UI, 9.75pt</Font> |
||||
<StringTrimming>None</StringTrimming> |
||||
<ContentAlignment>TopLeft</ContentAlignment> |
||||
<CanGrow>False</CanGrow> |
||||
<CanShrink>False</CanShrink> |
||||
<RTL>No</RTL> |
||||
<Text>= Globals!ReportFolder + Globals!ReportName</Text> |
||||
<DrawBorder>False</DrawBorder> |
||||
<FrameColor>Black</FrameColor> |
||||
<ForeColor>ControlText</ForeColor> |
||||
<Name>BaseTextItem2147483641</Name> |
||||
</BaseTextItem> |
||||
<BaseTextItem> |
||||
<Location>624, 5</Location> |
||||
<Size>100, 20</Size> |
||||
<BackColor>White</BackColor> |
||||
<Font>Microsoft Sans Serif, 10pt</Font> |
||||
<StringTrimming>None</StringTrimming> |
||||
<ContentAlignment>TopLeft</ContentAlignment> |
||||
<CanGrow>False</CanGrow> |
||||
<CanShrink>False</CanShrink> |
||||
<DataType>System.String</DataType> |
||||
<RTL>No</RTL> |
||||
<Text>= 'Page : ' + Globals!PageNumber</Text> |
||||
<DrawBorder>False</DrawBorder> |
||||
<FrameColor>Black</FrameColor> |
||||
<ForeColor>Black</ForeColor> |
||||
<Name>PageNumber1</Name> |
||||
</BaseTextItem> |
||||
</Items> |
||||
<FrameColor>Black</FrameColor> |
||||
<Name>ReportPageFooter</Name> |
||||
</BaseSection> |
||||
<BaseSection> |
||||
<Location>50, 390</Location> |
||||
<Size>727, 60</Size> |
||||
<BackColor>White</BackColor> |
||||
<SectionOffset>0</SectionOffset> |
||||
<SectionMargin>0</SectionMargin> |
||||
<DrawBorder>False</DrawBorder> |
||||
<PageBreakAfter>False</PageBreakAfter> |
||||
<Items /> |
||||
<FrameColor>Black</FrameColor> |
||||
<Name>ReportFooter</Name> |
||||
</BaseSection> |
||||
</SectionCollection> |
||||
</ReportModel> |
@ -0,0 +1,116 @@
@@ -0,0 +1,116 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel.Design; |
||||
using System.Diagnostics; |
||||
using System.Linq; |
||||
using System.Windows.Media; |
||||
using ICSharpCode.AvalonEdit.Document; |
||||
using ICSharpCode.AvalonEdit.Highlighting; |
||||
using ICSharpCode.AvalonEdit.Rendering; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.NRefactory.CSharp; |
||||
using ICSharpCode.NRefactory.CSharp.Analysis; |
||||
using ICSharpCode.NRefactory.CSharp.Resolver; |
||||
using ICSharpCode.NRefactory.Editor; |
||||
using ICSharpCode.NRefactory.Semantics; |
||||
using ICSharpCode.NRefactory.TypeSystem; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Parser; |
||||
using CSharpBinding.Parser; |
||||
|
||||
namespace CSharpBinding |
||||
{ |
||||
class CSharpSemanticHighlighterVisitor : SemanticHighlightingVisitor<HighlightingColor>, IDisposable |
||||
{ |
||||
readonly CSharpSemanticHighlighter highlighter; |
||||
readonly IDocument document; |
||||
|
||||
#region Constructor + Dispose
|
||||
public CSharpSemanticHighlighterVisitor(CSharpSemanticHighlighter highlighter, IDocument document) |
||||
{ |
||||
if (highlighter == null) |
||||
throw new ArgumentNullException("highlighter"); |
||||
if (document == null) |
||||
throw new ArgumentNullException("document"); |
||||
this.document = document; |
||||
this.highlighter = highlighter; |
||||
|
||||
var highlighting = HighlightingManager.Instance.GetDefinition("C#"); |
||||
//this.defaultTextColor = ???;
|
||||
this.referenceTypeColor = highlighting.GetNamedColor("ReferenceTypes"); |
||||
this.valueTypeColor = highlighting.GetNamedColor("ValueTypes"); |
||||
this.interfaceTypeColor = this.referenceTypeColor; |
||||
this.enumerationTypeColor = this.valueKeywordColor; |
||||
this.typeParameterTypeColor = this.referenceTypeColor; |
||||
this.delegateTypeColor = this.referenceTypeColor; |
||||
this.methodDeclarationColor = this.methodCallColor = highlighting.GetNamedColor("MethodCall"); |
||||
//this.eventDeclarationColor = this.eventAccessColor = defaultTextColor;
|
||||
//this.propertyDeclarationColor = this.propertyAccessColor = defaultTextColor;
|
||||
this.fieldDeclarationColor = this.fieldAccessColor = highlighting.GetNamedColor("FieldAccess"); |
||||
//this.variableDeclarationColor = this.variableAccessColor = defaultTextColor;
|
||||
//this.parameterDeclarationColor = this.parameterAccessColor = defaultTextColor;
|
||||
this.valueKeywordColor = highlighting.GetNamedColor("NullOrValueKeywords"); |
||||
//this.externAliasKeywordColor = ...;
|
||||
this.parameterModifierColor = highlighting.GetNamedColor("ParameterModifiers"); |
||||
this.inactiveCodeColor = highlighting.GetNamedColor("InactiveCode"); |
||||
this.syntaxErrorColor = highlighting.GetNamedColor("SemanticError"); |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
resolver = null; |
||||
} |
||||
#endregion
|
||||
|
||||
#region Colorize
|
||||
protected override void Colorize(TextLocation start, TextLocation end, HighlightingColor color) |
||||
{ |
||||
highlighter.Colorize(start, end, color); |
||||
} |
||||
#endregion
|
||||
|
||||
#if DEBUG
|
||||
public override void VisitSyntaxTree(ICSharpCode.NRefactory.CSharp.SyntaxTree syntaxTree) |
||||
{ |
||||
base.VisitSyntaxTree(syntaxTree); |
||||
|
||||
} |
||||
#endif
|
||||
|
||||
internal void UpdateLineInformation(int lineNumber) |
||||
{ |
||||
regionStart = new TextLocation(lineNumber, 1); |
||||
regionEnd = new TextLocation(lineNumber, 1 + document.GetLineByNumber(lineNumber).Length); |
||||
} |
||||
|
||||
internal CSharpAstResolver Resolver { |
||||
get { |
||||
return resolver; |
||||
} |
||||
set { |
||||
this.resolver = value; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,222 @@
@@ -0,0 +1,222 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Threading; |
||||
using System.Windows.Media; |
||||
using ICSharpCode.AvalonEdit.Document; |
||||
using ICSharpCode.AvalonEdit.Rendering; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.NRefactory.CSharp; |
||||
using ICSharpCode.NRefactory.CSharp.Resolver; |
||||
using ICSharpCode.NRefactory.Editor; |
||||
using ICSharpCode.NRefactory.Semantics; |
||||
using ICSharpCode.NRefactory.TypeSystem; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
using ICSharpCode.SharpDevelop.Parser; |
||||
using CSharpBinding.Parser; |
||||
|
||||
namespace CSharpBinding |
||||
{ |
||||
class CaretReferenceHighlightRenderer : IDisposable, IBackgroundRenderer |
||||
{ |
||||
readonly ITextEditor editor; |
||||
readonly TextView textView; |
||||
|
||||
ISymbolReference currentSymbolReference; |
||||
CancellationTokenSource caretMovementTokenSource; |
||||
List<ISegment> currentReferences; |
||||
|
||||
Pen borderPen; |
||||
Brush backgroundBrush; |
||||
|
||||
public readonly Color DefaultBorderColor = Color.FromArgb(52, 30, 130, 255); |
||||
public readonly Color DefaultFillColor = Color.FromArgb(22, 30, 130, 255); |
||||
readonly int borderThickness = 1; |
||||
readonly int cornerRadius = 1; |
||||
|
||||
public CaretReferenceHighlightRenderer(ITextEditor editor) |
||||
{ |
||||
if (editor == null) |
||||
throw new ArgumentNullException("editor"); |
||||
this.editor = editor; |
||||
this.textView = editor.GetService<TextView>(); |
||||
this.borderPen = new Pen(new SolidColorBrush(DefaultBorderColor), borderThickness); |
||||
this.backgroundBrush = new SolidColorBrush(DefaultFillColor); |
||||
this.borderPen.Freeze(); |
||||
this.backgroundBrush.Freeze(); |
||||
editor.Caret.LocationChanged += CaretLocationChanged; |
||||
textView.VisualLinesChanged += VisualLinesChanged; |
||||
SD.ParserService.ParseInformationUpdated += ParseInformationUpdated; |
||||
SD.ParserService.LoadSolutionProjectsThread.Finished += LoadSolutionProjectsThreadFinished; |
||||
this.textView.BackgroundRenderers.Add(this); |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
this.textView.BackgroundRenderers.Remove(this); |
||||
editor.Caret.LocationChanged -= CaretLocationChanged; |
||||
} |
||||
|
||||
public void Draw(TextView textView, DrawingContext drawingContext) |
||||
{ |
||||
if (currentReferences == null) { |
||||
var start = textView.VisualLines.First().FirstDocumentLine.LineNumber; |
||||
var end = textView.VisualLines.Last().LastDocumentLine.LineNumber; |
||||
currentReferences = new List<ISegment>(); |
||||
FindCurrentReferences(start, end); |
||||
} |
||||
if (currentReferences.Count == 0) |
||||
return; |
||||
BackgroundGeometryBuilder builder = new BackgroundGeometryBuilder(); |
||||
builder.CornerRadius = cornerRadius; |
||||
builder.AlignToMiddleOfPixels = true; |
||||
foreach (var reference in this.currentReferences) { |
||||
builder.AddSegment(textView, new TextSegment() { |
||||
StartOffset = reference.Offset, |
||||
Length = reference.Length |
||||
}); |
||||
builder.CloseFigure(); |
||||
} |
||||
Geometry geometry = builder.CreateGeometry(); |
||||
if (geometry != null) { |
||||
drawingContext.DrawGeometry(backgroundBrush, borderPen, geometry); |
||||
} |
||||
} |
||||
|
||||
void VisualLinesChanged(object sender, System.EventArgs e) |
||||
{ |
||||
currentReferences = null; |
||||
} |
||||
|
||||
void ParseInformationUpdated(object sender, ParseInformationEventArgs e) |
||||
{ |
||||
if (SD.ParserService.LoadSolutionProjectsThread.IsRunning) |
||||
return; |
||||
if (!e.FileName.Equals(editor.FileName)) |
||||
return; |
||||
currentReferences = null; |
||||
textView.InvalidateLayer(KnownLayer.Selection); |
||||
|
||||
} |
||||
|
||||
void LoadSolutionProjectsThreadFinished(object sender, EventArgs e) |
||||
{ |
||||
currentReferences = null; |
||||
textView.InvalidateLayer(KnownLayer.Selection); |
||||
} |
||||
|
||||
void CaretLocationChanged(object sender, EventArgs e) |
||||
{ |
||||
if (caretMovementTokenSource != null) |
||||
caretMovementTokenSource.Cancel(); |
||||
caretMovementTokenSource = new CancellationTokenSource(); |
||||
var rr = SD.ParserService.Resolve(editor.FileName, editor.Caret.Location, editor.Document, cancellationToken: caretMovementTokenSource.Token); |
||||
SetCurrentSymbol(rr.GetSymbol()); |
||||
} |
||||
|
||||
IResolveVisitorNavigator InitNavigator(ICompilation compilation) |
||||
{ |
||||
if (currentSymbolReference == null || compilation == null) |
||||
return null; |
||||
var symbol = currentSymbolReference.Resolve(compilation.TypeResolveContext); |
||||
FindReferences findReferences = new FindReferences(); |
||||
if (symbol == null) return null; |
||||
var searchScopes = findReferences.GetSearchScopes(symbol); |
||||
if (searchScopes.Count == 0) |
||||
return null; |
||||
var navigators = new IResolveVisitorNavigator[searchScopes.Count]; |
||||
for (int i = 0; i < navigators.Length; i++) { |
||||
navigators[i] = searchScopes[i].GetNavigator(compilation, ColorizeMatch); |
||||
} |
||||
IResolveVisitorNavigator combinedNavigator; |
||||
if (searchScopes.Count == 1) { |
||||
combinedNavigator = navigators[0]; |
||||
} |
||||
else { |
||||
combinedNavigator = new CompositeResolveVisitorNavigator(navigators); |
||||
} |
||||
return combinedNavigator; |
||||
} |
||||
|
||||
void FindCurrentReferences(int start, int end) |
||||
{ |
||||
ICompilation compilation = SD.ParserService.GetCompilationForFile(editor.FileName); |
||||
CSharpFullParseInformation parseInfo = SD.ParserService.GetCachedParseInformation(editor.FileName) as CSharpFullParseInformation; |
||||
|
||||
if (currentSymbolReference == null || parseInfo == null) |
||||
return; |
||||
|
||||
IResolveVisitorNavigator currentNavigator = InitNavigator(compilation); |
||||
CSharpAstResolver resolver = parseInfo.GetResolver(compilation); |
||||
|
||||
if (currentNavigator == null || resolver == null) |
||||
return; |
||||
|
||||
VisitVisibleNodes(parseInfo.SyntaxTree, currentNavigator, resolver, start, end); |
||||
} |
||||
|
||||
void VisitVisibleNodes(AstNode node, IResolveVisitorNavigator currentNavigator, CSharpAstResolver resolver, int start, int end) |
||||
{ |
||||
if (!CSharpAstResolver.IsUnresolvableNode(node)) |
||||
currentNavigator.Resolved(node, resolver.Resolve(node, caretMovementTokenSource.Token)); |
||||
for (var child = node.FirstChild; child != null; child = child.NextSibling) { |
||||
if (child.StartLocation.Line <= end && child.EndLocation.Line >= start) |
||||
VisitVisibleNodes(child, currentNavigator, resolver, start, end); |
||||
} |
||||
} |
||||
|
||||
void ColorizeMatch(AstNode node, ResolveResult result) |
||||
{ |
||||
var identifierNode = FindReferences.GetNodeToReplace(node); |
||||
TextLocation start, end; |
||||
if (!identifierNode.IsNull) { |
||||
start = identifierNode.StartLocation; |
||||
end = identifierNode.EndLocation; |
||||
} |
||||
else { |
||||
start = node.StartLocation; |
||||
end = node.EndLocation; |
||||
} |
||||
currentReferences.Add(new TextSegment { |
||||
StartOffset = editor.Document.GetOffset(start), |
||||
EndOffset = editor.Document.GetOffset(end) |
||||
}); |
||||
} |
||||
|
||||
public KnownLayer Layer { |
||||
get { |
||||
return KnownLayer.Selection; |
||||
} |
||||
} |
||||
|
||||
void SetCurrentSymbol(ISymbol symbol) |
||||
{ |
||||
currentSymbolReference = null; |
||||
if (symbol != null) |
||||
currentSymbolReference = symbol.ToReference(); |
||||
currentReferences = null; |
||||
textView.InvalidateLayer(KnownLayer.Selection); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
@ -1,156 +0,0 @@
@@ -1,156 +0,0 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using ICSharpCode.NRefactory.Ast;
|
||||
//using ICSharpCode.PackageManagement.EnvDTE;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using ICSharpCode.SharpDevelop.Dom.Refactoring;
|
||||
//
|
||||
//namespace ICSharpCode.PackageManagement
|
||||
//{
|
||||
// public class ClassCodeGenerator
|
||||
// {
|
||||
// public ClassCodeGenerator(IClass c)
|
||||
// : this(c, new DocumentLoader())
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public ClassCodeGenerator(IClass c, IDocumentLoader documentLoader)
|
||||
// {
|
||||
// this.Class = c;
|
||||
// this.DocumentLoader = documentLoader;
|
||||
// }
|
||||
//
|
||||
// IClass Class { get; set; }
|
||||
// IDocumentLoader DocumentLoader { get; set; }
|
||||
//
|
||||
// ICompilationUnit CompilationUnit {
|
||||
// get { return Class.CompilationUnit; }
|
||||
// }
|
||||
//
|
||||
// public CodeVariable AddPublicVariable(string name, string type)
|
||||
// {
|
||||
// CodeGenerator codeGenerator = GetCodeGenerator();
|
||||
// IRefactoringDocumentView view = LoadClassDocumentView();
|
||||
// codeGenerator.InsertCodeAtEnd(Class.Region, view.RefactoringDocument, CreateField(name, type));
|
||||
// return GetVariableInserted(view);
|
||||
// }
|
||||
//
|
||||
// CodeGenerator GetCodeGenerator()
|
||||
// {
|
||||
// return CompilationUnit.Language.CodeGenerator;
|
||||
// }
|
||||
//
|
||||
// IRefactoringDocumentView LoadClassDocumentView()
|
||||
// {
|
||||
// return DocumentLoader.LoadRefactoringDocumentView(CompilationUnit.FileName);
|
||||
// }
|
||||
//
|
||||
// FieldDeclaration CreateField(string name, string type)
|
||||
// {
|
||||
// return new FieldDeclaration(new List<AttributeSection>()) {
|
||||
// Fields = CreateVariableDeclarations(name),
|
||||
// Modifier = Modifiers.Public,
|
||||
// TypeReference = new TypeReference(type)
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// List<VariableDeclaration> CreateVariableDeclarations(string name)
|
||||
// {
|
||||
// var variables = new List<VariableDeclaration>();
|
||||
// variables.Add(new VariableDeclaration(name));
|
||||
// return variables;
|
||||
// }
|
||||
//
|
||||
// CodeVariable GetVariableInserted(IRefactoringDocumentView view)
|
||||
// {
|
||||
// IField field = FindField(view);
|
||||
// return new CodeVariable(field);
|
||||
// }
|
||||
//
|
||||
// IField FindField(IRefactoringDocumentView view)
|
||||
// {
|
||||
// return FindMatchingClass(view).Fields.Last();
|
||||
// }
|
||||
//
|
||||
// IClass FindMatchingClass(IRefactoringDocumentView view)
|
||||
// {
|
||||
// ICompilationUnit unit = view.Parse();
|
||||
// return FindMatchingClass(unit);
|
||||
// }
|
||||
//
|
||||
// IClass FindMatchingClass(ICompilationUnit unit)
|
||||
// {
|
||||
// foreach (IClass c in unit.Classes) {
|
||||
// if (c.FullyQualifiedName == Class.FullyQualifiedName) {
|
||||
// return c;
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// The fully qualified type will not be added as the method's return value since
|
||||
// /// NRefactory returns the incorrect start column for the method's region in this case.
|
||||
// /// Instead we add the last part of the type so for "System.Object" we add "Object" so the
|
||||
// /// method's region is correct. This only seems to affect methods where there is no modifier
|
||||
// /// (e.g. public, private) explicitly defined in code.
|
||||
// ///
|
||||
// /// For MvcScaffolding we only need the start and end points to be correctly defined since the
|
||||
// /// function will be immediately replaced with different code.
|
||||
// /// </summary>
|
||||
// public CodeFunction AddPublicMethod(string name, string type)
|
||||
// {
|
||||
// CodeGenerator codeGenerator = GetCodeGenerator();
|
||||
// IRefactoringDocumentView view = LoadClassDocumentView();
|
||||
// codeGenerator.InsertCodeAtEnd(Class.Region, view.RefactoringDocument, CreateMethod(name, type));
|
||||
// return GetMethodInserted(view);
|
||||
// }
|
||||
//
|
||||
// MethodDeclaration CreateMethod(string name, string type)
|
||||
// {
|
||||
// return new MethodDeclaration {
|
||||
// Name = name,
|
||||
// TypeReference = new TypeReference(GetShortTypeName(type))
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// string GetShortTypeName(string type)
|
||||
// {
|
||||
// int index = type.LastIndexOf('.');
|
||||
// if (index > 0) {
|
||||
// return type.Substring(index + 1);
|
||||
// }
|
||||
// return type;
|
||||
// }
|
||||
//
|
||||
// CodeFunction GetMethodInserted(IRefactoringDocumentView view)
|
||||
// {
|
||||
// IMethod method = FindMethod(view);
|
||||
// return new CodeFunction(method);
|
||||
// }
|
||||
//
|
||||
// IMethod FindMethod(IRefactoringDocumentView view)
|
||||
// {
|
||||
// return FindMatchingClass(view).Methods.Last();
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,81 +0,0 @@
@@ -1,81 +0,0 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
//using System;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using ICSharpCode.SharpDevelop.Dom.Refactoring;
|
||||
//
|
||||
//namespace ICSharpCode.PackageManagement
|
||||
//{
|
||||
// public class ClassKindUpdater : IClassKindUpdater
|
||||
// {
|
||||
// public ClassKindUpdater(IClass c)
|
||||
// : this(c, new DocumentLoader())
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public ClassKindUpdater(IClass c, IDocumentLoader documentLoader)
|
||||
// {
|
||||
// this.Class = c;
|
||||
// this.DocumentLoader = documentLoader;
|
||||
// }
|
||||
//
|
||||
// IClass Class { get; set; }
|
||||
// IDocumentLoader DocumentLoader { get; set; }
|
||||
// IRefactoringDocument Document { get; set; }
|
||||
//
|
||||
// public void MakeClassPartial()
|
||||
// {
|
||||
// if (Class.IsPartial)
|
||||
// return;
|
||||
//
|
||||
// OpenFileContainingClass();
|
||||
// int offset = GetPartialKeywordInsertOffset();
|
||||
// InsertPartialKeyword(offset);
|
||||
// }
|
||||
//
|
||||
// void OpenFileContainingClass()
|
||||
// {
|
||||
// Document = DocumentLoader.LoadRefactoringDocument(Class.CompilationUnit.FileName);
|
||||
// }
|
||||
//
|
||||
// int GetPartialKeywordInsertOffset()
|
||||
// {
|
||||
// IRefactoringDocumentLine line = Document.GetLine(Class.Region.BeginLine);
|
||||
// int offset = line.Text.IndexOf(" class", StringComparison.OrdinalIgnoreCase);
|
||||
// if (offset >= 0) {
|
||||
// return offset + line.Offset + 1;
|
||||
// }
|
||||
// throw new ApplicationException("Unable to find 'class' declaration.");
|
||||
// }
|
||||
//
|
||||
// void InsertPartialKeyword(int offset)
|
||||
// {
|
||||
// string partialKeyword = GetLanguageSpecificPartialKeyword();
|
||||
// Document.Insert(offset, partialKeyword + " ");
|
||||
// }
|
||||
//
|
||||
// string GetLanguageSpecificPartialKeyword()
|
||||
// {
|
||||
// if (Class.ProjectContent.Language == LanguageProperties.VBNet) {
|
||||
// return "Partial";
|
||||
// }
|
||||
// return "partial";
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -0,0 +1,61 @@
@@ -0,0 +1,61 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using ICSharpCode.NRefactory.Editor; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
|
||||
namespace ICSharpCode.PackageManagement |
||||
{ |
||||
public class DocumentView : IDocumentView |
||||
{ |
||||
public DocumentView(string fileName) |
||||
{ |
||||
View = FileService.OpenFile(fileName); |
||||
TextEditor = GetTextEditor(); |
||||
FormattingStrategy = TextEditor.Language.FormattingStrategy; |
||||
Document = LoadDocument(); |
||||
} |
||||
|
||||
IViewContent View { get; set; } |
||||
ITextEditor TextEditor { get; set; } |
||||
IFormattingStrategy FormattingStrategy { get; set; } |
||||
|
||||
ITextEditor GetTextEditor() |
||||
{ |
||||
return View.GetService<ITextEditor>(); |
||||
} |
||||
|
||||
public IDocument Document { get; private set; } |
||||
|
||||
IDocument LoadDocument() |
||||
{ |
||||
return new ThreadSafeDocument(TextEditor.Document); |
||||
} |
||||
|
||||
public void IndentLines(int beginLine, int endLine) |
||||
{ |
||||
SD.MainThread.InvokeIfRequired(() => { |
||||
using (IDisposable undoGroup = TextEditor.Document.OpenUndoGroup()) { |
||||
FormattingStrategy.IndentLines(TextEditor, beginLine, endLine); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
} |
@ -1,37 +0,0 @@
@@ -1,37 +0,0 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
//using System;
|
||||
//using ICSharpCode.NRefactory.TypeSystem;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//
|
||||
//namespace ICSharpCode.PackageManagement
|
||||
//{
|
||||
// public static class DomRegionExtensions
|
||||
// {
|
||||
// public static FilePosition ToStartPosition(this DomRegion region, ICompilationUnit compilationUnit)
|
||||
// {
|
||||
// return new FilePosition(compilationUnit, region.BeginLine, region.BeginColumn);
|
||||
// }
|
||||
//
|
||||
// public static FilePosition ToEndPosition(this DomRegion region, ICompilationUnit compilationUnit)
|
||||
// {
|
||||
// return new FilePosition(compilationUnit, region.EndLine, region.EndColumn);
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -0,0 +1,68 @@
@@ -0,0 +1,68 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
|
||||
using ICSharpCode.NRefactory.TypeSystem; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.PackageManagement.EnvDTE |
||||
{ |
||||
public class CodeElementsInNamespace : CodeElementsList<CodeElement> |
||||
{ |
||||
CodeModelContext context; |
||||
INamespace ns; |
||||
|
||||
public CodeElementsInNamespace(CodeModelContext context) |
||||
: this(context, context.DteProject.GetCompilationUnit().RootNamespace) |
||||
{ |
||||
} |
||||
|
||||
public CodeElementsInNamespace(CodeModelContext context, INamespace ns) |
||||
{ |
||||
this.context = context; |
||||
this.ns = ns; |
||||
GetCodeElements(); |
||||
} |
||||
|
||||
void GetCodeElements() |
||||
{ |
||||
foreach (INamespace childNamespace in ns.ChildNamespaces) { |
||||
AddCodeNamespace(childNamespace); |
||||
} |
||||
|
||||
foreach (IType type in ns.Types) { |
||||
AddType(type); |
||||
} |
||||
} |
||||
|
||||
void AddCodeNamespace(INamespace ns) |
||||
{ |
||||
Add(new CodeNamespace(context, ns)); |
||||
} |
||||
|
||||
void AddType(IType type) |
||||
{ |
||||
Add(CodeType.Create(context, type)); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,58 @@
@@ -0,0 +1,58 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.PackageManagement.EnvDTE |
||||
{ |
||||
public class NamespaceName |
||||
{ |
||||
public NamespaceName(string parentNamespace, string name) |
||||
: this(GetQualifiedNamespaceName(parentNamespace, name)) |
||||
{ |
||||
} |
||||
|
||||
static string GetQualifiedNamespaceName(string parentNamespace, string name) |
||||
{ |
||||
if (String.IsNullOrEmpty(parentNamespace)) { |
||||
return name; |
||||
} |
||||
return String.Format("{0}.{1}", parentNamespace, name); |
||||
} |
||||
|
||||
public NamespaceName(string qualifiedName) |
||||
{ |
||||
this.QualifiedName = qualifiedName; |
||||
LastPart = GetLastPartOfNamespace(); |
||||
} |
||||
|
||||
string GetLastPartOfNamespace() |
||||
{ |
||||
int index = QualifiedName.LastIndexOf('.'); |
||||
return QualifiedName.Substring(index + 1); |
||||
} |
||||
|
||||
public string LastPart { get; private set; } |
||||
public string QualifiedName { get; private set; } |
||||
|
||||
public NamespaceName CreateChildNamespaceName(string name) |
||||
{ |
||||
return new NamespaceName(QualifiedName, name); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.NRefactory.TypeSystem; |
||||
|
||||
namespace ICSharpCode.PackageManagement |
||||
{ |
||||
public interface ICodeGenerator |
||||
{ |
||||
void AddImport(FileName fileName, string name); |
||||
void MakePartial(ITypeDefinition typeDefinition); |
||||
void MakeVirtual(IMember member); |
||||
void AddFieldAtStart(ITypeDefinition typeDefinition, Accessibility accessibility, IType fieldType, string name); |
||||
void AddMethodAtStart(ITypeDefinition typeDefinition, Accessibility accessibility, IType returnType, string name); |
||||
} |
||||
} |
@ -1,62 +0,0 @@
@@ -1,62 +0,0 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
//using System;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//
|
||||
//namespace ICSharpCode.PackageManagement
|
||||
//{
|
||||
// public static class IMethodOrPropertyExtensions
|
||||
// {
|
||||
// public static FilePosition GetStartPosition(this IMethodOrProperty method)
|
||||
// {
|
||||
// return method.Region.ToStartPosition(method.CompilationUnit);
|
||||
// }
|
||||
//
|
||||
// public static FilePosition GetEndPosition(this IMethodOrProperty method)
|
||||
// {
|
||||
// if (method.DeclaringTypeIsInterface()) {
|
||||
// return method.Region.ToEndPosition(method.CompilationUnit);
|
||||
// }
|
||||
// return method.BodyRegion.ToEndPosition(method.CompilationUnit);
|
||||
// }
|
||||
//
|
||||
// public static bool DeclaringTypeIsInterface(this IMethodOrProperty method)
|
||||
// {
|
||||
// return method.DeclaringType.ClassType == ClassType.Interface;
|
||||
// }
|
||||
//
|
||||
// public static bool IsConstructor(this IMethodOrProperty methodOrProperty)
|
||||
// {
|
||||
// var method = methodOrProperty as IMethod;
|
||||
// if (method != null) {
|
||||
// return method.IsConstructor;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// public static bool HasTypeParameters(this IMethodOrProperty methodOrProperty)
|
||||
// {
|
||||
// var method = methodOrProperty as IMethod;
|
||||
// if ((method != null) && (method.TypeParameters != null)) {
|
||||
// return method.TypeParameters.Count > 0;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -0,0 +1,203 @@
@@ -0,0 +1,203 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.PackageManagement |
||||
{ |
||||
public class PackageManagementSolution : IPackageManagementSolution |
||||
{ |
||||
IRegisteredPackageRepositories registeredPackageRepositories; |
||||
IPackageManagementProjectService projectService; |
||||
IPackageManagementProjectFactory projectFactory; |
||||
ISolutionPackageRepositoryFactory solutionPackageRepositoryFactory; |
||||
|
||||
public PackageManagementSolution( |
||||
IRegisteredPackageRepositories registeredPackageRepositories, |
||||
IPackageManagementEvents packageManagementEvents) |
||||
: this( |
||||
registeredPackageRepositories, |
||||
new PackageManagementProjectService(), |
||||
new PackageManagementProjectFactory(packageManagementEvents), |
||||
new SolutionPackageRepositoryFactory()) |
||||
{ |
||||
} |
||||
|
||||
public PackageManagementSolution( |
||||
IRegisteredPackageRepositories registeredPackageRepositories, |
||||
IPackageManagementProjectService projectService, |
||||
IPackageManagementProjectFactory projectFactory, |
||||
ISolutionPackageRepositoryFactory solutionPackageRepositoryFactory) |
||||
{ |
||||
this.registeredPackageRepositories = registeredPackageRepositories; |
||||
this.projectFactory = projectFactory; |
||||
this.projectService = projectService; |
||||
this.solutionPackageRepositoryFactory = solutionPackageRepositoryFactory; |
||||
} |
||||
|
||||
public string FileName { |
||||
get { return OpenSolution.FileName; } |
||||
} |
||||
|
||||
ISolution OpenSolution { |
||||
get { return projectService.OpenSolution; } |
||||
} |
||||
|
||||
public IPackageManagementProject GetActiveProject() |
||||
{ |
||||
if (HasActiveProject()) { |
||||
return GetActiveProject(ActivePackageRepository); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
bool HasActiveProject() |
||||
{ |
||||
return GetActiveMSBuildBasedProject() != null; |
||||
} |
||||
|
||||
public IProject GetActiveMSBuildProject() |
||||
{ |
||||
return projectService.CurrentProject; |
||||
} |
||||
|
||||
IPackageRepository ActivePackageRepository { |
||||
get { return registeredPackageRepositories.ActiveRepository; } |
||||
} |
||||
|
||||
public IPackageManagementProject GetActiveProject(IPackageRepository sourceRepository) |
||||
{ |
||||
MSBuildBasedProject activeProject = GetActiveMSBuildBasedProject(); |
||||
if (activeProject != null) { |
||||
return CreateProject(sourceRepository, activeProject); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
MSBuildBasedProject GetActiveMSBuildBasedProject() |
||||
{ |
||||
return GetActiveMSBuildProject() as MSBuildBasedProject; |
||||
} |
||||
|
||||
IPackageManagementProject CreateProject(IPackageRepository sourceRepository, MSBuildBasedProject project) |
||||
{ |
||||
return projectFactory.CreateProject(sourceRepository, project); |
||||
} |
||||
|
||||
IPackageRepository CreatePackageRepository(PackageSource source) |
||||
{ |
||||
return registeredPackageRepositories.CreateRepository(source); |
||||
} |
||||
|
||||
public IPackageManagementProject GetProject(PackageSource source, string projectName) |
||||
{ |
||||
MSBuildBasedProject msbuildProject = GetMSBuildProject(projectName); |
||||
return CreateProject(source, msbuildProject); |
||||
} |
||||
|
||||
MSBuildBasedProject GetMSBuildProject(string name) |
||||
{ |
||||
var openProjects = new OpenMSBuildProjects(projectService); |
||||
return openProjects.FindProject(name); |
||||
} |
||||
|
||||
IPackageManagementProject CreateProject(PackageSource source, MSBuildBasedProject project) |
||||
{ |
||||
IPackageRepository sourceRepository = CreatePackageRepository(source); |
||||
return CreateProject(sourceRepository, project); |
||||
} |
||||
|
||||
public IPackageManagementProject GetProject(IPackageRepository sourceRepository, string projectName) |
||||
{ |
||||
MSBuildBasedProject msbuildProject = GetMSBuildProject(projectName); |
||||
return CreateProject(sourceRepository, msbuildProject); |
||||
} |
||||
|
||||
public IPackageManagementProject GetProject(IPackageRepository sourceRepository, IProject project) |
||||
{ |
||||
var msbuildProject = project as MSBuildBasedProject; |
||||
return CreateProject(sourceRepository, msbuildProject); |
||||
} |
||||
|
||||
public IEnumerable<IProject> GetMSBuildProjects() |
||||
{ |
||||
return projectService.AllProjects.OfType<MSBuildBasedProject>();; |
||||
} |
||||
|
||||
public bool IsOpen { |
||||
get { return OpenSolution != null; } |
||||
} |
||||
|
||||
public bool HasMultipleProjects() |
||||
{ |
||||
return projectService.AllProjects.Count > 1; |
||||
} |
||||
|
||||
public bool IsPackageInstalled(IPackage package) |
||||
{ |
||||
ISolutionPackageRepository repository = CreateSolutionPackageRepository(); |
||||
return repository.IsInstalled(package); |
||||
} |
||||
|
||||
ISolutionPackageRepository CreateSolutionPackageRepository() |
||||
{ |
||||
return solutionPackageRepositoryFactory.CreateSolutionPackageRepository(OpenSolution); |
||||
} |
||||
|
||||
public IQueryable<IPackage> GetPackages() |
||||
{ |
||||
ISolutionPackageRepository repository = CreateSolutionPackageRepository(); |
||||
List<IPackageManagementProject> projects = GetProjects(ActivePackageRepository).ToList(); |
||||
return repository |
||||
.GetPackages() |
||||
.Where(package => IsPackageInstalledInSolutionOrAnyProject(projects, package)); |
||||
} |
||||
|
||||
bool IsPackageInstalledInSolutionOrAnyProject(IList<IPackageManagementProject> projects, IPackage package) |
||||
{ |
||||
if (projects.Any(project => project.IsPackageInstalled(package))) { |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public string GetInstallPath(IPackage package) |
||||
{ |
||||
ISolutionPackageRepository repository = CreateSolutionPackageRepository(); |
||||
return repository.GetInstallPath(package); |
||||
} |
||||
|
||||
public IEnumerable<IPackage> GetPackagesInReverseDependencyOrder() |
||||
{ |
||||
ISolutionPackageRepository repository = CreateSolutionPackageRepository(); |
||||
return repository.GetPackagesByReverseDependencyOrder(); |
||||
} |
||||
|
||||
public IEnumerable<IPackageManagementProject> GetProjects(IPackageRepository sourceRepository) |
||||
{ |
||||
foreach (MSBuildBasedProject msbuildProject in GetMSBuildProjects()) { |
||||
yield return projectFactory.CreateProject(sourceRepository, msbuildProject); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,204 @@
@@ -0,0 +1,204 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.PackageManagement |
||||
{ |
||||
public class PackageManagementSolution : IPackageManagementSolution |
||||
{ |
||||
IRegisteredPackageRepositories registeredPackageRepositories; |
||||
IPackageManagementProjectService projectService; |
||||
IPackageManagementProjectFactory projectFactory; |
||||
ISolutionPackageRepositoryFactory solutionPackageRepositoryFactory; |
||||
|
||||
public PackageManagementSolution( |
||||
IRegisteredPackageRepositories registeredPackageRepositories, |
||||
IPackageManagementEvents packageManagementEvents) |
||||
: this( |
||||
registeredPackageRepositories, |
||||
new PackageManagementProjectService(), |
||||
new PackageManagementProjectFactory(packageManagementEvents), |
||||
new SolutionPackageRepositoryFactory()) |
||||
{ |
||||
} |
||||
|
||||
public PackageManagementSolution( |
||||
IRegisteredPackageRepositories registeredPackageRepositories, |
||||
IPackageManagementProjectService projectService, |
||||
IPackageManagementProjectFactory projectFactory, |
||||
ISolutionPackageRepositoryFactory solutionPackageRepositoryFactory) |
||||
{ |
||||
this.registeredPackageRepositories = registeredPackageRepositories; |
||||
this.projectFactory = projectFactory; |
||||
this.projectService = projectService; |
||||
this.solutionPackageRepositoryFactory = solutionPackageRepositoryFactory; |
||||
} |
||||
|
||||
public string FileName { |
||||
get { return OpenSolution.FileName; } |
||||
} |
||||
|
||||
ISolution OpenSolution { |
||||
get { return projectService.OpenSolution; } |
||||
} |
||||
|
||||
public IPackageManagementProject GetActiveProject() |
||||
{ |
||||
if (HasActiveProject()) { |
||||
return GetActiveProject(ActivePackageRepository); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
bool HasActiveProject() |
||||
{ |
||||
return GetActiveMSBuildBasedProject() != null; |
||||
} |
||||
|
||||
public IProject GetActiveMSBuildProject() |
||||
{ |
||||
return projectService.CurrentProject; |
||||
} |
||||
|
||||
IPackageRepository ActivePackageRepository { |
||||
get { return registeredPackageRepositories.ActiveRepository; } |
||||
} |
||||
|
||||
public IPackageManagementProject GetActiveProject(IPackageRepository sourceRepository) |
||||
{ |
||||
MSBuildBasedProject activeProject = GetActiveMSBuildBasedProject(); |
||||
if (activeProject != null) { |
||||
return CreateProject(sourceRepository, activeProject); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
MSBuildBasedProject GetActiveMSBuildBasedProject() |
||||
{ |
||||
return GetActiveMSBuildProject() as MSBuildBasedProject; |
||||
} |
||||
|
||||
IPackageManagementProject CreateProject(IPackageRepository sourceRepository, MSBuildBasedProject project) |
||||
{ |
||||
return projectFactory.CreateProject(sourceRepository, project); |
||||
} |
||||
|
||||
IPackageRepository CreatePackageRepository(PackageSource source) |
||||
{ |
||||
return registeredPackageRepositories.CreateRepository(source); |
||||
} |
||||
|
||||
public IPackageManagementProject GetProject(PackageSource source, string projectName) |
||||
{ |
||||
MSBuildBasedProject msbuildProject = GetMSBuildProject(projectName); |
||||
return CreateProject(source, msbuildProject); |
||||
} |
||||
|
||||
MSBuildBasedProject GetMSBuildProject(string name) |
||||
{ |
||||
var openProjects = new OpenMSBuildProjects(projectService); |
||||
return openProjects.FindProject(name); |
||||
} |
||||
|
||||
IPackageManagementProject CreateProject(PackageSource source, MSBuildBasedProject project) |
||||
{ |
||||
IPackageRepository sourceRepository = CreatePackageRepository(source); |
||||
return CreateProject(sourceRepository, project); |
||||
} |
||||
|
||||
public IPackageManagementProject GetProject(IPackageRepository sourceRepository, string projectName) |
||||
{ |
||||
MSBuildBasedProject msbuildProject = GetMSBuildProject(projectName); |
||||
return CreateProject(sourceRepository, msbuildProject); |
||||
} |
||||
|
||||
public IPackageManagementProject GetProject(IPackageRepository sourceRepository, IProject project) |
||||
{ |
||||
var msbuildProject = project as MSBuildBasedProject; |
||||
return CreateProject(sourceRepository, msbuildProject); |
||||
} |
||||
|
||||
public IEnumerable<IProject> GetMSBuildProjects() |
||||
{ |
||||
return projectService.AllProjects.OfType<MSBuildBasedProject>();; |
||||
} |
||||
|
||||
public bool IsOpen { |
||||
get { return OpenSolution != null; } |
||||
} |
||||
|
||||
public bool HasMultipleProjects() |
||||
{ |
||||
return projectService.AllProjects.Count > 1; |
||||
} |
||||
|
||||
public bool IsPackageInstalled(IPackage package) |
||||
{ |
||||
return CreateSolutionPackageRepository().IsInstalled(package); |
||||
} |
||||
|
||||
public ISolutionPackageRepository CreateSolutionPackageRepository() |
||||
{ |
||||
return solutionPackageRepositoryFactory.CreateSolutionPackageRepository(OpenSolution); |
||||
} |
||||
|
||||
public IQueryable<IPackage> GetPackages() |
||||
{ |
||||
List<IPackageManagementProject> projects = GetProjects(ActivePackageRepository).ToList(); |
||||
return CreateSolutionPackageRepository() |
||||
.GetPackages() |
||||
.Where(package => IsPackageInstalledInSolutionOrAnyProject(projects, package)); |
||||
} |
||||
|
||||
bool IsPackageInstalledInSolutionOrAnyProject(IList<IPackageManagementProject> projects, IPackage package) |
||||
{ |
||||
return IsPackageInstalled(package) || IsPackageInstalledInAnyProject(projects, package); |
||||
} |
||||
|
||||
bool IsPackageInstalledInAnyProject(IList<IPackageManagementProject> projects, IPackage package) |
||||
{ |
||||
if (projects.Any(project => project.IsPackageInstalled(package))) { |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public string GetInstallPath(IPackage package) |
||||
{ |
||||
return CreateSolutionPackageRepository().GetInstallPath(package); |
||||
} |
||||
|
||||
public IEnumerable<IPackage> GetPackagesInReverseDependencyOrder() |
||||
{ |
||||
return CreateSolutionPackageRepository().GetPackagesByReverseDependencyOrder(); |
||||
} |
||||
|
||||
public IEnumerable<IPackageManagementProject> GetProjects(IPackageRepository sourceRepository) |
||||
{ |
||||
foreach (MSBuildBasedProject msbuildProject in GetMSBuildProjects()) { |
||||
yield return projectFactory.CreateProject(sourceRepository, msbuildProject); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,208 @@
@@ -0,0 +1,208 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.PackageManagement |
||||
{ |
||||
public class PackageManagementSolution : IPackageManagementSolution |
||||
{ |
||||
IRegisteredPackageRepositories registeredPackageRepositories; |
||||
IPackageManagementProjectService projectService; |
||||
IPackageManagementProjectFactory projectFactory; |
||||
ISolutionPackageRepositoryFactory solutionPackageRepositoryFactory; |
||||
|
||||
public PackageManagementSolution( |
||||
IRegisteredPackageRepositories registeredPackageRepositories, |
||||
IPackageManagementEvents packageManagementEvents) |
||||
: this( |
||||
registeredPackageRepositories, |
||||
new PackageManagementProjectService(), |
||||
new PackageManagementProjectFactory(packageManagementEvents), |
||||
new SolutionPackageRepositoryFactory()) |
||||
{ |
||||
} |
||||
|
||||
public PackageManagementSolution( |
||||
IRegisteredPackageRepositories registeredPackageRepositories, |
||||
IPackageManagementProjectService projectService, |
||||
IPackageManagementProjectFactory projectFactory, |
||||
ISolutionPackageRepositoryFactory solutionPackageRepositoryFactory) |
||||
{ |
||||
this.registeredPackageRepositories = registeredPackageRepositories; |
||||
this.projectFactory = projectFactory; |
||||
this.projectService = projectService; |
||||
this.solutionPackageRepositoryFactory = solutionPackageRepositoryFactory; |
||||
} |
||||
|
||||
public string FileName { |
||||
get { return OpenSolution.FileName; } |
||||
} |
||||
|
||||
ISolution OpenSolution { |
||||
get { return projectService.OpenSolution; } |
||||
} |
||||
|
||||
public IPackageManagementProject GetActiveProject() |
||||
{ |
||||
if (HasActiveProject()) { |
||||
return GetActiveProject(ActivePackageRepository); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
bool HasActiveProject() |
||||
{ |
||||
return GetActiveMSBuildBasedProject() != null; |
||||
} |
||||
|
||||
public IProject GetActiveMSBuildProject() |
||||
{ |
||||
return projectService.CurrentProject; |
||||
} |
||||
|
||||
IPackageRepository ActivePackageRepository { |
||||
get { return registeredPackageRepositories.ActiveRepository; } |
||||
} |
||||
|
||||
public IPackageManagementProject GetActiveProject(IPackageRepository sourceRepository) |
||||
{ |
||||
MSBuildBasedProject activeProject = GetActiveMSBuildBasedProject(); |
||||
if (activeProject != null) { |
||||
return CreateProject(sourceRepository, activeProject); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
MSBuildBasedProject GetActiveMSBuildBasedProject() |
||||
{ |
||||
return GetActiveMSBuildProject() as MSBuildBasedProject; |
||||
} |
||||
|
||||
IPackageManagementProject CreateProject(IPackageRepository sourceRepository, MSBuildBasedProject project) |
||||
{ |
||||
return projectFactory.CreateProject(sourceRepository, project); |
||||
} |
||||
|
||||
IPackageRepository CreatePackageRepository(PackageSource source) |
||||
{ |
||||
return registeredPackageRepositories.CreateRepository(source); |
||||
} |
||||
|
||||
public IPackageManagementProject GetProject(PackageSource source, string projectName) |
||||
{ |
||||
MSBuildBasedProject msbuildProject = GetMSBuildProject(projectName); |
||||
return CreateProject(source, msbuildProject); |
||||
} |
||||
|
||||
MSBuildBasedProject GetMSBuildProject(string name) |
||||
{ |
||||
var openProjects = new OpenMSBuildProjects(projectService); |
||||
return openProjects.FindProject(name); |
||||
} |
||||
|
||||
IPackageManagementProject CreateProject(PackageSource source, MSBuildBasedProject project) |
||||
{ |
||||
IPackageRepository sourceRepository = CreatePackageRepository(source); |
||||
return CreateProject(sourceRepository, project); |
||||
} |
||||
|
||||
public IPackageManagementProject GetProject(IPackageRepository sourceRepository, string projectName) |
||||
{ |
||||
MSBuildBasedProject msbuildProject = GetMSBuildProject(projectName); |
||||
return CreateProject(sourceRepository, msbuildProject); |
||||
} |
||||
|
||||
public IPackageManagementProject GetProject(IPackageRepository sourceRepository, IProject project) |
||||
{ |
||||
var msbuildProject = project as MSBuildBasedProject; |
||||
return CreateProject(sourceRepository, msbuildProject); |
||||
} |
||||
|
||||
public IEnumerable<IProject> GetMSBuildProjects() |
||||
{ |
||||
return projectService.AllProjects.OfType<MSBuildBasedProject>();; |
||||
} |
||||
|
||||
public bool IsOpen { |
||||
get { return OpenSolution != null; } |
||||
} |
||||
|
||||
public bool HasMultipleProjects() |
||||
{ |
||||
return projectService.AllProjects.Count > 1; |
||||
} |
||||
|
||||
public bool IsPackageInstalled(IPackage package) |
||||
{ |
||||
ISolutionPackageRepository repository = CreateSolutionPackageRepository(); |
||||
return repository.IsInstalled(package); |
||||
} |
||||
|
||||
ISolutionPackageRepository CreateSolutionPackageRepository() |
||||
{ |
||||
return solutionPackageRepositoryFactory.CreateSolutionPackageRepository(OpenSolution); |
||||
} |
||||
|
||||
public IQueryable<IPackage> GetPackages() |
||||
{ |
||||
ISolutionPackageRepository repository = CreateSolutionPackageRepository(); |
||||
return repository.GetPackages(); |
||||
} |
||||
|
||||
public IQueryable<IPackage> GetInstalledPackages() |
||||
{ |
||||
ISolutionPackageRepository repository = CreateSolutionPackageRepository(); |
||||
List<IPackageManagementProject> projects = GetProjects(ActivePackageRepository).ToList(); |
||||
return repository |
||||
.GetPackages() |
||||
.Where(package => IsPackageInstalledInSolutionOrAnyProject(projects, package)); |
||||
} |
||||
|
||||
bool IsPackageInstalledInSolutionOrAnyProject(IList<IPackageManagementProject> projects, IPackage package) |
||||
{ |
||||
if (projects.Any(project => project.IsPackageInstalled(package))) { |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public string GetInstallPath(IPackage package) |
||||
{ |
||||
ISolutionPackageRepository repository = CreateSolutionPackageRepository(); |
||||
return repository.GetInstallPath(package); |
||||
} |
||||
|
||||
public IEnumerable<IPackage> GetPackagesInReverseDependencyOrder() |
||||
{ |
||||
ISolutionPackageRepository repository = CreateSolutionPackageRepository(); |
||||
return repository.GetPackagesByReverseDependencyOrder(); |
||||
} |
||||
|
||||
public IEnumerable<IPackageManagementProject> GetProjects(IPackageRepository sourceRepository) |
||||
{ |
||||
foreach (MSBuildBasedProject msbuildProject in GetMSBuildProjects()) { |
||||
yield return projectFactory.CreateProject(sourceRepository, msbuildProject); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,74 +0,0 @@
@@ -1,74 +0,0 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
//using System;
|
||||
//using ICSharpCode.SharpDevelop;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using ICSharpCode.SharpDevelop.Dom.Refactoring;
|
||||
//using ICSharpCode.SharpDevelop.Editor;
|
||||
//using ICSharpCode.SharpDevelop.Gui;
|
||||
//
|
||||
//namespace ICSharpCode.PackageManagement
|
||||
//{
|
||||
// public class RefactoringDocumentView : IRefactoringDocumentView
|
||||
// {
|
||||
// public RefactoringDocumentView(string fileName)
|
||||
// {
|
||||
// View = FileService.OpenFile(fileName);
|
||||
// TextEditor = GetTextEditor();
|
||||
// FormattingStrategy = TextEditor.Language.FormattingStrategy;
|
||||
// RefactoringDocument = LoadDocument();
|
||||
// }
|
||||
//
|
||||
// IViewContent View { get; set; }
|
||||
// ITextEditor TextEditor { get; set; }
|
||||
// IFormattingStrategy FormattingStrategy { get; set; }
|
||||
//
|
||||
// ITextEditor GetTextEditor()
|
||||
// {
|
||||
// var textEditorProvider = View as ITextEditorProvider;
|
||||
// return textEditorProvider.TextEditor;
|
||||
// }
|
||||
//
|
||||
// public IRefactoringDocument RefactoringDocument { get; private set; }
|
||||
//
|
||||
// IRefactoringDocument LoadDocument()
|
||||
// {
|
||||
// return new RefactoringDocumentAdapter(new ThreadSafeDocument(TextEditor.Document));
|
||||
// }
|
||||
//
|
||||
// public ICompilationUnit Parse()
|
||||
// {
|
||||
// if (WorkbenchSingleton.InvokeRequired) {
|
||||
// return WorkbenchSingleton.SafeThreadFunction(() => Parse());
|
||||
// }
|
||||
// return ParserService.ParseViewContent(View).CompilationUnit;
|
||||
// }
|
||||
//
|
||||
// public void IndentLines(int beginLine, int endLine)
|
||||
// {
|
||||
// if (WorkbenchSingleton.InvokeRequired) {
|
||||
// WorkbenchSingleton.SafeThreadCall(() => IndentLines(beginLine, endLine));
|
||||
// } else {
|
||||
// using (IDisposable undoGroup = TextEditor.Document.OpenUndoGroup()) {
|
||||
// FormattingStrategy.IndentLines(TextEditor, beginLine, endLine);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -0,0 +1,68 @@
@@ -0,0 +1,68 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.NRefactory.TypeSystem; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Refactoring; |
||||
|
||||
namespace ICSharpCode.PackageManagement |
||||
{ |
||||
public class ThreadSafeCodeGenerator : ICodeGenerator |
||||
{ |
||||
readonly CodeGenerator codeGenerator; |
||||
readonly IMessageLoop mainThread; |
||||
|
||||
public ThreadSafeCodeGenerator(CodeGenerator codeGenerator) |
||||
{ |
||||
this.codeGenerator = codeGenerator; |
||||
this.mainThread = SD.MainThread; |
||||
} |
||||
|
||||
public void AddImport(FileName fileName, string name) |
||||
{ |
||||
InvokeIfRequired(() => codeGenerator.AddImport(fileName, name)); |
||||
} |
||||
|
||||
public void MakePartial(ITypeDefinition typeDefinition) |
||||
{ |
||||
InvokeIfRequired(() => codeGenerator.MakePartial(typeDefinition)); |
||||
} |
||||
|
||||
void InvokeIfRequired(Action action) |
||||
{ |
||||
mainThread.InvokeIfRequired(action); |
||||
} |
||||
|
||||
public void AddFieldAtStart(ITypeDefinition typeDefinition, Accessibility accessibility, IType fieldType, string name) |
||||
{ |
||||
InvokeIfRequired(() => codeGenerator.AddFieldAtStart(typeDefinition, accessibility, fieldType, name)); |
||||
} |
||||
|
||||
public void AddMethodAtStart(ITypeDefinition typeDefinition, Accessibility accessibility, IType returnType, string name) |
||||
{ |
||||
InvokeIfRequired(() => codeGenerator.AddMethodAtStart(typeDefinition, accessibility, returnType, name)); |
||||
} |
||||
|
||||
public void MakeVirtual(IMember member) |
||||
{ |
||||
InvokeIfRequired(() => codeGenerator.MakeVirtual(member)); |
||||
} |
||||
} |
||||
} |
@ -1,327 +0,0 @@
@@ -1,327 +0,0 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
//using System;
|
||||
//using ICSharpCode.NRefactory.Ast;
|
||||
//using ICSharpCode.PackageManagement;
|
||||
//using ICSharpCode.PackageManagement.EnvDTE;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using ICSharpCode.SharpDevelop.Dom.Refactoring;
|
||||
//using NUnit.Framework;
|
||||
//using PackageManagement.Tests.Helpers;
|
||||
//using Rhino.Mocks;
|
||||
//
|
||||
//namespace PackageManagement.Tests
|
||||
//{
|
||||
// [TestFixture]
|
||||
// public class ClassCodeGeneratorTests
|
||||
// {
|
||||
// ClassHelper helper;
|
||||
// ClassCodeGenerator codeGenerator;
|
||||
// CodeVariable codeVariable;
|
||||
// CodeFunction codeFunction;
|
||||
// IDocumentLoader documentLoader;
|
||||
// IRefactoringDocument document;
|
||||
// FakeCodeGenerator fakeCodeGenerator;
|
||||
// IRefactoringDocumentView documentView;
|
||||
//
|
||||
// [SetUp]
|
||||
// public void Init()
|
||||
// {
|
||||
// helper = new ClassHelper();
|
||||
// document = MockRepository.GenerateStub<IRefactoringDocument>();
|
||||
// documentView = MockRepository.GenerateStub<IRefactoringDocumentView>();
|
||||
// documentLoader = MockRepository.GenerateStub<IDocumentLoader>();
|
||||
// fakeCodeGenerator = helper.CompilationUnitHelper.FakeCodeGenerator;
|
||||
// }
|
||||
//
|
||||
// void CreateClass(string name)
|
||||
// {
|
||||
// helper.CreatePublicClass(name);
|
||||
// helper.SetClassType(ICSharpCode.SharpDevelop.Dom.ClassType.Class);
|
||||
// }
|
||||
//
|
||||
// void CreateCodeGenerator()
|
||||
// {
|
||||
// codeGenerator = new ClassCodeGenerator(helper.Class, documentLoader);
|
||||
// }
|
||||
//
|
||||
// void SetClassFileName(string fileName)
|
||||
// {
|
||||
// helper.SetClassFileName(fileName);
|
||||
// }
|
||||
//
|
||||
// void SetDocumentFileName(string fileName)
|
||||
// {
|
||||
// documentView.Stub(view => view.RefactoringDocument).Return(document);
|
||||
// documentLoader.Stub(loader => loader.LoadRefactoringDocumentView(fileName)).Return(documentView);
|
||||
// }
|
||||
//
|
||||
// void AddFieldToClassForReparse(string name)
|
||||
// {
|
||||
// AddFieldToClassForReparse(name, DomRegion.Empty);
|
||||
// }
|
||||
//
|
||||
// void AddFieldToClassForReparse(string name, DomRegion region)
|
||||
// {
|
||||
// ClassHelper helper = CreateClassHelper("MyClass");
|
||||
// helper.AddFieldToClass(name, region);
|
||||
// AddClassesToReparsedCompilationUnit(helper);
|
||||
// }
|
||||
//
|
||||
// void AddFieldsToClassForReparse(params string[] names)
|
||||
// {
|
||||
// ClassHelper helper = CreateClassHelper("MyClass");
|
||||
// foreach (string name in names) {
|
||||
// helper.AddFieldToClass(name);
|
||||
// }
|
||||
// AddClassesToReparsedCompilationUnit(helper);
|
||||
// }
|
||||
//
|
||||
// void AddClassesToReparsedCompilationUnit(params ClassHelper[] classHelpers)
|
||||
// {
|
||||
// var compilationUnitHelper = new CompilationUnitHelper();
|
||||
// foreach (ClassHelper helper in classHelpers) {
|
||||
// compilationUnitHelper.AddClass(helper.Class);
|
||||
// }
|
||||
// documentView.Stub(d => d.Parse()).Return(compilationUnitHelper.CompilationUnit);
|
||||
// }
|
||||
//
|
||||
// ClassHelper CreateClassHelper(string name)
|
||||
// {
|
||||
// var helper = new ClassHelper();
|
||||
// helper.CreateClass(name);
|
||||
// return helper;
|
||||
// }
|
||||
//
|
||||
// void AddMethodToClassForReparse(string name)
|
||||
// {
|
||||
// AddMethodToClassForReparse(name, DomRegion.Empty, DomRegion.Empty);
|
||||
// }
|
||||
//
|
||||
// void AddMethodToClassForReparse(string name, DomRegion region, DomRegion bodyRegion)
|
||||
// {
|
||||
// ClassHelper helper = CreateClassHelper("MyClass");
|
||||
// helper.AddMethodToClass(name, region, bodyRegion);
|
||||
// AddClassesToReparsedCompilationUnit(helper);
|
||||
// }
|
||||
//
|
||||
// void AddMethodsToClassForReparse(params string[] names)
|
||||
// {
|
||||
// ClassHelper helper = CreateClassHelper("MyClass");
|
||||
// foreach (string name in names) {
|
||||
// helper.AddMethodToClass(name);
|
||||
// }
|
||||
// AddClassesToReparsedCompilationUnit(helper);
|
||||
// }
|
||||
//
|
||||
// void AddPublicVariable(string name, string type)
|
||||
// {
|
||||
// codeVariable = codeGenerator.AddPublicVariable(name, type);
|
||||
// }
|
||||
//
|
||||
// void AddPublicMethod(string name, string type)
|
||||
// {
|
||||
// codeFunction = codeGenerator.AddPublicMethod(name, type);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void AddPublicVariable_VariableTypeIsString_ReturnsCodeVariable()
|
||||
// {
|
||||
// CreateClass("MyClass");
|
||||
// CreateCodeGenerator();
|
||||
// string fileName = @"d:\projects\myproject\MyClass.cs";
|
||||
// SetClassFileName(fileName);
|
||||
// SetDocumentFileName(fileName);
|
||||
// AddFieldToClassForReparse("MyClass.MyVariable", new DomRegion(1, 2, 1, 5));
|
||||
//
|
||||
// AddPublicVariable("MyVariable", "System.String");
|
||||
//
|
||||
// TextPoint start = (TextPoint)codeVariable.GetStartPoint();
|
||||
// TextPoint end = (TextPoint)codeVariable.GetEndPoint();
|
||||
// Assert.AreEqual("MyVariable", codeVariable.Name);
|
||||
// Assert.AreEqual(1, start.Line);
|
||||
// Assert.AreEqual(2, start.LineCharOffset);
|
||||
// Assert.AreEqual(1, end.Line);
|
||||
// Assert.AreEqual(5, end.LineCharOffset);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void AddPublicVariable_VariableTypeIsCustomType_CodeForFieldAddedAtEndOfClass()
|
||||
// {
|
||||
// CreateClass("MyClass");
|
||||
// CreateCodeGenerator();
|
||||
// var classRegion = new DomRegion(1, 2, 3, 4);
|
||||
// helper.SetClassRegion(classRegion);
|
||||
// string fileName = @"d:\projects\myproject\MyClass.cs";
|
||||
// SetClassFileName(fileName);
|
||||
// SetDocumentFileName(fileName);
|
||||
// AddFieldToClassForReparse("MyClass.MyVariable");
|
||||
//
|
||||
// AddPublicVariable("MyVar", "MyType");
|
||||
//
|
||||
// FieldDeclaration field = fakeCodeGenerator.NodePassedToInsertCodeAtEnd as FieldDeclaration;
|
||||
// Assert.AreEqual(classRegion, fakeCodeGenerator.RegionPassedToInsertCodeAtEnd);
|
||||
// Assert.AreEqual(document, fakeCodeGenerator.DocumentPassedToInsertCodeAtEnd);
|
||||
// Assert.AreEqual(Modifiers.Public, field.Modifier);
|
||||
// Assert.AreEqual("MyType", field.TypeReference.Type);
|
||||
// Assert.AreEqual("MyVar", field.Fields[0].Name);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void AddPublicVariable_ReparsedClassHasTwoFields_LastFieldReturned()
|
||||
// {
|
||||
// CreateClass("MyClass");
|
||||
// CreateCodeGenerator();
|
||||
// string fileName = @"d:\projects\myproject\MyClass.cs";
|
||||
// SetClassFileName(fileName);
|
||||
// SetDocumentFileName(fileName);
|
||||
// AddFieldsToClassForReparse("MyClass.First", "MyClass.MyVariable");
|
||||
//
|
||||
// AddPublicVariable("MyVariable", "System.String");
|
||||
//
|
||||
// Assert.AreEqual("MyVariable", codeVariable.Name);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void AddPublicVariable_ReparsedCompilationUnitHasThreeClasses_VariableReturnedFromCorrectClass()
|
||||
// {
|
||||
// CreateClass("MyClass2");
|
||||
// CreateCodeGenerator();
|
||||
// string fileName = @"d:\projects\myproject\MyClass2.cs";
|
||||
// SetClassFileName(fileName);
|
||||
// SetDocumentFileName(fileName);
|
||||
// ClassHelper class1 = CreateClassHelper("MyClass1");
|
||||
// ClassHelper class2 = CreateClassHelper("MyClass2");
|
||||
// ClassHelper class3 = CreateClassHelper("MyClass3");
|
||||
//
|
||||
// class2.AddFieldToClass("MyClass2.MyVariable");
|
||||
//
|
||||
// AddClassesToReparsedCompilationUnit(class1, class2, class3);
|
||||
//
|
||||
// AddPublicVariable("MyVariable", "System.String");
|
||||
//
|
||||
// Assert.AreEqual("MyVariable", codeVariable.Name);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void AddPublicMethod_MethodReturnTypeIsSystemCustomType_CodeForMethodAddedAtEndOfClass()
|
||||
// {
|
||||
// CreateClass("MyClass");
|
||||
// CreateCodeGenerator();
|
||||
// var classRegion = new DomRegion(1, 2, 3, 4);
|
||||
// helper.SetClassRegion(classRegion);
|
||||
// string fileName = @"d:\projects\myproject\MyClass.cs";
|
||||
// SetClassFileName(fileName);
|
||||
// SetDocumentFileName(fileName);
|
||||
// AddMethodToClassForReparse("MyClass.MyMethod");
|
||||
//
|
||||
// AddPublicMethod("MyMethod", "MyType");
|
||||
//
|
||||
// MethodDeclaration method = fakeCodeGenerator.NodePassedToInsertCodeAtEnd as MethodDeclaration;
|
||||
// Assert.AreEqual(classRegion, fakeCodeGenerator.RegionPassedToInsertCodeAtEnd);
|
||||
// Assert.AreEqual(document, fakeCodeGenerator.DocumentPassedToInsertCodeAtEnd);
|
||||
// Assert.AreEqual(Modifiers.None, method.Modifier);
|
||||
// Assert.AreEqual("MyType", method.TypeReference.Type);
|
||||
// Assert.AreEqual("MyMethod", method.Name);
|
||||
// Assert.IsNotNull(method.Body);
|
||||
// Assert.IsTrue(method.Body.IsNull);
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Workaround NRefactory giving incorrect begin column for interface methods that use fully
|
||||
// /// qualified return types (e.g. System.Object). Begin column points to the "Object" part of the
|
||||
// /// return type not the start of the return type.
|
||||
// /// </summary>
|
||||
// [Test]
|
||||
// public void AddPublicMethod_MethodReturnTypeIsSystemObject_SystemNotAddedToReturnType()
|
||||
// {
|
||||
// CreateClass("MyClass");
|
||||
// CreateCodeGenerator();
|
||||
// var classRegion = new DomRegion(1, 2, 3, 4);
|
||||
// helper.SetClassRegion(classRegion);
|
||||
// string fileName = @"d:\projects\myproject\MyClass.cs";
|
||||
// SetClassFileName(fileName);
|
||||
// SetDocumentFileName(fileName);
|
||||
// AddMethodToClassForReparse("MyClass.MyMethod");
|
||||
//
|
||||
// AddPublicMethod("MyMethod", "System.Object");
|
||||
//
|
||||
// MethodDeclaration method = fakeCodeGenerator.NodePassedToInsertCodeAtEnd as MethodDeclaration;
|
||||
// Assert.AreEqual("Object", method.TypeReference.Type);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void AddPublicMethod_MethodReturnTypeIsString_ReturnsCodeMethod()
|
||||
// {
|
||||
// CreateClass("MyClass");
|
||||
// CreateCodeGenerator();
|
||||
// string fileName = @"d:\projects\myproject\MyClass.cs";
|
||||
// SetClassFileName(fileName);
|
||||
// SetDocumentFileName(fileName);
|
||||
//
|
||||
// AddMethodToClassForReparse("MyClass.MyMethod", new DomRegion(1, 2, 1, 5), new DomRegion(1, 5, 3, 3));
|
||||
//
|
||||
// AddPublicMethod("MyMethod", "System.String");
|
||||
//
|
||||
// TextPoint start = (TextPoint)codeFunction.GetStartPoint();
|
||||
// TextPoint end = (TextPoint)codeFunction.GetEndPoint();
|
||||
// Assert.AreEqual("MyMethod", codeFunction.Name);
|
||||
// Assert.AreEqual(1, start.Line);
|
||||
// Assert.AreEqual(2, start.LineCharOffset);
|
||||
// Assert.AreEqual(3, end.Line);
|
||||
// Assert.AreEqual(3, end.LineCharOffset);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void AddPublicMethod_ReparsedClassHasTwoMethods_LastMethodReturned()
|
||||
// {
|
||||
// CreateClass("MyClass");
|
||||
// CreateCodeGenerator();
|
||||
// string fileName = @"d:\projects\myproject\MyClass.cs";
|
||||
// SetClassFileName(fileName);
|
||||
// SetDocumentFileName(fileName);
|
||||
// AddMethodsToClassForReparse("MyClass.First", "MyClass.MyMethod");
|
||||
//
|
||||
// AddPublicMethod("MyMethod", "System.String");
|
||||
//
|
||||
// Assert.AreEqual("MyMethod", codeFunction.Name);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void AddPublicFunction_ReparsedCompilationUnitHasThreeClasses_MethodReturnedFromCorrectClass()
|
||||
// {
|
||||
// CreateClass("MyClass2");
|
||||
// CreateCodeGenerator();
|
||||
// string fileName = @"d:\projects\myproject\MyClass2.cs";
|
||||
// SetClassFileName(fileName);
|
||||
// SetDocumentFileName(fileName);
|
||||
// ClassHelper class1 = CreateClassHelper("MyClass1");
|
||||
// ClassHelper class2 = CreateClassHelper("MyClass2");
|
||||
// ClassHelper class3 = CreateClassHelper("MyClass3");
|
||||
//
|
||||
// class2.AddMethodToClass("MyClass2.MyMethod");
|
||||
//
|
||||
// AddClassesToReparsedCompilationUnit(class1, class2, class3);
|
||||
//
|
||||
// AddPublicMethod("MyMethod", "System.String");
|
||||
//
|
||||
// Assert.AreEqual("MyMethod", codeFunction.Name);
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,180 +0,0 @@
@@ -1,180 +0,0 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
//using System;
|
||||
//using ICSharpCode.PackageManagement;
|
||||
//using ICSharpCode.SharpDevelop.Dom.Refactoring;
|
||||
//using NUnit.Framework;
|
||||
//using PackageManagement.Tests.Helpers;
|
||||
//using Rhino.Mocks;
|
||||
//
|
||||
//namespace PackageManagement.Tests
|
||||
//{
|
||||
// [TestFixture]
|
||||
// public class ClassKindUpdaterTests
|
||||
// {
|
||||
// ClassKindUpdater updater;
|
||||
// ClassHelper classHelper;
|
||||
// IRefactoringDocument document;
|
||||
// IDocumentLoader documentLoader;
|
||||
//
|
||||
// [SetUp]
|
||||
// public void Init()
|
||||
// {
|
||||
// classHelper = new ClassHelper();
|
||||
// document = MockRepository.GenerateStub<IRefactoringDocument>();
|
||||
// documentLoader = MockRepository.GenerateStub<IDocumentLoader>();
|
||||
// }
|
||||
//
|
||||
// void CreatePublicCSharpClass()
|
||||
// {
|
||||
// classHelper.CreatePublicClass("MyClass");
|
||||
// classHelper.ProjectContentHelper.ProjectContentIsForCSharpProject();
|
||||
// }
|
||||
//
|
||||
// void CreatePublicVisualBasicClass()
|
||||
// {
|
||||
// classHelper.CreatePublicClass("MyClass");
|
||||
// classHelper.ProjectContentHelper.ProjectContentIsForVisualBasicProject();
|
||||
// }
|
||||
//
|
||||
// void SetDocumentFileName(string fileName)
|
||||
// {
|
||||
// documentLoader.Stub(loader => loader.LoadRefactoringDocument(fileName)).Return(document);
|
||||
// }
|
||||
//
|
||||
// void CreateClassKindUpdater()
|
||||
// {
|
||||
// updater = new ClassKindUpdater(classHelper.Class, documentLoader);
|
||||
// }
|
||||
//
|
||||
// void SetClassFileName(string fileName)
|
||||
// {
|
||||
// classHelper.SetClassFileName(fileName);
|
||||
// SetDocumentFileName(fileName);
|
||||
// }
|
||||
//
|
||||
// void SetClassDeclarationLineWithOffset(int line, string text, int offset)
|
||||
// {
|
||||
// classHelper.SetRegionBeginLine(line);
|
||||
// SetDocumentLineText(line, text, offset);
|
||||
// }
|
||||
//
|
||||
// void SetClassDeclarationLine(int line, string text)
|
||||
// {
|
||||
// SetClassDeclarationLineWithOffset(line, text, 0);
|
||||
// }
|
||||
//
|
||||
// void SetDocumentLineText(int lineNumber, string text, int offset)
|
||||
// {
|
||||
// IRefactoringDocumentLine documentLine = MockRepository.GenerateStub<IRefactoringDocumentLine>();
|
||||
// documentLine.Stub(line => line.Text).Return(text);
|
||||
// documentLine.Stub(line => line.Offset).Return(offset);
|
||||
// document.Stub(doc => doc.GetLine(lineNumber)).Return(documentLine);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MakeClassPartial_PublicCSharpClassWithNoOtherModifiers_OpensFileContainingClassInSharpDevelop()
|
||||
// {
|
||||
// CreatePublicCSharpClass();
|
||||
// CreateClassKindUpdater();
|
||||
// string fileName = @"d:\projects\MyProject\MyClass.cs";
|
||||
// SetClassFileName(fileName);
|
||||
// SetClassDeclarationLine(1, "public class MyClass");
|
||||
//
|
||||
// updater.MakeClassPartial();
|
||||
//
|
||||
// documentLoader.AssertWasCalled(loader => loader.LoadRefactoringDocument(fileName));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MakeClassPartial_PublicCSharpClassWithNoOtherModifiers_AddsPartialKeywordToClassDefinition()
|
||||
// {
|
||||
// CreatePublicCSharpClass();
|
||||
// CreateClassKindUpdater();
|
||||
// SetClassFileName(@"d:\projects\MyProject\MyClass.cs");
|
||||
// SetClassDeclarationLine(1, "public class MyClass");
|
||||
//
|
||||
// updater.MakeClassPartial();
|
||||
//
|
||||
// document.AssertWasCalled(doc => doc.Insert(7, "partial "));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MakeClassPartial_PublicCSharpClassThatIsAlreadyPartial_ClassDefinitionIsUnchanged()
|
||||
// {
|
||||
// CreatePublicCSharpClass();
|
||||
// CreateClassKindUpdater();
|
||||
// classHelper.MakeClassPartial();
|
||||
// SetClassFileName(@"d:\projects\MyProject\MyClass.cs");
|
||||
// SetClassDeclarationLine(1, "public class MyClass");
|
||||
//
|
||||
// updater.MakeClassPartial();
|
||||
//
|
||||
// document.AssertWasNotCalled(doc => doc.Insert(Arg<int>.Is.Anything, Arg<string>.Is.Anything));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MakeClassPartial_PublicVisualBasicClassWithNoOtherModifiers_AddsVisualBasicPartialKeywordToClassDefinition()
|
||||
// {
|
||||
// CreatePublicVisualBasicClass();
|
||||
// CreateClassKindUpdater();
|
||||
// SetClassFileName(@"d:\projects\MyProject\MyClass.vb");
|
||||
// SetClassDeclarationLine(1, "Public Class MyClass");
|
||||
//
|
||||
// updater.MakeClassPartial();
|
||||
//
|
||||
// document.AssertWasCalled(doc => doc.Insert(7, "Partial "));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MakeClassPartial_NoClassKeywordInClassDeclarationLine_ExceptionIsThrown()
|
||||
// {
|
||||
// CreatePublicCSharpClass();
|
||||
// CreateClassKindUpdater();
|
||||
// SetClassFileName(@"d:\projects\MyProject\test.cs");
|
||||
// SetClassDeclarationLine(1, "public test");
|
||||
//
|
||||
// Assert.Throws<ApplicationException>(() => updater.MakeClassPartial());
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MakeClassPartial_NoClassKeywordButClassNameIncludesClassKeyword_ExceptionIsThrown()
|
||||
// {
|
||||
// CreatePublicCSharpClass();
|
||||
// CreateClassKindUpdater();
|
||||
// SetClassFileName(@"d:\projects\MyProject\MyClass.cs");
|
||||
// SetClassDeclarationLine(1, "public MyClass");
|
||||
//
|
||||
// Assert.Throws<ApplicationException>(() => updater.MakeClassPartial());
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MakeClassPartial_PublicCSharpClassNotOnFirstLine_AddsPartialKeywordToClassDefinitionAtCorrectOffset()
|
||||
// {
|
||||
// CreatePublicCSharpClass();
|
||||
// CreateClassKindUpdater();
|
||||
// SetClassFileName(@"d:\projects\MyProject\MyClass.cs");
|
||||
// SetClassDeclarationLineWithOffset(1, "public class MyClass", offset: 10);
|
||||
//
|
||||
// updater.MakeClassPartial();
|
||||
//
|
||||
// document.AssertWasCalled(doc => doc.Insert(17, "partial "));
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,86 +0,0 @@
@@ -1,86 +0,0 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using ICSharpCode.PackageManagement.EnvDTE;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using NUnit.Framework;
|
||||
//using PackageManagement.Tests.Helpers;
|
||||
//
|
||||
//namespace PackageManagement.Tests.EnvDTE
|
||||
//{
|
||||
// [TestFixture]
|
||||
// public class CodeAttributesTests
|
||||
// {
|
||||
// CodeAttributes attributes;
|
||||
// ClassHelper helper;
|
||||
//
|
||||
// [SetUp]
|
||||
// public void Init()
|
||||
// {
|
||||
// helper = new ClassHelper();
|
||||
// }
|
||||
//
|
||||
// void CreateCodeAttributes()
|
||||
// {
|
||||
// attributes = new CodeAttributes(helper.Class);
|
||||
// }
|
||||
//
|
||||
// void CreateMSBuildClass()
|
||||
// {
|
||||
// helper.CreateClass("MyClass");
|
||||
// }
|
||||
//
|
||||
// void AddAttributeToClass(string name)
|
||||
// {
|
||||
// helper.AddAttributeToClass(name);
|
||||
// }
|
||||
//
|
||||
// List<CodeElement> GetEnumerator()
|
||||
// {
|
||||
// return attributes.ToList();
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GetEnumerator_ClassHasOneAttribute_ReturnsOneAttribute()
|
||||
// {
|
||||
// CreateMSBuildClass();
|
||||
// AddAttributeToClass("TestAttribute");
|
||||
// CreateCodeAttributes();
|
||||
//
|
||||
// CodeAttribute2 attribute = attributes.FirstCodeAttribute2OrDefault();
|
||||
//
|
||||
// Assert.AreEqual(1, attributes.Count);
|
||||
// Assert.AreEqual("Test", attribute.Name);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Item_GetItemByNameWhenClassHasOneAttribute_ReturnsOneAttribute()
|
||||
// {
|
||||
// CreateMSBuildClass();
|
||||
// AddAttributeToClass("TestAttribute");
|
||||
// CreateCodeAttributes();
|
||||
//
|
||||
// CodeAttribute2 attribute = attributes.Item("Test") as CodeAttribute2;
|
||||
//
|
||||
// Assert.AreEqual("Test", attribute.Name);
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,162 +0,0 @@
@@ -1,162 +0,0 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using ICSharpCode.PackageManagement.EnvDTE;
|
||||
//using NUnit.Framework;
|
||||
//using PackageManagement.Tests.Helpers;
|
||||
//
|
||||
//namespace PackageManagement.Tests.EnvDTE
|
||||
//{
|
||||
// [TestFixture]
|
||||
// public class CodeElementsInNamespaceTests
|
||||
// {
|
||||
// CodeElementsInNamespace codeElements;
|
||||
// ProjectContentHelper helper;
|
||||
//
|
||||
// [SetUp]
|
||||
// public void Init()
|
||||
// {
|
||||
// helper = new ProjectContentHelper();
|
||||
// }
|
||||
//
|
||||
// void CreateCodeElements(string namespaceName)
|
||||
// {
|
||||
// codeElements = new CodeElementsInNamespace(helper.ProjectContent, namespaceName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Count_NoItemsInNamespace_ReturnsZero()
|
||||
// {
|
||||
// helper.NoCompletionItemsInNamespace("Test");
|
||||
// CreateCodeElements("Test");
|
||||
//
|
||||
// int count = codeElements.Count;
|
||||
//
|
||||
// Assert.AreEqual(0, count);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GetEnumerator_NoItemsInNamespace_ReturnsNoItems()
|
||||
// {
|
||||
// helper.NoCompletionItemsInNamespace("Test");
|
||||
// CreateCodeElements("Test");
|
||||
//
|
||||
// List<CodeElement> codeElementsList = codeElements.ToList();
|
||||
//
|
||||
// Assert.AreEqual(0, codeElementsList.Count);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GetEnumerator_OneNamespaceCompletionEntryInNamespace_ReturnsOneCodeNamespace()
|
||||
// {
|
||||
// helper.AddNamespaceCompletionEntryInNamespace("Parent", "Child");
|
||||
// CreateCodeElements("Parent");
|
||||
//
|
||||
// CodeNamespace codeNamespace = codeElements.FirstCodeNamespaceOrDefault();
|
||||
//
|
||||
// Assert.AreEqual(1, codeElements.Count);
|
||||
// Assert.AreEqual("Child", codeNamespace.Name);
|
||||
// Assert.AreEqual("Parent.Child", codeNamespace.FullName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GetEnumerator_OneClassCompletionEntryInNamespace_ReturnsOneCodeClass()
|
||||
// {
|
||||
// helper.AddClassToProjectContentAndCompletionEntries("Test", "Test.MyClass");
|
||||
// CreateCodeElements("Test");
|
||||
//
|
||||
// CodeClass2 codeClass = codeElements.ToList().FirstOrDefault() as CodeClass2;
|
||||
//
|
||||
// Assert.AreEqual(1, codeElements.Count);
|
||||
// Assert.AreEqual("MyClass", codeClass.Name);
|
||||
// Assert.AreEqual("Test.MyClass", codeClass.FullName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GetEnumerator_UnknownCompletionEntryInNamespace_ReturnsNoItems()
|
||||
// {
|
||||
// helper.AddUnknownCompletionEntryTypeToNamespace("Test");
|
||||
// CreateCodeElements("Test");
|
||||
//
|
||||
// List<CodeElement> codeElementsList = codeElements.ToList();
|
||||
//
|
||||
// Assert.AreEqual(0, codeElementsList.Count);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GetEnumerator_EmptyNamespaceEntry_ReturnsNoItems()
|
||||
// {
|
||||
// helper.AddNamespaceCompletionEntryInNamespace(String.Empty, String.Empty);
|
||||
// CreateCodeElements(String.Empty);
|
||||
//
|
||||
// List<CodeElement> codeElementsList = codeElements.ToList();
|
||||
//
|
||||
// Assert.AreEqual(0, codeElementsList.Count);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GetEnumerator_ParentChildAndGrandChildNamespaces_ReturnsOneCodeNamespaceWhichHasGrandChildNamespace()
|
||||
// {
|
||||
// helper.AddNamespaceCompletionEntryInNamespace("Parent", "Child");
|
||||
// helper.AddNamespaceCompletionEntryInNamespace("Parent.Child", "GrandChild");
|
||||
// helper.NoCompletionItemsInNamespace("Parent.Child.GrandChild");
|
||||
// CreateCodeElements("Parent");
|
||||
//
|
||||
// CodeNamespace codeNamespace = codeElements.FirstCodeNamespaceOrDefault();
|
||||
// CodeNamespace grandChildNamespace = codeNamespace.Members.FirstCodeNamespaceOrDefault();
|
||||
//
|
||||
// Assert.AreEqual("GrandChild", grandChildNamespace.Name);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Item_OneClassCompletionEntryAndFirstItemSelected_ReturnsOneCodeClass()
|
||||
// {
|
||||
// helper.AddClassToProjectContentAndCompletionEntries("Test", "Test.MyClass");
|
||||
// CreateCodeElements("Test");
|
||||
//
|
||||
// CodeClass2 codeClass = codeElements.Item(1) as CodeClass2;
|
||||
//
|
||||
// Assert.AreEqual("Test.MyClass", codeClass.FullName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Item_OneClassCompletionEntryAndItemSelectedByName_ReturnsOneCodeClass()
|
||||
// {
|
||||
// helper.AddClassToProjectContentAndCompletionEntries("Test", "Test.MyClass");
|
||||
// CreateCodeElements("Test");
|
||||
//
|
||||
// CodeClass2 codeClass = codeElements.Item("MyClass") as CodeClass2;
|
||||
//
|
||||
// Assert.AreEqual("Test.MyClass", codeClass.FullName);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Item_OneInterfaceCompletionEntryAndItemSelectedByName_ReturnsOneCodeInterface()
|
||||
// {
|
||||
// helper.AddInterfaceToProjectContentAndCompletionEntries("Test", "Test.IClass");
|
||||
// CreateCodeElements("Test");
|
||||
//
|
||||
// CodeInterface codeInterface = codeElements.Item("IClass") as CodeInterface;
|
||||
//
|
||||
// Assert.AreEqual("Test.IClass", codeInterface.FullName);
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,66 +0,0 @@
@@ -1,66 +0,0 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
//using System;
|
||||
//using ICSharpCode.PackageManagement.EnvDTE;
|
||||
//using NUnit.Framework;
|
||||
//using PackageManagement.Tests.Helpers;
|
||||
//using Rhino.Mocks;
|
||||
//
|
||||
//namespace PackageManagement.Tests.EnvDTE
|
||||
//{
|
||||
// [TestFixture]
|
||||
// public class CodeImportTests
|
||||
// {
|
||||
// CodeImport codeImport;
|
||||
// UsingHelper helper;
|
||||
//
|
||||
// void CreateCodeImport(string namespaceName)
|
||||
// {
|
||||
// helper = new UsingHelper();
|
||||
// helper.AddNamespace(namespaceName);
|
||||
// codeImport = new CodeImport(helper.Using);
|
||||
// }
|
||||
//
|
||||
// void CreateCodeImportWithNoNamespace()
|
||||
// {
|
||||
// helper = new UsingHelper();
|
||||
// codeImport = new CodeImport(helper.Using);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Kind_SystemXmlNamespace_ReturnsImport()
|
||||
// {
|
||||
// CreateCodeImport("System.Xml");
|
||||
//
|
||||
// global::EnvDTE.vsCMElement kind = codeImport.Kind;
|
||||
//
|
||||
// Assert.AreEqual(global::EnvDTE.vsCMElement.vsCMElementImportStmt, kind);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Namespace_UsingHasNoNamespacesAndAliasesIsNull_ReturnsEmptyString()
|
||||
// {
|
||||
// CreateCodeImportWithNoNamespace();
|
||||
//
|
||||
// string name = codeImport.Namespace;
|
||||
//
|
||||
// Assert.AreEqual(String.Empty, name);
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,66 +0,0 @@
@@ -1,66 +0,0 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
//using System;
|
||||
//using ICSharpCode.PackageManagement.EnvDTE;
|
||||
//using NUnit.Framework;
|
||||
//using PackageManagement.Tests.Helpers;
|
||||
//
|
||||
//namespace PackageManagement.Tests.EnvDTE
|
||||
//{
|
||||
// [TestFixture]
|
||||
// public class CodeParameterTests
|
||||
// {
|
||||
// ParameterHelper helper;
|
||||
// CodeParameter parameter;
|
||||
//
|
||||
// [SetUp]
|
||||
// public void Init()
|
||||
// {
|
||||
// helper = new ParameterHelper();
|
||||
// }
|
||||
//
|
||||
// void CreateParameter()
|
||||
// {
|
||||
// parameter = new CodeParameter(null, helper.Parameter);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Kind_Parameter_ReturnsParameter()
|
||||
// {
|
||||
// CreateParameter();
|
||||
//
|
||||
// global::EnvDTE.vsCMElement kind = parameter.Kind;
|
||||
//
|
||||
// Assert.AreEqual(global::EnvDTE.vsCMElement.vsCMElementParameter, kind);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Attributes_ParameterHasOneAttribute_ReturnsOneAttribute()
|
||||
// {
|
||||
// CreateParameter();
|
||||
// helper.AddAttributeToParameter("System.Web.Mvc.BindAttribute");
|
||||
//
|
||||
// global::EnvDTE.CodeElements attributes = parameter.Attributes;
|
||||
//
|
||||
// CodeAttribute2 attribute = parameter.Attributes.FirstCodeAttribute2OrDefault();
|
||||
// Assert.AreEqual(1, attributes.Count);
|
||||
// Assert.AreEqual("System.Web.Mvc.BindAttribute", attribute.FullName);
|
||||
// }
|
||||
// }
|
||||
//}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue