50 changed files with 1095 additions and 784 deletions
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// CodeAction.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <mkrueger@xamarin.com>
|
||||
//
|
||||
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
|
||||
//
|
||||
// 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.NRefactory.CSharp.Refactoring |
||||
{ |
||||
public class CodeAction |
||||
{ |
||||
public string Description { |
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public Action<Script> Run { |
||||
get; |
||||
private set; |
||||
} |
||||
|
||||
public CodeAction (string description, Action<Script> action) |
||||
{ |
||||
if (action == null) { |
||||
throw new ArgumentNullException ("action"); |
||||
} |
||||
if (description == null) { |
||||
throw new ArgumentNullException ("description"); |
||||
} |
||||
Description = description; |
||||
Run = action; |
||||
} |
||||
} |
||||
} |
||||
|
@ -0,0 +1,76 @@
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// CreateBackingStore.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <mkrueger@novell.com>
|
||||
//
|
||||
// Copyright (c) 2011 Mike Krüger <mkrueger@novell.com>
|
||||
//
|
||||
// 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; |
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp.Refactoring |
||||
{ |
||||
[ContextAction("Create backing store for auto property", Description = "Creates a backing field for an auto property.")] |
||||
public class CreateBackingStore : ICodeActionProvider |
||||
{ |
||||
public IEnumerable<CodeAction> GetActions(RefactoringContext context) |
||||
{ |
||||
var property = context.GetNode<PropertyDeclaration>(); |
||||
if (!(property != null && |
||||
!property.Getter.IsNull && !property.Setter.IsNull && // automatic properties always need getter & setter
|
||||
property.Getter.Body.IsNull && |
||||
property.Setter.Body.IsNull)) { |
||||
yield break; |
||||
} |
||||
|
||||
yield return new CodeAction (context.TranslateString("Add null check for parameter"), script => { |
||||
string backingStoreName = context.GetNameProposal (property.Name); |
||||
|
||||
// create field
|
||||
var backingStore = new FieldDeclaration (); |
||||
backingStore.ReturnType = property.ReturnType.Clone (); |
||||
|
||||
var initializer = new VariableInitializer (backingStoreName); |
||||
backingStore.Variables.Add (initializer); |
||||
|
||||
// create new property & implement the get/set bodies
|
||||
var newProperty = (PropertyDeclaration)property.Clone (); |
||||
Expression id1; |
||||
if (backingStoreName == "value") |
||||
id1 = new ThisReferenceExpression().Member("value"); |
||||
else |
||||
id1 = new IdentifierExpression (backingStoreName); |
||||
Expression id2 = id1.Clone(); |
||||
newProperty.Getter.Body = new BlockStatement () { |
||||
new ReturnStatement (id1) |
||||
}; |
||||
newProperty.Setter.Body = new BlockStatement () { |
||||
new AssignmentExpression (id2, AssignmentOperatorType.Assign, new IdentifierExpression ("value")) |
||||
}; |
||||
|
||||
script.Replace (property, newProperty); |
||||
script.InsertBefore (property, backingStore); |
||||
script.Link (initializer, id1, id2); |
||||
}); |
||||
} |
||||
} |
||||
} |
||||
|
@ -0,0 +1,112 @@
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// CreateEventInvocator.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <mkrueger@novell.com>
|
||||
//
|
||||
// Copyright (c) 2011 Mike Krüger <mkrueger@novell.com>
|
||||
//
|
||||
// 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.Linq; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.NRefactory.TypeSystem; |
||||
using System.Threading; |
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp.Refactoring |
||||
{ |
||||
[ContextAction("Create event invocator", Description = "Creates a standard OnXXX event method.")] |
||||
public class CreateEventInvocator : ICodeActionProvider |
||||
{ |
||||
public IEnumerable<CodeAction> GetActions(RefactoringContext context) |
||||
{ |
||||
VariableInitializer initializer; |
||||
var eventDeclaration = GetEventDeclaration(context, out initializer); |
||||
if (eventDeclaration == null) { |
||||
yield break; |
||||
} |
||||
var type = (TypeDeclaration)eventDeclaration.Parent; |
||||
if (type.Members.Any(m => m is MethodDeclaration && ((MethodDeclaration)m).Name == "On" + initializer.Name)) { |
||||
yield break; |
||||
} |
||||
var resolvedType = context.Resolve(eventDeclaration.ReturnType).Type; |
||||
if (resolvedType.Kind == TypeKind.Unknown) { |
||||
yield break; |
||||
} |
||||
var invokeMethod = resolvedType.GetDelegateInvokeMethod(); |
||||
if (invokeMethod == null) { |
||||
yield break; |
||||
} |
||||
yield return new CodeAction (context.TranslateString("Create event invocator"), script => { |
||||
bool hasSenderParam = false; |
||||
IEnumerable<IParameter> pars = invokeMethod.Parameters; |
||||
if (invokeMethod.Parameters.Any ()) { |
||||
var first = invokeMethod.Parameters [0]; |
||||
if (first.Name == "sender" /*&& first.Type == "System.Object"*/) { |
||||
hasSenderParam = true; |
||||
pars = invokeMethod.Parameters.Skip (1); |
||||
} |
||||
} |
||||
const string handlerName = "handler"; |
||||
|
||||
var arguments = new List<Expression> (); |
||||
if (hasSenderParam) |
||||
arguments.Add (new ThisReferenceExpression ()); |
||||
foreach (var par in pars) |
||||
arguments.Add (new IdentifierExpression (par.Name)); |
||||
|
||||
var methodDeclaration = new MethodDeclaration () { |
||||
Name = "On" + initializer.Name, |
||||
ReturnType = new PrimitiveType ("void"), |
||||
Modifiers = ICSharpCode.NRefactory.CSharp.Modifiers.Protected | ICSharpCode.NRefactory.CSharp.Modifiers.Virtual, |
||||
Body = new BlockStatement () { |
||||
new VariableDeclarationStatement (eventDeclaration.ReturnType.Clone (), handlerName, new MemberReferenceExpression (new ThisReferenceExpression (), initializer.Name)), |
||||
new IfElseStatement () { |
||||
Condition = new BinaryOperatorExpression (new IdentifierExpression (handlerName), BinaryOperatorType.InEquality, new PrimitiveExpression (null)), |
||||
TrueStatement = new ExpressionStatement (new InvocationExpression (new IdentifierExpression (handlerName), arguments)) |
||||
} |
||||
} |
||||
}; |
||||
|
||||
foreach (var par in pars) { |
||||
var typeName = context.CreateShortType (par.Type); |
||||
var decl = new ParameterDeclaration (typeName, par.Name); |
||||
methodDeclaration.Parameters.Add (decl); |
||||
} |
||||
|
||||
script.InsertWithCursor (context.TranslateString("Create event invocator"), methodDeclaration, Script.InsertPosition.After); |
||||
}); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
static EventDeclaration GetEventDeclaration (RefactoringContext context, out VariableInitializer initializer) |
||||
{ |
||||
var result = context.GetNode<EventDeclaration> (); |
||||
if (result == null) { |
||||
initializer = null; |
||||
return null; |
||||
} |
||||
initializer = result.Variables.FirstOrDefault (v => v.NameToken.Contains (context.Location)); |
||||
return initializer != null ? result : null; |
||||
} |
||||
} |
||||
} |
||||
|
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// IssueCategories.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <mkrueger@xamarin.com>
|
||||
//
|
||||
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
|
||||
//
|
||||
// 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.NRefactory.CSharp |
||||
{ |
||||
public class IssueCategories |
||||
{ |
||||
public const string Improvements = "Code Improvements"; |
||||
public const string CodeQualityIssues = "Code Quality Issues"; |
||||
public const string ConstraintViolations = "Constraint Violations"; |
||||
public const string Redundancies = "Redundancies"; |
||||
public const string Opportunities = "Language Usage Opportunities"; |
||||
public const string Notifications = "Code Notifications"; |
||||
} |
||||
} |
||||
|
||||
|
@ -1,78 +0,0 @@
@@ -1,78 +0,0 @@
|
||||
//
|
||||
// CreateBackingStore.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <mkrueger@novell.com>
|
||||
//
|
||||
// Copyright (c) 2011 Mike Krüger <mkrueger@novell.com>
|
||||
//
|
||||
// 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.Threading; |
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp.Refactoring |
||||
{ |
||||
public class CreateBackingStore : IContextAction |
||||
{ |
||||
public bool IsValid (RefactoringContext context) |
||||
{ |
||||
var propertyDeclaration = context.GetNode<PropertyDeclaration> (); |
||||
return propertyDeclaration != null && |
||||
!propertyDeclaration.Getter.IsNull && !propertyDeclaration.Setter.IsNull && // automatic properties always need getter & setter
|
||||
propertyDeclaration.Getter.Body.IsNull && |
||||
propertyDeclaration.Setter.Body.IsNull; |
||||
} |
||||
|
||||
public void Run (RefactoringContext context) |
||||
{ |
||||
var property = context.GetNode<PropertyDeclaration> (); |
||||
|
||||
string backingStoreName = context.GetNameProposal (property.Name); |
||||
|
||||
// create field
|
||||
var backingStore = new FieldDeclaration (); |
||||
backingStore.ReturnType = property.ReturnType.Clone (); |
||||
|
||||
var initializer = new VariableInitializer (backingStoreName); |
||||
backingStore.Variables.Add (initializer); |
||||
|
||||
// create new property & implement the get/set bodies
|
||||
var newProperty = (PropertyDeclaration)property.Clone (); |
||||
Expression id1; |
||||
if (backingStoreName == "value") |
||||
id1 = new ThisReferenceExpression().Member("value"); |
||||
else |
||||
id1 = new IdentifierExpression (backingStoreName); |
||||
Expression id2 = id1.Clone(); |
||||
newProperty.Getter.Body = new BlockStatement () { |
||||
new ReturnStatement (id1) |
||||
}; |
||||
newProperty.Setter.Body = new BlockStatement () { |
||||
new AssignmentExpression (id2, AssignmentOperatorType.Assign, new IdentifierExpression ("value")) |
||||
}; |
||||
|
||||
using (var script = context.StartScript ()) { |
||||
script.Replace (property, newProperty); |
||||
script.InsertBefore (property, backingStore); |
||||
script.Link (initializer, id1, id2); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,110 +0,0 @@
@@ -1,110 +0,0 @@
|
||||
//
|
||||
// CreateEventInvocator.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <mkrueger@novell.com>
|
||||
//
|
||||
// Copyright (c) 2011 Mike Krüger <mkrueger@novell.com>
|
||||
//
|
||||
// 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.Linq; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.NRefactory.TypeSystem; |
||||
using System.Threading; |
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp.Refactoring |
||||
{ |
||||
public class CreateEventInvocator : IContextAction |
||||
{ |
||||
public bool IsValid (RefactoringContext context) |
||||
{ |
||||
VariableInitializer initializer; |
||||
var eventDeclaration = GetEventDeclaration (context, out initializer); |
||||
if (eventDeclaration == null) |
||||
return false; |
||||
var type = (TypeDeclaration)eventDeclaration.Parent; |
||||
return !type.Members.Any (m => m is MethodDeclaration && ((MethodDeclaration)m).Name == "On" + initializer.Name); |
||||
} |
||||
|
||||
public void Run (RefactoringContext context) |
||||
{ |
||||
VariableInitializer initializer; |
||||
var eventDeclaration = GetEventDeclaration (context, out initializer); |
||||
var type = context.Resolve (eventDeclaration.ReturnType).Type; |
||||
if (type == null) |
||||
return; |
||||
var invokeMethod = type.GetDelegateInvokeMethod (); |
||||
if (invokeMethod == null) |
||||
return; |
||||
|
||||
bool hasSenderParam = false; |
||||
IEnumerable<IParameter> pars = invokeMethod.Parameters; |
||||
if (invokeMethod.Parameters.Any ()) { |
||||
var first = invokeMethod.Parameters [0]; |
||||
if (first.Name == "sender" /*&& first.Type == "System.Object"*/) { |
||||
hasSenderParam = true; |
||||
pars = invokeMethod.Parameters.Skip (1); |
||||
} |
||||
} |
||||
const string handlerName = "handler"; |
||||
|
||||
var arguments = new List<Expression> (); |
||||
if (hasSenderParam) |
||||
arguments.Add (new ThisReferenceExpression ()); |
||||
foreach (var par in pars) |
||||
arguments.Add (new IdentifierExpression (par.Name)); |
||||
|
||||
var methodDeclaration = new MethodDeclaration () { |
||||
Name = "On" + initializer.Name, |
||||
ReturnType = new PrimitiveType ("void"), |
||||
Modifiers = ICSharpCode.NRefactory.CSharp.Modifiers.Protected | ICSharpCode.NRefactory.CSharp.Modifiers.Virtual, |
||||
Body = new BlockStatement () { |
||||
new VariableDeclarationStatement (eventDeclaration.ReturnType.Clone (), handlerName, new MemberReferenceExpression (new ThisReferenceExpression (), initializer.Name)), |
||||
new IfElseStatement () { |
||||
Condition = new BinaryOperatorExpression (new IdentifierExpression (handlerName), BinaryOperatorType.InEquality, new PrimitiveExpression (null)), |
||||
TrueStatement = new ExpressionStatement (new InvocationExpression (new IdentifierExpression (handlerName), arguments)) |
||||
} |
||||
} |
||||
}; |
||||
|
||||
foreach (var par in pars) { |
||||
var typeName = context.CreateShortType (par.Type); |
||||
var decl = new ParameterDeclaration (typeName, par.Name); |
||||
methodDeclaration.Parameters.Add (decl); |
||||
} |
||||
|
||||
using (var script = context.StartScript ()) { |
||||
script.InsertWithCursor ("Create event invocator", methodDeclaration, Script.InsertPosition.After); |
||||
} |
||||
} |
||||
|
||||
static EventDeclaration GetEventDeclaration (RefactoringContext context, out VariableInitializer initializer) |
||||
{ |
||||
var result = context.GetNode<EventDeclaration> (); |
||||
if (result == null) { |
||||
initializer = null; |
||||
return null; |
||||
} |
||||
initializer = result.Variables.FirstOrDefault (v => v.NameToken.Contains (context.Location)); |
||||
return initializer != null ? result : null; |
||||
} |
||||
} |
||||
} |
||||
|
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// ProviderDescriptionAttribute.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <mkrueger@xamarin.com>
|
||||
//
|
||||
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
|
||||
//
|
||||
// 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.NRefactory.CSharp |
||||
{ |
||||
public class ContextActionAttribute : System.Attribute |
||||
{ |
||||
public string Title { get; private set;} |
||||
public string Description { get; set; } |
||||
public string Category { get; set; } |
||||
|
||||
public ContextActionAttribute (string title) |
||||
{ |
||||
Title = title; |
||||
} |
||||
} |
||||
} |
||||
|
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// IssueAttribute.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <mkrueger@xamarin.com>
|
||||
//
|
||||
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
|
||||
//
|
||||
// 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.NRefactory.CSharp |
||||
{ |
||||
public class IssueDescriptionAttribute : System.Attribute |
||||
{ |
||||
public string Title { get; private set;} |
||||
|
||||
public string Description { get; set; } |
||||
|
||||
public string Category { get; set; } |
||||
|
||||
public Severity Severity { get; set; } |
||||
|
||||
public IssueMarker IssueMarker { get; set; } |
||||
|
||||
public IssueDescriptionAttribute (string title) |
||||
{ |
||||
Title = title; |
||||
Severity = Severity.Suggestion; |
||||
IssueMarker = IssueMarker.Underline; |
||||
} |
||||
} |
||||
} |
||||
|
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// IssueMarker.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <mkrueger@xamarin.com>
|
||||
//
|
||||
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
|
||||
//
|
||||
// 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.NRefactory.CSharp |
||||
{ |
||||
/// <summary>
|
||||
/// The issue marker is used to set how an issue should be marked inside the text editor.
|
||||
/// </summary>
|
||||
public enum IssueMarker |
||||
{ |
||||
/// <summary>
|
||||
/// The issue is not shown inside the text editor. (But in the task bar)
|
||||
/// </summary>
|
||||
None, |
||||
|
||||
/// <summary>
|
||||
/// The region is marked as underline in the severity color.
|
||||
/// </summary>
|
||||
Underline, |
||||
|
||||
/// <summary>
|
||||
/// The text is grayed out.
|
||||
/// </summary>
|
||||
GrayOut |
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Severity.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <mkrueger@xamarin.com>
|
||||
//
|
||||
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
|
||||
//
|
||||
// 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.NRefactory.CSharp |
||||
{ |
||||
public enum Severity |
||||
{ |
||||
None, |
||||
|
||||
Error, |
||||
Warning, |
||||
Hint, |
||||
Suggestion, |
||||
|
||||
Usage |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue