summaryrefslogtreecommitdiff
path: root/Util
diff options
context:
space:
mode:
authorGravatar kyessenov <unknown>2010-08-20 00:39:58 +0000
committerGravatar kyessenov <unknown>2010-08-20 00:39:58 +0000
commit02d463afad48835d8143a179c574ce5b246b3e31 (patch)
tree0fc872c1b5fffee3c8655818c08d59fca8d9112b /Util
parent495d07eb040d3e04e5266ea6dec3999c4f3e0df1 (diff)
VS 2010 mode for Chalice: some errors didn't show up in the window because positions were negative
Diffstat (limited to 'Util')
-rw-r--r--Util/VS2010/Chalice/ChaliceLanguageService/Integration/IronyLanguageService.cs85
1 files changed, 47 insertions, 38 deletions
diff --git a/Util/VS2010/Chalice/ChaliceLanguageService/Integration/IronyLanguageService.cs b/Util/VS2010/Chalice/ChaliceLanguageService/Integration/IronyLanguageService.cs
index 4791df00..281040ca 100644
--- a/Util/VS2010/Chalice/ChaliceLanguageService/Integration/IronyLanguageService.cs
+++ b/Util/VS2010/Chalice/ChaliceLanguageService/Integration/IronyLanguageService.cs
@@ -9,6 +9,7 @@ using Irony.Parsing;
using Irony.Ast;
using System.IO;
+using System.Text.RegularExpressions;
namespace Demo
{
@@ -108,26 +109,26 @@ namespace Demo
}
// Used for brace matching.
- TokenStack braces = parser.Context.OpenBraces;
- foreach (Token brace in braces) {
- if (brace.OtherBrace == null) continue;
- TextSpan openBrace = new TextSpan();
- openBrace.iStartLine = brace.Location.Line;
- openBrace.iStartIndex = brace.Location.Column;
- openBrace.iEndLine = brace.Location.Line;
- openBrace.iEndIndex = openBrace.iStartIndex + brace.Length;
-
- TextSpan closeBrace = new TextSpan();
- closeBrace.iStartLine = brace.OtherBrace.Location.Line;
- closeBrace.iStartIndex = brace.OtherBrace.Location.Column;
- closeBrace.iEndLine = brace.OtherBrace.Location.Line;
- closeBrace.iEndIndex = closeBrace.iStartIndex + brace.OtherBrace.Length;
-
- if (source.Braces == null) {
- source.Braces = new List<TextSpan[]>();
- }
- source.Braces.Add(new TextSpan[2] { openBrace, closeBrace });
- }
+ //TokenStack braces = parser.Context.OpenBraces;
+ //foreach (Token brace in braces) {
+ // if (brace.OtherBrace == null) continue;
+ // TextSpan openBrace = new TextSpan();
+ // openBrace.iStartLine = brace.Location.Line;
+ // openBrace.iStartIndex = brace.Location.Column;
+ // openBrace.iEndLine = brace.Location.Line;
+ // openBrace.iEndIndex = openBrace.iStartIndex + brace.Length;
+
+ // TextSpan closeBrace = new TextSpan();
+ // closeBrace.iStartLine = brace.OtherBrace.Location.Line;
+ // closeBrace.iStartIndex = brace.OtherBrace.Location.Column;
+ // closeBrace.iEndLine = brace.OtherBrace.Location.Line;
+ // closeBrace.iEndIndex = closeBrace.iStartIndex + brace.OtherBrace.Length;
+
+ // if (source.Braces == null) {
+ // source.Braces = new List<TextSpan[]>();
+ // }
+ // source.Braces.Add(new TextSpan[2] { openBrace, closeBrace });
+ //}
if (parser.Context.CurrentParseTree.ParserMessages.Count > 0) {
foreach (ParserMessage error in parser.Context.CurrentParseTree.ParserMessages) {
@@ -172,7 +173,15 @@ namespace Demo
//string result = reader.ReadToEnd();
//Console.Write(result);
- for (string line = reader.ReadLine(); !String.IsNullOrEmpty(line); line = reader.ReadLine()) {
+ for (string line = reader.ReadLine(); line != null; line = reader.ReadLine()) {
+ if (line == "")
+ continue;
+ if (line.StartsWith("Boogie program verifier")) {
+ if (!Regex.IsMatch(line, "Boogie program verifier finished with [0-9]* verified, 0 errors"))
+ AddErrorBecauseOfToolProblems(req, line);
+ continue;
+ }
+
// each line is of the form: "x,y,w,z:arbitrary text"
string[] numbersAndText = line.Split(':');
if (numbersAndText.Length != 2) {
@@ -188,10 +197,10 @@ namespace Demo
}
try {
TextSpan span = new TextSpan();
- span.iStartLine = span.iEndLine = Int32.Parse(positions[0]);
- span.iStartIndex = Int32.Parse(positions[1]);
- span.iEndLine = Int32.Parse(positions[2]);
- span.iEndIndex = Int32.Parse(positions[3]);
+ span.iStartLine = span.iEndLine = Math.Max(0, Int32.Parse(positions[0]) - 1);
+ span.iStartIndex = Math.Max(0, Int32.Parse(positions[1]) - 1);
+ span.iEndLine = Math.Max(0, Int32.Parse(positions[2]) - 1);
+ span.iEndIndex = Math.Max(0, Int32.Parse(positions[3]) - 1);
req.Sink.AddError(req.FileName, message, span, Severity.Error);
} catch (System.ArgumentNullException) {
AddErrorBecauseOfToolProblems(req, "Couldn't parse numbers: '" + numbers + "'");
@@ -230,16 +239,16 @@ namespace Demo
case ParseReason.HighlightBraces:
case ParseReason.MemberSelectAndHighlightBraces:
- if (source.Braces != null)
- {
- foreach (TextSpan[] brace in source.Braces)
- {
- if (brace.Length == 2)
- req.Sink.MatchPair(brace[0], brace[1], 1);
- else if (brace.Length >= 3)
- req.Sink.MatchTriple(brace[0], brace[1], brace[2], 1);
- }
- }
+ //if (source.Braces != null)
+ //{
+ // foreach (TextSpan[] brace in source.Braces)
+ // {
+ // if (brace.Length == 2)
+ // req.Sink.MatchPair(brace[0], brace[1], 1);
+ // else if (brace.Length >= 3)
+ // req.Sink.MatchTriple(brace[0], brace[1], brace[2], 1);
+ // }
+ //}
break;
}
@@ -248,9 +257,9 @@ namespace Demo
private static void AddErrorBecauseOfToolProblems(ParseRequest req, string msg) {
TextSpan span = new TextSpan();
- span.iStartLine = span.iEndLine = 1;
- span.iStartIndex = 1;
- span.iEndIndex = 2;
+ span.iStartLine = span.iEndLine = 0;
+ span.iStartIndex = 0;
+ span.iEndIndex = 5;
req.Sink.AddError(req.FileName, msg, span, Severity.Error);
}