Ejemplo n.º 1
0
        /// <summary>
        /// Check current file's syntax
        /// </summary>
        public override void CheckSyntax()
        {
            EventManager.DispatchEvent(this, new NotifyEvent(EventType.ProcessStart));
            HaXeCompletion hc     = new HaXeCompletion(ASContext.CurSciControl, 0);
            ArrayList      result = hc.getList(false);

            if (result.Count == 0 || (string)result[0] != "error")
            {
                EventManager.DispatchEvent(this, new TextEvent(EventType.ProcessEnd, "Done(0)"));
                return;
            }
            foreach (string line in result)
            {
                if (line != "error")
                {
                    TraceManager.Add(line);
                }
            }
            EventManager.DispatchEvent(this, new TextEvent(EventType.ProcessEnd, "Done(1)"));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Let contexts handle code completion
        /// </summary>
        /// <param name="sci">Scintilla control</param>
        /// <param name="expression">Completion context</param>
        /// <returns>Null (not handled) or function signature</returns>
        public override MemberModel ResolveFunctionContext(ScintillaNet.ScintillaControl sci, ASExpr expression, bool autoHide)
        {
            if (resolvingFunction || hxsettings.CompletionMode == HaxeCompletionModeEnum.FlashDevelop || PluginBase.MainForm.CurrentDocument.IsUntitled)
                return null;

            if (autoHide && !hxsettings.DisableCompletionOnDemand)
                return null;

            // Do not show error
            string val = expression.Value;
            if (val == "for" ||
                val == "while" ||
                val == "if" ||
                val == "switch" ||
                val == "function" ||
                val == "catch" ||
                val == "trace")
                return null;

            expression.Position++;
            HaXeCompletion hc = new HaXeCompletion(sci, expression, autoHide, completionModeHandler);
            hc.getList(OnFunctionCompletionResult);

            resolvingFunction = true;
            return null; // running asynchronously
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Let contexts handle code completion
        /// </summary>
        /// <param name="sci">Scintilla control</param>
        /// <param name="expression">Completion context</param>
        /// <param name="autoHide">Auto-started completion (is false when pressing Ctrl+Space)</param>
        /// <returns>Null (not handled) or member list</returns>
        public override MemberList ResolveDotContext(ScintillaNet.ScintillaControl sci, ASExpr expression, bool autoHide)
        {
            if (resolvingDot || hxsettings.CompletionMode == HaxeCompletionModeEnum.FlashDevelop || PluginBase.MainForm.CurrentDocument.IsUntitled)
                return null;

            if (autoHide && !hxsettings.DisableCompletionOnDemand)
                return null;

            // auto-started completion, can be ignored for performance (show default completion tooltip)
            if (expression.Value.IndexOf(".") < 0 || (autoHide && !expression.Value.EndsWith(".")))
                if (hxsettings.DisableMixedCompletion && expression.Value.Length > 0 && autoHide) return new MemberList();
                else return null;

            // empty expression
            if (expression.Value != "")
            {
                // async processing
                HaXeCompletion hc = new HaXeCompletion(sci, expression, autoHide, completionModeHandler);
                hc.getList(OnDotCompletionResult);
                resolvingDot = true;
            }

            if (hxsettings.DisableMixedCompletion) return new MemberList();
            return null;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Check current file's syntax
 /// </summary>
 public override void CheckSyntax()
 {
     EventManager.DispatchEvent(this, new NotifyEvent(EventType.ProcessStart));
     HaXeCompletion hc = new HaXeCompletion(ASContext.CurSciControl, new ASExpr(), false, completionModeHandler);
     hc.getList(OnCheckSyntaxResult);
 }
Ejemplo n.º 5
0
        internal void OnFunctionCompletionResult(HaXeCompletion hc, ArrayList al)
        {
            resolvingFunction = false;
            if (al == null || al.Count == 0)
                return; // haxe.exe not found

            ScintillaNet.ScintillaControl sci = hc.sci;
            string[] parts = hc.expr.Value.Split('.');
            string name = parts[parts.Length - 1];

            MemberModel member = new MemberModel();
            string outputType = al[0].ToString();

            if (outputType == "type" )
            {
                member.Name = name;
                member.Flags = FlagType.Function;
                member.Access = Visibility.Public;

                string type = al[1].ToString();

                Array types = type.Split(new string[] { "->" }, StringSplitOptions.RemoveEmptyEntries);

                // Function's arguments
                member.Parameters = new List<MemberModel>();
                int j = 0;
                while (j < types.Length - 1)
                {
                    MemberModel param = new MemberModel(types.GetValue(j).ToString(), "", FlagType.ParameterVar, Visibility.Public);
                    member.Parameters.Add(param);
                    j++;
                }
                // Function's return type
                member.Type = types.GetValue(types.Length - 1).ToString();
            }
            else if ( outputType == "error" )
            {
                string err = al[1].ToString();
                TraceManager.AddAsync(err, -3);
                //sci.CallTipShow(sci.CurrentPos, err);
                //sci.CharAdded += new ScintillaNet.CharAddedHandler(removeTip);
            }

            // show call tip
            hc.expr.Position--;
            ASComplete.FunctionContextResolved(sci, hc.expr, member, null, true);
        }
Ejemplo n.º 6
0
        internal void OnDotCompletionResult(HaXeCompletion hc, ArrayList al)
        {
            resolvingDot = false;
            if (al == null || al.Count == 0)
                return; // haxe.exe not found

            ScintillaNet.ScintillaControl sci = hc.sci;
            MemberList list = new MemberList();
            string outputType = al[0].ToString();

            if (outputType == "error")
            {
                string err = al[1].ToString();
                TraceManager.AddAsync(err, -3);
                //sci.CallTipShow(sci.CurrentPos, err);
                //sci.CharAdded += new ScintillaNet.CharAddedHandler(removeTip);

                // show default completion tooltip
                if (!hxsettings.DisableMixedCompletion)
                    return;
            }
            else if (outputType == "list")
            {
                foreach (ArrayList i in al[1] as ArrayList)
                {
                    string var = i[0].ToString();
                    string type = i[1].ToString();
                    string desc = i[2].ToString();

                    FlagType flag = FlagType.Variable;

                    MemberModel member = new MemberModel();
                    member.Name = var;
                    member.Access = Visibility.Public;
                    member.Comments = desc;
                    var p1 = desc.IndexOf('\r');
                    var p2 = desc.IndexOf('\n');

                    // Package or Class
                    if (type == "")
                    {
                        string bl = var.Substring(0, 1);
                        if (bl == bl.ToLower())
                            flag = FlagType.Package;
                        else
                            flag = FlagType.Class;
                    }
                    // Function or Variable
                    else
                    {
                        Array types = type.Split(new string[] { "->" }, StringSplitOptions.RemoveEmptyEntries);

                        // Function
                        if (types.Length > 1)
                        {
                            flag = FlagType.Function;

                            // Function's arguments
                            member.Parameters = new List<MemberModel>();
                            int j = 0;
                            while (j < types.Length - 1)
                            {
                                MemberModel param = new MemberModel(types.GetValue(j).ToString(), "", FlagType.ParameterVar, Visibility.Public);
                                member.Parameters.Add(param);
                                j++;
                            }

                            // Function's return type
                            member.Type = types.GetValue(types.Length - 1).ToString();
                        }
                        // Variable
                        else
                        {
                            flag = FlagType.Variable;
                            // Variable's type
                            member.Type = type;
                        }

                    }

                    member.Flags = flag;

                    list.Add(member);
                }
            }

            // update completion
            if (list.Count > 0)
            {
                list.Sort();
                ASComplete.DotContextResolved(sci, hc.expr, list, hc.autoHide);
            }
        }
Ejemplo n.º 7
0
 internal void OnCheckSyntaxResult(HaXeCompletion hc, ArrayList result)
 {
     if (result.Count == 0 || (string)result[0] != "error")
     {
         EventManager.DispatchEvent(this, new TextEvent(EventType.ProcessEnd, "Done(0)"));
         return;
     }
     foreach (string line in result)
     {
         if (line != "error") TraceManager.Add(line);
     }
     EventManager.DispatchEvent(this, new TextEvent(EventType.ProcessEnd, "Done(1)"));
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Let contexts handle code completion
        /// </summary>
        /// <param name="sci">Scintilla control</param>
        /// <param name="expression">Completion context</param>
        /// <param name="autoHide">Auto-started completion (is false when pressing Ctrl+Space)</param>
        /// <returns>Null (not handled) or member list</returns>
        public override MemberList ResolveDotContext(ScintillaNet.ScintillaControl sci, ASExpr expression, bool autoHide)
        {
            if (hxsettings.DisableCompilerCompletion)
            {
                return(null);
            }

            if (autoHide && !hxsettings.DisableCompletionOnDemand)
            {
                return(null);
            }

            // auto-started completion, can be ignored for performance (show default completion tooltip)
            if (autoHide && !expression.Value.EndsWith("."))
            {
                if (hxsettings.DisableMixedCompletion)
                {
                    return(new MemberList());
                }
                else
                {
                    return(null);
                }
            }

            MemberList list = new MemberList();

            HaXeCompletion hc = new HaXeCompletion(sci, expression.Position);
            ArrayList      al = hc.getList();

            if (al == null || al.Count == 0)
            {
                return(null); // haxe.exe not found
            }
            string outputType = al[0].ToString();

            if (outputType == "error")
            {
                string err = al[1].ToString();
                sci.CallTipShow(sci.CurrentPos, err);
                sci.CharAdded += new ScintillaNet.CharAddedHandler(removeTip);

                // show default completion tooltip
                if (!hxsettings.DisableMixedCompletion)
                {
                    return(null);
                }
            }
            else if (outputType == "list")
            {
                foreach (ArrayList i in al[1] as ArrayList)
                {
                    string var  = i[0].ToString();
                    string type = i[1].ToString();
                    string desc = i[2].ToString();

                    FlagType flag = FlagType.Variable;

                    MemberModel member = new MemberModel();
                    member.Name   = var;
                    member.Access = Visibility.Public;

                    // Package or Class
                    if (type == "")
                    {
                        string bl = var.Substring(0, 1);
                        if (bl == bl.ToLower())
                        {
                            flag = FlagType.Package;
                        }
                        else
                        {
                            flag = FlagType.Class;
                        }
                    }
                    // Function or Variable
                    else
                    {
                        Array types = type.Split(new string[] { "->" }, StringSplitOptions.RemoveEmptyEntries);

                        // Function
                        if (types.Length > 1)
                        {
                            flag = FlagType.Function;

                            // Function's arguments
                            member.Parameters = new List <MemberModel>();
                            int j = 0;
                            while (j < types.Length - 1)
                            {
                                MemberModel param = new MemberModel(types.GetValue(j).ToString(), "", FlagType.ParameterVar, Visibility.Public);
                                member.Parameters.Add(param);
                                j++;
                            }

                            // Function's return type
                            member.Type = types.GetValue(types.Length - 1).ToString();
                        }
                        // Variable
                        else
                        {
                            flag = FlagType.Variable;
                            // Variable's type
                            member.Type = type;
                        }
                    }

                    member.Flags = flag;

                    list.Add(member);
                }
            }
            return(list);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Let contexts handle code completion
        /// </summary>
        /// <param name="sci">Scintilla control</param>
        /// <param name="expression">Completion context</param>
        /// <returns>Null (not handled) or function signature</returns>
        public override MemberModel ResolveFunctionContext(ScintillaNet.ScintillaControl sci, ASExpr expression, bool autoHide)
        {
            if (hxsettings.DisableCompilerCompletion)
            {
                return(null);
            }

            if (autoHide && !hxsettings.DisableCompletionOnDemand)
            {
                return(null);
            }

            string[] parts = expression.Value.Split('.');
            string   name  = parts[parts.Length - 1];

            MemberModel member = new MemberModel();

            // Do not show error
            string val = expression.Value;

            if (val == "for" ||
                val == "while" ||
                val == "if" ||
                val == "switch" ||
                val == "function" ||
                val == "catch" ||
                val == "trace")
            {
                return(null);
            }

            HaXeCompletion hc = new HaXeCompletion(sci, expression.Position);
            ArrayList      al = hc.getList();

            if (al == null || al.Count == 0)
            {
                return(null); // haxe.exe not found
            }
            string outputType = al[0].ToString();

            if (outputType == "type")
            {
                member.Name   = name;
                member.Flags  = FlagType.Function;
                member.Access = Visibility.Public;

                string type = al[1].ToString();

                Array types = type.Split(new string[] { "->" }, StringSplitOptions.RemoveEmptyEntries);

                // Function's arguments
                member.Parameters = new List <MemberModel>();
                int j = 0;
                while (j < types.Length - 1)
                {
                    MemberModel param = new MemberModel(types.GetValue(j).ToString(), "", FlagType.ParameterVar, Visibility.Public);
                    member.Parameters.Add(param);
                    j++;
                }
                // Function's return type
                member.Type = types.GetValue(types.Length - 1).ToString();
            }
            else if (outputType == "error")
            {
                string err = al[1].ToString();
                sci.CallTipShow(sci.CurrentPos, err);
                sci.CharAdded += new ScintillaNet.CharAddedHandler(removeTip);
            }

            return(member);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Check current file's syntax
 /// </summary>
 public override void CheckSyntax()
 {
     EventManager.DispatchEvent(this, new NotifyEvent(EventType.ProcessStart));
     HaXeCompletion hc = new HaXeCompletion(ASContext.CurSciControl, 0);
     ArrayList result = hc.getList(false);
     if (result.Count == 0 || (string)result[0] != "error")
     {
         EventManager.DispatchEvent(this, new TextEvent(EventType.ProcessEnd, "Done(0)"));
         return;
     }
     foreach (string line in result)
     {
         if (line != "error") TraceManager.Add(line);
     }
     EventManager.DispatchEvent(this, new TextEvent(EventType.ProcessEnd, "Done(1)"));
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Let contexts handle code completion
        /// </summary>
        /// <param name="sci">Scintilla control</param>
        /// <param name="expression">Completion context</param>
        /// <returns>Null (not handled) or function signature</returns>
        public override MemberModel ResolveFunctionContext(ScintillaNet.ScintillaControl sci, ASExpr expression, bool autoHide)
        {
            if (hxsettings.DisableCompilerCompletion)
                return null;

            if (autoHide && !hxsettings.DisableCompletionOnDemand)
                return null;

            string[] parts = expression.Value.Split('.');
            string name = parts[parts.Length - 1];
            
            MemberModel member = new MemberModel();

            // Do not show error
            string val = expression.Value;
            if (val == "for" || 
                val == "while" ||
                val == "if" ||
                val == "switch" ||
                val == "function" ||
                val == "catch" ||
                val == "trace")
                return null;

            HaXeCompletion hc = new HaXeCompletion(sci, expression.Position);
            ArrayList al = hc.getList();
            if (al == null || al.Count == 0)
                return null; // haxe.exe not found

            string outputType = al[0].ToString();

            if (outputType == "type" )
            {
                member.Name = name;
                member.Flags = FlagType.Function;
                member.Access = Visibility.Public;

                string type = al[1].ToString();

                Array types = type.Split(new string[] { "->" }, StringSplitOptions.RemoveEmptyEntries);

                // Function's arguments
                member.Parameters = new List<MemberModel>();
                int j = 0;
                while (j < types.Length - 1)
                {
                    MemberModel param = new MemberModel(types.GetValue(j).ToString(), "", FlagType.ParameterVar, Visibility.Public);
                    member.Parameters.Add(param);
                    j++;
                }
                // Function's return type
                member.Type = types.GetValue(types.Length - 1).ToString();
            }
            else if ( outputType == "error" )
            {
                string err = al[1].ToString();
                sci.CallTipShow(sci.CurrentPos, err);
                sci.CharAdded += new ScintillaNet.CharAddedHandler(removeTip);
            }
                        
            return member;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Let contexts handle code completion
        /// </summary>
        /// <param name="sci">Scintilla control</param>
        /// <param name="expression">Completion context</param>
        /// <param name="autoHide">Auto-started completion (is false when pressing Ctrl+Space)</param>
        /// <returns>Null (not handled) or member list</returns>
        public override MemberList ResolveDotContext(ScintillaNet.ScintillaControl sci, ASExpr expression, bool autoHide)
        {
            if (hxsettings.DisableCompilerCompletion)
                return null;

            if (autoHide && !hxsettings.DisableCompletionOnDemand)
                return null;

            // auto-started completion, can be ignored for performance (show default completion tooltip)
            if (autoHide && !expression.Value.EndsWith("."))
                if ( hxsettings.DisableMixedCompletion )
                    return new MemberList();
                else
                    return null;

            MemberList list = new MemberList();
           
            HaXeCompletion hc = new HaXeCompletion(sci, expression.Position);
            ArrayList al = hc.getList();
            if (al == null || al.Count == 0) 
                return null; // haxe.exe not found
            
            string outputType = al[0].ToString();

            if( outputType == "error" )
            {
                string err = al[1].ToString();
                sci.CallTipShow(sci.CurrentPos, err);
                sci.CharAdded += new ScintillaNet.CharAddedHandler(removeTip);
                
                // show default completion tooltip
                if (!hxsettings.DisableMixedCompletion)
                    return null;
            }
            else if (outputType == "list")
            {
                foreach (ArrayList i in al[ 1 ] as ArrayList)
                {
                    string var = i[0].ToString();
                    string type = i[1].ToString();
                    string desc = i[2].ToString();

                    FlagType flag = FlagType.Variable;

                    MemberModel member = new MemberModel();
                    member.Name = var;
                    member.Access = Visibility.Public;
                    
                    // Package or Class
                    if (type == "")
                    {
                        string bl = var.Substring( 0, 1 );
                        if (bl == bl.ToLower())
                            flag = FlagType.Package;
                        else
                            flag = FlagType.Class;
                    }
                    // Function or Variable
                    else
                    {
                        Array types = type.Split(new string[] { "->" }, StringSplitOptions.RemoveEmptyEntries);

                        // Function
                        if (types.Length > 1)
                        {
                            flag = FlagType.Function;

                            // Function's arguments
                            member.Parameters = new List<MemberModel>();
                            int j = 0;
                            while (j < types.Length - 1)
                            {
                                MemberModel param = new MemberModel(types.GetValue(j).ToString(), "", FlagType.ParameterVar, Visibility.Public);
                                member.Parameters.Add(param);
                                j++;
                            }

                            // Function's return type
                            member.Type = types.GetValue(types.Length - 1).ToString();
                        }
                        // Variable
                        else
                        {
                            flag = FlagType.Variable;
                            // Variable's type
                            member.Type = type;
                        }    
                       
                    }
                                        
                    member.Flags = flag;
                    
                   list.Add(member);
                }
            }
            return list;
        }