/// <summary>
        /// Generates completion data for the specified text. The text should be everything before
        /// the dot character that triggered the completion. The text can contain the command line prompt
        /// '>>>' as this will be ignored.
        /// </summary>
        public void GenerateDescription(string stub, string item, DescriptionUpdateDelegate updateDescription, bool isInstance)
        {
            System.IO.Stream stream      = commandLine.ScriptScope.Engine.Runtime.IO.OutputStream;
            string           description = "";

            if (!String.IsNullOrEmpty(item))
            {
                try
                {
                    AutocompletionInProgress = true;
                    // Another possibility:
                    //commandLine.ScriptScope.Engine.Runtime.IO.SetOutput(new System.IO.MemoryStream(), Encoding.UTF8);
                    //object value = commandLine.ScriptScope.Engine.CreateScriptSourceFromString(item, SourceCodeKind.Expression).Execute(commandLine.ScriptScope);
                    //description = commandLine.ScriptScope.Engine.Operations.GetDocumentation(value);
                    string docCommand = "";

                    if (isInstance)
                    {
                        if (stub != string.Empty)
                        {
                            docCommand = "type(" + stub + ")" + "." + item + ".__doc__";
                        }
                        else
                        {
                            docCommand = "type(" + item + ")" + ".__doc__";
                        }
                    }
                    else
                    {
                        if (stub != string.Empty)
                        {
                            docCommand = stub + "." + item + ".__doc__";
                        }
                        else
                        {
                            docCommand = item + ".__doc__";
                        }
                    }

                    object value = commandLine.ScriptScope.Engine.CreateScriptSourceFromString(docCommand, SourceCodeKind.Expression).Execute(commandLine.ScriptScope);
                    description = (string)value;
                    AutocompletionInProgress = false;
                }
                catch (ThreadAbortException tae)
                {
                    if (tae.ExceptionState is Microsoft.Scripting.KeyboardInterruptException)
                    {
                        Thread.ResetAbort();
                    }
                    AutocompletionInProgress = false;
                }
                catch
                {
                    AutocompletionInProgress = false;
                    // Do nothing.
                }
                commandLine.ScriptScope.Engine.Runtime.IO.SetOutput(stream, Encoding.UTF8);
                updateDescription(description);
            }
        }
示例#2
0
        /// <summary>
        /// Generates completion data for the specified text. The text should be everything before
        /// the dot character that triggered the completion. The text can contain the command line prompt
        /// '>>>' as this will be ignored.
        /// </summary>
        public void GetDescription(string stub, string item, DescriptionUpdateDelegate updateDescription, bool isInstance)
        {
            string description = this.GetDescription(stub, item, isInstance);

            updateDescription(description);
        }
 /// <summary>
 /// Generates completion data for the specified text. The text should be everything before
 /// the dot character that triggered the completion. The text can contain the command line prompt
 /// '>>>' as this will be ignored.
 /// </summary>
 public void GetDescription(string stub, string item, DescriptionUpdateDelegate updateDescription, bool isInstance)
 {
     string description = this.GetDescription(stub, item, isInstance);
     updateDescription(description);
 }
 /// <summary>
 /// Generates completion data for the specified text. The text should be everything before
 /// the dot character that triggered the completion. The text can contain the command line prompt
 /// '>>>' as this will be ignored.
 /// </summary>
 public void GenerateDescription(string stub, string item, DescriptionUpdateDelegate updateDescription, bool isInstance)
 {
     System.IO.Stream stream = commandLine.ScriptScope.Engine.Runtime.IO.OutputStream;
     string description = "";
     if (!String.IsNullOrEmpty(item))
     {
         try
         {
             AutocompletionInProgress = true;
             // Another possibility:
             //commandLine.ScriptScope.Engine.Runtime.IO.SetOutput(new System.IO.MemoryStream(), Encoding.UTF8);
             //object value = commandLine.ScriptScope.Engine.CreateScriptSourceFromString(item, SourceCodeKind.Expression).Execute(commandLine.ScriptScope);
             //description = commandLine.ScriptScope.Engine.Operations.GetDocumentation(value);
             string docCommand = "";
             if (isInstance) docCommand = "type(" + stub + ")" + "." + item + ".__doc__";
             else docCommand = stub + "." + item + ".__doc__";
             object value = commandLine.ScriptScope.Engine.CreateScriptSourceFromString(docCommand, SourceCodeKind.Expression).Execute(commandLine.ScriptScope);
             description = (string)value;
             AutocompletionInProgress = false;
         }
         catch (ThreadAbortException tae)
         {
             if (tae.ExceptionState is Microsoft.Scripting.KeyboardInterruptException) Thread.ResetAbort();
             AutocompletionInProgress = false;
         }
         catch
         {
             AutocompletionInProgress = false;
             // Do nothing.
         }
         commandLine.ScriptScope.Engine.Runtime.IO.SetOutput(stream, Encoding.UTF8);
         updateDescription(description);
     }
 }