Browse Source

Fix context actions and issue manager.

newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
485309d3e4
  1. 96
      src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin
  2. 9
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/CSharpFullParseInformation.cs
  3. 2
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/Parser.cs
  4. 13
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/IssueManager.cs
  5. 7
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/SDScript.cs
  6. 85
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlParser.cs
  7. 1
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/EditorActionsProvider.cs
  8. 2
      src/Main/Base/Project/Src/Project/Solution/SolutionPreferences.cs
  9. 12
      src/Main/SharpDevelop/Parser/ParserService.cs
  10. 8
      src/Main/SharpDevelop/Parser/ParserServiceEntry.cs

96
src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin

@ -130,78 +130,88 @@
</Path> </Path>
<Path path = "/SharpDevelop/ViewContent/TextEditor/C#/IssueProviders"> <Path path = "/SharpDevelop/ViewContent/TextEditor/C#/IssueProviders">
<Class id = "ConditionalToNullCoalescingInspector" <Class id = "ConditionalToNullCoalescing"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.ConditionalToNullCoalescingInspector" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.ConditionalToNullCoalescingIssue" />
<Class id = "NotImplementedExceptionInspector" <Class id = "NotImplementedException"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.NotImplementedExceptionInspector" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.NotImplementedExceptionIssue" />
<Class id = "RedundantInternalInspector" <Class id = "RedundantInternal"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.RedundantInternalInspector" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.RedundantInternalIssue" />
<Class id = "RedundantNamespaceUsageInspector" <Class id = "RedundantNamespaceUsage"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.RedundantNamespaceUsageInspector" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.RedundantNamespaceUsageIssue" />
<Class id = "RedundantPrivateInspector" <Class id = "RedundantPrivate"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.RedundantPrivateInspector" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.RedundantPrivateIssue" />
<Class id = "RedundantThisInspector" <Class id = "RedundantThis"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.RedundantThisInspector" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.RedundantThisIssue" />
<Class id = "RedundantUsingInspector" <Class id = "RedundantUsing"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.RedundantUsingInspector" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.RedundantUsingIssue" />
<Class id = "StringIsNullOrEmptyInspector" <Class id = "StringIsNullOrEmpty"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.StringIsNullOrEmptyInspector" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.StringIsNullOrEmptyIssue" />
<Class id = "UseVarKeywordInspector" <Class id = "UseVarKeyword"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.UseVarKeywordInspector" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.UseVarKeywordIssue" />
</Path> </Path>
<Path path = "/SharpDevelop/ViewContent/TextEditor/C#/ContextActions"> <Path path = "/SharpDevelop/ViewContent/TextEditor/C#/ContextActions">
<!-- In this path, you can add SD context action providers using <Class>, <!-- In this path, you can add SD context action providers using <Class>,
or you can add NR5 code action providers using <CSharpCodeActionProvider> --> or you can add NR5 code action providers using <CSharpCodeActionProvider> -->
<CSharpCodeActionProvider id = "AddAnotherAccessor" <CSharpCodeActionProvider id = "AddAnotherAccessor"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.AddAnotherAccessor" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.AddAnotherAccessorAction" />
<CSharpCodeActionProvider id = "CheckIfParameterIsNull" <CSharpCodeActionProvider id = "CheckIfParameterIsNull"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.CheckIfParameterIsNull" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.CheckIfParameterIsNullAction" />
<CSharpCodeActionProvider id = "ConvertDecToHex" <CSharpCodeActionProvider id = "ConvertDecToHex"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.ConvertDecToHex" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.ConvertDecToHexAction" />
<CSharpCodeActionProvider id = "ConvertHexToDec" <CSharpCodeActionProvider id = "ConvertHexToDec"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.ConvertHexToDec" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.ConvertHexToDecAction" />
<CSharpCodeActionProvider id = "ConvertForeachToFor" <CSharpCodeActionProvider id = "ConvertForeachToFor"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.ConvertForeachToFor" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.ConvertForeachToForAction" />
<CSharpCodeActionProvider id = "CreateBackingStore" <CSharpCodeActionProvider id = "CreateBackingStore"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.CreateBackingStore" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.CreateBackingStoreAction" />
<CSharpCodeActionProvider id = "CreateClassDeclaration"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.CreateClassDeclarationAction" />
<CSharpCodeActionProvider id = "CreateConstructorDeclaration"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.CreateConstructorDeclarationAction" />
<CSharpCodeActionProvider id = "CreateDelegateAction"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.CreateDelegateAction" />
<CSharpCodeActionProvider id = "CreateEventInvocator" <CSharpCodeActionProvider id = "CreateEventInvocator"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.CreateEventInvocator" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.CreateEventInvocatorAction" />
<CSharpCodeActionProvider id = "CreateField" <CSharpCodeActionProvider id = "CreateField"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.CreateField" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.CreateFieldAction" />
<CSharpCodeActionProvider id = "CreateLocalVariable" <CSharpCodeActionProvider id = "CreateLocalVariable"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.CreateLocalVariable" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.CreateLocalVariableAction" />
<CSharpCodeActionProvider id = "CreateMethodDeclaration"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.CreateMethodDeclarationAction" />
<CSharpCodeActionProvider id = "CreateProperty" <CSharpCodeActionProvider id = "CreateProperty"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.CreateProperty" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.CreatePropertyAction" />
<CSharpCodeActionProvider id = "DeclareLocalVariable"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.DeclareLocalVariableAction" />
<CSharpCodeActionProvider id = "FlipOperatorArguments" <CSharpCodeActionProvider id = "FlipOperatorArguments"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.FlipOperatorArguments" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.FlipOperatorArgumentsAction" />
<CSharpCodeActionProvider id = "GenerateGetter" <CSharpCodeActionProvider id = "GenerateGetter"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.GenerateGetter" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.GenerateGetterAction" />
<CSharpCodeActionProvider id = "GenerateProperty" <CSharpCodeActionProvider id = "GenerateProperty"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.GenerateProperty" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.GeneratePropertyAction" />
<CSharpCodeActionProvider id = "GenerateSwitchLabels" <CSharpCodeActionProvider id = "GenerateSwitchLabels"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.GenerateSwitchLabels" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.GenerateSwitchLabelsAction" />
<CSharpCodeActionProvider id = "InsertAnonymousMethodSignature" <CSharpCodeActionProvider id = "InsertAnonymousMethodSignature"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.InsertAnonymousMethodSignature" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.InsertAnonymousMethodSignatureAction" />
<CSharpCodeActionProvider id = "IntroduceFormatItem" <CSharpCodeActionProvider id = "IntroduceFormatItem"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.IntroduceFormatItem" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.IntroduceFormatItemAction" />
<CSharpCodeActionProvider id = "InvertIf" <CSharpCodeActionProvider id = "InvertIf"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.InvertIf" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.InvertIfAction" />
<CSharpCodeActionProvider id = "RemoveBackingStore" <CSharpCodeActionProvider id = "RemoveBackingStore"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.RemoveBackingStore" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.RemoveBackingStoreAction" />
<CSharpCodeActionProvider id = "RemoveBraces" <CSharpCodeActionProvider id = "RemoveBraces"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.RemoveBraces" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.RemoveBracesAction" />
<CSharpCodeActionProvider id = "RemoveRegion" <CSharpCodeActionProvider id = "RemoveRegion"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.RemoveRegion" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.RemoveRegionAction" />
<CSharpCodeActionProvider id = "ReplaceEmptyString" <CSharpCodeActionProvider id = "ReplaceEmptyString"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.ReplaceEmptyString" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.ReplaceEmptyStringAction" />
<CSharpCodeActionProvider id = "SplitDeclarationAndAssignment" <CSharpCodeActionProvider id = "SplitDeclarationAndAssignment"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.SplitDeclarationAndAssignment" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.SplitDeclarationAndAssignmentAction" />
<CSharpCodeActionProvider id = "SplitString" <CSharpCodeActionProvider id = "SplitString"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.SplitString" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.SplitStringAction" />
<CSharpCodeActionProvider id = "UseExplicitType" <CSharpCodeActionProvider id = "UseExplicitType"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.UseExplicitType" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.UseExplicitTypeAction" />
<CSharpCodeActionProvider id = "UseVarKeyword" <CSharpCodeActionProvider id = "UseVarKeyword"
class = "ICSharpCode.NRefactory.CSharp.Refactoring.UseVarKeyword" /> class = "ICSharpCode.NRefactory.CSharp.Refactoring.UseVarKeywordAction" />
</Path> </Path>
</AddIn> </AddIn>

9
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/CSharpFullParseInformation.cs

@ -6,6 +6,7 @@ using System.Threading;
using ICSharpCode.NRefactory.CSharp; using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.CSharp.Resolver; using ICSharpCode.NRefactory.CSharp.Resolver;
using ICSharpCode.NRefactory.CSharp.TypeSystem; using ICSharpCode.NRefactory.CSharp.TypeSystem;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Parser; using ICSharpCode.SharpDevelop.Parser;
@ -14,14 +15,16 @@ namespace CSharpBinding.Parser
public class CSharpFullParseInformation : ParseInformation public class CSharpFullParseInformation : ParseInformation
{ {
readonly CompilationUnit compilationUnit; readonly CompilationUnit compilationUnit;
readonly ITextSourceVersion parsedVersion;
public CSharpFullParseInformation(CSharpParsedFile parsedFile, CompilationUnit compilationUnit) public CSharpFullParseInformation(CSharpParsedFile parsedFile, ITextSourceVersion parsedVersion, CompilationUnit compilationUnit)
: base(parsedFile, isFullParseInformation: true) : base(parsedFile, isFullParseInformation: true)
{ {
if (parsedFile == null) if (parsedFile == null)
throw new ArgumentNullException("parsedFile"); throw new ArgumentNullException("parsedFile");
if (compilationUnit == null) if (compilationUnit == null)
throw new ArgumentNullException("compilationUnit"); throw new ArgumentNullException("compilationUnit");
this.parsedVersion = parsedVersion;
this.compilationUnit = compilationUnit; this.compilationUnit = compilationUnit;
} }
@ -33,6 +36,10 @@ namespace CSharpBinding.Parser
get { return compilationUnit; } get { return compilationUnit; }
} }
public ITextSourceVersion ParsedVersion {
get { return parsedVersion; }
}
public CSharpAstResolver GetResolver(ICompilation compilation) public CSharpAstResolver GetResolver(ICompilation compilation)
{ {
return (CSharpAstResolver)compilation.CacheManager.GetOrAddShared( return (CSharpAstResolver)compilation.CacheManager.GetOrAddShared(

2
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/Parser.cs

@ -79,7 +79,7 @@ namespace CSharpBinding.Parser
ParseInformation parseInfo; ParseInformation parseInfo;
if (fullParseInformationRequested) if (fullParseInformationRequested)
parseInfo = new CSharpFullParseInformation(file, cu); parseInfo = new CSharpFullParseInformation(file, fileContent.Version, cu);
else else
parseInfo = new ParseInformation(file, fullParseInformationRequested); parseInfo = new ParseInformation(file, fullParseInformationRequested);

13
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/IssueManager.cs

@ -92,6 +92,7 @@ namespace CSharpBinding.Refactoring
this.editor = editor; this.editor = editor;
this.markerService = editor.GetService(typeof(ITextMarkerService)) as ITextMarkerService; this.markerService = editor.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
//SD.ParserService.ParserUpdateStepFinished += ParserService_ParserUpdateStepFinished; //SD.ParserService.ParserUpdateStepFinished += ParserService_ParserUpdateStepFinished;
SD.ParserService.ParseInformationUpdated += new EventHandler<ParseInformationEventArgs>(SD_ParserService_ParseInformationUpdated);
editor.ContextActionProviders.Add(this); editor.ContextActionProviders.Add(this);
} }
@ -218,17 +219,19 @@ namespace CSharpBinding.Refactoring
analyzedVersion = null; analyzedVersion = null;
} }
void ParserService_ParserUpdateStepFinished(object sender, ParserUpdateStepEventArgs e) void SD_ParserService_ParseInformationUpdated(object sender, ParseInformationEventArgs e)
{ {
var parseInfo = e.ParseInformation as CSharpFullParseInformation; var parseInfo = e.NewParseInformation as CSharpFullParseInformation;
ITextSourceVersion currentVersion = editor.Document.Version; ITextSourceVersion currentVersion = editor.Document.Version;
ITextSourceVersion parsedVersion = e.Content.Version; if (parseInfo == null)
if (parseInfo != null && parsedVersion != null && currentVersion != null && parsedVersion.BelongsToSameDocumentAs(currentVersion)) { return;
ITextSourceVersion parsedVersion = parseInfo.ParsedVersion;
if (parsedVersion != null && currentVersion != null && parsedVersion.BelongsToSameDocumentAs(currentVersion)) {
if (analyzedVersion != null && analyzedVersion.CompareAge(parsedVersion) == 0) { if (analyzedVersion != null && analyzedVersion.CompareAge(parsedVersion) == 0) {
// don't analyze the same version twice // don't analyze the same version twice
return; return;
} }
RunAnalysis(e.Content, parseInfo); RunAnalysis(editor.Document.CreateSnapshot(), parseInfo);
} }
} }

7
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/SDScript.cs

@ -73,5 +73,12 @@ namespace CSharpBinding.Refactoring
{ {
// TODO // TODO
} }
public override void Dispose()
{
base.Dispose();
// refresh parse information so that the issue can disappear immediately
SD.ParserService.ParseAsync(editor.FileName, editor.Document).FireAndForget();
}
} }
} }

85
src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlParser.cs

@ -48,91 +48,20 @@ namespace ICSharpCode.XamlBinding
return false; return false;
} }
// volatile ITextSourceVersion lastParsedVersion;
/// <summary>
/// Parse the given text and enter read lock.
/// No parsing is done if the text is older than seen before.
/// </summary>
// public IDisposable ParseAndLock(ITextSource fileContent)
// {
// // Copy to ensure thread-safety
// var lastVer = this.lastParsedVersion;
// if (lastVer == null || // First parse
// fileContent.Version == null || // Versioning not supported
// !fileContent.Version.BelongsToSameDocumentAs(lastVer) || // Different document instance? Can happen after closing and reopening of file.
// fileContent.Version.CompareAge(lastVer) > 0) // Is fileContent newer?
// {
// parser.Lock.EnterWriteLock();
// // Double check, now that we are thread-safe
// lastVer = this.lastParsedVersion;
// if (lastVer == null || fileContent.Version == null || !fileContent.Version.BelongsToSameDocumentAs(lastVer)) {
// // First parse or versioning not supported
// using (DebugTimer.Time("normal parse"))
// parser.Parse(fileContent.Text, null);
// this.lastParsedVersion = fileContent.Version;
// } else if (fileContent.Version.CompareAge(lastParsedVersion) > 0) {
// // Incremental parse
// var changes = lastParsedVersion.GetChangesTo(fileContent.Version).
// Select(c => new DocumentChangeEventArgs(c.Offset, c.RemovedText, c.InsertedText));
// using (DebugTimer.Time("incremental parse"))
// parser.Parse(fileContent.Text, changes);
// this.lastParsedVersion = fileContent.Version;
// } else {
// // fileContent is older - no need to parse
// }
// parser.Lock.EnterReadLock();
// parser.Lock.ExitWriteLock();
// } else {
// // fileContent is older - no need to parse
// parser.Lock.EnterReadLock();
// }
// return new CallbackOnDispose(() => parser.Lock.ExitReadLock());
// }
//
// public ICompilationUnit Parse(IProjectContent projectContent, string fileName, ITextSource fileContent)
// {
// ICompilationUnit compilationUnit;
//
// using (ParseAndLock(fileContent)) {
// var document = parser.LastDocument;
//
// CompilationUnitCreatorVisitor visitor =
// new CompilationUnitCreatorVisitor(projectContent, fileContent.Text, fileName, lexerTags);
//
// document.AcceptVisitor(visitor);
//
// compilationUnit = visitor.CompilationUnit;
// }
//
// // During project load all XAML files are parsed
// // most of them are not opened, thus fileContent.Version is null.
// // We can clear the parser data, because the file will be reparsed
// // as soon as it is opened by the user.
//
// // This will save us some memory, because we only use the
// // compilation unit created by the visitor above for code completion.
// if (fileContent.Version == null) {
// parser.Lock.EnterWriteLock();
// // double-checked locking (other threads might parse the document in the meantime)
// if (lastParsedVersion == null) {
// parser.Clear();
// }
// parser.Lock.ExitWriteLock();
// }
//
// return compilationUnit;
// }
volatile IncrementalParserState parserState; volatile IncrementalParserState parserState;
public ParseInformation Parse(FileName fileName, ITextSource fileContent, bool fullParseInformationRequested, public ParseInformation Parse(FileName fileName, ITextSource fileContent, bool fullParseInformationRequested,
IProject parentProject, CancellationToken cancellationToken) IProject parentProject, CancellationToken cancellationToken)
{ {
AXmlParser parser = new AXmlParser(); AXmlParser parser = new AXmlParser();
AXmlDocument document; AXmlDocument document;
IncrementalParserState newParserState; IncrementalParserState newParserState;
document = parser.ParseIncremental(parserState, fileContent, out newParserState); if (fileContent.Version is OnDiskTextSourceVersion) {
document = parser.Parse(fileContent, cancellationToken);
newParserState = null;
} else {
document = parser.ParseIncremental(parserState, fileContent, out newParserState, cancellationToken);
}
parserState = newParserState; parserState = newParserState;
XamlParsedFile parsedFile = XamlParsedFile.Create(fileName, fileContent, document); XamlParsedFile parsedFile = XamlParsedFile.Create(fileName, fileContent, document);
ParseInformation parseInfo; ParseInformation parseInfo;

1
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/EditorActionsProvider.cs

@ -50,6 +50,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions
throw new ArgumentNullException("editorContext"); throw new ArgumentNullException("editorContext");
if (providers == null) if (providers == null)
throw new ArgumentNullException("providers"); throw new ArgumentNullException("providers");
LoadProviderVisibilities(providers);
this.providers = providers; this.providers = providers;
this.editorContext = editorContext; this.editorContext = editorContext;
} }

2
src/Main/Base/Project/Src/Project/Solution/SolutionPreferences.cs

@ -78,7 +78,7 @@ namespace ICSharpCode.SharpDevelop.Project
/// </summary> /// </summary>
Properties IMementoCapable.CreateMemento() Properties IMementoCapable.CreateMemento()
{ {
Properties p = properties; Properties p = properties.Clone();
p.Set("StartupProject", startupProject); p.Set("StartupProject", startupProject);
p.Set("ActiveConfiguration", activeConfiguration); p.Set("ActiveConfiguration", activeConfiguration);
p.Set("ActivePlatform", activePlatform); p.Set("ActivePlatform", activePlatform);

12
src/Main/SharpDevelop/Parser/ParserService.cs

@ -142,9 +142,7 @@ namespace ICSharpCode.SharpDevelop.Parser
#endregion #endregion
#region Entry management #region Entry management
const int cachedEntryCount = 5;
Dictionary<FileName, ParserServiceEntry> fileEntryDict = new Dictionary<FileName, ParserServiceEntry>(); Dictionary<FileName, ParserServiceEntry> fileEntryDict = new Dictionary<FileName, ParserServiceEntry>();
Queue<ParserServiceEntry> cacheExpiryQueue = new Queue<ParserServiceEntry>();
ParserServiceEntry GetFileEntry(FileName fileName, bool createIfMissing) ParserServiceEntry GetFileEntry(FileName fileName, bool createIfMissing)
{ {
@ -182,16 +180,22 @@ namespace ICSharpCode.SharpDevelop.Parser
} }
} }
const int cachedEntryCount = 5;
List<ParserServiceEntry> cacheExpiryQueue = new List<ParserServiceEntry>();
internal void RegisterForCacheExpiry(ParserServiceEntry entry) internal void RegisterForCacheExpiry(ParserServiceEntry entry)
{ {
// This method should not be called within any locks // This method should not be called within any locks
Debug.Assert(!Monitor.IsEntered(entry)); Debug.Assert(!Monitor.IsEntered(entry));
ParserServiceEntry expiredItem = null; ParserServiceEntry expiredItem = null;
lock (cacheExpiryQueue) { lock (cacheExpiryQueue) {
cacheExpiryQueue.Remove(entry); // remove entry from queue if it's already enqueued
if (cacheExpiryQueue.Count >= cachedEntryCount) { if (cacheExpiryQueue.Count >= cachedEntryCount) {
expiredItem = cacheExpiryQueue.Dequeue(); // dequeue item at front
expiredItem = cacheExpiryQueue[0];
cacheExpiryQueue.RemoveAt(0);
} }
cacheExpiryQueue.Enqueue(entry); cacheExpiryQueue.Add(entry); // add entry to back
} }
if (expiredItem != null) if (expiredItem != null)
expiredItem.ExpireCache(); expiredItem.ExpireCache();

8
src/Main/SharpDevelop/Parser/ParserServiceEntry.cs

@ -156,7 +156,7 @@ namespace ICSharpCode.SharpDevelop.Parser
fileContent = SD.FileService.GetFileContent(fileName); fileContent = SD.FileService.GetFileContent(fileName);
} }
return DoParse(fileContent, parentProject, false, cancellationToken).CachedParseInformation; return DoParse(fileContent, parentProject, true, cancellationToken).CachedParseInformation;
} }
public IParsedFile ParseFile(ITextSource fileContent, IProject parentProject, CancellationToken cancellationToken) public IParsedFile ParseFile(ITextSource fileContent, IProject parentProject, CancellationToken cancellationToken)
@ -231,10 +231,10 @@ namespace ICSharpCode.SharpDevelop.Parser
// Only if all parse runs succeeded, register the parse information. // Only if all parse runs succeeded, register the parse information.
currentVersion = fileContent.Version; currentVersion = fileContent.Version;
for (int i = 0; i < entries.Count; i++) { for (int i = 0; i < entries.Count; i++) {
if (fullParseInformationRequested || entries[i].CachedParseInformation != null) if (fullParseInformationRequested || (entries[i].CachedParseInformation != null && results[i].NewParseInformation.IsFullParseInformation))
entries[i] = new ProjectEntry(entries[i].Project, entries[i].ParsedFile, results[i].NewParseInformation); entries[i] = new ProjectEntry(entries[i].Project, results[i].NewParsedFile, results[i].NewParseInformation);
else else
entries[i] = new ProjectEntry(entries[i].Project, entries[i].ParsedFile, null); entries[i] = new ProjectEntry(entries[i].Project, results[i].NewParsedFile, null);
if (entries[i].Project != null) if (entries[i].Project != null)
entries[i].Project.OnParseInformationUpdated(results[i]); entries[i].Project.OnParseInformationUpdated(results[i]);
parserService.RaiseParseInformationUpdated(results[i]); parserService.RaiseParseInformationUpdated(results[i]);

Loading…
Cancel
Save