Exemple #1
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++;
            var hc = new HaxeComplete(sci, expression, autoHide, completionModeHandler, HaxeCompilerService.COMPLETION, GetCurrentSDKVersion());
            hc.GetList(OnFunctionCompletionResult);

            resolvingFunction = true;
            return null; // running asynchronously
        }
Exemple #2
0
        public override bool HandleGotoDeclaration(ScintillaControl sci, ASExpr expression)
        {
            if (hxsettings.CompletionMode == HaxeCompletionModeEnum.FlashDevelop || GetCurrentSDKVersion().IsOlderThan(new SemVer("3.2.0")))
                return false;

            var hc = new HaxeComplete(sci, expression, false, completionModeHandler, HaxeCompilerService.POSITION, GetCurrentSDKVersion());
            hc.GetPosition(OnPositionResult);
            return true;
        }
Exemple #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.IndexOfOrdinal(".") < 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
                var hc = new HaxeComplete(sci, expression, autoHide, completionModeHandler, HaxeCompilerService.COMPLETION, GetCurrentSDKVersion());
                hc.GetList(OnDotCompletionResult);
                resolvingDot = true;
            }

            if (hxsettings.DisableMixedCompletion) return new MemberList();
            return null;
        }
Exemple #4
0
        private void HandlePositionResult(HaxeComplete hc, HaxePositionResult result, HaxeCompleteStatus status)
        {
            switch (status)
            {
                case HaxeCompleteStatus.ERROR:
                    TraceManager.Add(hc.Errors, -3);
                    break;

                case HaxeCompleteStatus.POSITION:
                    if (result == null) return;

                    ASComplete.SaveLastLookupPosition(hc.Sci);

                    PluginBase.MainForm.OpenEditableDocument(result.Path, false);
                    const string keywords = "(function|var|[,(])";

                    ASComplete.LocateMember(keywords, hc.CurrentWord, result.LineStart - 1);
                    break;
            }
        }
Exemple #5
0
        /// <summary>
        /// Check current file's syntax
        /// </summary>
        public override void CheckSyntax()
        {
            if (hxsettings.CompletionMode == HaxeCompletionModeEnum.FlashDevelop || PluginBase.MainForm.CurrentDocument.IsUntitled) return;

            EventManager.DispatchEvent(this, new NotifyEvent(EventType.ProcessStart));
            var hc = new HaxeComplete(ASContext.CurSciControl, new ASExpr(), false, completionModeHandler, HaxeCompilerService.COMPLETION, GetCurrentSDKVersion());
            hc.GetList(OnCheckSyntaxResult);
        }
Exemple #6
0
 internal void OnPositionResult(HaxeComplete hc, HaxePositionResult result, HaxeCompleteStatus status)
 {
     if (hc.Sci.InvokeRequired)
     {
         hc.Sci.BeginInvoke((MethodInvoker)delegate
         {
             HandlePositionResult(hc, result, status);
         });
     }
     else HandlePositionResult(hc, result, status);
 }
Exemple #7
0
        internal void OnFunctionCompletionResult(HaxeComplete hc, HaxeCompleteResult result, HaxeCompleteStatus status)
        {
            resolvingFunction = false;

            switch (status)
            {
                case HaxeCompleteStatus.ERROR:
                    TraceManager.AddAsync(hc.Errors, -3);
                    break;

                case HaxeCompleteStatus.TYPE:
                    hc.Expr.Position--;
                    ASComplete.FunctionContextResolved(hc.Sci, hc.Expr, result.Type, null, true);
                    break;
            }
        }
Exemple #8
0
        internal void OnDotCompletionResult(HaxeComplete hc,  HaxeCompleteResult result, HaxeCompleteStatus status)
        {
            resolvingDot = false;

            switch (status)
            {
                case HaxeCompleteStatus.ERROR:
                    TraceManager.AddAsync(hc.Errors, -3);
                    break;

                case HaxeCompleteStatus.MEMBERS:
                    if (result.Members != null && result.Members.Count > 0)
                        ASComplete.DotContextResolved(hc.Sci, hc.Expr, result.Members, hc.AutoHide);
                    break;

                case HaxeCompleteStatus.TYPE:
                    // eg. Int
                    break;
            }
        }
Exemple #9
0
        internal void OnCheckSyntaxResult(HaxeComplete hc, HaxeCompleteResult result, HaxeCompleteStatus status)
        {
            switch (status)
            {
                case HaxeCompleteStatus.ERROR:
                    TraceManager.Add(hc.Errors);
                    EventManager.DispatchEvent(this, new TextEvent(EventType.ProcessEnd, "Done(1)"));
                    break;

                default:
                    EventManager.DispatchEvent(this, new TextEvent(EventType.ProcessEnd, "Done(0)"));
                    break;
            }
        }
Exemple #10
0
 /// <summary>
 /// Check current file's syntax
 /// </summary>
 public override void CheckSyntax()
 {
     EventManager.DispatchEvent(this, new NotifyEvent(EventType.ProcessStart));
     var hc = new HaxeComplete(ASContext.CurSciControl, new ASExpr(), false, completionModeHandler);
     hc.GetList(OnCheckSyntaxResult);
 }