Browse Source

Fixed code analysis AddIn (fixed support for custom MSBuild loggers, ported SuppressMessageCommand to ITextEditor).

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4523 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
ee2a4e29cb
  1. 7
      src/AddIns/Misc/CodeAnalysis/Src/SuppressMessageCommand.cs
  2. 2
      src/AddIns/Misc/SearchAndReplace/Project/Gui/SearchResultNode.cs
  3. 48
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/OffsetChangeMap.cs
  4. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedInlineBuilder.cs
  5. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs
  6. 3
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/ThrowUtil.cs
  7. 14
      src/Main/Base/Project/Src/Project/MSBuildEngine/MSBuildEngine.cs
  8. 2
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/SearchClassReturnType.cs
  9. 11
      src/Main/ICSharpCode.SharpDevelop.Sda/Src/log4netLoggingService.cs

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

@ -42,10 +42,10 @@ namespace ICSharpCode.CodeAnalysis @@ -42,10 +42,10 @@ namespace ICSharpCode.CodeAnalysis
if (p.CompilationUnit == null || p.FileName == null || p.Line <= 0)
continue;
IViewContent viewContent = FileService.OpenFile(p.FileName);
ITextEditorControlProvider provider = viewContent as ITextEditorControlProvider;
ITextEditorProvider provider = viewContent as ITextEditorProvider;
if (provider == null)
continue;
IDocument document = new TextEditorDocument(provider.TextEditorControl.Document);
IDocument document = provider.TextEditor.Document;
if (p.Line >= document.TotalNumberOfLines)
continue;
IDocumentLine line = document.GetLine(p.Line);
@ -60,8 +60,7 @@ namespace ICSharpCode.CodeAnalysis @@ -60,8 +60,7 @@ namespace ICSharpCode.CodeAnalysis
string code = codegen.GenerateCode(CreateSuppressAttribute(p.CompilationUnit, tag), indentation.ToString());
if (!code.EndsWith("\n")) code += Environment.NewLine;
document.Insert(line.Offset, code);
provider.TextEditorControl.ActiveTextAreaControl.Caret.Line = p.Line - 1;
provider.TextEditorControl.ActiveTextAreaControl.ScrollToCaret();
provider.TextEditor.JumpTo(p.Line, p.Column);
TaskService.Remove(t);
ParserService.ParseViewContent(viewContent);
}

2
src/AddIns/Misc/SearchAndReplace/Project/Gui/SearchResultNode.cs

@ -96,7 +96,7 @@ namespace SearchAndReplace @@ -96,7 +96,7 @@ namespace SearchAndReplace
if (displayText != null) {
textBlock.Inlines.Add(displayText);
} else if (inlineBuilder != null) {
textBlock.Inlines.AddRange(inlineBuilder.CreateInlines());
textBlock.Inlines.AddRange(inlineBuilder.CreateRuns());
}
if (showFileName) {

48
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/OffsetChangeMap.cs

@ -5,10 +5,12 @@ @@ -5,10 +5,12 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.AvalonEdit.Utils;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using ICSharpCode.AvalonEdit.Utils;
namespace ICSharpCode.AvalonEdit.Document
{
@ -59,11 +61,15 @@ namespace ICSharpCode.AvalonEdit.Document @@ -59,11 +61,15 @@ namespace ICSharpCode.AvalonEdit.Document
/// Describes a series of offset changes.
/// </summary>
[Serializable]
[SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix",
Justification="It's a mapping old offsets -> new offsets")]
public sealed class OffsetChangeMap : Collection<OffsetChangeMapEntry>
{
/// <summary>
/// Immutable OffsetChangeMap that is empty.
/// </summary>
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
Justification="The Empty instance is immutable")]
public static readonly OffsetChangeMap Empty = new OffsetChangeMap(Utils.Empty<OffsetChangeMapEntry>.ReadOnlyCollection);
/// <summary>
@ -138,7 +144,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -138,7 +144,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// This represents the offset of a document change (either insertion or removal, not both at once).
/// </summary>
[Serializable]
public struct OffsetChangeMapEntry
public struct OffsetChangeMapEntry : IEquatable<OffsetChangeMapEntry>
{
readonly int offset;
readonly int removalLength;
@ -155,7 +161,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -155,7 +161,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// The number of characters removed.
/// Returns 0 if this entry represents an insertion.
/// </summary>
public int RemovalLength {
public int RemovalLength {
get { return removalLength; }
}
@ -206,5 +212,41 @@ namespace ICSharpCode.AvalonEdit.Document @@ -206,5 +212,41 @@ namespace ICSharpCode.AvalonEdit.Document
this.removalLength = removalLength;
this.insertionLength = insertionLength;
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked {
return offset + 3559 * insertionLength + 3571 * removalLength;
}
}
/// <inheritdoc/>
public override bool Equals(object obj)
{
return obj is OffsetChangeMapEntry && this.Equals((OffsetChangeMapEntry)obj);
}
/// <inheritdoc/>
public bool Equals(OffsetChangeMapEntry other)
{
return offset == other.offset && insertionLength == other.insertionLength && removalLength == other.removalLength;
}
/// <summary>
/// Tests the two entries for equality.
/// </summary>
public static bool operator ==(OffsetChangeMapEntry left, OffsetChangeMapEntry right)
{
return left.Equals(right);
}
/// <summary>
/// Tests the two entries for inequality.
/// </summary>
public static bool operator !=(OffsetChangeMapEntry left, OffsetChangeMapEntry right)
{
return !left.Equals(right);
}
}
}

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedInlineBuilder.cs

@ -52,7 +52,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -52,7 +52,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
int GetIndexForOffset(int offset)
{
if (offset < 0 || offset > text.Length)
throw new ArgumentOutOfRangeException();
throw new ArgumentOutOfRangeException("offset");
int index = stateChangeOffsets.BinarySearch(offset);
if (index < 0) {
index = ~index;
@ -152,7 +152,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -152,7 +152,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
/// <summary>
/// Creates WPF Run instances that can be used for TextBlock.Inlines.
/// </summary>
public Run[] CreateInlines()
public Run[] CreateRuns()
{
Run[] runs = new Run[stateChanges.Count];
for (int i = 0; i < runs.Length; i++) {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs

@ -384,6 +384,8 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -384,6 +384,8 @@ namespace ICSharpCode.AvalonEdit.Rendering
return mode == CaretPositioningMode.Normal;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "mode",
Justification = "make method consistent with HasImplicitStopAtLineStart; might depend on mode in the future")]
static bool HasImplicitStopAtLineEnd(CaretPositioningMode mode)
{
return true;

3
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/ThrowUtil.cs

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
// </file>
using System;
using System.Globalization;
namespace ICSharpCode.AvalonEdit.Utils
{
@ -42,7 +43,7 @@ namespace ICSharpCode.AvalonEdit.Utils @@ -42,7 +43,7 @@ namespace ICSharpCode.AvalonEdit.Utils
public static int CheckInRangeInclusive(int val, string parameterName, int lower, int upper)
{
if (val < lower || val > upper)
throw new ArgumentOutOfRangeException(parameterName, val, "Expected: " + lower.ToString() + " <= " + parameterName + " <= " + upper.ToString());
throw new ArgumentOutOfRangeException(parameterName, val, "Expected: " + lower.ToString(CultureInfo.InvariantCulture) + " <= " + parameterName + " <= " + upper.ToString(CultureInfo.InvariantCulture));
return val;
}

14
src/Main/Base/Project/Src/Project/MSBuildEngine/MSBuildEngine.cs

@ -187,6 +187,14 @@ namespace ICSharpCode.SharpDevelop.Project @@ -187,6 +187,14 @@ namespace ICSharpCode.SharpDevelop.Project
InterestingTasks.AddRange(MSBuildEngine.CompileTaskNames);
List<ILogger> loggers = new List<ILogger> {
new SharpDevelopLogger(this),
//new BuildLogFileLogger(fileName + ".log", LoggerVerbosity.Diagnostic)
};
foreach (IMSBuildAdditionalLogger loggerProvider in MSBuildEngine.AdditionalMSBuildLoggers) {
loggers.Add(loggerProvider.CreateLogger(this));
}
// Get ParallelMSBuildManager (or create a new one if one doesn't exist already).
// The serviceContainer will automatically dispose it after the build has completed.
ParallelMSBuildManager manager = (ParallelMSBuildManager)serviceContainer.GetOrCreateService(
@ -226,10 +234,6 @@ namespace ICSharpCode.SharpDevelop.Project @@ -226,10 +234,6 @@ namespace ICSharpCode.SharpDevelop.Project
string fileName = project.FileName;
string[] targets = { options.Target.TargetName };
BuildRequestData requestData = new BuildRequestData(fileName, globalProperties, null, targets, new HostServices());
ILogger[] loggers = {
new SharpDevelopLogger(this),
//new BuildLogFileLogger(fileName + ".log", LoggerVerbosity.Diagnostic)
};
manager.StartBuild(requestData, loggers, OnComplete);
}
@ -285,7 +289,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -285,7 +289,7 @@ namespace ICSharpCode.SharpDevelop.Project
buildInProcess = true;
}
LoggingService.Info("Start job (buildInProcess=" + buildInProcess + "): " + job.ToString());
*/
*/
static string EnsureBackslash(string path)
{

2
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/SearchClassReturnType.cs

@ -13,7 +13,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -13,7 +13,7 @@ namespace ICSharpCode.SharpDevelop.Dom
{
/// <summary>
/// The SearchClassReturnType is used when only a part of the class name is known and the
/// type can only be resolved on demand (the ConvertVisitor uses SearchClassReturnType's).
/// type can only be resolved on demand (the ConvertVisitor uses SearchClassReturnTypes).
/// </summary>
public sealed class SearchClassReturnType : ProxyReturnType
{

11
src/Main/ICSharpCode.SharpDevelop.Sda/Src/log4netLoggingService.cs

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
// </file>
using System;
using System.Globalization;
using System.IO;
using ICSharpCode.Core.Services;
using log4net;
@ -30,7 +31,7 @@ namespace ICSharpCode.SharpDevelop.Sda @@ -30,7 +31,7 @@ namespace ICSharpCode.SharpDevelop.Sda
public void DebugFormatted(string format, params object[] args)
{
log.DebugFormat(format, args);
log.DebugFormat(CultureInfo.InvariantCulture, format, args);
}
public void Info(object message)
@ -40,7 +41,7 @@ namespace ICSharpCode.SharpDevelop.Sda @@ -40,7 +41,7 @@ namespace ICSharpCode.SharpDevelop.Sda
public void InfoFormatted(string format, params object[] args)
{
log.InfoFormat(format, args);
log.InfoFormat(CultureInfo.InvariantCulture, format, args);
}
public void Warn(object message)
@ -55,7 +56,7 @@ namespace ICSharpCode.SharpDevelop.Sda @@ -55,7 +56,7 @@ namespace ICSharpCode.SharpDevelop.Sda
public void WarnFormatted(string format, params object[] args)
{
log.WarnFormat(format, args);
log.WarnFormat(CultureInfo.InvariantCulture, format, args);
}
public void Error(object message)
@ -70,7 +71,7 @@ namespace ICSharpCode.SharpDevelop.Sda @@ -70,7 +71,7 @@ namespace ICSharpCode.SharpDevelop.Sda
public void ErrorFormatted(string format, params object[] args)
{
log.ErrorFormat(format, args);
log.ErrorFormat(CultureInfo.InvariantCulture, format, args);
}
public void Fatal(object message)
@ -85,7 +86,7 @@ namespace ICSharpCode.SharpDevelop.Sda @@ -85,7 +86,7 @@ namespace ICSharpCode.SharpDevelop.Sda
public void FatalFormatted(string format, params object[] args)
{
log.FatalFormat(format, args);
log.FatalFormat(CultureInfo.InvariantCulture, format, args);
}
public bool IsDebugEnabled {

Loading…
Cancel
Save