Ejemplo n.º 1
0
        public ServerProxy Configure(string eclipsePath)
        {
            Telemetry.Client.Get().TrackEvent("App.ConfigureEditor");

            // Remove itself from properties
            TextView.Properties.RemoveProperty(typeof(JavaUnconfiguredEditor));

            // Set path in registry
            Registry.SetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\JavaPkgSrv", "EclipseInstall", eclipsePath, RegistryValueKind.String);

            // Reboot editor
            var fileName         = VSHelpers.GetFileName(TextView);
            var eclipseWorkspace = EclipseWorkspace.FromFilePath(fileName);
            var javaPkgServer    = JavaPkgServerManager.GetProxy(eclipseWorkspace);
            var javaEditor       = new JavaEditor(SubjectBuffers, TextView, javaPkgServer, eclipseWorkspace);

            Telemetry.Client.Get().TrackEvent("App.EditorOpenConfigured");

            javaPkgServer.Send(javaEditor, ProtocolHandlers.CreateOpenTypeRootRequest(fileName)).ContinueWith((System.Threading.Tasks.Task <Protocol.Response> responseTask) =>
            {
                var openTypeResponse = responseTask.Result;

                if (openTypeResponse.responseType == Protocol.Response.ResponseType.OpenTypeRoot &&
                    openTypeResponse.openTypeRootResponse != null)
                {
                    javaEditor.TypeRootIdentifier = openTypeResponse.openTypeRootResponse.typeRootIdentifier;
                }
            });

            TextView.Properties.RemoveProperty(typeof(ServerProxy));
            TextView.Properties.AddProperty(typeof(ServerProxy), javaPkgServer);

            TextView.Properties.RemoveProperty(typeof(JavaEditor));
            TextView.Properties.AddProperty(typeof(JavaEditor), javaEditor);

            foreach (var buffer in SubjectBuffers)
            {
                buffer.Properties.RemoveProperty(typeof(JavaUnconfiguredEditor));
                buffer.Properties.RemoveProperty(typeof(ServerProxy));
                buffer.Properties.AddProperty(typeof(ServerProxy), javaPkgServer);
                buffer.Properties.RemoveProperty(typeof(JavaEditor));
                buffer.Properties.AddProperty(typeof(JavaEditor), javaEditor);

                JavaOutline outline = null;
                if (buffer.Properties.TryGetProperty <JavaOutline>(typeof(JavaOutline), out outline))
                {
                    outline.JavaEditor = javaEditor;
                }

                JavaSquiggles squiggles = null;
                if (buffer.Properties.TryGetProperty <JavaSquiggles>(typeof(JavaSquiggles), out squiggles))
                {
                    squiggles.JavaEditor = javaEditor;
                }
            }
            return(javaPkgServer);
        }
Ejemplo n.º 2
0
        public JavaEditor(Collection<ITextBuffer> subjectBuffers, IWpfTextView textView, ServerProxy javaPkgServer, EclipseWorkspace eclipseWorkspace)
            : base(subjectBuffers, textView, eclipseWorkspace)
        {
            JavaPkgServer = javaPkgServer;
            OnIdleQueue = new Dictionary<object,Action>();
            IdleActions = new List<Action>(3);
            TypeRootIdentifier = null;
            ParserEnabled = true;

            JavaPkgServer.TerminatedAbnormally += JavaPkgServer_TerminatedAbnormally;
        }
        public JavaUnconfiguredEditor(Collection<ITextBuffer> subjectBuffers, IWpfTextView textView, ServerProxyManager mgr, EclipseWorkspace workspace)
            : base(subjectBuffers, textView, workspace)
        {
            this.JavaPkgServerManager = mgr;

            if (workspace == null)
                Telemetry.Client.Get().TrackEvent("App.EditorOpenUnconfigured.EclipseNotFound");
            else
                Telemetry.Client.Get().TrackEvent("App.EditorOpenUnconfigured.WorkspaceNotFound");

            if (Helpers.VSHelpers.IsBuildInProgress())
            {
                BuildTicker = new Timer();
                BuildTicker.Interval = 1000;
                BuildTicker.Elapsed += BuildTicker_Elapsed;
                BuildTicker.Enabled = true;
            }
        }
Ejemplo n.º 4
0
        public static JavaUnconfiguredEditor Unconfigure(IWpfTextView textView, Collection <ITextBuffer> subjectBuffers)
        {
            var oldEditor = Disconnect(textView, subjectBuffers);

            string                 fileName               = VSHelpers.GetFileName(textView);
            EclipseWorkspace       eclipseWorkspace       = EclipseWorkspace.FromFilePath(fileName);
            JavaUnconfiguredEditor javaUnconfiguredEditor = null;

            javaUnconfiguredEditor = textView.Properties.GetOrCreateSingletonProperty <JavaUnconfiguredEditor>(() => new JavaUnconfiguredEditor(subjectBuffers, textView, JavaPkgServerMgr, eclipseWorkspace));
            Telemetry.Client.Get().TrackEvent("App.EditorOpenUnconfigured");

            if (oldEditor != null)
            {
                oldEditor.Fire_EditorReplaced(javaUnconfiguredEditor);
            }

            foreach (var buffer in subjectBuffers)
            {
                buffer.Properties.AddProperty(typeof(JavaUnconfiguredEditor), javaUnconfiguredEditor);
            }

            return(javaUnconfiguredEditor);
        }
Ejemplo n.º 5
0
        public JavaEditor(Collection <ITextBuffer> subjectBuffers, IWpfTextView textView, ServerProxy javaPkgServer, EclipseWorkspace eclipseWorkspace)
            : base(subjectBuffers, textView, eclipseWorkspace)
        {
            JavaPkgServer      = javaPkgServer;
            OnIdleQueue        = new Dictionary <object, Action>();
            IdleActions        = new List <Action>(3);
            TypeRootIdentifier = null;
            ParserEnabled      = true;

            JavaPkgServer.TerminatedAbnormally += JavaPkgServer_TerminatedAbnormally;
        }
Ejemplo n.º 6
0
        public JavaUnconfiguredEditor(Collection <ITextBuffer> subjectBuffers, IWpfTextView textView, ServerProxyManager mgr, EclipseWorkspace workspace)
            : base(subjectBuffers, textView, workspace)
        {
            this.JavaPkgServerManager = mgr;

            if (workspace == null)
            {
                Telemetry.Client.Get().TrackEvent("App.EditorOpenUnconfigured.EclipseNotFound");
            }
            else
            {
                Telemetry.Client.Get().TrackEvent("App.EditorOpenUnconfigured.WorkspaceNotFound");
            }

            if (Helpers.VSHelpers.IsBuildInProgress())
            {
                BuildTicker          = new Timer();
                BuildTicker.Interval = 1000;
                BuildTicker.Elapsed += BuildTicker_Elapsed;
                BuildTicker.Enabled  = true;
            }
        }
Ejemplo n.º 7
0
 public JavaEditorBase(Collection <ITextBuffer> subjectBuffers, IWpfTextView textView, EclipseWorkspace workspace)
 {
     this.SubjectBuffers   = subjectBuffers;
     this.TextView         = textView;
     this.EclipseWorkspace = workspace;
 }
Ejemplo n.º 8
0
        public static JavaEditor Configure(IWpfTextView textView, Collection <ITextBuffer> subjectBuffers)
        {
            var oldEditor = Disconnect(textView, subjectBuffers);

            EclipseWorkspace eclipseWorkspace = null;

            Protocol.TypeRootIdentifier presetTypeRootIdentifier = null;

            string fileName = VSHelpers.GetFileName(textView);

            if (DefinitionCache.ContainsKey(fileName))
            {
                eclipseWorkspace         = DefinitionCache[fileName].Item1;
                presetTypeRootIdentifier = DefinitionCache[fileName].Item2;
                DefinitionCache.Remove(fileName);
            }
            else if (File.Exists(fileName + ".id"))
            {
                string[] info = File.ReadAllLines(fileName + ".id");
                if (info.Length >= 2)
                {
                    eclipseWorkspace                = EclipseWorkspace.FromRootPath(info[0]);
                    presetTypeRootIdentifier        = new Protocol.TypeRootIdentifier();
                    presetTypeRootIdentifier.handle = info[1];
                }
            }
            else
            {
                eclipseWorkspace = EclipseWorkspace.FromFilePath(fileName);
            }

            var        javaPkgServer = JavaPkgServerMgr.GetProxy(eclipseWorkspace);
            JavaEditor javaEditor    = null;

            if (javaPkgServer != null)
            {
                textView.Properties.AddProperty(typeof(ServerProxy), javaPkgServer);

                javaEditor = textView.Properties.GetOrCreateSingletonProperty <JavaEditor>(() => new JavaEditor(subjectBuffers, textView, javaPkgServer, eclipseWorkspace));
                Telemetry.Client.Get().TrackEvent("App.EditorOpenConfigured");

                if (presetTypeRootIdentifier == null)
                {
                    javaPkgServer.Send(javaEditor, ProtocolHandlers.CreateOpenTypeRootRequest(fileName)).ContinueWith((System.Threading.Tasks.Task <Protocol.Response> responseTask) =>
                    {
                        var openTypeResponse = responseTask.Result;

                        if (openTypeResponse.responseType == Protocol.Response.ResponseType.OpenTypeRoot &&
                            openTypeResponse.openTypeRootResponse != null)
                        {
                            javaEditor.TypeRootIdentifier = openTypeResponse.openTypeRootResponse.typeRootIdentifier;
                        }
                    });
                }
                else if (File.Exists(fileName + ".id"))
                {
                    // Reopening a .class file from the cache
                    javaPkgServer.Send(javaEditor, ProtocolHandlers.CreataAddTypeRootRequest(presetTypeRootIdentifier)).ContinueWith((System.Threading.Tasks.Task <Protocol.Response> responseTask) =>
                    {
                        var addTypeResponse = responseTask.Result;

                        if (addTypeResponse.responseType == Protocol.Response.ResponseType.AddTypeRoot &&
                            addTypeResponse.addTypeRootResponse != null)
                        {
                            javaEditor.TypeRootIdentifier = addTypeResponse.addTypeRootResponse.typeRootIdentifier;
                        }
                    });
                    javaEditor.DisableParsing(); // No need to parse .class files from .jar for squiggles
                }
                else
                {
                    // Usually preset when opening a source file from a .jar via gotodef
                    javaEditor.TypeRootIdentifier = presetTypeRootIdentifier;
                    javaEditor.DisableParsing(); // No need to parse .class files from .jar for squiggles
                }
            }
            else
            {
                return(null);
            }

            if (oldEditor != null)
            {
                oldEditor.Fire_EditorReplaced(javaEditor);
            }

            foreach (var buffer in subjectBuffers)
            {
                buffer.Properties.AddProperty(typeof(ServerProxy), javaPkgServer);
                buffer.Properties.AddProperty(typeof(JavaEditor), javaEditor);

                JavaOutline outline = null;
                if (buffer.Properties.TryGetProperty <JavaOutline>(typeof(JavaOutline), out outline))
                {
                    outline.JavaEditor = javaEditor;
                }

                JavaSquiggles squiggles = null;
                if (buffer.Properties.TryGetProperty <JavaSquiggles>(typeof(JavaSquiggles), out squiggles))
                {
                    squiggles.JavaEditor = javaEditor;
                }
            }
            return(javaEditor);
        }
Ejemplo n.º 9
0
 public JavaEditorBase(Collection<ITextBuffer> subjectBuffers, IWpfTextView textView, EclipseWorkspace workspace)
 {
     this.SubjectBuffers = subjectBuffers;
     this.TextView = textView;
     this.EclipseWorkspace = workspace;
 }