Browse Source

Add "Suppress message" command to FxCop warnings on the error list

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1601 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
ee3b8e7273
  1. 34
      AddIns/ICSharpCode.SharpDevelop.addin
  2. 9
      src/AddIns/Misc/CodeAnalysis/CodeAnalysis.addin
  3. 9
      src/AddIns/Misc/CodeAnalysis/CodeAnalysis.csproj
  4. 89
      src/AddIns/Misc/CodeAnalysis/Src/FxCopLogger.cs
  5. 101
      src/AddIns/Misc/CodeAnalysis/Src/SuppressMessageCommand.cs
  6. 42
      src/Libraries/ICSharpCode.Build.Tasks/Project/FxCop.cs
  7. 33
      src/Main/Base/Project/Src/Gui/Pads/ErrorList/ErrorListPad.cs
  8. 40
      src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs
  9. 74
      src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs
  10. 79
      src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs
  11. 3
      src/Main/Base/Project/Src/Services/ParserService/Position.cs
  12. 28
      src/Main/Base/Project/Src/Services/Tasks/Task.cs

34
AddIns/ICSharpCode.SharpDevelop.addin

@ -894,24 +894,24 @@ @@ -894,24 +894,24 @@
<ToolbarItem id="NavigationSeparator" type="Separator"/>
<Condition name="CanNavigateBack" action="Disable">
<ToolbarItem id="NavigateBack"
type="SplitButton"
icon="Icons.16x16.NavigateBack"
type="SplitButton"
icon="Icons.16x16.NavigateBack"
tooltip="Navigate Back"
disabledIcon="Icons.16x16.NavigateBack"
loadclasslazy="false"
class="ICSharpCode.SharpDevelop.Commands.NavigateBack"
>
disabledIcon="Icons.16x16.NavigateBack"
loadclasslazy="false"
class="ICSharpCode.SharpDevelop.Commands.NavigateBack"
>
<MenuItem id="NavigationHistoryBuilder"
type="Builder"
class="ICSharpCode.SharpDevelop.Commands.NavigationHistoryMenuBuilder"/>
type="Builder"
class="ICSharpCode.SharpDevelop.Commands.NavigationHistoryMenuBuilder"/>
</ToolbarItem>
</Condition>
<Condition name="CanNavigateForward" action="Disable">
<ToolbarItem id="NavigateForward"
icon="Icons.16x16.NavigateForward"
tooltip="Navigate Forward"
loadclasslazy="false"
class="ICSharpCode.SharpDevelop.Commands.NavigateForward"/>
icon="Icons.16x16.NavigateForward"
tooltip="Navigate Forward"
loadclasslazy="false"
class="ICSharpCode.SharpDevelop.Commands.NavigateForward"/>
</Condition>
</Path>
<!-- end toolbars -->
@ -1750,7 +1750,7 @@ @@ -1750,7 +1750,7 @@
<MenuItem id = "FindNextSelected"
label = "${res:XML.MainMenu.SearchMenu.FindNextSelected}"
shortcut = "Control|F3"
class = "SearchAndReplace.FindNextSelected"/>
class = "SearchAndReplace.FindNextSelected"/>
<MenuItem id = "Replace"
label = "${res:XML.MainMenu.SearchMenu.Replace}"
icon = "Icons.16x16.ReplaceIcon"
@ -2150,4 +2150,12 @@ @@ -2150,4 +2150,12 @@
<Path name="/SharpDevelop/BackendBindings/ProjectOptions/AllManaged">
<!-- put project option panels valid for all .NET projects here -->
</Path>
<Path name="/SharpDevelop/Pads/ErrorList/TaskContextMenu">
<MenuItem id = "Copy"
label = "${res:XML.MainMenu.EditMenu.Copy}"
type = "Item"
icon = "Icons.16x16.CopyIcon"
class = "ICSharpCode.SharpDevelop.Commands.Copy"/>
</Path>
</AddIn>

9
src/AddIns/Misc/CodeAnalysis/CodeAnalysis.addin

@ -33,4 +33,13 @@ @@ -33,4 +33,13 @@
taskname = "FxCop"
class = "ICSharpCode.CodeAnalysis.FxCopLogger"/>
</Path>
<Path name="/SharpDevelop/Pads/ErrorList/CodeAnalysisTaskContextMenu">
<MenuItem id = "Exclude"
label = "Suppress message"
loadclasslazy = "false"
class = "ICSharpCode.CodeAnalysis.SuppressMessageCommand"/>
<MenuItem id = "Separator" type = "Separator"/>
<Include id="default" path="/SharpDevelop/Pads/ErrorList/TaskContextMenu"/>
</Path>
</AddIn>

9
src/AddIns/Misc/CodeAnalysis/CodeAnalysis.csproj

@ -63,6 +63,7 @@ @@ -63,6 +63,7 @@
<Compile Include="Src\FxCopRule.cs" />
<Compile Include="Src\CheckCurrentProjectCommand.cs" />
<Compile Include="Src\FxCopLogger.cs" />
<Compile Include="Src\SuppressMessageCommand.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
@ -75,6 +76,14 @@ @@ -75,6 +76,14 @@
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj">
<Project>{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}</Project>
<Name>ICSharpCode.TextEditor</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project>
<Name>NRefactory</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

89
src/AddIns/Misc/CodeAnalysis/Src/FxCopLogger.cs

@ -6,9 +6,10 @@ @@ -6,9 +6,10 @@
*/
using System;
using Microsoft.Build.Framework;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
using Microsoft.Build.Framework;
namespace ICSharpCode.CodeAnalysis
{
@ -67,24 +68,32 @@ namespace ICSharpCode.CodeAnalysis @@ -67,24 +68,32 @@ namespace ICSharpCode.CodeAnalysis
void OnError(object sender, BuildErrorEventArgs e)
{
AppendError(e.File, e.LineNumber, e.ColumnNumber, e.Code, e.Message, false);
AppendError(e.File, e.LineNumber, e.ColumnNumber, e.Message, false,
e.HelpKeyword, e.Code, e.Subcategory);
}
void OnWarning(object sender, BuildWarningEventArgs e)
{
AppendError(e.File, e.LineNumber, e.ColumnNumber, e.Code, e.Message, true);
AppendError(e.File, e.LineNumber, e.ColumnNumber, e.Message, true,
e.HelpKeyword, e.Code, e.Subcategory);
}
void AppendError(string file, int lineNumber, int columnNumber, string code, string message, bool isWarning)
void AppendError(string file, int lineNumber, int columnNumber,
string message, bool isWarning,
string category, string checkId, string subcategory)
{
string[] moreData = (subcategory ?? "").Split('|');
BuildError err = engine.CurrentErrorOrWarning;
if (file.StartsWith("positionof#")) {
string memberName = file.Substring(11);
file = "";
IProject project = ProjectService.GetProject(engine.CurrentProjectFile);
if (project != null) {
IProjectContent pc = ParserService.GetProjectContent(project);
if (pc != null) {
if (Path.GetFileName(file) == "SharpDevelop.CodeAnalysis.targets") {
err.FileName = null;
}
IProject project = ProjectService.GetProject(engine.CurrentProjectFile);
if (project != null) {
IProjectContent pc = ParserService.GetProjectContent(project);
if (pc != null) {
if (file.StartsWith("positionof#")) {
string memberName = file.Substring(11);
file = "";
Position pos = pc.GetPosition(memberName);
if (pos != null && pos.Cu != null) {
err.FileName = pos.Cu.FileName ?? "";
@ -92,9 +101,67 @@ namespace ICSharpCode.CodeAnalysis @@ -92,9 +101,67 @@ namespace ICSharpCode.CodeAnalysis
err.Column = pos.Column;
}
}
if (moreData.Length > 0 && moreData[0].Length > 0) {
err.Tag = new FxCopTaskTag(pc, moreData[0], category, checkId);
err.ContextMenuAddInTreeEntry = "/SharpDevelop/Pads/ErrorList/CodeAnalysisTaskContextMenu";
if (moreData.Length > 1) {
(err.Tag as FxCopTaskTag).MessageID = moreData[1];
}
}
}
}
}
}
}
public class FxCopTaskTag
{
IProjectContent projectContent;
string memberName;
string category;
string checkID;
string messageID;
public IProjectContent ProjectContent {
get {
return projectContent;
}
}
public string MemberName {
get {
return memberName;
}
}
public string Category {
get {
return category;
}
}
public string CheckID {
get {
return checkID;
}
}
public string MessageID {
get {
return messageID;
}
set {
messageID = value;
}
}
public FxCopTaskTag(IProjectContent projectContent, string memberName, string category, string checkID)
{
this.projectContent = projectContent;
this.memberName = memberName;
this.category = category;
this.checkID = checkID;
}
}
}

101
src/AddIns/Misc/CodeAnalysis/Src/SuppressMessageCommand.cs

@ -0,0 +1,101 @@ @@ -0,0 +1,101 @@
/*
* Created by SharpDevelop.
* User: Daniel Grunwald
* Date: 19.07.2006
* Time: 17:57
*/
using System;
using System.Collections.Generic;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Refactoring;
using ICSharpCode.TextEditor.Document;
using Ast = ICSharpCode.NRefactory.Parser.Ast;
namespace ICSharpCode.CodeAnalysis
{
public class SuppressMessageCommand : AbstractMenuCommand
{
public override void Run()
{
TaskView view = (TaskView)Owner;
foreach (Task t in new List<Task>(view.SelectedTasks)) {
FxCopTaskTag tag = t.Tag as FxCopTaskTag;
if (tag == null)
continue;
CodeGenerator codegen = tag.ProjectContent.Language.CodeGenerator;
if (codegen == null)
continue;
Position p = tag.ProjectContent.GetPosition(tag.MemberName);
if (p == null || p.Cu == null || p.Cu.FileName == null || p.Line <= 0)
continue;
IWorkbenchWindow window = FileService.OpenFile(p.Cu.FileName);
if (window == null)
continue;
ITextEditorControlProvider provider = window.ViewContent as ITextEditorControlProvider;
if (provider == null)
continue;
IDocument document = provider.TextEditorControl.Document;
if (p.Line >= document.TotalNumberOfLines)
continue;
LineSegment line = document.GetLineSegment(p.Line - 1);
StringBuilder indentation = new StringBuilder();
for (int i = line.Offset; i < document.TextLength; i++) {
char c = document.GetCharAt(i);
if (c == ' ' || c == '\t')
indentation.Append(c);
else
break;
}
string code = codegen.GenerateCode(CreateSuppressAttribute(p.Cu, tag), indentation.ToString());
if (!code.EndsWith("\n")) code += Environment.NewLine;
document.Insert(line.Offset, code);
TaskService.Remove(t);
ParserService.ParseViewContent(window.ViewContent);
}
}
const string NamespaceName = "System.Diagnostics.CodeAnalysis";
const string AttributeName = "SuppressMessage";
static Ast.AbstractNode CreateSuppressAttribute(ICompilationUnit cu, FxCopTaskTag tag)
{
//System.Diagnostics.CodeAnalysis.SuppressMessageAttribute
bool importedCodeAnalysis = CheckImports(cu.ProjectContent.DefaultImports);
if (importedCodeAnalysis == false) {
foreach (IUsing u in cu.Usings) {
if (CheckImports(u)) {
importedCodeAnalysis = true;
break;
}
}
}
// [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId:="fileIdentifier"]
Ast.Attribute a = new Ast.Attribute(importedCodeAnalysis ? AttributeName : NamespaceName + "." + AttributeName, null, null);
a.PositionalArguments.Add(new Ast.PrimitiveExpression(tag.Category, tag.Category));
a.PositionalArguments.Add(new Ast.PrimitiveExpression(tag.CheckID, tag.CheckID));
if (tag.MessageID != null) {
a.NamedArguments.Add(new Ast.NamedArgumentExpression("MessageId",
new Ast.PrimitiveExpression(tag.MessageID, tag.MessageID)));
}
Ast.AttributeSection sec = new Ast.AttributeSection(null, null);
sec.Attributes.Add(a);
return sec;
}
static bool CheckImports(IUsing u)
{
if (u == null)
return false;
else
return u.Usings.Contains(NamespaceName);
}
}
}

42
src/Libraries/ICSharpCode.Build.Tasks/Project/FxCop.cs

@ -155,33 +155,37 @@ namespace ICSharpCode.Build.Tasks @@ -155,33 +155,37 @@ namespace ICSharpCode.Build.Tasks
string issueLine = issueEl.GetAttribute("Line");
int issueLineNumber = 0;
string issueFullFile = null;
// Try to find additional information about this type
string memberName = null;
XmlNode parent = message.ParentNode;
while (parent != null) {
if (parent.Name == "Member" || parent.Name == "Type" || parent.Name == "Namespace") {
if (memberName == null)
memberName = ((XmlElement)parent).GetAttribute("Name");
else
memberName = ((XmlElement)parent).GetAttribute("Name") + "." + memberName;
}
parent = parent.ParentNode;
}
if (issuePath.Length > 0 && issueLine.Length > 0 && issueFile.Length > 0) {
issueFullFile = Path.Combine(issuePath, issueFile);
issueLineNumber = int.Parse(issueLine, CultureInfo.InvariantCulture);
} else {
// Try to find additional information about this type
string memberName = null;
XmlNode parent = message.ParentNode;
while (parent != null) {
if (parent.Name == "Member" || parent.Name == "Type" || parent.Name == "Namespace") {
if (memberName == null)
memberName = ((XmlElement)parent).GetAttribute("Name");
else
memberName = ((XmlElement)parent).GetAttribute("Name") + "." + memberName;
}
parent = parent.ParentNode;
}
if (memberName != null) {
issueFullFile = "positionof#" + memberName;
}
} else if (memberName != null) {
issueFullFile = "positionof#" + memberName;
}
issueText = checkId + " : " + category + " : " + issueText;
if (message.HasAttribute("TypeName")) {
checkId = checkId + ":" + message.GetAttribute("TypeName");
}
if (message.HasAttribute("Id")) {
memberName = memberName + "|" + message.GetAttribute("Id");
}
if (isWarning) {
Log.LogWarning(null, null, checkId, issueFullFile, issueLineNumber, 0, 0, 0, issueText);
Log.LogWarning(memberName, checkId, category, issueFullFile, issueLineNumber, 0, 0, 0, issueText);
} else {
Log.LogError(null, null, checkId, issueFullFile, issueLineNumber, 0, 0, 0, issueText);
Log.LogError(memberName, checkId, category, issueFullFile, issueLineNumber, 0, 0, 0, issueText);
}
}
return isWarning;

33
src/Main/Base/Project/Src/Gui/Pads/ErrorList/ErrorListPad.cs

@ -13,7 +13,7 @@ using ICSharpCode.SharpDevelop.Project; @@ -13,7 +13,7 @@ using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui
{
public class ErrorListPad : AbstractPadContent
public class ErrorListPad : AbstractPadContent, IClipboardHandler
{
static ErrorListPad instance;
public static ErrorListPad Instance {
@ -210,5 +210,36 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -210,5 +210,36 @@ namespace ICSharpCode.SharpDevelop.Gui
taskView.EndUpdate();
UpdateToolstripStatus();
}
#region IClipboardHandler interface implementation
public bool EnableCut {
get { return false; }
}
public bool EnableCopy {
get { return taskView.TaskIsSelected; }
}
public bool EnablePaste {
get { return false; }
}
public bool EnableDelete {
get { return false; }
}
public bool EnableSelectAll {
get { return true; }
}
public void Cut() {}
public void Paste() {}
public void Delete() {}
public void Copy()
{
taskView.CopySelectionToClipboard();
}
public void SelectAll()
{
taskView.SelectAll();
}
#endregion
}
}

40
src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs

@ -7,17 +7,12 @@ @@ -7,17 +7,12 @@
using System;
using System.Windows.Forms;
using System.Drawing;
using System.CodeDom.Compiler;
using System.Collections;
using System.IO;
using System.Diagnostics;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui
{
public class TaskListPad : AbstractPadContent
public class TaskListPad : AbstractPadContent, IClipboardHandler
{
TaskView taskView = new TaskView();
@ -56,8 +51,6 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -56,8 +51,6 @@ namespace ICSharpCode.SharpDevelop.Gui
taskView.ClearTasks();
}
public CompilerResults CompilerResults = null;
void TaskServiceCleared(object sender, EventArgs e)
{
taskView.ClearTasks();
@ -87,6 +80,37 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -87,6 +80,37 @@ namespace ICSharpCode.SharpDevelop.Gui
taskView.Invoke(new EventHandler(InternalShowResults));
// SelectTaskView(null, null);
}
#region IClipboardHandler interface implementation
public bool EnableCut {
get { return false; }
}
public bool EnableCopy {
get { return taskView.TaskIsSelected; }
}
public bool EnablePaste {
get { return false; }
}
public bool EnableDelete {
get { return false; }
}
public bool EnableSelectAll {
get { return true; }
}
public void Cut() {}
public void Paste() {}
public void Delete() {}
public void Copy()
{
taskView.CopySelectionToClipboard();
}
public void SelectAll()
{
taskView.SelectAll();
}
#endregion
}
}

74
src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs

@ -10,7 +10,10 @@ @@ -10,7 +10,10 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
namespace ICSharpCode.Core
@ -50,6 +53,48 @@ namespace ICSharpCode.Core @@ -50,6 +53,48 @@ namespace ICSharpCode.Core
}
}
public IEnumerable<Task> SelectedTasks {
get {
foreach (ListViewItem item in this.SelectedItems) {
yield return (Task)item.Tag;
}
}
}
public void CopySelectionToClipboard()
{
StringBuilder b = new StringBuilder();
foreach (Task t in this.SelectedTasks) {
if (b.Length > 0) b.AppendLine();
b.Append(t.Description);
if (!string.IsNullOrEmpty(t.FileName)) {
b.Append(" - ");
b.Append(t.FileName);
if (t.Line >= 0) {
b.Append(':');
b.Append(t.Line + 1);
if (t.Column > 0) {
b.Append(',');
b.Append(t.Column + 1);
}
}
}
}
ClipboardWrapper.SetText(b.ToString());
}
public void SelectAll()
{
BeginUpdate();
try {
foreach (ListViewItem item in this.Items) {
item.Selected = true;
}
} finally {
EndUpdate();
}
}
public TaskView() : base()
{
RefreshColumnNames();
@ -154,6 +199,35 @@ namespace ICSharpCode.Core @@ -154,6 +199,35 @@ namespace ICSharpCode.Core
currentListViewItem = item;
}
}
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x007B) { // handle WM_CONTEXTMENU
if (this.SelectedItems.Count > 0) {
long lParam = m.LParam.ToInt64();
int x = unchecked((short)(lParam & 0xffff));
int y = unchecked((short)((lParam & 0xffff0000) >> 16));
Point pos;
if (x == -1 && y == -1) {
pos = this.SelectedItems[0].Bounds.Location;
pos.X += 30;
pos.Y += 4;
} else {
pos = PointToClient(new Point(x, y));
}
string entry = ((Task)this.SelectedItems[0].Tag).ContextMenuAddInTreeEntry;
for (int i = 1; i < this.SelectedItems.Count; i++) {
string entry2 = ((Task)this.SelectedItems[i].Tag).ContextMenuAddInTreeEntry;
if (entry2 != entry) {
entry = Task.DefaultContextMenuAddInTreeEntry;
break;
}
}
MenuService.ShowContextMenu(this, entry, this, pos.X, pos.Y);
}
}
base.WndProc(ref m);
}
#endregion
#region Task Management

79
src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs

@ -815,25 +815,82 @@ namespace ICSharpCode.Core @@ -815,25 +815,82 @@ namespace ICSharpCode.Core
/// Gets the position of a member in this project content (not a referenced one).
/// </summary>
/// <param name="fullMemberName">Fully qualified member name (always case sensitive).</param>
public Position GetPosition(string fullMemberName)
public IDecoration GetElement(string fullMemberName)
{
IClass curClass = GetClass(fullMemberName, 0, LanguageProperties.CSharp, false);
if (curClass != null) {
return new Position(curClass.CompilationUnit, curClass.Region.BeginLine, curClass.Region.BeginColumn);
return curClass;
}
int pos = fullMemberName.LastIndexOf('.');
int pos = fullMemberName.IndexOf('(');
if (pos > 0) {
string className = fullMemberName.Substring(0, pos);
string memberName = fullMemberName.Substring(pos + 1);
curClass = GetClass(className, 0, LanguageProperties.CSharp, false);
if (curClass != null) {
IMember member = curClass.SearchMember(memberName, LanguageProperties.CSharp);
if (member != null) {
return new Position(member.DeclaringType.CompilationUnit, member.Region.BeginLine, member.Region.BeginColumn);
// is method call
int colonPos = fullMemberName.LastIndexOf(':');
if (colonPos > 0) {
fullMemberName = fullMemberName.Substring(0, colonPos);
}
string memberName = fullMemberName.Substring(0, pos);
int pos2 = memberName.LastIndexOf('.');
if (pos2 > 0) {
string className = memberName.Substring(0, pos2);
memberName = memberName.Substring(pos2 + 1);
curClass = GetClass(className, 0, LanguageProperties.CSharp, false);
if (curClass != null) {
IMethod firstMethod = null;
foreach (IMethod m in curClass.Methods) {
if (m.Name == memberName) {
if (firstMethod == null) firstMethod = m;
StringBuilder dotnetName = new StringBuilder(m.DotNetName);
dotnetName.Append('(');
for (int i = 0; i < m.Parameters.Count; i++) {
if (i > 0) dotnetName.Append(',');
if (m.Parameters[i].ReturnType != null) {
dotnetName.Append(m.Parameters[i].ReturnType.DotNetName);
}
}
dotnetName.Append(')');
if (dotnetName.ToString() == fullMemberName) {
return m;
}
}
}
}
}
} else {
pos = fullMemberName.LastIndexOf('.');
if (pos > 0) {
string className = fullMemberName.Substring(0, pos);
string memberName = fullMemberName.Substring(pos + 1);
curClass = GetClass(className, 0, LanguageProperties.CSharp, false);
if (curClass != null) {
// get first method with that name, but prefer method without parameters
IMethod firstMethod = null;
foreach (IMethod m in curClass.Methods) {
if (m.Name == memberName) {
if (firstMethod == null || m.Parameters.Count == 0)
firstMethod = m;
}
}
return firstMethod;
}
}
}
return new Position(null, -1, -1);
return null;
}
public Position GetPosition(string fullMemberName)
{
IDecoration d = GetElement(fullMemberName);
IMember m = d as IMember;
IClass c = d as IClass;
if (m != null) {
return new Position(m.DeclaringType.CompilationUnit, m.Region.BeginLine, m.Region.BeginColumn);
} else if (c != null) {
return new Position(c.CompilationUnit, c.Region.BeginLine, c.Region.BeginColumn);
} else {
return new Position(null, -1, -1);
}
}
#endregion

3
src/Main/Base/Project/Src/Services/ParserService/Position.cs

@ -9,9 +9,6 @@ using ICSharpCode.SharpDevelop.Dom; @@ -9,9 +9,6 @@ using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.Core
{
/// <summary>
/// Used in many methods as parameter, to shorten the parameter lists
/// </summary>
public class Position
{
int line = -1;

28
src/Main/Base/Project/Src/Services/Tasks/Task.cs

@ -23,13 +23,15 @@ namespace ICSharpCode.Core @@ -23,13 +23,15 @@ namespace ICSharpCode.Core
public class Task
{
public const string DefaultContextMenuAddInTreeEntry = "/SharpDevelop/Pads/ErrorList/TaskContextMenu";
string description;
string fileName;
TaskType type;
int line;
int column;
object contextMenuOwner;
string contextMenuAddInTreeEntry;
string contextMenuAddInTreeEntry = DefaultContextMenuAddInTreeEntry;
object tag;
public override string ToString()
{
@ -40,7 +42,7 @@ namespace ICSharpCode.Core @@ -40,7 +42,7 @@ namespace ICSharpCode.Core
type,
description);
}
/// <summary>
/// The line number of the task. Zero-based (text editor coordinate)
/// </summary>
@ -80,21 +82,21 @@ namespace ICSharpCode.Core @@ -80,21 +82,21 @@ namespace ICSharpCode.Core
}
}
public object ContextMenuOwner {
public string ContextMenuAddInTreeEntry {
get {
return contextMenuOwner;
return contextMenuAddInTreeEntry;
}
set {
contextMenuOwner = value;
contextMenuAddInTreeEntry = value;
}
}
public string ContextMenuAddInTreeEntry {
public object Tag {
get {
return contextMenuAddInTreeEntry;
return tag;
}
set {
contextMenuAddInTreeEntry = value;
tag = value;
}
}
@ -116,10 +118,12 @@ namespace ICSharpCode.Core @@ -116,10 +118,12 @@ namespace ICSharpCode.Core
if (string.IsNullOrEmpty(error.ErrorCode)) {
description = error.ErrorText;
} else {
description = error.ErrorText + "(" + error.ErrorCode + ")";
description = error.ErrorText + " (" + error.ErrorCode + ")";
}
if (error.ContextMenuAddInTreeEntry != null) {
contextMenuAddInTreeEntry = error.ContextMenuAddInTreeEntry;
}
contextMenuAddInTreeEntry = error.ContextMenuAddInTreeEntry;
contextMenuOwner = error;
tag = error.Tag;
}
public void JumpToPosition()

Loading…
Cancel
Save