public void FilePositionsAreEqualWhenFileNameAndPositionAreEqual()
		{
			FilePosition lhs = new FilePosition("test.cs", 1, 2);
			FilePosition rhs = new FilePosition("test.cs", 1, 2);
			
			Assert.AreEqual(lhs, rhs);
		}
		public void FilePositionsAreNotEqualWhenLinesAreNotEqual()
		{
			FilePosition lhs = new FilePosition("test.cs", 500, 2);
			FilePosition rhs = new FilePosition("test.cs", 1, 2);
			
			Assert.AreNotEqual(lhs, rhs);
		}
		public void FilePositionsAreNotEqualWhenFileNamesAreNotEqual()
		{
			FilePosition lhs = new FilePosition("test1.cs", 1, 2);
			FilePosition rhs = new FilePosition("test2.cs", 1, 2);
			
			Assert.AreNotEqual(lhs, rhs);
		}
Example #4
0
        public void GettingFilePositionWithAnOffsetOf10()
        {
            position = source.GetFilePosition(10);

            Assert.AreEqual(1, position.Line, "An offset of 10 is on the first line ending at 'function t'");
            Assert.AreEqual(10, position.Column, "The column ends at 'function t'");
        }
		public void FilePositionsAreNotEqualWhenColumnsAreNotEqual()
		{
			FilePosition lhs = new FilePosition("test.cs", 1, 2000);
			FilePosition rhs = new FilePosition("test.cs", 1, 2);
			
			Assert.AreNotEqual(lhs, rhs);
		}
Example #6
0
        public void GettingFilePositionWithAnOffsetOf22()
        {
            position = source.GetFilePosition(22);

            Assert.AreEqual(1, position.Line, "An offset of 22 is on the first line ending at 'function table.copy(t)\n'");
            Assert.AreEqual(22, position.Column, "The column ends at 'function table.copy(t)\n'");
        }
Example #7
0
        public void GettingFilePositionWithAnOffsetOf23()
        {
            position = source.GetFilePosition(23);

            Assert.AreEqual(2, position.Line, "An offset of 23 is on the second line ending");
            Assert.AreEqual(0, position.Column, "The column is the first character in the line");
        }
Example #8
0
        public void GettingFilePositionWithAnOffsetOf32()
        {
            position = source.GetFilePosition(32);

            Assert.AreEqual(2, position.Line);
            Assert.AreEqual(9, position.Column);
        }
 // Handles complete-snippet command
 public void Handle(Guid clientID, CommandMessage message)
 {
     Logger.Write("Handling complete-snippet");
     var caret = _editor.GetCaret();
     if (caret == "")
         return;
     Logger.Write("caret is: " + caret);
     var lines = caret.Split(new[] {Environment.NewLine}, StringSplitOptions.None);
     var position = new FilePosition(lines[0]);
     var line = lines[position.Line];
     var word = Word.Extract(line, position.Column);
     _editor.Send(string.Format(
         "remove \"{0}|{1}|{2}\" \"{3}|{4}\"",
         position.Fullpath,
         position.Line.ToString(),
         word.Column.ToString(),
         position.Line.ToString(),
         (word.Column + word.Content.Length).ToString()
     ));
     var whitespaces = getWhitespacePrefix(line);
     // Dispatch message to be handled by the handle method if not overridden by another
     // external handler
     _dispatch(string.Format(
         "snippet-complete \"{0}\" \"{1}\" \"{2}|{3}|{4}\" \"{5}\"",
         Path.GetExtension(position.Fullpath),
         word.Content,
         position.Fullpath,
         position.Line,
         word.Column,
         whitespaces
     ));
 }
 public SyntaxTreeDyadicOpNode(FilePosition position, Symbol opCodeSymbol,
     SyntaxTreeNode leftHandOperand, SyntaxTreeNode rightHandOperand)
     : base(position)
 {
     this._children.Add(leftHandOperand);
     this._children.Add(rightHandOperand);
     this._opCodeSymbol = opCodeSymbol;
 }
 public SyntaxTreeIfStatementNode(FilePosition position, SyntaxTreeNode conditionNode,
     SyntaxTreeNode thenStatement, SyntaxTreeNode elseStatement)
     : base(position)
 {
     this._children.Add(conditionNode);
     this._children.Add(thenStatement);
     this._children.Add(elseStatement);
 }
		public void MethodIsJumpedTo()
		{
			int line = 2; // zero based.
			int col = 5; // zero based.
			FilePosition expectedFilePos = new FilePosition(@"c:\projects\mytest.cs", line, col);
			
			Assert.AreEqual(expectedFilePos, fileService.FilePositionJumpedTo);
		}
 public SyntaxTreeInlineIfNode(FilePosition position, SyntaxTreeNode boolExprNode,
     SyntaxTreeNode thenIntExprNode, SyntaxTreeNode elseIntExprNode)
     : base(position)
 {
     this._children.Add(boolExprNode);
     this._children.Add(thenIntExprNode);
     this._children.Add(elseIntExprNode);
 }
 public SyntaxTreeForStatementNode(FilePosition position, SyntaxTreeNode variableInitialization,
     SyntaxTreeNode condition, SyntaxTreeNode variableAltering, SyntaxTreeNode statement)
     : base(position)
 {
     this._children.Add(variableInitialization);
     this._children.Add(condition);
     this._children.Add(variableAltering);
     this._children.Add(statement);
 }
Example #15
0
        public Error At(FilePosition? position)
        {
            if (position == null)
                return this;

            Position = position;
            Message += "\n ... At " + position.ToString();
            return this;
        }
        public SetBreakpointCommand(int id, NodeModule module, NodeBreakpoint breakpoint, bool withoutPredicate, bool remote, SourceMapper sourceMapper = null)
            : base(id, "setbreakpoint") {
            Utilities.ArgumentNotNull("breakpoint", breakpoint);

            _module = module;
            _breakpoint = breakpoint;
            _sourceMapper = sourceMapper;

            _position = breakpoint.GetPosition(_sourceMapper);

            // Zero based line numbers
            int line = _position.Line;

            // Zero based column numbers
            // Special case column to avoid (line 0, column 0) which
            // Node (V8) treats specially for script loaded via require
            // Script wrapping process: https://github.com/joyent/node/blob/v0.10.26-release/src/node.js#L880
            int column = _position.Column;
            if (line == 0) {
                column += NodeConstants.ScriptWrapBegin.Length;
            }

            _arguments = new Dictionary<string, object> {
                { "line", line },
                { "column", column }
            };

            if (_module != null) {
                _arguments["type"] = "scriptId";
                _arguments["target"] = _module.Id;
            } else if (remote) {
                _arguments["type"] = "scriptRegExp";
                _arguments["target"] = CreateRemoteScriptRegExp(_position.FileName);
            } else {
                _arguments["type"] = "scriptRegExp";
                _arguments["target"] = CreateLocalScriptRegExp(_position.FileName);
            }

            if (!NodeBreakpointBinding.GetEngineEnabled(_breakpoint.Enabled, _breakpoint.BreakOn, 0)) {
                _arguments["enabled"] = false;
            }

            if (withoutPredicate) {
                return;
            }

            int ignoreCount = NodeBreakpointBinding.GetEngineIgnoreCount(_breakpoint.BreakOn, 0);
            if (ignoreCount > 0) {
                _arguments["ignoreCount"] = ignoreCount;
            }

            if (!string.IsNullOrEmpty(_breakpoint.Condition)) {
                _arguments["condition"] = _breakpoint.Condition;
            }
        }
 public SyntaxTreeSequenceNode(FilePosition position, SyntaxTreeNode statementNode, SyntaxTreeNode prevSequenceNode)
     : base(position)
 {
     this._children.Add(statementNode);
     this._children.Add(prevSequenceNode);
     /*
     if (null != prevSequenceNode && prevSequenceNode is SyntaxTreeSequenceNode)
     {
         SyntaxTreeSequenceNode curNode = (SyntaxTreeSequenceNode)prevSequenceNode;
         while (curNode._children[1] != null)
         {
             curNode = (SyntaxTreeSequenceNode)curNode._children[1];
         }
         curNode._children[1] = this;
     }*/
 }
Example #18
0
 public SignatureLocation SignatureFromPosition(FilePosition position)
 {
     try {
         var lines = run(
             string.Format(
                 "signature-from-position \"{0}\"",
                 position.ToCommand())).ToArray();
         if (lines.Length != 4)
             return null;
         return new SignatureLocation(
             lines[0],
             lines[1],
             new Position(lines[2]),
             new Position(lines[3]));
     } catch {
         return null;
     }
 }
Example #19
0
 public ArithmeticShiftRight(IExpression <T> first, IExpression <T> second, FilePosition position)
     : base(first, second, EAExpressionType.ArithmeticRightShift, position)
 {
 }
 public ExpressionList(IEnumerable <IExpression <T> > expressions, FilePosition startPosition)
 {
     this.expressions  = new List <IExpression <T> >(expressions);
     this.filePosition = startPosition;
 }
Example #21
0
        public void TestClose()
        {
#if FALSE
            string path = TempFolder + Path.DirectorySeparatorChar + "TestClose";
            DeleteFile(path);

            StdioFileStream stream = new StdioFileStream(path, FileMode.CreateNew, FileAccess.ReadWrite);

            stream.Write(new byte [] { 1, 2, 3, 4 }, 0, 4);
            stream.ReadByte();
            stream.Close();

            try {
                stream.ReadByte();
                Assert.Fail();
            } catch (Exception e) {
                Assert.AreEqual(typeof(ObjectDisposedException), e.GetType(), "test#01");
            }

            try {
                stream.WriteByte(64);
                Assert.Fail();
            } catch (Exception e) {
                Assert.AreEqual(typeof(ObjectDisposedException), e.GetType(), "test#02");
            }

            try {
                stream.Flush();
                Assert.Fail();
            } catch (Exception e) {
                Assert.AreEqual(typeof(ObjectDisposedException), e.GetType(), "test#03");
            }

            try {
                long l = stream.Length;
                Assert.Fail();
            } catch (Exception e) {
                Assert.AreEqual(typeof(ObjectDisposedException), e.GetType(), "test#04");
            }

            try {
                long l = stream.Position;
                Assert.Fail();
            } catch (Exception e) {
                Assert.AreEqual(typeof(ObjectDisposedException), e.GetType(), "test#05");
            }

            try {
                FilePosition fp = stream.FilePosition;
                fp.Dispose();
                Assert.Fail();
            } catch (Exception e) {
                Assert.AreEqual(typeof(ObjectDisposedException), e.GetType(), "test#05");
            }

            Assert.AreEqual(false, stream.CanRead, "test#06");
            Assert.AreEqual(false, stream.CanSeek, "test#07");
            Assert.AreEqual(false, stream.CanWrite, "test#08");

            DeleteFile(path);
#endif
        }
Example #22
0
 public Assingment(Symbol <T> name, IEnumerable <Symbol <T> > variables, IExpression <T> result, FilePosition position)
 {
     this.Name      = name;
     this.variables = variables.ToArray();
     this.Result    = result;
     this.Position  = position;
 }
Example #23
0
 public BitShiftLeft(IExpression <T> first, IExpression <T> second, FilePosition position)
     : base(first, second, EAExpressionType.LeftShift, position)
 {
 }
Example #24
0
 public RelIndDefinition(RelInd relind, string baseTableName, ProbeClassifiedString source, string devDesc, FilePosition filePos)
     : base(relind.Name, filePos, GetExternalRefId(baseTableName, relind.Name))
 {
     _relind        = relind;
     _source        = source;
     _devDesc       = devDesc;
     _baseTableName = baseTableName;
 }
Example #25
0
        public void GettingFilePositionWithAnOffsetOfZero()
        {
            position = source.GetFilePosition(0);

            Assert.AreEqual(1, position.Line);
            Assert.AreEqual(0, position.Column);
        }
Example #26
0
        public static void ParseMoaiCodeFile(FileInfo codeFile, FilePosition filePosition, TypeCollection types, WarningList warnings)
        {
            string code = codeFile.ReadAllText();

            ParseMoaiCodeFile(code, filePosition, types, warnings);
        }
Example #27
0
 public static void ParseMoaiCodeFile(string code, FilePosition filePosition, TypeCollection types, WarningList warnings)
 {
     ClassParser.ParseClassDefinitions(code, filePosition, types, warnings);
     MethodParser.ParseMethodDefinitions(code, filePosition, types, warnings);
 }
 public SyntaxTreeConstNode(FilePosition position, Symbol symbol)
     : base(position)
 {
     this.ConstSymbol = symbol;
 }
Example #29
0
 public Symbol(string name, FilePosition position)
 {
     this.name     = name;
     this.position = position;
 }
Example #30
0
 public ExtractFieldDefinition(string name, FilePosition filePos, ExtractTableDefinition tableDef)
     : base(name, filePos, tableDef.Permanent ? GetExternalRefId(tableDef.Name, name) : null)
 {
 }
Example #31
0
 public Sum(IExpression <T> first, IExpression <T> second, FilePosition position)
     : base(first, second, EAExpressionType.Sum, position)
 {
 }
Example #32
0
 public RelInd(RelIndType type, string name, int number, string tableName, FilePosition filePos)
     : base(name, number, 0, filePos)
 {
     _type      = type;
     _tableName = tableName;
 }
Example #33
0
 public Assignment(string name, IExpression <T> value, FilePosition position)
 {
     Name  = name;
     Value = value;
     pos   = position;
 }
Example #34
0
 public static Nintenlord.Event_Assembler.Core.Code.Language.Expression.Code <T> EmptyCode(FilePosition position)
 {
     return(new Nintenlord.Event_Assembler.Core.Code.Language.Expression.Code <T>(position, (Symbol <T>)null, new List <IExpression <T> >()));
 }
Example #35
0
 public BitwiseOr(IExpression <T> first, IExpression <T> second, FilePosition position)
     : base(first, second, EAExpressionType.OR, position)
 {
 }
Example #36
0
 private Code(FilePosition position, Symbol <T> codeName, List <IExpression <T> > parameters)
 {
     this.codeName   = codeName;
     this.parameters = parameters.ToArray();
     this.position   = position;
 }
		public void FilePositionJumpedToReturnsParametersPassedToJumpToFilePositionMethod()
		{
			int line = 1;
			int col = 10;
			string fileName = "test.cs";
			fileService.JumpToFilePosition(fileName, line, col);
			
			FilePosition expectedFilePos = new FilePosition(fileName, line, col);
			
			Assert.AreEqual(expectedFilePos, fileService.FilePositionJumpedTo);
		}
Example #38
0
 public SyntaxTreeNode(FilePosition position)
 {
     this._children = new List<SyntaxTreeNode>();
     this._position = position;
 }
Example #39
0
 public Modulus(IExpression <T> first, IExpression <T> second, FilePosition position)
     : base(first, second, EAExpressionType.Modulus, position)
 {
 }
Example #40
0
 public SignatureLocation SignatureFromPosition(FilePosition position)
 {
     try {
         var lines = new List<string>();
         run(string.Format(
                 "signature-from-position \"{0}\"",
                 position.ToCommand()),
             (m) => lines.Add(m));
         if (lines.Count != 4)
             return null;
         return new SignatureLocation(
             lines[0],
             lines[1],
             new Position(lines[2]),
             new Position(lines[3]));
     } catch {
         return null;
     }
 }
 public GherkinSemanticErrorException(string message, FilePosition position)
     : base(message, position.Line - 1, position.Column - 1)
 {
 }
 /// <summary>
 /// Expand the file position forward by a given number of columns (or characters) and
 /// return the resulting source range.
 /// </summary>
 /// <param name="columns">Number of columns</param>
 /// <returns>Source range of expanded position</returns>
 public SourceRange Expand(int columns)
 {
     FilePosition end = new FilePosition(Line, Column + columns);
     return new SourceRange(this, end);
 }
 public SyntaxTreeParenthesisNode(FilePosition position, SyntaxTreeNode intExprNode)
     : base(position)
 {
     this._children.Add(intExprNode);
 }
Example #44
0
 protected virtual void AppendNodeLine(StringBuilder result, FilePosition filePosition, string textFormat, params object[] args)
 {
     result.AppendFormat(textFormat, args);
     AppendLine(result);
 }
        public void FilePositionEqualsReturnsFalseWhenNullPassed()
        {
            FilePosition lhs = new FilePosition("test.cs", 1, 2);

            Assert.IsFalse(lhs.Equals(null));
        }
Example #46
0
 public ColumnDefinition(string tableName, string fieldName, string prompt, string comment, DataType dataType, string description, FilePosition filePos)
     : base(fieldName, filePos, DkDict.Column.GetTableFieldExternalRefId(tableName, fieldName))
 {
     _tableName = tableName;
     _fieldName = fieldName;
     _prompt    = prompt;
     _comment   = comment;
     _dataType  = dataType;
     _repoDesc  = description;
 }
 public SyntaxTreeErrorNode(FilePosition position)
     : base(position)
 {
 }
Example #48
0
        public ScenarioStep CreateStep(string keyword, StepKeyword stepKeyword, string text, FilePosition position, ScenarioBlock scenarioBlock)
        {
            ScenarioStep step;

            switch (stepKeyword)
            {
            case StepKeyword.Given:
                step = new Given();
                break;

            case StepKeyword.When:
                step = new When();
                break;

            case StepKeyword.Then:
                step = new Then();
                break;

            case StepKeyword.And:
                step = new And();
                break;

            case StepKeyword.But:
                step = new But();
                break;

            default:
                throw new NotSupportedException();
            }

            step.Keyword       = keyword;
            step.Text          = text;
            step.FilePosition  = position;
            step.ScenarioBlock = scenarioBlock;
            step.StepKeyword   = stepKeyword;
            return(step);
        }
Example #49
0
        public void TheLastOffsetofTheContents()
        {
            position = source.GetFilePosition(129);

            Assert.AreEqual(7, position.Line);
            Assert.AreEqual(2, position.Column);
        }
Example #50
0
 public static Code <T> EmptyCode(FilePosition position)
 {
     return(new Code <T>(position, null, new List <IExpression <T> >()));
 }
Example #51
0
 public LabelExpression(FilePosition position, string labelName)
 {
     this.position  = position;
     this.labelName = labelName;
 }
		public void FilePositionEqualsReturnsFalseWhenNullPassed()
		{
			FilePosition lhs = new FilePosition("test.cs", 1, 2);
			Assert.IsFalse(lhs.Equals(null));
		}
Example #53
0
 internal EditPoint(FilePosition filePosition, IDocumentLoader documentLoader)
     : base(filePosition, documentLoader)
 {
 }
 public void ProcessTableRow(string[] cells, FilePosition rowPosition)
 {
     tableBuilder.ProcessTableRow(cells, rowPosition);
 }
Example #55
0
 public Code(Symbol <T> codeName, List <IExpression <T> > parameters)
 {
     this.codeName   = codeName;
     this.parameters = parameters.ToArray();
     this.position   = codeName.Position;
 }
Example #56
0
 public Scope(List <IExpression <T> > expressions, FilePosition position)
 {
     this.expressions = expressions;
     this.position    = position;
 }
Example #57
0
 public Comment(string text, FilePosition filePosition)
 {
     FilePosition = filePosition;
     Text = text;
 }
Example #58
0
        public SetBreakpointCommand(int id, NodeModule module, NodeBreakpoint breakpoint, bool withoutPredicate, bool remote, SourceMapper sourceMapper = null)
            : base(id, "setbreakpoint")
        {
            Utilities.ArgumentNotNull("breakpoint", breakpoint);

            this._module       = module;
            this._breakpoint   = breakpoint;
            this._sourceMapper = sourceMapper;

            this._position = breakpoint.GetPosition(this._sourceMapper);

            // Zero based line numbers
            var line = this._position.Line;

            // Zero based column numbers
            // Special case column to avoid (line 0, column 0) which
            // Node (V8) treats specially for script loaded via require
            // Script wrapping process: https://github.com/joyent/node/blob/v0.10.26-release/src/node.js#L880
            var column = this._position.Column;

            if (line == 0)
            {
                column += NodeConstants.ScriptWrapBegin.Length;
            }

            this._arguments = new Dictionary <string, object> {
                { "line", line },
                { "column", column }
            };

            if (this._module != null)
            {
                this._arguments["type"]   = "scriptId";
                this._arguments["target"] = this._module.Id;
            }
            else if (remote)
            {
                this._arguments["type"]   = "scriptRegExp";
                this._arguments["target"] = CreateRemoteScriptRegExp(this._position.FileName);
            }
            else
            {
                this._arguments["type"]   = "scriptRegExp";
                this._arguments["target"] = CreateLocalScriptRegExp(this._position.FileName);
            }

            if (!NodeBreakpointBinding.GetEngineEnabled(this._breakpoint.Enabled, this._breakpoint.BreakOn, 0))
            {
                this._arguments["enabled"] = false;
            }

            if (withoutPredicate)
            {
                return;
            }

            var ignoreCount = NodeBreakpointBinding.GetEngineIgnoreCount(this._breakpoint.BreakOn, 0);

            if (ignoreCount > 0)
            {
                this._arguments["ignoreCount"] = ignoreCount;
            }

            if (!string.IsNullOrEmpty(this._breakpoint.Condition))
            {
                this._arguments["condition"] = this._breakpoint.Condition;
            }
        }
 public SyntaxTreeAssignmentNode(FilePosition position, SyntaxTreeNode identNode, SyntaxTreeNode intExprNode)
     : base(position)
 {
     this._children.Add(identNode);
     this._children.Add(intExprNode);
 }
Example #60
0
 public ValueExpression(T value, FilePosition position)
 {
     this.Value    = value;
     this.position = position;
 }