예제 #1
0
        public WorkspaceRequest(
            Workspace workspace,
            BufferId activeBufferId = null,
            HttpRequest httpRequest = null,
            int?position            = null,
            string requestId        = null,
            string runArgs          = "")
        {
            Workspace = workspace ?? throw new ArgumentNullException(nameof(workspace));

            RequestId = requestId;
            RunArgs   = runArgs;

            HttpRequest = httpRequest;

            if (activeBufferId != null)
            {
                ActiveBufferId = activeBufferId;
            }
            else if (workspace.Buffers.Length == 1)
            {
                ActiveBufferId = workspace.Buffers[0].Id;
            }

            if (position != null)
            {
                var buffer = Workspace.GetBufferWithSpecifiedIdOrSingleBufferIfThereIsOnlyOne(ActiveBufferId);
                buffer.Position = position.Value;
            }
        }
예제 #2
0
 public Buffer(BufferId id, string content, int position = 0, int offSetFromParentBuffer = 0, int order = 0)
 {
     this.offSetFromParentBuffer = offSetFromParentBuffer;
     Id       = id ?? throw new ArgumentNullException(nameof(id));
     Content  = content;
     Position = position;
     Order    = order;
 }
예제 #3
0
 public SerializableDiagnostic(
     int start,
     int end,
     string message,
     DiagnosticSeverity severity,
     string id,
     BufferId bufferId = null,
     string location   = null)
 {
     Start    = start;
     End      = end;
     Message  = message;
     Severity = severity;
     Id       = id;
     Location = location;
 }
예제 #4
0
        public static Buffer GetBufferWithSpecifiedIdOrSingleBufferIfThereIsOnlyOne(
            this Workspace workspace,
            BufferId bufferId = null)
        {
            // TODO: (GetBufferWithSpecifiedIdOrSingleBufferIfThereIsOnlyOne) this concept should go away

            var buffer = workspace.Buffers.SingleOrDefault(b => b.Id == bufferId);

            if (buffer == null)
            {
                if (workspace.Buffers.Length == 1)
                {
                    buffer = workspace.Buffers.Single();
                }
                else
                {
                    throw new ArgumentException("Ambiguous buffer");
                }
            }

            return(buffer);
        }