Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Nodejs/Product/Nodejs/Intellisense/AnalysisQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ sealed class AnalysisQueue : IDisposable {
private readonly HashSet<IGroupableAnalysisProject> _enqueuedGroups;
[NonSerialized]
private DateTime _lastSave;
private CancellationTokenSource _cancel;
private readonly CancellationTokenSource _cancel;
private bool _isAnalyzing;
private int _analysisPending;
private static readonly TimeSpan _SaveAnalysisTime = TimeSpan.FromMinutes(15);
Expand Down Expand Up @@ -137,6 +137,9 @@ public int AnalysisPending {

void IDisposable.Dispose() {
Stop();

_cancel.Dispose();
_workEvent.Dispose();
}

#endregion
Expand Down
38 changes: 19 additions & 19 deletions Nodejs/Product/Nodejs/Intellisense/BufferParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,15 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Threading;
using Microsoft.NodejsTools.Analysis;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;

namespace Microsoft.NodejsTools.Intellisense {
sealed partial class VsProjectAnalyzer {

class BufferParser {
class BufferParser : IDisposable {
internal VsProjectAnalyzer _parser;
private readonly Timer _timer;
private IList<ITextBuffer> _buffers;
Expand All @@ -51,18 +45,6 @@ public BufferParser(IProjectEntry initialProjectEntry, VsProjectAnalyzer parser,
InitBuffer(buffer);
}

public void StopMonitoring() {
foreach (var buffer in _buffers) {
buffer.ChangedLowPriority -= BufferChangedLowPriority;
buffer.Properties.RemoveProperty(typeof(BufferParser));
if (_document != null) {
_document.EncodingChanged -= EncodingChanged;
_document = null;
}
}
_timer.Dispose();
}

public ITextBuffer[] Buffers {
get {
return _buffers.ToArray();
Expand Down Expand Up @@ -270,6 +252,24 @@ internal ITextDocument Document {
return _document;
}
}

#region IDisposable
private bool disposedValue = false;

protected virtual void Dispose(bool disposing) {
if (!disposedValue) {
if (disposing) {
_timer.Dispose();
}

disposedValue = true;
}
}

public void Dispose() {
Dispose(true);
}
#endregion
}
}
}
7 changes: 7 additions & 0 deletions Nodejs/Product/Nodejs/Intellisense/VsProjectAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,13 @@ public void Dispose() {
_analysisQueue.Stop();
}

foreach (var bufferParser in _activeBufferParsers) {
bufferParser.Dispose();
}
_activeBufferParsers.Clear();

_queueActivityEvent.Dispose();

TaskProvider.Dispose();
}

Expand Down
4 changes: 4 additions & 0 deletions Nodejs/Product/Nodejs/Project/NodeModulesNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ protected override void Dispose(bool disposing) {
_npmController.CommandCompleted -= NpmController_CommandCompleted;
}

_devModulesNode.Dispose();
_optionalModulesNode.Dispose();
_globalModulesNode.Dispose();

_isDisposed = true;
}

Expand Down