コード例 #1
0
		protected override async Task SetWatchTextAsync (WatchVariable w, List<string> vals)
		{
            var doc = IdeApp.Workbench.GetDocument (w.FilePath);
            if (doc == null)
                return;
			var ed = doc.Editor;
			if (ed == null || !ed.CanEdit (w.FileLine))
				return;
			var line = ed.GetLine (w.FileLine);
			if (line == null)
				return;
			var newText = "//" + w.ExplicitExpression + "= " + GetValsText (vals);
			var lineText = ed.GetLineText (w.FileLine);
			var commentIndex = lineText.IndexOf ("//");
			if (commentIndex < 0)
				return;
			var commentCol = commentIndex + 1;
			if (commentCol != w.FileColumn)
				return;

			var existingText = lineText.Substring (commentIndex);

			if (existingText != newText) {
				var offset = line.Offset + commentIndex;
				var remLen = line.Length - commentIndex;
				ed.Remove (offset, remLen);
				ed.Insert (offset, newText);
			}
		}
コード例 #2
0
        SyntaxNode AddWatchNode(StatementSyntax node, ExpressionSyntax expr)
        {
            var id = Guid.NewGuid().ToString();
            var c  = node.GetTrailingTrivia().First(t => t.Kind() == SyntaxKind.SingleLineCommentTrivia && t.ToString().StartsWith("//=", StringComparison.InvariantCultureIgnoreCase));
            var p  = c.GetLocation().GetLineSpan().StartLinePosition;

            var wv = new WatchVariable {
                Id                 = id,
                Expression         = expr.ToString(),
                ExplicitExpression = "",
                FilePath           = path,
                FileLine           = p.Line + 1,        // 0-based index
                FileColumn         = p.Character + 1,   // 0-based index
            };

            WatchVariables.Add(wv);

            var wi = GetWatchInstrument(id, expr);

            // creating a block and removing the open/close braces is a bit of a hack but
            // lets us replace one node with two...
            return
                (SyntaxFactory
                 .Block(node, wi)
                 .WithOpenBraceToken(SyntaxFactory.MissingToken(SyntaxKind.OpenBraceToken))
                 .WithCloseBraceToken(SyntaxFactory.MissingToken(SyntaxKind.CloseBraceToken))
                 .WithTrailingTrivia(SyntaxFactory.EndOfLine("\r\n")));
        }
コード例 #3
0
        protected override async Task SetWatchTextAsync(WatchVariable w, List <string> vals)
        {
            var doc = IdeApp.Workbench.GetDocument(w.FilePath);

            if (doc == null)
            {
                return;
            }
            var ed = doc.Editor;

            if (ed == null || !ed.CanEdit(w.FileLine))
            {
                return;
            }
            var line = ed.GetLine(w.FileLine);

            if (line == null)
            {
                return;
            }
            var newText      = "//" + w.ExplicitExpression + "= " + GetValsText(vals);
            var lineText     = ed.GetLineText(w.FileLine);
            var commentIndex = lineText.IndexOf("//");

            if (commentIndex < 0)
            {
                return;
            }
            var commentCol = commentIndex + 1;

            if (commentCol != w.FileColumn)
            {
                return;
            }

            var existingText = lineText.Substring(commentIndex);

            if (existingText != newText)
            {
                var offset = line.Offset + commentIndex;
                var remLen = line.Length - commentIndex;
                ed.Remove(offset, remLen);
                ed.Insert(offset, newText);
            }
        }
コード例 #4
0
        protected override async Task SetWatchTextAsync(WatchVariable w, List <string> vals)
        {
            Console.WriteLine("Ignoring SetWatchTextAsync");

            return;

            /*
             * var doc = IdeApp.Workbench.GetDocument(w.FilePath);
             * if (doc == null)
             *  return;
             *
             *          var ed = doc.Editor;
             *
             * if (ed == null || ed.IsReadOnly)
             *                  return;
             *          var line = ed.GetLine (w.FileLine);
             *          if (line == null)
             *                  return;
             *          var newText = "//" + w.ExplicitExpression + "= " + GetValsText (vals);
             *          var lineText = ed.GetLineText (w.FileLine);
             *          var commentIndex = lineText.IndexOf ("//");
             *          if (commentIndex < 0)
             *                  return;
             *          var commentCol = commentIndex + 1;
             *          if (commentCol != w.FileColumn)
             *                  return;
             *
             *          var existingText = lineText.Substring (commentIndex);
             *
             *          if (existingText != newText) {
             *                  var offset = line.Offset + commentIndex;
             *                  var remLen = line.Length - commentIndex;
             *                  ed.RemoveText (offset, remLen);
             *                  ed.InsertText (offset, newText);
             *          }
             */
        }
コード例 #5
0
 protected override async Task SetWatchTextAsync (WatchVariable w, List<string> vals)
 {
     // throw new NotImplementedException ();
 }
コード例 #6
0
ファイル: ContinuousEnv.cs プロジェクト: mono/Continuous
 protected abstract Task SetWatchTextAsync (WatchVariable w, List<string> vals);
コード例 #7
0
		SyntaxNode AddWatchNode(StatementSyntax node, ExpressionSyntax expr)
		{
			var id = Guid.NewGuid().ToString();
			var c = node.GetTrailingTrivia().First(t => t.Kind() == SyntaxKind.SingleLineCommentTrivia && t.ToString().StartsWith("//="));
			var p = c.GetLocation().GetLineSpan().StartLinePosition;

			var wv = new WatchVariable {
				Id = id,
				Expression = expr.ToString(),
				ExplicitExpression = "",
				FilePath = path,
				FileLine = p.Line + 1,  // 0-based index
				FileColumn = p.Character + 1, // 0-based index
			};
			WatchVariables.Add(wv);

			var wi = GetWatchInstrument(id, expr);

			// creating a block and removing the open/close braces is a bit of a hack but
			// lets us replace one node with two... 
			return
				SyntaxFactory
					.Block(node, wi)
					.WithOpenBraceToken(SyntaxFactory.MissingToken(SyntaxKind.OpenBraceToken))
					.WithCloseBraceToken(SyntaxFactory.MissingToken(SyntaxKind.CloseBraceToken))
					.WithTrailingTrivia(SyntaxFactory.EndOfLine("\r\n"));
		}
コード例 #8
0
 protected abstract Task SetWatchTextAsync(WatchVariable w, List <string> vals);
コード例 #9
0
 protected override async Task SetWatchTextAsync(WatchVariable w, List <string> vals)
 {
     // throw new NotImplementedException ();
 }