public virtual IDebugVariable[] GetChildren(DebugVariableLinkCollection collection, IDebugVariable parent)
        {
            // Get the array.
            if (parent.Value is CsvArray array)
            {
                // Get the values.
                IDebugVariable[] children = new IDebugVariable[array.Values.Length];
                for (int i = 0; i < children.Length; i++)
                {
                    children[i] = GetChildDebugVariable(collection, array.Values[i], "[" + i + "]");
                    collection.Add(children[i]);
                }

                // Done
                return(children);
            }
            // Get the vector.
            else if (parent.Value is CsvVector vector)
            {
                var x = GetChildDebugVariable(collection, new CsvNumber(vector.Value.X), "X");
                var y = GetChildDebugVariable(collection, new CsvNumber(vector.Value.Y), "Y");
                var z = GetChildDebugVariable(collection, new CsvNumber(vector.Value.Z), "Z");
                collection.Add(x);
                collection.Add(y);
                collection.Add(z);
                return(new IDebugVariable[] { x, y, z });
            }
            return(new LinkableDebugVariable[0]);
        }
        public DBPVariable GetVariable(DebugVariableLinkCollection collection, IDebugVariable debugVariable)
        {
            // Return null if there is no value.
            if (debugVariable.Value == null)
            {
                return(null);
            }

            // Create the variable.
            DBPVariable variable = GetProtocolVariable(debugVariable);

            // Add the clipboard value copy.
            variable.evaluateName = collection.AddClipboardKey(debugVariable.Name, debugVariable.Value.AsOSTWExpression());

            // If the value is an array, assign a reference.
            if (debugVariable.Value is CsvArray array)
            {
                variable.indexedVariables   = array.Values.Length;
                variable.variablesReference = IDebugVariable.ApplyReference(collection, debugVariable);
            }
            // If the value is a vector, assign a reference.
            else if (debugVariable.Value is CsvVector vector)
            {
                variable.namedVariables     = 3; // X, Y, and Z.
                variable.variablesReference = IDebugVariable.ApplyReference(collection, debugVariable);
            }

            return(variable);
        }
        public EvaluateResponse GetEvaluation(DebugVariableLinkCollection collection, IDebugVariable debugVariable)
        {
            // Return null if there is no value.
            if (debugVariable.Value == null)
            {
                return(EvaluateResponse.Empty);
            }

            // Create the evaluation response.
            EvaluateResponse response = new EvaluateResponse(collection, debugVariable);

            // Array
            if (debugVariable.Value is CsvArray array)
            {
                response.indexedVariables   = array.Values.Length;
                response.variablesReference = IDebugVariable.ApplyReference(collection, debugVariable);
            }
            // Vector
            else if (debugVariable.Value is CsvVector)
            {
                response.namedVariables     = 3;
                response.variablesReference = IDebugVariable.ApplyReference(collection, debugVariable);
            }

            return(response);
        }
Exemple #4
0
        async Task Listen()
        {
            var token = _cancellationTokenSource.Token;

            string last = null;

            while (!token.IsCancellationRequested && !token.WaitHandle.WaitOne(500))
            {
                string clipboard = Clipboard.GetText(); // Get clipboard.
                if (clipboard == last || clipboard == null)
                {
                    continue;                                         // Clipboard did not change.
                }
                last = clipboard;

                // Clipboard changed.

                try
                {
                    // As workshop actions
                    ConvertTextToElement tte      = new ConvertTextToElement(clipboard);
                    Workshop             workshop = tte.GetActionList();

                    if (workshop != null) // Determines if the clipboard is an action list.
                    {
                        DebuggerActionSetResult actionStream = new DebuggerActionSetResult(workshop);

                        // Action list successfully parsed.
                        // Get the DeltinScript.
                        VariableCollection = (await _languageServer.DocumentHandler.OnScriptAvailability())?.DebugVariables;

                        // Error obtaining debug variables.
                        if (VariableCollection == null)
                        {
                            return;
                        }

                        // Apply debugger variables.
                        VariableCollection.Apply(actionStream);

                        // Notify the adapter of the new state.
                        _languageServer.Server.SendNotification("debugger.activated");
                    }
                }
                catch (Exception ex)
                {
                    _languageServer.DebuggerException(ex);
                }
            }
        }
 protected override ChildDebugVariable GetChildDebugVariable(DebugVariableLinkCollection collection, CsvPart arrayValue, string indexName) => new ChildDebugVariable(_typeResolver, arrayValue, indexName, _arrayOfTypeName);
 protected virtual ChildDebugVariable GetChildDebugVariable(DebugVariableLinkCollection collection, CsvPart arrayValue, string indexName) => new ChildDebugVariable(this, arrayValue, indexName, "define");
Exemple #7
0
 public IDebugVariable[] GetChildren(DebugVariableLinkCollection collection) => Variables.ToArray();
Exemple #8
0
 public DBPScope GetScope(DebugVariableLinkCollection collection) => new DBPScope()
 {
     name = Name,
     variablesReference = collection.References[this]
 };