public void ConsumeHighlighting(HighlightingInfo highlightingInfo) { if (!(highlightingInfo.Highlighting is AnnotationRedundancyInHierarchyWarning)) { _decorated.ConsumeHighlighting(highlightingInfo); } }
private void ReportDuplicateDirective([NotNull] IT4Directive directive) { var warning = new IgnoredDirectiveWarning(directive); var highlightingInfo = new HighlightingInfo(directive.GetHighlightingRange(), warning); MyHighlightings.Add(highlightingInfo); }
private void AddHighLighting(DocumentRange range, ITreeNode element, IHighlightingConsumer consumer, IHighlighting highlighting) { var info = new HighlightingInfo(range, highlighting, new Severity?()); IFile file = element.GetContainingFile(); if (file != null) { consumer.AddHighlighting(info.Highlighting, file); } }
public void Execute(Action <DaemonStageResult> commiter) { try { // GetText gives the unsaved file contents, unlike file.ProjectFile.GetReadStream(). string codeText = myDaemonProcess.Document.GetText(); // I do not remember anymore why I created the Shallow version... var cloneFinder = new MethodsOnASingleClassCloneFinder(new ShallowExpansionFactory()); //var cloneFinder = new MethodsOnASingleClassCloneFinder(new OscillatingExtractMethodExpansionFactory()); cloneFinder.AddRefactoring(new LiteralToParameterExpansion()); ScanResult scan_result = cloneFinder.GetCloneReplacements(codeText); if (scan_result != null) { var document = myDaemonProcess.SourceFile.Document; var Highlightings = new List <HighlightingInfo>(); foreach (var info in scan_result.Clones) { // We basically highlight the first line of the clone. var start = document.GetLineStartOffset(((Int32 <DocLine>)(info.HighlightStartLocationLine - 1))) + info.HighlightStartLocationColumn; var end = start + info.HighlightLength;// Hmm, HighlightLength seems sort of arbitrary. var warningHighlightRange = new DocumentRange(document, new TextRange(start, end)); // And this defines the chunk that gets replaced. var replacedCodeRange = new DocumentRange(document, new TextRange( document.GetLineStartOffset( (Int32 <DocLine>) (info.ReplacementSectionStartLine - 1)), document.GetLineStartOffset( (Int32 <DocLine>) info.ReplacementSectionEndLine))); var highlight = new HighlightingInfo(warningHighlightRange, new CloneDetectionHighlighting(info, replacedCodeRange)); Highlightings.Add(highlight); } // Creating container to put highlightings into. DaemonStageResult ret = new DaemonStageResult(Highlightings); commiter(ret); } } catch (Exception e) { System.Diagnostics.Debug.Write(e); throw; } }
private HighlightingInfo[] GetHighlightings() { #if RESHARPER_60_OR_NEWER var projectFile = DaemonProcess.SourceFile.ToProjectFile(); if (projectFile == null || !projectFile.IsValid()) #else IProjectFile projectFile = DaemonProcess.ProjectFile; if (!projectFile.IsValid) #endif { return(EmptyArray <HighlightingInfo> .Instance); } var state = ProjectFileState.GetFileState(projectFile); if (state == null) { return(EmptyArray <HighlightingInfo> .Instance); } var highlightings = new List <HighlightingInfo>(); foreach (AnnotationState annotation in state.Annotations) { IDeclaredElement declaredElement = annotation.GetDeclaredElement(); if (declaredElement != null && declaredElement.IsValid()) { #if RESHARPER_60_OR_NEWER foreach (IDeclaration declaration in declaredElement.GetDeclarationsIn(DaemonProcess.SourceFile)) #else foreach (IDeclaration declaration in declaredElement.GetDeclarationsIn(projectFile)) #endif { if (declaration.IsValid()) { ReSharperDocumentRange range = declaration.GetNameDocumentRange(); #if RESHARPER_31 || RESHARPER_40 || RESHARPER_41 if (range.IsValid) #else if (range.IsValid()) #endif { var annotationHighlighting = AnnotationHighlighting.CreateHighlighting(annotation); #if RESHARPER_60_OR_NEWER var highlightingInfo = new HighlightingInfo(range, annotationHighlighting, null, null); #else var highlightingInfo = new HighlightingInfo(range, annotationHighlighting); #endif highlightings.Add(highlightingInfo); } } } } } return(highlightings.ToArray()); }
public void Execute(Action<DaemonStageResult> commiter) { try { // GetText gives the unsaved file contents, unlike file.ProjectFile.GetReadStream(). string codeText = myDaemonProcess.Document.GetText(); // I do not remember anymore why I created the Shallow version... var cloneFinder = new MethodsOnASingleClassCloneFinder(new ShallowExpansionFactory()); //var cloneFinder = new MethodsOnASingleClassCloneFinder(new OscillatingExtractMethodExpansionFactory()); cloneFinder.AddRefactoring(new LiteralToParameterExpansion()); ScanResult scan_result = cloneFinder.GetCloneReplacements(codeText); if (scan_result != null) { var document = myDaemonProcess.SourceFile.Document; var Highlightings = new List<HighlightingInfo>(); foreach (var info in scan_result.Clones) { // We basically highlight the first line of the clone. var start = document.GetLineStartOffset(((Int32<DocLine>) (info.HighlightStartLocationLine - 1))) + info.HighlightStartLocationColumn; var end = start + info.HighlightLength;// Hmm, HighlightLength seems sort of arbitrary. var warningHighlightRange = new DocumentRange(document, new TextRange(start, end)); // And this defines the chunk that gets replaced. var replacedCodeRange = new DocumentRange(document, new TextRange( document.GetLineStartOffset( (Int32<DocLine>) (info.ReplacementSectionStartLine-1)), document.GetLineStartOffset( (Int32<DocLine>) info.ReplacementSectionEndLine))); var highlight = new HighlightingInfo(warningHighlightRange, new CloneDetectionHighlighting(info, replacedCodeRange)); Highlightings.Add(highlight); } // Creating container to put highlightings into. DaemonStageResult ret = new DaemonStageResult(Highlightings); commiter(ret); } } catch (Exception e) { System.Diagnostics.Debug.Write(e); throw; } }
public override void CommitHighlighters(DaemonCommitContext context) { HighlightingSettingsManager instance = HighlightingSettingsManager.Instance; foreach (HighlightingInfo highlightingInfo in context.HighlightingsToAdd) { if (highlightingInfo.Range.Contains(myCaretRange) && instance.GetSeverity(highlightingInfo.Highlighting, SourceFile) == Severity.INFO) { if (highlightingInfo.Highlighting is CSharpIdentifierHighlighting) HighlightingInfo = highlightingInfo; break; } } }
public override void CommitHighlighters(DaemonCommitContext context) { HighlightingSettingsManager instance = HighlightingSettingsManager.Instance; foreach (HighlightingInfo highlightingInfo in context.HighlightingsToAdd) { if (highlightingInfo.Range.Contains(myCaretRange) && instance.GetSeverity(highlightingInfo.Highlighting, SourceFile) == Severity.INFO) { if (highlightingInfo.Highlighting is CSharpIdentifierHighlighting) { HighlightingInfo = highlightingInfo; } break; } } }
protected override void CommitHighlighters(DaemonCommitContext context) { var instance = HighlightingSettingsManager.Instance; foreach (var highlightingInfo in context.HighlightingsToAdd) { var severity = instance.GetSeverity(highlightingInfo.Highlighting, SourceFile, Solution, ContextBoundSettingsStore); if (highlightingInfo.Range.Contains(myCaretRange) && severity == Severity.INFO) { if (highlightingInfo.Highlighting is CSharpIdentifierHighlighting) { HighlightingInfo = highlightingInfo; } break; } } }
private static void InsertFolding(IList <HighlightingInfo> result, HighlightingInfo highlightingInfo) { var textRange = highlightingInfo.Highlighting.CalculateRange().TextRange; var start = textRange.StartOffset; var end = textRange.EndOffset; var insertIndex = result.Count; for (var i = 0; i < result.Count; i++) { var range = result[i].Highlighting.CalculateRange().TextRange; var rStart = range.StartOffset; var rEnd = range.EndOffset; if (rStart < start) { if (start < rEnd && rEnd < end) { return; } } else if (rStart == start) { if (rEnd == end) { return; } if (rEnd > end) { insertIndex = Math.Min(insertIndex, i); } } else { insertIndex = Math.Min(insertIndex, i); if (rStart > end) { break; } if (rStart < end && end < rEnd) { return; } } } result.Insert(insertIndex, highlightingInfo); }
void ColorizeMember(HighlightingInfo info, DocumentLine line, IMember member) { try { Action <VisualLineElement> handler = null; if (info.Token.StartsWith(info.Context.XamlNamespacePrefix + ":", StringComparison.Ordinal)) { handler = HighlightProperty; } else if (info.Context.IgnoredXmlns.Any(item => info.Token.StartsWith(item + ":", StringComparison.Ordinal))) { handler = HighlightIgnored; } else if (member != null) { if (member is IEvent) { handler = HighlightEvent; } else { handler = HighlightProperty; } } else { if (info.Token.StartsWith("xmlns", StringComparison.OrdinalIgnoreCase) || info.Token.StartsWith(Utils.GetNamespacePrefix(CompletionDataHelper.MarkupCompatibilityNamespace, info.Context) + ":", StringComparison.OrdinalIgnoreCase)) { handler = HighlightNamespaceDeclaration; } else if (info.Token.StartsWith("xml:", StringComparison.OrdinalIgnoreCase)) { handler = HighlightProperty; } else { Core.LoggingService.Debug(info.Token + " not highlighted; line " + line.LineNumber); } } if (handler != null) { ChangeLinePart(line.Offset + info.StartOffset, line.Offset + info.EndOffset, handler); } } catch (ArgumentOutOfRangeException) {} }
public override void ConsumeHighlighting(HighlightingInfo highlightingInfo) { var highlighting = highlightingInfo.Highlighting; Assertion.Assert(highlighting is PerformanceHighlightingBase, "highlightingInfo is PerformanceCriticalCodeHighlightingBase"); var performanceHighlighting = highlighting as PerformanceHighlightingBase; if (myRegionsInfo != null) { if (myRegionsInfo.ShouldIgnoreWarningHighlighting(performanceHighlighting.SeverityId, highlightingInfo, false, out var _)) { return; } } ConsumeInfo(highlightingInfo); }
private void AddHighlighting(HighlightedWarning warning, ITreeNode node) { var sameHighlight = highlightings.SingleOrDefault(SameNode(node)); if (sameHighlight != null) { ((LintHighlightingBase)sameHighlight.Highlighting).AddWarning(warning.Warning); } else { var highlightingInfo = new HighlightingInfo(node.GetDocumentRange(), CreateHighlighting(warning, node)); highlightings.Add(highlightingInfo); } warning.Highlighted = true; }
protected void AddHighlighting([NotNull] HighlightingInfo highlighting) { _highlightings.Add(highlighting); }
void ColorizeMember(HighlightingInfo info, DocumentLine line, IMember member) { try { Action<VisualLineElement> handler = null; if (info.Token.StartsWith(info.Context.XamlNamespacePrefix + ":", StringComparison.Ordinal)) handler = HighlightProperty; else if (info.Context.IgnoredXmlns.Any(item => info.Token.StartsWith(item + ":", StringComparison.Ordinal))) handler = HighlightIgnored; else if (member != null) { if (member is IEvent) handler = HighlightEvent; else handler = HighlightProperty; } else { if (info.Token.StartsWith("xmlns", StringComparison.OrdinalIgnoreCase) || info.Token.StartsWith(Utils.GetNamespacePrefix(CompletionDataHelper.MarkupCompatibilityNamespace, info.Context) + ":", StringComparison.OrdinalIgnoreCase)) handler = HighlightNamespaceDeclaration; else if (info.Token.StartsWith("xml:", StringComparison.OrdinalIgnoreCase)) handler = HighlightProperty; else Core.LoggingService.Debug(info.Token + " not highlighted; line " + line.LineNumber); } if (handler != null) ChangeLinePart(line.Offset + info.StartOffset, line.Offset + info.EndOffset, handler); } catch (ArgumentOutOfRangeException) {} }
private HighlightingInfo[] GetHighlightings() { #if RESHARPER_60_OR_NEWER var projectFile = DaemonProcess.SourceFile.ToProjectFile(); if (projectFile == null || !projectFile.IsValid()) #else IProjectFile projectFile = DaemonProcess.ProjectFile; if (! projectFile.IsValid) #endif return EmptyArray<HighlightingInfo>.Instance; var state = ProjectFileState.GetFileState(projectFile); if (state == null) return EmptyArray<HighlightingInfo>.Instance; var highlightings = new List<HighlightingInfo>(); foreach (AnnotationState annotation in state.Annotations) { IDeclaredElement declaredElement = annotation.GetDeclaredElement(); if (declaredElement != null && declaredElement.IsValid()) { #if RESHARPER_60_OR_NEWER foreach (IDeclaration declaration in declaredElement.GetDeclarationsIn(DaemonProcess.SourceFile)) #else foreach (IDeclaration declaration in declaredElement.GetDeclarationsIn(projectFile)) #endif { if (declaration.IsValid()) { ReSharperDocumentRange range = declaration.GetNameDocumentRange(); #if RESHARPER_31 || RESHARPER_40 || RESHARPER_41 if (range.IsValid) #else if (range.IsValid()) #endif { var annotationHighlighting = AnnotationHighlighting.CreateHighlighting(annotation); #if RESHARPER_60_OR_NEWER var highlightingInfo = new HighlightingInfo(range, annotationHighlighting, null, null); #else var highlightingInfo = new HighlightingInfo(range, annotationHighlighting); #endif highlightings.Add(highlightingInfo); } } } } } return highlightings.ToArray(); }
private void AddHighLighting(DocumentRange range, IHighlightingConsumer consumer, IHighlighting highlighting) { var info = new HighlightingInfo(range, highlighting, new Severity?()); consumer.AddHighlighting(info.Highlighting, file); }