mirror of
https://github.com/OlivierGuinart/Merlin32Language.git
synced 2024-05-31 18:41:30 +00:00
Refactoring only
This commit is contained in:
parent
22df541220
commit
6933f485a3
|
@ -13,35 +13,35 @@ namespace VSMerlin32.Coloring.Classification
|
|||
/// </summary>
|
||||
[Export(typeof(ClassificationTypeDefinition))]
|
||||
[Name(Merlin32TokenHelper.Merlin32Opcode)]
|
||||
internal static ClassificationTypeDefinition opcode = null;
|
||||
internal static ClassificationTypeDefinition Opcode = null;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the "directive" classification type.
|
||||
/// </summary>
|
||||
[Export(typeof(ClassificationTypeDefinition))]
|
||||
[Name(Merlin32TokenHelper.Merlin32Directive)]
|
||||
internal static ClassificationTypeDefinition directive = null;
|
||||
internal static ClassificationTypeDefinition Directive = null;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the "datadefine" classification type.
|
||||
/// </summary>
|
||||
[Export(typeof(ClassificationTypeDefinition))]
|
||||
[Name(Merlin32TokenHelper.Merlin32DataDefine)]
|
||||
internal static ClassificationTypeDefinition datadefine = null;
|
||||
internal static ClassificationTypeDefinition Datadefine = null;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the "text" classification type.
|
||||
/// </summary>
|
||||
[Export(typeof(ClassificationTypeDefinition))]
|
||||
[Name(Merlin32TokenHelper.Merlin32Text)]
|
||||
internal static ClassificationTypeDefinition text = null;
|
||||
internal static ClassificationTypeDefinition Text = null;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the "comment" classification type.
|
||||
/// </summary>
|
||||
[Export(typeof(ClassificationTypeDefinition))]
|
||||
[Name(Merlin32TokenHelper.Merlin32Comment)]
|
||||
internal static ClassificationTypeDefinition comment = null;
|
||||
internal static ClassificationTypeDefinition Comment = null;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ namespace VSMerlin32.Coloring.Classification
|
|||
[TagType(typeof(ClassificationTag))]
|
||||
internal sealed class Merlin32ClassifierProvider : ITaggerProvider
|
||||
{
|
||||
|
||||
[Export]
|
||||
[Name("Merlin32")]
|
||||
[BaseDefinition("code")]
|
||||
|
@ -28,34 +27,33 @@ namespace VSMerlin32.Coloring.Classification
|
|||
internal IClassificationTypeRegistryService ClassificationTypeRegistry = null;
|
||||
|
||||
[Import]
|
||||
internal IBufferTagAggregatorFactoryService aggregatorFactory = null;
|
||||
internal IBufferTagAggregatorFactoryService AggregatorFactory = null;
|
||||
|
||||
public ITagger<T> CreateTagger<T>(ITextBuffer buffer) where T : ITag
|
||||
{
|
||||
ITagAggregator<Merlin32TokenTag> merlin32TagAggregator =
|
||||
AggregatorFactory.CreateTagAggregator<Merlin32TokenTag>(buffer);
|
||||
|
||||
ITagAggregator<Merlin32TokenTag> Merlin32TagAggregator =
|
||||
aggregatorFactory.CreateTagAggregator<Merlin32TokenTag>(buffer);
|
||||
|
||||
return new Merlin32Classifier(buffer, Merlin32TagAggregator, ClassificationTypeRegistry) as ITagger<T>;
|
||||
return new Merlin32Classifier(buffer, merlin32TagAggregator, ClassificationTypeRegistry) as ITagger<T>;
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class Merlin32Classifier : ITagger<ClassificationTag>
|
||||
{
|
||||
ITextBuffer _buffer;
|
||||
ITagAggregator<Merlin32TokenTag> _aggregator;
|
||||
IDictionary<Merlin32TokenTypes, IClassificationType> _Merlin32Types;
|
||||
private ITextBuffer _buffer;
|
||||
private readonly ITagAggregator<Merlin32TokenTag> _aggregator;
|
||||
private readonly IDictionary<Merlin32TokenTypes, IClassificationType> _merlin32Types;
|
||||
|
||||
internal Merlin32Classifier(ITextBuffer buffer,
|
||||
ITagAggregator<Merlin32TokenTag> Merlin32TagAggregator,
|
||||
ITagAggregator<Merlin32TokenTag> merlin32TagAggregator,
|
||||
IClassificationTypeRegistryService typeService)
|
||||
{
|
||||
_buffer = buffer;
|
||||
_aggregator = Merlin32TagAggregator;
|
||||
_Merlin32Types = new Dictionary<Merlin32TokenTypes, IClassificationType>();
|
||||
_aggregator = merlin32TagAggregator;
|
||||
_merlin32Types = new Dictionary<Merlin32TokenTypes, IClassificationType>();
|
||||
|
||||
foreach (Merlin32TokenTypes token in Enum.GetValues(typeof(Merlin32TokenTypes)))
|
||||
_Merlin32Types[token] = typeService.GetClassificationType(token.ToString());
|
||||
_merlin32Types[token] = typeService.GetClassificationType(token.ToString());
|
||||
}
|
||||
|
||||
public event EventHandler<SnapshotSpanEventArgs> TagsChanged
|
||||
|
@ -66,13 +64,11 @@ namespace VSMerlin32.Coloring.Classification
|
|||
|
||||
public IEnumerable<ITagSpan<ClassificationTag>> GetTags(NormalizedSnapshotSpanCollection spans)
|
||||
{
|
||||
|
||||
foreach (var tagSpan in this._aggregator.GetTags(spans))
|
||||
foreach (var tagSpan in _aggregator.GetTags(spans))
|
||||
{
|
||||
var tagSpans = tagSpan.Span.GetSpans(spans[0].Snapshot);
|
||||
yield return
|
||||
new TagSpan<ClassificationTag>(tagSpans[0],
|
||||
new ClassificationTag(_Merlin32Types[tagSpan.Tag.Tokentype]));
|
||||
new TagSpan<ClassificationTag>(tagSpans[0], new ClassificationTag(_merlin32Types[tagSpan.Tag.Tokentype]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,17 +8,17 @@ namespace VSMerlin32.Coloring
|
|||
{
|
||||
internal class Merlin32CodeHelper
|
||||
{
|
||||
const string CommentRegex = @"((\u003B)|(\u002A))(.*)"; // ;
|
||||
const string TextRegex = @"(""|')[^']*(""|')";
|
||||
private static readonly string CommentRegex = @"((\u003B)|(\u002A))(.*)"; // ;
|
||||
private static readonly string TextRegex = @"(""|')[^']*(""|')";
|
||||
// OPCODE_REG and below are initialized dynamically below.
|
||||
const string RegexBoilerplate = @"(\b|\s)(?<{0}>{1})(\b|\s)";
|
||||
const string Opcode = "OPCODE";
|
||||
const string Data = "DATA";
|
||||
const string Directive = "DIRECTIVE";
|
||||
const string Elup = "ELUP";
|
||||
static string OpcodeRegex = "";
|
||||
static string DirectiveRegex = "";
|
||||
static string DataRegex = "";
|
||||
private static readonly string RegexBoilerplate = @"(\b|\s)(?<{0}>{1})(\b|\s)";
|
||||
private static readonly string Opcode = "OPCODE";
|
||||
private static readonly string Data = "DATA";
|
||||
private static readonly string Directive = "DIRECTIVE";
|
||||
private static readonly string Elup = "ELUP";
|
||||
private static string _opcodeRegex = "";
|
||||
private static string _directiveRegex = "";
|
||||
private static string _dataRegex = "";
|
||||
|
||||
public static IEnumerable<SnapshotHelper> GetTokens(SnapshotSpan span)
|
||||
{
|
||||
|
@ -47,13 +47,13 @@ namespace VSMerlin32.Coloring
|
|||
TempRegex = "";
|
||||
foreach (Merlin32Opcodes token in Enum.GetValues(typeof(Merlin32Opcodes)))
|
||||
{
|
||||
TempRegex += (token.ToString() + ("|"));
|
||||
TempRegex += token.ToString() + ("|");
|
||||
}
|
||||
// we remove the last "|" added
|
||||
TempRegex = TempRegex.Remove(TempRegex.LastIndexOf("|"));
|
||||
OpcodeRegex = string.Format(RegexBoilerplate, Opcode, TempRegex);
|
||||
TempRegex = TempRegex.Remove(TempRegex.LastIndexOf("|", StringComparison.Ordinal));
|
||||
_opcodeRegex = string.Format(RegexBoilerplate, Opcode, TempRegex);
|
||||
|
||||
reg = new Regex(OpcodeRegex,RegexOptions.IgnoreCase);
|
||||
reg = new Regex(_opcodeRegex,RegexOptions.IgnoreCase);
|
||||
Match opcodeMatch = reg.Match(formattedLine);
|
||||
if (opcodeMatch.Success)
|
||||
{
|
||||
|
@ -68,21 +68,21 @@ namespace VSMerlin32.Coloring
|
|||
// OG NEW
|
||||
// DIRECTIVES
|
||||
TempRegex = "";
|
||||
string ElupDirective = Resources.directives.ELUP;
|
||||
string elupDirective = Resources.directives.ELUP;
|
||||
foreach (Merlin32Directives token in Enum.GetValues(typeof(Merlin32Directives)))
|
||||
{
|
||||
if (token.ToString() != ElupDirective)
|
||||
TempRegex += (token.ToString() + ("|"));
|
||||
if (token.ToString() != elupDirective)
|
||||
TempRegex += token.ToString() + ("|");
|
||||
}
|
||||
// we remove the last "|" added
|
||||
TempRegex = TempRegex.Remove(TempRegex.LastIndexOf("|"));
|
||||
DirectiveRegex = string.Format(RegexBoilerplate, Directive, TempRegex);
|
||||
TempRegex = TempRegex.Remove(TempRegex.LastIndexOf("|", StringComparison.Ordinal));
|
||||
_directiveRegex = string.Format(RegexBoilerplate, Directive, TempRegex);
|
||||
|
||||
reg = new Regex(DirectiveRegex, RegexOptions.IgnoreCase);
|
||||
Match DirectiveMatch = reg.Match(formattedLine);
|
||||
if (DirectiveMatch.Success)
|
||||
reg = new Regex(_directiveRegex, RegexOptions.IgnoreCase);
|
||||
Match directiveMatch = reg.Match(formattedLine);
|
||||
if (directiveMatch.Success)
|
||||
{
|
||||
foreach (Capture directive in DirectiveMatch.Groups[Directive].Captures)
|
||||
foreach (Capture directive in directiveMatch.Groups[Directive].Captures)
|
||||
{
|
||||
if (directive.Index < commentMatch)
|
||||
yield return new SnapshotHelper(new SnapshotSpan(new SnapshotPoint(span.Snapshot, directive.Index + curLoc), directive.Length), Merlin32TokenTypes.Merlin32Directive);
|
||||
|
@ -91,10 +91,10 @@ namespace VSMerlin32.Coloring
|
|||
|
||||
// We also need to check for special ELUP directive...
|
||||
reg = new Regex(Resources.directives.ELUPRegex);
|
||||
Match ElupMatch = reg.Match(formattedLine);
|
||||
if (ElupMatch.Success)
|
||||
Match elupMatch = reg.Match(formattedLine);
|
||||
if (elupMatch.Success)
|
||||
{
|
||||
foreach (Capture elup in ElupMatch.Groups[Elup].Captures)
|
||||
foreach (Capture elup in elupMatch.Groups[Elup].Captures)
|
||||
{
|
||||
if (elup.Index < commentMatch)
|
||||
yield return new SnapshotHelper(new SnapshotSpan(new SnapshotPoint(span.Snapshot, elup.Index + curLoc), elup.Length), Merlin32TokenTypes.Merlin32Directive);
|
||||
|
@ -106,13 +106,13 @@ namespace VSMerlin32.Coloring
|
|||
TempRegex = "";
|
||||
foreach (Merlin32DataDefines token in Enum.GetValues(typeof(Merlin32DataDefines)))
|
||||
{
|
||||
TempRegex += (token.ToString() + ("|"));
|
||||
TempRegex += token.ToString() + ("|");
|
||||
}
|
||||
// we remove the last "|" added
|
||||
TempRegex = TempRegex.Remove(TempRegex.LastIndexOf("|"));
|
||||
DataRegex = string.Format(RegexBoilerplate, Data, TempRegex);
|
||||
TempRegex = TempRegex.Remove(TempRegex.LastIndexOf("|", StringComparison.Ordinal));
|
||||
_dataRegex = string.Format(RegexBoilerplate, Data, TempRegex);
|
||||
|
||||
reg = new Regex(DataRegex, RegexOptions.IgnoreCase);
|
||||
reg = new Regex(_dataRegex, RegexOptions.IgnoreCase);
|
||||
Match dataMatch = reg.Match(formattedLine);
|
||||
if (dataMatch.Success)
|
||||
{
|
||||
|
|
|
@ -10,13 +10,11 @@ using VSMerlin32.Coloring.Data;
|
|||
|
||||
namespace VSMerlin32.Coloring
|
||||
{
|
||||
|
||||
[Export(typeof(ITaggerProvider))]
|
||||
[ContentType("Merlin32")]
|
||||
[TagType(typeof(Merlin32TokenTag))]
|
||||
internal sealed class Merlin32TokenTagProvider : ITaggerProvider
|
||||
{
|
||||
|
||||
public ITagger<T> CreateTagger<T>(ITextBuffer buffer) where T : ITag
|
||||
{
|
||||
return new Merlin32TokenTagger(buffer) as ITagger<T>;
|
||||
|
@ -35,17 +33,16 @@ namespace VSMerlin32.Coloring
|
|||
|
||||
internal sealed class Merlin32TokenTagger : ITagger<Merlin32TokenTag>
|
||||
{
|
||||
|
||||
ITextBuffer _buffer;
|
||||
IDictionary<string, Merlin32TokenTypes> _Merlin32Types;
|
||||
private ITextBuffer _buffer;
|
||||
private readonly IDictionary<string, Merlin32TokenTypes> _merlin32Types;
|
||||
|
||||
internal Merlin32TokenTagger(ITextBuffer buffer)
|
||||
{
|
||||
_buffer = buffer;
|
||||
_Merlin32Types = new Dictionary<string, Merlin32TokenTypes>();
|
||||
_merlin32Types = new Dictionary<string, Merlin32TokenTypes>();
|
||||
|
||||
foreach (Merlin32TokenTypes token in Enum.GetValues(typeof(Merlin32TokenTypes)))
|
||||
_Merlin32Types.Add(token.ToString(), token);
|
||||
_merlin32Types.Add(token.ToString(), token);
|
||||
}
|
||||
|
||||
public event EventHandler<SnapshotSpanEventArgs> TagsChanged
|
||||
|
@ -67,8 +64,9 @@ namespace VSMerlin32.Coloring
|
|||
foreach (SnapshotHelper item in Merlin32CodeHelper.GetTokens(curSpan))
|
||||
{
|
||||
if (item.Snapshot.IntersectsWith(curSpan))
|
||||
yield return new TagSpan<Merlin32TokenTag>(item.Snapshot,
|
||||
new Merlin32TokenTag(item.TokenType));
|
||||
{
|
||||
yield return new TagSpan<Merlin32TokenTag>(item.Snapshot, new Merlin32TokenTag(item.TokenType));
|
||||
}
|
||||
}
|
||||
|
||||
//add an extra char location because of the space
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Resources;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
|
||||
namespace VSMerlin32
|
||||
{
|
||||
|
|
|
@ -15,7 +15,6 @@ using Microsoft.VisualStudio.Utilities;
|
|||
|
||||
using Microsoft.VisualStudio.Text.Operations;
|
||||
|
||||
|
||||
namespace VSMerlin32
|
||||
{
|
||||
#region Command Filter
|
||||
|
@ -39,37 +38,37 @@ namespace VSMerlin32
|
|||
if (textView == null)
|
||||
return;
|
||||
|
||||
Func<CommandFilter> createCommandHandler = delegate() { return new CommandFilter(textViewAdapter, textView, this); };
|
||||
Func<CommandFilter> createCommandHandler = delegate { return new CommandFilter(textViewAdapter, textView, this); };
|
||||
textView.Properties.GetOrCreateSingletonProperty(createCommandHandler);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class CommandFilter : IOleCommandTarget
|
||||
{
|
||||
private IOleCommandTarget m_nextCommandHandler;
|
||||
private ITextView m_textView;
|
||||
private VsTextViewCreationListener m_provider;
|
||||
private ICompletionSession m_session;
|
||||
private IOleCommandTarget _nextCommandHandler;
|
||||
private ITextView _textView;
|
||||
private VsTextViewCreationListener _provider;
|
||||
private ICompletionSession _session;
|
||||
|
||||
internal CommandFilter(IVsTextView textViewAdapter, ITextView textView, VsTextViewCreationListener provider)
|
||||
{
|
||||
this.m_textView = textView;
|
||||
this.m_provider = provider;
|
||||
_textView = textView;
|
||||
_provider = provider;
|
||||
|
||||
//add the command to the command chain
|
||||
textViewAdapter.AddCommandFilter(this, out m_nextCommandHandler);
|
||||
textViewAdapter.AddCommandFilter(this, out _nextCommandHandler);
|
||||
}
|
||||
|
||||
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
|
||||
{
|
||||
return m_nextCommandHandler.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText);
|
||||
return _nextCommandHandler.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText);
|
||||
}
|
||||
|
||||
public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
|
||||
{
|
||||
if (VsShellUtilities.IsInAutomationFunction(m_provider.ServiceProvider))
|
||||
if (VsShellUtilities.IsInAutomationFunction(_provider.ServiceProvider))
|
||||
{
|
||||
return m_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
|
||||
return _nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
|
||||
}
|
||||
//make a copy of this so we can look at it after forwarding some commands
|
||||
uint commandID = nCmdID;
|
||||
|
@ -87,56 +86,56 @@ namespace VSMerlin32
|
|||
|| char.IsPunctuation(typedChar))
|
||||
{
|
||||
//check for a a selection
|
||||
if (m_session != null && !m_session.IsDismissed)
|
||||
if (_session != null && !_session.IsDismissed)
|
||||
{
|
||||
//if the selection is fully selected, commit the current session
|
||||
if (m_session.SelectedCompletionSet.SelectionStatus.IsSelected)
|
||||
if (_session.SelectedCompletionSet.SelectionStatus.IsSelected)
|
||||
{
|
||||
m_session.Commit();
|
||||
_session.Commit();
|
||||
//also, don't add the character to the buffer
|
||||
return VSConstants.S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
//if there is no selection, dismiss the session
|
||||
m_session.Dismiss();
|
||||
_session.Dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//pass along the command so the char is added to the buffer
|
||||
int retVal = m_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
|
||||
int retVal = _nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
|
||||
bool handled = false;
|
||||
// Test for '-' is to catch ELUP (--^)
|
||||
if (!typedChar.Equals(char.MinValue) && ((char.IsLetterOrDigit(typedChar)) || ((typedChar == '\'') || (typedChar == '"') || (typedChar == '-'))))
|
||||
{
|
||||
if (m_session == null || m_session.IsDismissed) // If there is no active session, bring up completion
|
||||
if (_session == null || _session.IsDismissed) // If there is no active session, bring up completion
|
||||
{
|
||||
this.TriggerCompletion();
|
||||
TriggerCompletion();
|
||||
// No need to filter for single and double-quotes, the choice IS the characted, just doubled, and already populated in a single completionset if we're here...
|
||||
if ((typedChar == '\'') || (typedChar == '"'))
|
||||
{
|
||||
// We need to save the currect caret position because we'll position it in between the single/double quotes after the commit...
|
||||
ITextCaret CaretBeforeCommit = m_session.TextView.Caret;
|
||||
m_session.Commit();
|
||||
this.m_textView.Caret.MoveTo(CaretBeforeCommit.Position.BufferPosition - 1);
|
||||
ITextCaret caretBeforeCommit = _session.TextView.Caret;
|
||||
_session.Commit();
|
||||
_textView.Caret.MoveTo(caretBeforeCommit.Position.BufferPosition - 1);
|
||||
}
|
||||
else if (!m_session.IsDismissed)
|
||||
else if (!_session.IsDismissed)
|
||||
{
|
||||
m_session.Filter();
|
||||
_session.Filter();
|
||||
}
|
||||
}
|
||||
else //the completion session is already active, so just filter
|
||||
{
|
||||
m_session.Filter();
|
||||
_session.Filter();
|
||||
}
|
||||
handled = true;
|
||||
}
|
||||
else if (commandID == (uint)VSConstants.VSStd2KCmdID.BACKSPACE //redo the filter if there is a deletion
|
||||
|| commandID == (uint)VSConstants.VSStd2KCmdID.DELETE)
|
||||
{
|
||||
if (m_session != null && !m_session.IsDismissed)
|
||||
m_session.Filter();
|
||||
if (_session != null && !_session.IsDismissed)
|
||||
_session.Filter();
|
||||
handled = true;
|
||||
}
|
||||
|
||||
|
@ -148,20 +147,20 @@ namespace VSMerlin32
|
|||
{
|
||||
//the caret must be in a non-projection location
|
||||
SnapshotPoint? caretPoint =
|
||||
m_textView.Caret.Position.Point.GetPoint(
|
||||
_textView.Caret.Position.Point.GetPoint(
|
||||
textBuffer => (!textBuffer.ContentType.IsOfType("projection")), PositionAffinity.Predecessor);
|
||||
if (!caretPoint.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_session = m_provider.CompletionBroker.CreateCompletionSession(m_textView,
|
||||
_session = _provider.CompletionBroker.CreateCompletionSession(_textView,
|
||||
caretPoint.Value.Snapshot.CreateTrackingPoint(caretPoint.Value.Position, PointTrackingMode.Positive),
|
||||
true);
|
||||
|
||||
// We need to check now whether we are in a comment or not, because if we are, we don't want to provide a completion list to the user
|
||||
ITextSnapshot snapshot = caretPoint.Value.Snapshot;
|
||||
var triggerPoint = (SnapshotPoint)m_session.GetTriggerPoint(snapshot);
|
||||
var triggerPoint = (SnapshotPoint)_session.GetTriggerPoint(snapshot);
|
||||
var snapshotSpan = new SnapshotSpan(triggerPoint, 0);
|
||||
foreach (VSMerlin32.Coloring.Data.SnapshotHelper item in VSMerlin32.Coloring.Merlin32CodeHelper.GetTokens(snapshotSpan))
|
||||
{
|
||||
|
@ -169,17 +168,17 @@ namespace VSMerlin32
|
|||
{
|
||||
if (item.TokenType == Merlin32TokenTypes.Merlin32Comment)
|
||||
{
|
||||
m_session.Dismiss();
|
||||
_session.Dismiss();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_session.IsDismissed)
|
||||
if (!_session.IsDismissed)
|
||||
{
|
||||
//subscribe to the Dismissed event on the session
|
||||
m_session.Dismissed += this.OnSessionDismissed;
|
||||
m_session.Start();
|
||||
_session.Dismissed += OnSessionDismissed;
|
||||
_session.Start();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -187,8 +186,8 @@ namespace VSMerlin32
|
|||
|
||||
private void OnSessionDismissed(object sender, EventArgs e)
|
||||
{
|
||||
m_session.Dismissed -= this.OnSessionDismissed;
|
||||
m_session = null;
|
||||
_session.Dismissed -= OnSessionDismissed;
|
||||
_session = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Composition;
|
||||
using Microsoft.VisualStudio.Language.Intellisense;
|
||||
using Microsoft.VisualStudio.Text;
|
||||
|
@ -26,20 +24,20 @@ namespace VSMerlin32
|
|||
|
||||
internal class Merlin32CompletionSource : ICompletionSource
|
||||
{
|
||||
private Merlin32CompletionSourceProvider m_sourceprovider;
|
||||
private ITextBuffer m_buffer;
|
||||
private List<Completion> m_compList;
|
||||
private bool m_isDisposed = false;
|
||||
private Merlin32CompletionSourceProvider _sourceprovider;
|
||||
private ITextBuffer _buffer;
|
||||
private List<Completion> _compList;
|
||||
private bool _isDisposed;
|
||||
|
||||
public Merlin32CompletionSource(Merlin32CompletionSourceProvider sourceprovider, ITextBuffer buffer)
|
||||
{
|
||||
m_sourceprovider = sourceprovider;
|
||||
m_buffer = buffer;
|
||||
_sourceprovider = sourceprovider;
|
||||
_buffer = buffer;
|
||||
}
|
||||
|
||||
public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
|
||||
{
|
||||
if (m_isDisposed)
|
||||
if (_isDisposed)
|
||||
throw new ObjectDisposedException("Merlin32CompletionSource");
|
||||
|
||||
List<string> strList = new List<string>();
|
||||
|
@ -78,27 +76,27 @@ namespace VSMerlin32
|
|||
// strList[strList.IndexOf(Merlin32Directives.ELUP.ToString())] = "--^";
|
||||
// OG
|
||||
}
|
||||
m_compList = new List<Completion>();
|
||||
_compList = new List<Completion>();
|
||||
foreach (string str in strList)
|
||||
m_compList.Add(new Completion(str, str, str, null, null));
|
||||
_compList.Add(new Completion(str, str, str, null, null));
|
||||
|
||||
completionSets.Add(new CompletionSet("All", "All", FindTokenSpanAtPosition(session.GetTriggerPoint(m_buffer), session), m_compList, null));
|
||||
completionSets.Add(new CompletionSet("All", "All", FindTokenSpanAtPosition(session), _compList, null));
|
||||
}
|
||||
|
||||
private ITrackingSpan FindTokenSpanAtPosition(ITrackingPoint point, ICompletionSession session)
|
||||
private ITrackingSpan FindTokenSpanAtPosition(ICompletionSession session)
|
||||
{
|
||||
SnapshotPoint currentPoint = (session.TextView.Caret.Position.BufferPosition) - 1;
|
||||
ITextStructureNavigator navigator = m_sourceprovider.NavigatorService.GetTextStructureNavigator(m_buffer);
|
||||
ITextStructureNavigator navigator = _sourceprovider.NavigatorService.GetTextStructureNavigator(_buffer);
|
||||
TextExtent extent = navigator.GetExtentOfWord(currentPoint);
|
||||
return currentPoint.Snapshot.CreateTrackingSpan(extent.Span, SpanTrackingMode.EdgeInclusive);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (!m_isDisposed)
|
||||
if (!_isDisposed)
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
m_isDisposed = true;
|
||||
_isDisposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.Language.Intellisense;
|
||||
using System.Collections.ObjectModel;
|
||||
using Microsoft.VisualStudio.Text;
|
||||
using Microsoft.VisualStudio.Text.Tagging;
|
||||
using System.ComponentModel.Composition;
|
||||
|
@ -12,19 +10,17 @@ using VSMerlin32.Coloring;
|
|||
|
||||
namespace VSMerlin32
|
||||
{
|
||||
|
||||
[Export(typeof(IQuickInfoSourceProvider))]
|
||||
[ContentType("Merlin32")]
|
||||
[Name("Merlin32QuickInfo")]
|
||||
class Merlin32QuickInfoSourceProvider : IQuickInfoSourceProvider
|
||||
{
|
||||
|
||||
[Import]
|
||||
IBufferTagAggregatorFactoryService aggService = null;
|
||||
private IBufferTagAggregatorFactoryService _aggService = null;
|
||||
|
||||
public IQuickInfoSource TryCreateQuickInfoSource(ITextBuffer textBuffer)
|
||||
{
|
||||
return new Merlin32QuickInfoSource(textBuffer, aggService.CreateTagAggregator<Merlin32TokenTag>(textBuffer));
|
||||
return new Merlin32QuickInfoSource(textBuffer, _aggService.CreateTagAggregator<Merlin32TokenTag>(textBuffer));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,8 +29,7 @@ namespace VSMerlin32
|
|||
private ITagAggregator<Merlin32TokenTag> _aggregator;
|
||||
private ITextBuffer _buffer;
|
||||
private Merlin32KeywordsHelper _Merlin32OpcodesHelper = new Merlin32KeywordsHelper();
|
||||
private bool _disposed = false;
|
||||
|
||||
private bool _disposed;
|
||||
|
||||
public Merlin32QuickInfoSource(ITextBuffer buffer, ITagAggregator<Merlin32TokenTag> aggregator)
|
||||
{
|
||||
|
|
|
@ -2,13 +2,10 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.VisualStudio.Language.Intellisense;
|
||||
using Microsoft.VisualStudio.Text;
|
||||
using Microsoft.VisualStudio.Text.Editor;
|
||||
using Microsoft.VisualStudio.Utilities;
|
||||
|
||||
namespace VSLTK.Intellisense
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user