public void Execute(Action <DaemonStageResult> committer) { var highlightings = new List <HighlightingInfo>(); foreach (var treeNode in myFile.Descendants()) { if (treeNode is PsiBuilderErrorElement error) { var range = error.GetDocumentRange(); highlightings.Add(new HighlightingInfo(range, new CSharpSyntaxError(error.ErrorDescription, range))); } if (treeNode is Spring_FunctionIdentifier id) { foreach (var reference in id.GetFirstClassReferences()) { if (!reference.Resolve().Info.ResolveErrorType.IsAcceptable&& !SpringLanguage.BuiltinNames.Contains(id.GetText())) { var range = id.GetDocumentRange(); highlightings.Add(new HighlightingInfo(range, new CSharpSyntaxError("Unresolved function name", range))); } } } } var result = new DaemonStageResult(highlightings); committer(result); }
public void Execute(Action <DaemonStageResult> committer) { var highlightings = new List <HighlightingInfo>(); foreach (var treeNode in _file.Descendants()) { if (treeNode is SpringNodeError error) { var range = error.GetDocumentRange().ExtendRight(error.Length); highlightings.Add(new HighlightingInfo(range, new CSharpSyntaxError(error.ErrorDescription, range))); } var references = _referenceFactory.GetReferences(treeNode, ReferenceCollection.Empty); if (references.Any(it => it.Resolve().Info.ResolveErrorType != ResolveErrorType.OK)) { var range = references.First().GetDocumentRange(); highlightings.Add(new HighlightingInfo(range, new CSharpSyntaxError("Undefined symbol", range))); } } var result = new DaemonStageResult(highlightings); committer(result); }
public void Execute(Action <DaemonStageResult> committer) { var highlightings = new List <HighlightingInfo>(); foreach (var treeNode in myFile.Descendants()) { if (treeNode is SpringPsiBuilderErrorElement error) { var range = error.GetDocumentRange().ExtendRight(error.Length); highlightings.Add(error.IsSyntaxError ? new HighlightingInfo(range, new CSharpSyntaxError(error.ErrorDescription, range)) : new HighlightingInfo(range, new SpringUnresolvedError(error.ErrorDescription, range))); } else { foreach (var reference in _factory.GetReferences(treeNode, ReferenceCollection.Empty)) { if (reference.Resolve().Info.ResolveErrorType != ResolveErrorType.OK) { var range = reference.GetDocumentRange(); highlightings.Add(new HighlightingInfo(range, new SpringUnresolvedError("Can't resolve identifier", range))); } } } } var result = new DaemonStageResult(highlightings); committer(result); }
public void Execute(Action <DaemonStageResult> commiter) { PsiManager manager = PsiManager.GetInstance(myDaemonProcess.Solution); ICSharpFile file = manager.GetPsiFile(myDaemonProcess.SourceFile, CSharpLanguage.Instance) as ICSharpFile; if (file == null) { return; } // Running visitor against the PSI var elementProcessor = new MakeEnumComparisonTypeSafeFinderElementProcessor(myDaemonProcess); file.ProcessDescendants(elementProcessor); // Checking if the daemon is interrupted by user activity if (myDaemonProcess.InterruptFlag) { throw new ProcessCancelledException(); } // Fill in the result DaemonStageResult result = new DaemonStageResult(elementProcessor.Highlightings); commiter(result); }
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 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 void Execute(Action <DaemonStageResult> committer) { var highlightings = new List <HighlightingInfo>(); foreach (var treeNode in myFile.Descendants()) { if (treeNode is PsiBuilderErrorElement error) { var range = error.GetDocumentRange(); highlightings.Add(new HighlightingInfo(range, new CSharpSyntaxError(error.ErrorDescription, range))); } } var result = new DaemonStageResult(highlightings); committer(result); }
public void Execute(Action<DaemonStageResult> commiter) { PsiManager manager = PsiManager.GetInstance(myDaemonProcess.Solution); ICSharpFile file = manager.GetPsiFile(myDaemonProcess.SourceFile, CSharpLanguage.Instance) as ICSharpFile; if (file == null) return; // Running visitor against the PSI var elementProcessor = new MakeEnumComparisonTypeSafeFinderElementProcessor(myDaemonProcess); file.ProcessDescendants(elementProcessor); // Checking if the daemon is interrupted by user activity if (myDaemonProcess.InterruptFlag) throw new ProcessCancelledException(); // Fill in the result DaemonStageResult result = new DaemonStageResult(elementProcessor.Highlightings); commiter(result); }
public void Execute(Action <DaemonStageResult> committer) { var highlightings = new List <HighlightingInfo>(); foreach (var treeNode in myFile.Descendants()) { switch (treeNode) { case PsiBuilderErrorElement error: { var range = error.GetDocumentRange(); highlightings.Add(new HighlightingInfo(range, new CSharpSyntaxError(error.ErrorDescription, range))); break; } case SpringIdent refer: { var refs = refer.GetFirstClassReferences(); foreach (var reff in refs) { if (reff.Resolve().Info.ResolveErrorType == ResolveErrorType.OK) { continue; } var rangeR = reff.GetDocumentRange(); if (!rangeR.IsEmpty) { highlightings.Add(new HighlightingInfo(rangeR, new CSharpSyntaxError("Cannot resolve a symbol", rangeR))); } } break; } } } var result = new DaemonStageResult(highlightings); committer(result); }
/// <summary> /// Called by ReSharper when it wants us to execute our work. /// </summary> /// <param name="committer">A call-back through which we supply the results /// of our processing.</param> public void Execute(Action<DaemonStageResult> committer) { DaemonStageResult result = null; if (_config != null) { List<HighlightingInfo> highlights = null; // Top-level imports (outside of any namespace blocks) are a singular special // case; the other place that imports can be found is in namespace blocks, and // since those can be nested, we have to walk them recursively. CheckImports(_file, ref highlights); WalkNamespaceDeclarations(_file.NamespaceDeclarations, ref highlights); if (highlights != null) { result = new DaemonStageResult(highlights); } } committer(result); }
public void Execute(Action <DaemonStageResult> committer) { var myLock = new object(); IEnumerable <IEnumerable <Statement> > receivedTraces = null; void SetResponseTraces(IEnumerable <IEnumerable <Statement> > traces) { lock (myLock) { receivedTraces = traces ?? new List <IEnumerable <Statement> >(); } } bool GotResponse() { lock (myLock) { return(receivedTraces != null); } } myCofraFacade.GetTaintedSinks(myPersistentIndexManager[mySourceFile], SetResponseTraces); while (!GotResponse()) { Thread.Sleep(100); CheckInterruptAndThrow(); } var highlightings = TaintedSinksHighlighterUtils.HighlightingsFromStackTraces( myPersistentIndexManager, mySourceFile.Document, receivedTraces); var result = new DaemonStageResult(highlightings); using (ReadLockCookie.Create()) { committer(result); } }
/// <summary> /// Called by ReSharper when it wants us to execute our work. /// </summary> /// <param name="committer">A call-back through which we supply the results /// of our processing.</param> public void Execute(Action <DaemonStageResult> committer) { DaemonStageResult result = null; if (_config != null) { List <HighlightingInfo> highlights = null; // Top-level imports (outside of any namespace blocks) are a singular special // case; the other place that imports can be found is in namespace blocks, and // since those can be nested, we have to walk them recursively. CheckImports(_file, ref highlights); WalkNamespaceDeclarations(_file.NamespaceDeclarations, ref highlights); if (highlights != null) { result = new DaemonStageResult(highlights); } } committer(result); }
public void DoHighlighting(DaemonStageResult result) { myCommiter(result); }