Exemplo n.º 1
0
        public static void SetHaxeFeatures(this IASContext mock)
        {
            var context = new HaXeContext.Context(new HaXeContext.HaXeSettings());

            ASContext.RegisterLanguage(context, "haxe");
            BuildClassPath(context);
            context.CurrentModel = new FileModel {
                Context = mock, Version = 4, haXe = true
            };
            SetFeatures(mock, context);
        }
Exemplo n.º 2
0
        public static void SetAs3Features(this IASContext mock)
        {
            var context = new AS3Context.Context(new AS3Context.AS3Settings());

            ASContext.RegisterLanguage(context, "as3");
            BuildClassPath(context);
            context.CurrentModel = new FileModel {
                Context = mock, Version = 3
            };
            SetFeatures(mock, context);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Handles the incoming events
 /// </summary>
 public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
 {
     switch (e.Type)
     {
     case EventType.UIStarted:
         contextInstance = new Context(settingObject);
         // Associate this context with a file type
         ASContext.RegisterLanguage(contextInstance, associatedSyntax);
         break;
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Handles the incoming events
 /// </summary>
 public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
 {
     switch (e.Type)
     {
     case EventType.UIStarted:
         contextInstance = new Context(settingObject);
         ValidateSettings();
         // Associate this context with AS2 language
         ASContext.RegisterLanguage(contextInstance, "as2");
         break;
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
        {
            if (priority == HandlingPriority.Low)
            {
                switch (e.Type)
                {
                case EventType.ProcessArgs:
                    TextEvent te = e as TextEvent;
                    if (te.Value.IndexOf("$(FlexSDK)") >= 0)
                    {
                        te.Value = te.Value.Replace("$(FlexSDK)", contextInstance.GetCompilerPath());
                    }
                    break;

                case EventType.Command:
                    DataEvent de     = e as DataEvent;
                    string    action = de.Action;
                    if (action == "ProjectManager.Project")
                    {
                        FlexShells.Instance.Stop();     // clear
                    }
                    else if (action == "ProjectManager.OpenVirtualFile")
                    {
                        if (PluginBase.CurrentProject != null && PluginBase.CurrentProject.Language == "as3")
                        {
                            e.Handled = OpenVirtualFileModel(de.Data as String);
                        }
                    }
                    else if (!(settingObject as AS3Settings).DisableFDB && action == "AS3Context.StartDebugger")
                    {
                        string workDir = (PluginBase.CurrentProject != null)
                                ? Path.GetDirectoryName(PluginBase.CurrentProject.ProjectPath)
                                : Environment.CurrentDirectory;

                        string flexSdk = (settingObject as AS3Settings).GetDefaultSDK().Path;

                        // if the default sdk is not defined ask for project sdk
                        if (String.IsNullOrEmpty(flexSdk))
                        {
                            flexSdk = PluginBase.MainForm.ProcessArgString("$(CompilerPath)");
                        }
                        e.Handled = FlexDebugger.Start(workDir, flexSdk, null);
                    }
                    else if (action == "AS3Context.StartProfiler")
                    {
                        if (profilerUI.AutoStart)
                        {
                            profilerUI.StartProfiling();
                        }
                    }
                    break;

                case EventType.Keys:
                    if (inMXML)
                    {
                        KeyEvent ke = e as KeyEvent;
                        if (ke.Value == PluginBase.MainForm.GetShortcutItemKeys("SearchMenu.GotoDeclaration"))
                        {
                            if (MxmlComplete.GotoDeclaration())
                            {
                                ke.Handled    = true;
                                ke.ProcessKey = false;
                            }
                        }
                    }
                    break;
                }
                return;
            }

            else if (priority == HandlingPriority.Normal)
            {
                switch (e.Type)
                {
                case EventType.UIStarted:
                    contextInstance = new Context(settingObject);
                    ValidateSettings();
                    AddToolbarItems();
                    // Associate this context with AS3 language
                    ASContext.RegisterLanguage(contextInstance, "as3");
                    ASContext.RegisterLanguage(contextInstance, "mxml");
                    break;

                case EventType.FileSave:
                case EventType.FileSwitch:
                    if (contextInstance != null)
                    {
                        contextInstance.OnFileOperation(e);
                    }

                    if (PluginBase.MainForm.CurrentDocument.IsEditable)
                    {
                        string ext = Path.GetExtension(PluginBase.MainForm.CurrentDocument.FileName);
                        inMXML = (ext.ToLower() == ".mxml");
                        MxmlComplete.IsDirty = true;
                    }
                    else
                    {
                        inMXML = false;
                    }
                    break;
                }
                return;
            }

            else if (priority == HandlingPriority.High)
            {
                if (e.Type == EventType.Command)
                {
                    string action = (e as DataEvent).Action;
                    if (action == "ProjectManager.Project")
                    {
                        FlexDebugger.Stop();
                        IProject project = PluginBase.CurrentProject;
                        viewButton.Enabled = project == null || project.Language == "as3" || project.Language == "haxe";
                    }
                    else if (action.StartsWith("FlashViewer."))
                    {
                        if (action == "FlashViewer.Closed")
                        {
                            FlexDebugger.Stop();
                        }
                        else if (action == "FlashViewer.External" || action == "FlashViewer.Default" ||
                                 action == "FlashViewer.Popup" || action == "FlashViewer.Document")
                        {
                            if (PluginBase.CurrentProject != null &&
                                PluginBase.CurrentProject.EnableInteractiveDebugger)
                            {
                                DataEvent de = new DataEvent(EventType.Command, "AS3Context.StartProfiler", null);
                                EventManager.DispatchEvent(this, de);

                                if (PluginBase.CurrentProject.TraceEnabled)
                                {
                                    de = new DataEvent(EventType.Command, "AS3Context.StartDebugger", (e as DataEvent).Data);
                                    EventManager.DispatchEvent(this, de);
                                }
                            }
                        }
                    }
                    else if (action == "FlashConnect")
                    {
                        ProfilerUI.HandleFlashConnect(sender, (e as DataEvent).Data);
                    }
                    else if (inMXML)
                    {
                        DataEvent de = e as DataEvent;
                        if (de.Action == "XMLCompletion.Element")
                        {
                            de.Handled = MxmlComplete.HandleElement(de.Data);
                        }
                        if (de.Action == "XMLCompletion.Namespace")
                        {
                            de.Handled = MxmlComplete.HandleNamespace(de.Data);
                        }
                        else if (de.Action == "XMLCompletion.CloseElement")
                        {
                            de.Handled = MxmlComplete.HandleElementClose(de.Data);
                        }
                        else if (de.Action == "XMLCompletion.Attribute")
                        {
                            de.Handled = MxmlComplete.HandleAttribute(de.Data);
                        }
                        else if (de.Action == "XMLCompletion.AttributeValue")
                        {
                            de.Handled = MxmlComplete.HandleAttributeValue(de.Data);
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
        {
            switch (e.Type)
            {
            case EventType.ProcessArgs:
                /*TextEvent te = e as TextEvent;
                 * if (te.Value.IndexOf("$(FlexSDK)") >= 0)
                 * {
                 *  te.Value = te.Value.Replace("$(FlexSDK)", contextInstance.GetCompilerPath());
                 * }*/
                break;

            case EventType.Command:
                DataEvent de     = e as DataEvent;
                string    action = de.Action;

                if (PluginBase.CurrentProject == null || !(PluginBase.CurrentProject is LoomProject))
                {
                    if (action == "ProjectManager.Project")
                    {
                        LoomHelper.Monitor(null);
                    }
                    return;
                }

                if (action == "ProjectManager.OpenVirtualFile")
                {
                    if (PluginBase.CurrentProject != null && PluginBase.CurrentProject.Language == "Loom")
                    {
                        e.Handled = OpenVirtualFileModel(de.Data as String);
                    }
                }
                else
                if (action == "ProjectManager.BuildingProject" &&
                    (PluginBase.CurrentProject as LoomProject).OutputType == OutputType.Application)
                {
                    de.Handled = true;
                    PluginBase.MainForm.CallCommand("SaveAllModified", null);
                    LoomHelper.Build(PluginBase.CurrentProject as LoomProject);
                }
                else if (action == "ProjectManager.TestingProject" &&
                         (PluginBase.CurrentProject as LoomProject).OutputType == OutputType.Application)
                {
                    de.Handled = true;
                    PluginBase.MainForm.CallCommand("SaveAllModified", null);
                    LoomHelper.Run(PluginBase.CurrentProject as LoomProject);
                }
                else if (action == "ProjectManager.Project")
                {
                    LoomHelper.Monitor(de.Data as LoomProject);
                }
                break;

            case EventType.UIStarted:
                contextInstance = new Context(settingObject);
                ValidateSettings();
                // Associate this context with Loom language
                ASContext.RegisterLanguage(contextInstance, "loom");
                break;

            case EventType.FileSave:
            case EventType.FileSwitch:
                //if (contextInstance != null) contextInstance.OnFileOperation(e); // TODO syntax check
                break;
            }
        }