summaryrefslogtreecommitdiff
path: root/Util/VS2010/Boogie/BoogieLanguageService/Integration/Configuration.cs
diff options
context:
space:
mode:
authorGravatar rustanleino <unknown>2010-07-19 20:46:55 +0000
committerGravatar rustanleino <unknown>2010-07-19 20:46:55 +0000
commit28e03877a9c41dc0556d17115ccd1647f9eddcf6 (patch)
tree0a4c8f27752ea637fcf1609cdea1fe498fed1596 /Util/VS2010/Boogie/BoogieLanguageService/Integration/Configuration.cs
parent4a0723a7c122f78f7e6808a4ed9a48d2d58b210f (diff)
Chalice: Introduced '[[ S ]]' as a shorthand syntax for 'lock (this) { S }'. Think of the new brackets as atomicity brackets (see PetersonsAlgorithm.chalice)
Chalice: Added Peterson's algorithm to test suite (safety properties only) VS 2010 integration: Updated Chalice and Dafny modes, added keyword highlighting for a new Boogie mode
Diffstat (limited to 'Util/VS2010/Boogie/BoogieLanguageService/Integration/Configuration.cs')
-rw-r--r--Util/VS2010/Boogie/BoogieLanguageService/Integration/Configuration.cs116
1 files changed, 116 insertions, 0 deletions
diff --git a/Util/VS2010/Boogie/BoogieLanguageService/Integration/Configuration.cs b/Util/VS2010/Boogie/BoogieLanguageService/Integration/Configuration.cs
new file mode 100644
index 00000000..f7412393
--- /dev/null
+++ b/Util/VS2010/Boogie/BoogieLanguageService/Integration/Configuration.cs
@@ -0,0 +1,116 @@
+using System;
+using System.Collections.Generic;
+using Microsoft.VisualStudio.Package;
+using Microsoft.VisualStudio.TextManager.Interop;
+
+namespace Demo
+{
+ public static partial class Configuration
+ {
+ public static Grammar Grammar = new Grammar();
+ static List<Microsoft.VisualStudio.TextManager.Interop.IVsColorableItem> colorableItems = new List<Microsoft.VisualStudio.TextManager.Interop.IVsColorableItem>();
+
+ public static IList<Microsoft.VisualStudio.TextManager.Interop.IVsColorableItem> ColorableItems
+ {
+ get { return colorableItems; }
+ }
+
+ public static TokenColor CreateColor(string name, COLORINDEX foreground, COLORINDEX background)
+ {
+ return CreateColor(name, foreground, background, false, false);
+ }
+
+ public static TokenColor CreateColor(string name, COLORINDEX foreground, COLORINDEX background, bool bold, bool strikethrough)
+ {
+ colorableItems.Add(new ColorableItem(name, foreground, background, bold, strikethrough));
+ return (TokenColor)colorableItems.Count;
+ }
+
+ public static void ColorToken(string tokenName, TokenType type, TokenColor color, TokenTriggers trigger)
+ {
+ definitions[tokenName] = new TokenDefinition(type, color, trigger);
+ }
+
+ public static TokenDefinition GetDefinition(string tokenName)
+ {
+ TokenDefinition result;
+ return definitions.TryGetValue(tokenName, out result) ? result : defaultDefinition;
+ }
+
+ private static TokenDefinition defaultDefinition = new TokenDefinition(TokenType.Text, TokenColor.Text, TokenTriggers.None);
+ private static Dictionary<string, TokenDefinition> definitions = new Dictionary<string, TokenDefinition>();
+
+ public struct TokenDefinition
+ {
+ public TokenDefinition(TokenType type, TokenColor color, TokenTriggers triggers)
+ {
+ this.TokenType = type;
+ this.TokenColor = color;
+ this.TokenTriggers = triggers;
+ }
+
+ public TokenType TokenType;
+ public TokenColor TokenColor;
+ public TokenTriggers TokenTriggers;
+ }
+ }
+
+ public class ColorableItem : Microsoft.VisualStudio.TextManager.Interop.IVsColorableItem
+ {
+ private string displayName;
+ private COLORINDEX background;
+ private COLORINDEX foreground;
+ private uint fontFlags = (uint)FONTFLAGS.FF_DEFAULT;
+
+ public ColorableItem(string displayName, COLORINDEX foreground, COLORINDEX background, bool bold, bool strikethrough)
+ {
+ this.displayName = displayName;
+ this.background = background;
+ this.foreground = foreground;
+
+ if (bold)
+ this.fontFlags = this.fontFlags | (uint)FONTFLAGS.FF_BOLD;
+ if (strikethrough)
+ this.fontFlags = this.fontFlags | (uint)FONTFLAGS.FF_STRIKETHROUGH;
+ }
+
+ #region IVsColorableItem Members
+ public int GetDefaultColors(COLORINDEX[] piForeground, COLORINDEX[] piBackground)
+ {
+ if (null == piForeground)
+ {
+ throw new ArgumentNullException("piForeground");
+ }
+ if (0 == piForeground.Length)
+ {
+ throw new ArgumentOutOfRangeException("piForeground");
+ }
+ piForeground[0] = foreground;
+
+ if (null == piBackground)
+ {
+ throw new ArgumentNullException("piBackground");
+ }
+ if (0 == piBackground.Length)
+ {
+ throw new ArgumentOutOfRangeException("piBackground");
+ }
+ piBackground[0] = background;
+
+ return Microsoft.VisualStudio.VSConstants.S_OK;
+ }
+
+ public int GetDefaultFontFlags(out uint pdwFontFlags)
+ {
+ pdwFontFlags = this.fontFlags;
+ return Microsoft.VisualStudio.VSConstants.S_OK;
+ }
+
+ public int GetDisplayName(out string pbstrName)
+ {
+ pbstrName = displayName;
+ return Microsoft.VisualStudio.VSConstants.S_OK;
+ }
+ #endregion
+ }
+} \ No newline at end of file