Browse Source

Added some documentation.

newNRvisualizers
Mike Krüger 14 years ago
parent
commit
484c1420de
  1. 18
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeAction.cs
  2. 47
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssue.cs
  3. 15
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/GatherVisitorBase.cs
  4. 9
      ICSharpCode.NRefactory.CSharp/Refactoring/ICodeIssueProvider.cs

18
ICSharpCode.NRefactory.CSharp/Refactoring/CodeAction.cs

@ -27,18 +27,36 @@ using System; @@ -27,18 +27,36 @@ using System;
namespace ICSharpCode.NRefactory.CSharp.Refactoring
{
/// <summary>
/// A code action provides a code transformation with a description.
/// </summary>
public class CodeAction
{
/// <summary>
/// Gets the description.
/// </summary>
public string Description {
get;
private set;
}
/// <summary>
/// Gets the code transformation.
/// </summary>
public Action<Script> Run {
get;
private set;
}
/// <summary>
/// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.CSharp.Refactoring.CodeAction"/> class.
/// </summary>
/// <param name='description'>
/// The description.
/// </param>
/// <param name='action'>
/// The code transformation.
/// </param>
public CodeAction (string description, Action<Script> action)
{
if (action == null) {

47
ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssue.cs

@ -29,28 +29,58 @@ using System.Linq; @@ -29,28 +29,58 @@ using System.Linq;
namespace ICSharpCode.NRefactory.CSharp.Refactoring
{
/// <summary>
/// A code issue marks a region of text with an issue and can provide solution actions for this issue.
/// </summary>
public class CodeIssue
{
/// <summary>
/// Gets the desription of the issue.
/// </summary>
public string Desription {
get;
private set;
}
/// <summary>
/// Gets the issue start location.
/// </summary>
public TextLocation Start {
get;
private set;
}
/// <summary>
/// Gets the issue end location.
/// </summary>
public TextLocation End {
get;
private set;
}
/// <summary>
/// Gets a list of potential solutions for the issue.
/// </summary>
public IList<CodeAction> Actions {
get;
private set;
}
/// <summary>
/// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.CSharp.Refactoring.CodeIssue"/> class.
/// </summary>
/// <param name='description'>
/// The desription of the issue.
/// </param>
/// <param name='start'>
/// The issue start location.
/// </param>
/// <param name='end'>
/// the issue end location.
/// </param>
/// <param name='actions'>
/// A list of potential solutions for the issue.
/// </param>
public CodeIssue(string description, TextLocation start, TextLocation end, IEnumerable<CodeAction> actions = null)
{
Desription = description;
@ -62,6 +92,21 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -62,6 +92,21 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
Actions = EmptyList<CodeAction>.Instance;
}
/// <summary>
/// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.CSharp.Refactoring.CodeIssue"/> class.
/// </summary>
/// <param name='description'>
/// The desription of the issue.
/// </param>
/// <param name='start'>
/// The issue start location.
/// </param>
/// <param name='end'>
/// the issue end location.
/// </param>
/// <param name='action'>
/// A potential solution for the issue.
/// </param>
public CodeIssue(string description, TextLocation start, TextLocation end, CodeAction action) : this (description, start, end, action != null ? new [] { action } : null)
{
}

15
ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/GatherVisitorBase.cs

@ -29,17 +29,32 @@ using System.Collections.Generic; @@ -29,17 +29,32 @@ using System.Collections.Generic;
namespace ICSharpCode.NRefactory.CSharp
{
/// <summary>
/// A base class for writing issue provider visitor implementations.
/// </summary>
class GatherVisitorBase : DepthFirstAstVisitor
{
protected readonly BaseRefactoringContext ctx;
public readonly List<CodeIssue> FoundIssues = new List<CodeIssue> ();
/// <summary>
/// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.CSharp.GatherVisitorBase"/> class.
/// </summary>
/// <param name='ctx'>
/// The refactoring context.
/// </param>
public GatherVisitorBase (BaseRefactoringContext ctx)
{
this.ctx = ctx;
}
/// <summary>
/// Gets all the issues using the context root node as base.
/// </summary>
/// <returns>
/// The issues.
/// </returns>
public IEnumerable<CodeIssue> GetIssues()
{
ctx.RootNode.AcceptVisitor(this);

9
ICSharpCode.NRefactory.CSharp/Refactoring/ICodeIssueProvider.cs

@ -28,8 +28,17 @@ using System.Collections.Generic; @@ -28,8 +28,17 @@ using System.Collections.Generic;
namespace ICSharpCode.NRefactory.CSharp.Refactoring
{
/// <summary>
/// The code issue provider gets a list of all code issues in a compilation unit.
/// </summary>
public interface ICodeIssueProvider
{
/// <summary>
/// Gets all code issues inside a compilation unit.
/// </summary>
/// <param name='context'>
/// The refactoring context of the issues to get.
/// </param>
IEnumerable<CodeIssue> GetIssues (BaseRefactoringContext context);
}
}

Loading…
Cancel
Save