Browse Source

vslol: fix an infinite recursion triggered by IntelliSense.

legacy
Sam Hocevar sam 12 years ago
parent
commit
080d9720de
3 changed files with 25 additions and 6 deletions
  1. +20
    -1
      tools/vslol/CppKeywordClassifier.cs
  2. +4
    -4
      tools/vslol/Properties/AssemblyInfo.cs
  3. +1
    -1
      tools/vslol/source.extension.vsixmanifest

+ 20
- 1
tools/vslol/CppKeywordClassifier.cs View File

@@ -1,7 +1,7 @@
//
// Lol Engine - VsLol add-in for Visual Studio
//
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -14,6 +14,7 @@ using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Windows.Media;
using System.Text.RegularExpressions;
using System.Diagnostics; /* For debugging purposes */

using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Classification;
@@ -59,6 +60,7 @@ internal class LolClassifierProvider : IClassifierProvider
class CppKeywordClassifier : IClassifier
{
private IClassifier m_classifier;
private bool m_inprogress;

private IClassificationType m_types_type, m_constant_type, m_normal_type;
private Regex m_types_regex, m_constant_regex, m_normal_regex;
@@ -137,6 +139,7 @@ class CppKeywordClassifier : IClassifier
IContentType type)
{
m_classifier = classifier;
m_inprogress = false;

m_types_type = registry.GetClassificationType("LolAnyType");
m_normal_type = registry.GetClassificationType("LolAnyIdentifier");
@@ -177,6 +180,20 @@ class CppKeywordClassifier : IClassifier
{
List<ClassificationSpan> ret = new List<ClassificationSpan>();

if (m_inprogress)
{
/* For some reason we can get called recursively when parsing a
* string for the IntelliSense drop-down menu. There is information
* on how to deal with it properly on the following SO page:
* http://stackoverflow.com/q/3155598/111461
* The crash can be reproduced by simply typing "vec2(" and waiting
* for IntelliSense to spawn the menu. */
ret.Add(new ClassificationSpan(span, m_constant_type));
return ret;
}

m_inprogress = true;

foreach (ClassificationSpan cs in m_classifier.GetClassificationSpans(span))
{
string cs_class = cs.ClassificationType.Classification.ToLower();
@@ -206,6 +223,8 @@ class CppKeywordClassifier : IClassifier
ret.Add(cs);
}

m_inprogress = false;

return ret;
}



+ 4
- 4
tools/vslol/Properties/AssemblyInfo.cs View File

@@ -1,7 +1,7 @@
//
// Lol Engine - VsLol add-in for Visual Studio
//
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -17,7 +17,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Lol")]
[assembly: AssemblyProduct("VsLol")]
[assembly: AssemblyCopyright("Copyright © Sam Hocevar 2012")]
[assembly: AssemblyCopyright("Copyright © 2012-2013 Sam Hocevar")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("58968f91-edb8-4a4c-9f4f-ba39fdb4a21a")]

[assembly: AssemblyVersion("1.0.0.7")]
[assembly: AssemblyFileVersion("1.0.0.7")]
[assembly: AssemblyVersion("1.0.0.8")]
[assembly: AssemblyFileVersion("1.0.0.8")]

+ 1
- 1
tools/vslol/source.extension.vsixmanifest View File

@@ -3,7 +3,7 @@
<Identifier Id="VsLol">
<Name>VsLol</Name>
<Author>Lol</Author>
<Version>1.0.0.7</Version>
<Version>1.0.0.8</Version>
<Description xml:space="preserve">Lol Engine Productivity Tools.</Description>
<Locale>1033</Locale>
<MoreInfoUrl>http://lol.zoy.org/</MoreInfoUrl>


Loading…
Cancel
Save