Exemplo n.º 1
0
        /// <summary>
        /// Calculates the 1-based line and column number position based
        /// on the given buffer offset.
        /// </summary>
        /// <param name="bufferOffset">The buffer offset to convert.</param>
        /// <returns>A new BufferPosition containing the position of the offset.</returns>
        public BufferPosition GetPositionAtOffset(int bufferOffset)
        {
            BufferRange bufferRange =
                GetRangeBetweenOffsets(
                    bufferOffset, bufferOffset);

            return(bufferRange.Start);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Compares two instances of the BufferRange class.
        /// </summary>
        /// <param name="obj">The object to which this instance will be compared.</param>
        /// <returns>True if the ranges are equal, false otherwise.</returns>
        public override bool Equals(object obj)
        {
            if (!(obj is BufferRange))
            {
                return(false);
            }

            BufferRange other = (BufferRange)obj;

            return
                (this.Start.Equals(other.Start) &&
                 this.End.Equals(other.End));
        }
        /// <summary>
        /// Creates a new instance of the FullScriptExtent class.
        /// </summary>
        /// <param name="fileContext">The FileContext this extent refers to.</param>
        /// <param name="bufferRange">The buffer range this extent is located at.</param>
        public FullScriptExtent(FileContext fileContext, BufferRange bufferRange)
        {
            Validate.IsNotNull(nameof(fileContext), fileContext);
            Validate.IsNotNull(nameof(bufferRange), bufferRange);

            BufferRange = bufferRange;
            FileContext = fileContext;

            StartOffset = fileContext.scriptFile.GetOffsetAtPosition(
                bufferRange.Start.Line,
                bufferRange.Start.Column);

            EndOffset = fileContext.scriptFile.GetOffsetAtPosition(
                bufferRange.End.Line,
                bufferRange.End.Column);
        }
Exemplo n.º 4
0
        internal static CompletionResults Create(
            ScriptFile scriptFile,
            CommandCompletion commandCompletion)
        {
            BufferRange replacedRange = null;

            // Only calculate the replacement range if there are completion results
            if (commandCompletion.CompletionMatches.Count > 0)
            {
                replacedRange =
                    scriptFile.GetRangeBetweenOffsets(
                        commandCompletion.ReplacementIndex,
                        commandCompletion.ReplacementIndex + commandCompletion.ReplacementLength);
            }

            return(new CompletionResults
            {
                Completions = GetCompletionsArray(commandCompletion),
                ReplacedRange = replacedRange
            });
        }
Exemplo n.º 5
0
 /// <summary>
 /// Creates an empty CompletionResults instance.
 /// </summary>
 public CompletionResults()
 {
     this.Completions   = new CompletionDetails[0];
     this.ReplacedRange = new BufferRange();
 }