예제 #1
0
        public async System.Threading.Tasks.Task CollectSignatureLists(ISignatureHelpSession newSession)
        {
            JavaEditor javaEditor = null;

            if (TextBuffer.Properties.TryGetProperty <JavaEditor>(typeof(JavaEditor), out javaEditor) &&
                javaEditor.TypeRootIdentifier != null)
            {
                var textReader       = new TextSnapshotToTextReader(TextBuffer.CurrentSnapshot) as TextReader;
                var position         = newSession.GetTriggerPoint(TextBuffer).GetPosition(TextBuffer.CurrentSnapshot);
                var paramHelpRequest = ProtocolHandlers.CreateParamHelpRequest(
                    textReader,
                    javaEditor.TypeRootIdentifier,
                    position);
                var paramHelpResponse = await javaEditor.JavaPkgServer.Send(javaEditor, paramHelpRequest);

                if (paramHelpResponse.responseType == Protocol.Response.ResponseType.ParamHelp &&
                    paramHelpResponse.paramHelpResponse != null)
                {
                    if (paramHelpResponse.paramHelpResponse.status && paramHelpResponse.paramHelpResponse.signatures.Count != 0)
                    {
                        var applicableTo           = TextBuffer.CurrentSnapshot.CreateTrackingSpan(new Span(paramHelpResponse.paramHelpResponse.scopeStart, paramHelpResponse.paramHelpResponse.scopeLength), SpanTrackingMode.EdgeInclusive, 0);
                        int selectedParameterIndex = paramHelpResponse.paramHelpResponse.paramCount;
                        Signatures = TransformSignatures(TextBuffer, paramHelpResponse.paramHelpResponse.signatures, applicableTo, selectedParameterIndex);
                    }
                }
            }
        }
예제 #2
0
        public async System.Threading.Tasks.Task CollectSignatureLists(ISignatureHelpSession newSession)
        {
            JavaEditor javaEditor = null;
            if (TextBuffer.Properties.TryGetProperty<JavaEditor>(typeof(JavaEditor), out javaEditor) &&
                javaEditor.TypeRootIdentifier != null)
            {
                var textReader = new TextSnapshotToTextReader(TextBuffer.CurrentSnapshot) as TextReader;
                var position = newSession.GetTriggerPoint(TextBuffer).GetPosition(TextBuffer.CurrentSnapshot);
                var paramHelpRequest = ProtocolHandlers.CreateParamHelpRequest(
                    textReader,
                    javaEditor.TypeRootIdentifier,
                    position);
                var paramHelpResponse = await javaEditor.JavaPkgServer.Send(javaEditor, paramHelpRequest);

                if (paramHelpResponse.responseType == Protocol.Response.ResponseType.ParamHelp &&
                    paramHelpResponse.paramHelpResponse != null)
                {
                    if (paramHelpResponse.paramHelpResponse.status && paramHelpResponse.paramHelpResponse.signatures.Count != 0)
                    {
                        var applicableTo = TextBuffer.CurrentSnapshot.CreateTrackingSpan(new Span(paramHelpResponse.paramHelpResponse.scopeStart, paramHelpResponse.paramHelpResponse.scopeLength), SpanTrackingMode.EdgeInclusive, 0);
                        int selectedParameterIndex = paramHelpResponse.paramHelpResponse.paramCount;
                        Signatures = TransformSignatures(TextBuffer, paramHelpResponse.paramHelpResponse.signatures, applicableTo, selectedParameterIndex); 
                    }
                }
            }
        }
예제 #3
0
        public async System.Threading.Tasks.Task CollectCompletionSets(ICompletionSession newSession)
        {
            JavaEditor javaEditor = null;
            if (TextBuffer.Properties.TryGetProperty<JavaEditor>(typeof(JavaEditor), out javaEditor) &&
                javaEditor.TypeRootIdentifier != null)
            {
                var textReader = new TextSnapshotToTextReader(TextBuffer.CurrentSnapshot) as TextReader;
                var autocompleteRequest = ProtocolHandlers.CreateAutocompleteRequest(
                        textReader, 
                        javaEditor.TypeRootIdentifier, 
                        newSession.GetTriggerPoint(TextBuffer).GetPosition(TextBuffer.CurrentSnapshot));
                var autocompleteResponse = await javaEditor.JavaPkgServer.Send(javaEditor, autocompleteRequest);

                if (autocompleteResponse.responseType == Protocol.Response.ResponseType.Autocomplete && 
                    autocompleteResponse.autocompleteResponse != null)
                {
                    if (autocompleteResponse.autocompleteResponse.status && autocompleteResponse.autocompleteResponse.proposals.Count != 0)
                    {
                        CompletionSetList = new List<CompletionSet>();
                        var list = TransformCompletions(TextBuffer.CurrentSnapshot, autocompleteResponse.autocompleteResponse.proposals);
                        CompletionSetList.Add(new CompletionSet("Autocomplete", "Autocomplete", GetReplacementSpanFromCompletions(TextBuffer.CurrentSnapshot, autocompleteResponse.autocompleteResponse.proposals.First()), list, null)); // FindTokenSpanAtPosition(newSession.GetTriggerPoint(TextBuffer), newSession), list, null));
                    }
                }
            }
        }
예제 #4
0
        public async System.Threading.Tasks.Task CollectCompletionSets(ICompletionSession newSession)
        {
            JavaEditor javaEditor = null;

            if (TextBuffer.Properties.TryGetProperty <JavaEditor>(typeof(JavaEditor), out javaEditor) &&
                javaEditor.TypeRootIdentifier != null)
            {
                var textReader          = new TextSnapshotToTextReader(TextBuffer.CurrentSnapshot) as TextReader;
                var autocompleteRequest = ProtocolHandlers.CreateAutocompleteRequest(
                    textReader,
                    javaEditor.TypeRootIdentifier,
                    newSession.GetTriggerPoint(TextBuffer).GetPosition(TextBuffer.CurrentSnapshot));
                var autocompleteResponse = await javaEditor.JavaPkgServer.Send(javaEditor, autocompleteRequest);

                if (autocompleteResponse.responseType == Protocol.Response.ResponseType.Autocomplete &&
                    autocompleteResponse.autocompleteResponse != null)
                {
                    if (autocompleteResponse.autocompleteResponse.status && autocompleteResponse.autocompleteResponse.proposals.Count != 0)
                    {
                        CompletionSetList = new List <CompletionSet>();
                        var list = TransformCompletions(TextBuffer.CurrentSnapshot, autocompleteResponse.autocompleteResponse.proposals);
                        CompletionSetList.Add(new CompletionSet("Autocomplete", "Autocomplete", GetReplacementSpanFromCompletions(TextBuffer.CurrentSnapshot, autocompleteResponse.autocompleteResponse.proposals.First()), list, null)); // FindTokenSpanAtPosition(newSession.GetTriggerPoint(TextBuffer), newSession), list, null));
                    }
                }
            }
        }
예제 #5
0
        public async Task ParseAsync()
        {
            FileParseResponse = null;
            TokenSource       = new CancellationTokenSource();
            var token      = TokenSource.Token;
            var textReader = new TextSnapshotToTextReader(TextSnapshot) as TextReader;

            await Task.Run(async() =>
            {
                // Trottle down parsing; wait another 200ms
                Thread.Sleep(TimeSpan.FromMilliseconds(200));
                if (token.IsCancellationRequested)
                {
                    return;
                }

                Trace.WriteLine("[@@ Java parser] getting ready to parse");
                var astRequest  = ProtocolHandlers.CreateFileParseRequest(textReader, VSHelpers.GetFileName(Parent.TextView));
                var astResponse = await Parent.JavaPkgServer.Send(Parent, astRequest);
                if (astResponse.responseType == Protocol.Response.ResponseType.FileParseStatus && astResponse.fileParseResponse != null)
                {
                    Trace.WriteLine(String.Format("Response from server: {0} {1}",
                                                  astResponse.fileParseResponse.status.ToString(),
                                                  string.IsNullOrEmpty(astResponse.fileParseResponse.errorMessage) ? astResponse.fileParseResponse.errorMessage : astResponse.fileParseResponse.fileIdentifier.ToString()));

                    if (astResponse.fileParseResponse.status)
                    {
                        // We have a successful parse; now we keep going asking questions about the AST
                        FileParseResponse = astResponse.fileParseResponse;

                        // Squiggles
                        var messagesRequest  = ProtocolHandlers.CreateFileParseMessagesRequest(astResponse.fileParseResponse.fileIdentifier);
                        var messagesResponse = await Parent.JavaPkgServer.Send(Parent, messagesRequest);
                        if (messagesResponse.responseType == Protocol.Response.ResponseType.FileParseMessages && messagesResponse.fileParseMessagesResponse != null)
                        {
                            Parent.Fire_FileParseMessagesAvailable(this, messagesResponse.fileParseMessagesResponse);
                        }

                        // Outline
                        var outlineRequest  = ProtocolHandlers.CreateOutlineFileRequest(astResponse.fileParseResponse.fileIdentifier);
                        var outlineResponse = await Parent.JavaPkgServer.Send(Parent, outlineRequest);
                        if (outlineResponse.responseType == Protocol.Response.ResponseType.OutlineResults && outlineResponse.outlineResultResponse != null)
                        {
                            Parent.Fire_OutlineResponseAvailable(this, outlineResponse.outlineResultResponse);
                        }

                        // We leave the AST in the cache in order to service any QuickInfo operations
                    }
                }
            }, token);
        }
        public void Parse()
        {
            if (this.TextView != null)
            {
                using (TextSnapshotToTextReader reader = new TextSnapshotToTextReader(this.TextView.TextBuffer.CurrentSnapshot))
                {
                    this.parser.Parse(reader);
                }
            }
            ////else
            ////{
            ////    frontend.Parse(this.Path);
            ////}

            this.NeedsCompilation = false;
        }
예제 #7
0
        public void Parse(FrontendCompiler frontend)
        {
            if (this.TextView != null)
            {
                using (TextSnapshotToTextReader reader = new TextSnapshotToTextReader(this.TextView.TextBuffer.CurrentSnapshot))
                {
                    frontend.Parse(reader, this.Path);
                }
            }
            else
            {
                frontend.Parse(this.Path);
            }

            this.NeedsCompilation = false;
        }
예제 #8
0
        public async Task ParseAsync()
        {
            FileParseResponse = null;
            TokenSource = new CancellationTokenSource();
            var token = TokenSource.Token;
            var textReader = new TextSnapshotToTextReader(TextSnapshot) as TextReader;

            await Task.Run(async () =>
            {
                // Trottle down parsing; wait another 200ms
                Thread.Sleep(TimeSpan.FromMilliseconds(200));
                if (token.IsCancellationRequested)
                    return;

                Trace.WriteLine("[@@ Java parser] getting ready to parse");
                var astRequest = ProtocolHandlers.CreateFileParseRequest(textReader, VSHelpers.GetFileName(Parent.TextView));
                var astResponse = await Parent.JavaPkgServer.Send(Parent, astRequest);
                if (astResponse.responseType == Protocol.Response.ResponseType.FileParseStatus && astResponse.fileParseResponse != null)
                {
                    Trace.WriteLine(String.Format("Response from server: {0} {1}",
                        astResponse.fileParseResponse.status.ToString(),
                        string.IsNullOrEmpty(astResponse.fileParseResponse.errorMessage) ? astResponse.fileParseResponse.errorMessage : astResponse.fileParseResponse.fileIdentifier.ToString()));

                    if (astResponse.fileParseResponse.status)
                    {
                        // We have a successful parse; now we keep going asking questions about the AST
                        FileParseResponse = astResponse.fileParseResponse;

                        // Squiggles
                        var messagesRequest = ProtocolHandlers.CreateFileParseMessagesRequest(astResponse.fileParseResponse.fileIdentifier);
                        var messagesResponse = await Parent.JavaPkgServer.Send(Parent, messagesRequest);
                        if (messagesResponse.responseType == Protocol.Response.ResponseType.FileParseMessages && messagesResponse.fileParseMessagesResponse != null)
                            Parent.Fire_FileParseMessagesAvailable(this, messagesResponse.fileParseMessagesResponse);

                        // Outline
                        var outlineRequest = ProtocolHandlers.CreateOutlineFileRequest(astResponse.fileParseResponse.fileIdentifier);
                        var outlineResponse = await Parent.JavaPkgServer.Send(Parent, outlineRequest);
                        if (outlineResponse.responseType == Protocol.Response.ResponseType.OutlineResults && outlineResponse.outlineResultResponse != null)
                            Parent.Fire_OutlineResponseAvailable(this, outlineResponse.outlineResultResponse);

                        // We leave the AST in the cache in order to service any QuickInfo operations
                    }
                }
            }, token);
        }
예제 #9
0
        private void BuildObjectTree()
        {
            using (TextSnapshotToTextReader snapshotReader = new TextSnapshotToTextReader(this.snapshot))
            {
                switch (this.language)
                {
                case ParserLanguage.Rtype:
                    var rtype = new RtypeParser(null);
                    this.statementNodeRoot = rtype.Parse(snapshotReader);
                    break;

                case ParserLanguage.Xml:
                    var xml = new XmlParser(null);
                    this.statementNodeRoot = xml.Parse(snapshotReader);
                    break;

                default:
                    break;
                }
            }
        }
예제 #10
0
        internal async Task RequestQuickInfo(ITextView textView, ITrackingPoint triggerPoint)
        {
            JavaEditor javaEditor = null;

            if (TextBuffer.Properties.TryGetProperty <JavaEditor>(typeof(JavaEditor), out javaEditor) &&
                javaEditor.TypeRootIdentifier != null)
            {
                var textReader        = new TextSnapshotToTextReader(TextBuffer.CurrentSnapshot) as TextReader;
                var position          = triggerPoint.GetPosition(TextBuffer.CurrentSnapshot);
                var quickInfoRequest  = ProtocolHandlers.CreateQuickInfoRequest(textReader, javaEditor.TypeRootIdentifier, position);
                var quickInfoResponse = await javaEditor.JavaPkgServer.Send(javaEditor, quickInfoRequest);

                if (quickInfoResponse.responseType == Protocol.Response.ResponseType.QuickInfo &&
                    quickInfoResponse.quickInfoResponse != null)
                {
                    foreach (var element in quickInfoResponse.quickInfoResponse.elements)
                    {
                        QuickInfoContent.Add(element.definition); // TODO: Better javadoc rendering + "\n\n" + element.javaDoc;
                    }
                }
            }
        }
예제 #11
0
        public async Task Run(IVsEditorAdaptersFactoryService editorFactory)
        {
            JavaEditor javaEditor = null;
            if (TextView.Properties.TryGetProperty<JavaEditor>(typeof(JavaEditor), out javaEditor) &&
                javaEditor.TypeRootIdentifier != null)
            {
                var textReader = new TextSnapshotToTextReader(TextView.TextBuffer.CurrentSnapshot) as TextReader;
                var position = CaretPoint.Position;
                var findDefinitionRequest = ProtocolHandlers.CreateFindDefinitionRequest(textReader, javaEditor.TypeRootIdentifier, position);
                var findDefinitionResponse = await javaEditor.JavaPkgServer.Send(javaEditor, findDefinitionRequest);

                if (findDefinitionResponse.responseType == Protocol.Response.ResponseType.FindDefinition && findDefinitionResponse.findDefinitionResponse != null)
                {
                    var elements = findDefinitionResponse.findDefinitionResponse.elements;
                    StringBuilder sb = new StringBuilder();
                    foreach(var element in elements)
                    {
                        if (element.hasSource && element.filePath.EndsWith(".java"))
                        {
                            Telemetry.Client.Get().TrackEvent("App.OpenSourceFile");

                            string fullPath = element.filePath; // (findDefinitionResponse.findDefinitionResponse.workspaceRootPath + element.filePath).Replace('/', '\\');
                            var window = VSHelpers.OpenDocument(fullPath, null);
                            var textView = VSHelpers.GetWpfTextView(VSHelpers.GetTextView(window));

                            textView.Caret.MoveTo(new SnapshotPoint(textView.TextBuffer.CurrentSnapshot, element.positionStart));
                            textView.Selection.Select(new SnapshotSpan(textView.TextBuffer.CurrentSnapshot, element.positionStart, element.positionLength), false);
                            textView.Caret.EnsureVisible();
                        }
                        else if (element.hasSource && element.filePath.EndsWith(".jar"))
                        {
                            Telemetry.Client.Get().TrackEvent("App.OpenSourceFileFromJar");

                            string folderName = Path.GetTempPath() + ".javacache" + Path.DirectorySeparatorChar + Path.GetFileName(element.filePath);
                            string fileName = folderName + Path.DirectorySeparatorChar + element.fileName;

                            // Check first if window is already opened
                            var window = VSHelpers.IsDocumentOpened(fileName);
                            if (window != null)
                            {
                                // Bring to front  
                                window.Show();
                            }
                            else
                            {
                                // If no editor is opened, create (or recreate) the temp file
                                string contents = element.fileContents;

                                Directory.CreateDirectory(folderName);
                                using (StreamWriter sw = new StreamWriter(fileName))
                                    sw.Write(element.fileContents);

                                JavaEditorFactory.DefinitionCache[fileName] =
                                    new Tuple<EclipseWorkspace, Protocol.TypeRootIdentifier>(javaEditor.EclipseWorkspace, element.typeRootIdentifier);

                                // Write info to be able to reconnect temp file to ISense services on reload
                                using (StreamWriter sw = new StreamWriter(fileName + ".id"))
                                {
                                    sw.WriteLine(javaEditor.EclipseWorkspace.Name);
                                    sw.WriteLine(element.typeRootIdentifier.handle);
                                }

                                // Open in editor as a readonly file
                                window = VSHelpers.OpenDocument(fileName, null);
                            }

                            var textView = VSHelpers.GetWpfTextView(VSHelpers.GetTextView(window));
                            var vsTextBuffer = VSHelpers.GetTextBuffer(editorFactory, textView.TextBuffer);
                            VSHelpers.MakeEditorReadOnly(vsTextBuffer, true);                            

                            textView.Caret.MoveTo(new SnapshotPoint(textView.TextBuffer.CurrentSnapshot, element.positionStart));
                            textView.Selection.Select(new SnapshotSpan(textView.TextBuffer.CurrentSnapshot, element.positionStart, element.positionLength), false);
                            textView.Caret.EnsureVisible();
                        }
                        else
                        {
                            // TODO: Prompt user to map source file to class file
                            // TODO: Show disasembly if no mapping
                            MessageBox.Show("Cannot navigate to symbol " + element.definition + ". Source not available.", "Source not found");
                            Telemetry.Client.Get().TrackEvent("App.OpenSourceFileNoSource");
                        }
                        break; // TODO: Handle ambiguous symbol resolution
                    }
                    if (elements.Count > 1)
                    {
                        Telemetry.Client.Get().TrackEvent("App.OpenSourceFileAmbiguousSymbol");
                    }
                }
            }
        }
예제 #12
0
        public async Task Run(IVsEditorAdaptersFactoryService editorFactory)
        {
            JavaEditor javaEditor = null;

            if (TextView.Properties.TryGetProperty <JavaEditor>(typeof(JavaEditor), out javaEditor) &&
                javaEditor.TypeRootIdentifier != null)
            {
                var textReader             = new TextSnapshotToTextReader(TextView.TextBuffer.CurrentSnapshot) as TextReader;
                var position               = CaretPoint.Position;
                var findDefinitionRequest  = ProtocolHandlers.CreateFindDefinitionRequest(textReader, javaEditor.TypeRootIdentifier, position);
                var findDefinitionResponse = await javaEditor.JavaPkgServer.Send(javaEditor, findDefinitionRequest);

                if (findDefinitionResponse.responseType == Protocol.Response.ResponseType.FindDefinition && findDefinitionResponse.findDefinitionResponse != null)
                {
                    var           elements = findDefinitionResponse.findDefinitionResponse.elements;
                    StringBuilder sb       = new StringBuilder();
                    foreach (var element in elements)
                    {
                        if (element.hasSource && element.filePath.EndsWith(".java"))
                        {
                            Telemetry.Client.Get().TrackEvent("App.OpenSourceFile");

                            string fullPath = element.filePath; // (findDefinitionResponse.findDefinitionResponse.workspaceRootPath + element.filePath).Replace('/', '\\');
                            var    window   = VSHelpers.OpenDocument(fullPath, null);
                            var    textView = VSHelpers.GetWpfTextView(VSHelpers.GetTextView(window));

                            textView.Caret.MoveTo(new SnapshotPoint(textView.TextBuffer.CurrentSnapshot, element.positionStart));
                            textView.Selection.Select(new SnapshotSpan(textView.TextBuffer.CurrentSnapshot, element.positionStart, element.positionLength), false);
                            textView.Caret.EnsureVisible();
                        }
                        else if (element.hasSource && element.filePath.EndsWith(".jar"))
                        {
                            Telemetry.Client.Get().TrackEvent("App.OpenSourceFileFromJar");

                            string folderName = Path.GetTempPath() + ".javacache" + Path.DirectorySeparatorChar + Path.GetFileName(element.filePath);
                            string fileName   = folderName + Path.DirectorySeparatorChar + element.fileName;

                            // Check first if window is already opened
                            var window = VSHelpers.IsDocumentOpened(fileName);
                            if (window != null)
                            {
                                // Bring to front
                                window.Show();
                            }
                            else
                            {
                                // If no editor is opened, create (or recreate) the temp file
                                string contents = element.fileContents;

                                Directory.CreateDirectory(folderName);
                                using (StreamWriter sw = new StreamWriter(fileName))
                                    sw.Write(element.fileContents);

                                JavaEditorFactory.DefinitionCache[fileName] =
                                    new Tuple <EclipseWorkspace, Protocol.TypeRootIdentifier>(javaEditor.EclipseWorkspace, element.typeRootIdentifier);

                                // Write info to be able to reconnect temp file to ISense services on reload
                                using (StreamWriter sw = new StreamWriter(fileName + ".id"))
                                {
                                    sw.WriteLine(javaEditor.EclipseWorkspace.Name);
                                    sw.WriteLine(element.typeRootIdentifier.handle);
                                }

                                // Open in editor as a readonly file
                                window = VSHelpers.OpenDocument(fileName, null);
                            }

                            var textView     = VSHelpers.GetWpfTextView(VSHelpers.GetTextView(window));
                            var vsTextBuffer = VSHelpers.GetTextBuffer(editorFactory, textView.TextBuffer);
                            VSHelpers.MakeEditorReadOnly(vsTextBuffer, true);

                            textView.Caret.MoveTo(new SnapshotPoint(textView.TextBuffer.CurrentSnapshot, element.positionStart));
                            textView.Selection.Select(new SnapshotSpan(textView.TextBuffer.CurrentSnapshot, element.positionStart, element.positionLength), false);
                            textView.Caret.EnsureVisible();
                        }
                        else
                        {
                            // TODO: Prompt user to map source file to class file
                            // TODO: Show disasembly if no mapping
                            MessageBox.Show("Cannot navigate to symbol " + element.definition + ". Source not available.", "Source not found");
                            Telemetry.Client.Get().TrackEvent("App.OpenSourceFileNoSource");
                        }
                        break; // TODO: Handle ambiguous symbol resolution
                    }
                    if (elements.Count > 1)
                    {
                        Telemetry.Client.Get().TrackEvent("App.OpenSourceFileAmbiguousSymbol");
                    }
                }
            }
        }
        void ReparseFile(object sender, EventArgs args)
        {
            ITextSnapshot snapshot = _buffer.CurrentSnapshot;
            var           spans    = new NormalizedSnapshotSpanCollection(new SnapshotSpan(snapshot, 0, snapshot.Length));

            _errorProvider.Tasks.Clear();

            brace_errors.Clear();
            syntax_error = null;

            var bracestack = new Stack <SnapshotSpanPair>();
            var bracelist  = new List <SnapshotSpanPair>();

            foreach (var tagSpan in this._aggregator.GetTags(spans))
            {
                var span = tagSpan.Span.GetSpans(spans[0].Snapshot)[0];

                switch (tagSpan.Tag.type)
                {
                case Tokens.error:
                {
                    var errtag = new ErrorTag(PredefinedErrorTypeNames.SyntaxError, tagSpan.Tag.ErrorMessage);
                    AddErrorTask(span, errtag);
                    break;
                }

                case Tokens.LBRACK:
                {
                    var tup = new Square {
                        Start = span
                    };
                    bracestack.Push(tup);
                    bracelist.Add(tup);
                    break;
                }

                case Tokens.LBRACE:
                case Tokens.VALUEVECTORLBRACE:
                case Tokens.VECTORLBRACE:
                {
                    var tup = new SnapshotSpanPair {
                        Start = span
                    };
                    bracestack.Push(tup);
                    bracelist.Add(tup);
                    break;
                }

                case Tokens.RBRACE:
                case Tokens.RBRACK:
                {
                    if (bracestack.Count > 0)
                    {
                        var tup = bracestack.Pop();
                        if ((tagSpan.Tag.type == Tokens.RBRACK && !(tup is Square)) || (tagSpan.Tag.type == Tokens.RBRACE && (tup is Square)))
                        {
                            var errtag = new ErrorTag(PredefinedErrorTypeNames.SyntaxError, "Missing opening parenthesis");
                            AddErrorTask(span, errtag);
                            brace_errors.Add(new TagSpan <ErrorTag>(span, errtag));
                        }
                        else
                        {
                            tup.End = span;
                        }
                    }
                    else
                    {
                        var errtag = new ErrorTag(PredefinedErrorTypeNames.SyntaxError, "Missing opening parenthesis");
                        AddErrorTask(span, errtag);
                        brace_errors.Add(new TagSpan <ErrorTag>(span, errtag));
                    }
                    break;
                }
                }
            }

            while (bracestack.Count > 0)
            {
                var bs     = bracestack.Pop();
                var errtag = new ErrorTag(PredefinedErrorTypeNames.SyntaxError, "Missing closing parenthesis");
                AddErrorTask(bs.Start, errtag);
                brace_errors.Add(new TagSpan <ErrorTag>(bs.Start, errtag));
            }

            _buffer.Properties[SnapshotSpanPair.BraceKey] = bracelist;

            if (_errorProvider.Tasks.Count == 0)
            {
                var port = new TextSnapshotToTextReader(snapshot);

                var prevbindings = _buffer.Properties["SchemeBindings"];

                try
                {
                    var result = "(read-file {0})".Eval(port);

                    if (result == null)
                    {
                        return;
                    }

                    var imports = "(read-imports {0})".Eval(result);
                    var env     = "(apply environment {0})".Eval(imports);

                    _buffer.Properties["SchemeEnvironment"] = env;

                    var b = "(environment-bindings {0})".Eval(env);

                    var bindings = ((Cons)b).ToDictionary(x => (((Cons)x).car).ToString(), GetBindingType);

                    _buffer.Properties["SchemeBindings"] = bindings;

                    var expanded = "(run-expansion {0})".Eval <MultipleValues>(result).ToArray(3);
                    var names    = expanded[0] as object[];
                    var types    = expanded[1] as object[];
                    var output   = expanded[2];

                    for (int i = 0; i < names.Length; i++)
                    {
                        if (names[i] is SymbolId)
                        {
                            var name = SymbolTable.IdToString((SymbolId)names[i]);
                            // ignore lst
                            int foo;
                            if (name == "using" || name == "dummy" || int.TryParse(name, out foo))
                            {
                                continue;
                            }
                            bindings[name] = GetBindingType2(types[i]) | BindingType.LocalMask;
                        }
                    }
                }
                catch (SchemeException ex)
                {
                    _buffer.Properties["SchemeBindings"] = prevbindings;
                    var cond    = ex.Condition;
                    var error   = "(get-error {0})".Eval <MultipleValues>(cond).ToArray(2);
                    var errtag  = new ErrorTag(PredefinedErrorTypeNames.CompilerError, error[0]);
                    var errspan = new SnapshotSpan(snapshot, 0, 0);
                    if (error[1] is string)
                    {
                        errspan      = MakeSnapshotSpan(snapshot, error[1] as string);
                        syntax_error = new TagSpan <ErrorTag>(errspan, errtag);
                    }
                    AddErrorTask(errspan, errtag);
                }

                var lines = _view.TextViewLines.ToArray();

                var start = lines[0].Start;
                var end   = lines[lines.Length - 1].End;

                var span = new SnapshotSpan(start, end);

                // notifiy classifier
                var classifier = _buffer.Properties[typeof(ITagger <IClassificationTag>)] as ClassificationTagger;
                classifier.RaiseTagsChanged(span);
            }

            if (TagsChanged != null)
            {
                TagsChanged(this, new SnapshotSpanEventArgs(new SnapshotSpan(snapshot, 0, snapshot.Length)));
            }
        }
예제 #14
0
        internal async Task RequestQuickInfo(ITextView textView, ITrackingPoint triggerPoint)
        {
            JavaEditor javaEditor = null;
            if (TextBuffer.Properties.TryGetProperty<JavaEditor>(typeof(JavaEditor), out javaEditor) &&
                javaEditor.TypeRootIdentifier != null)
            {
                var textReader = new TextSnapshotToTextReader(TextBuffer.CurrentSnapshot) as TextReader;
                var position = triggerPoint.GetPosition(TextBuffer.CurrentSnapshot);
                var quickInfoRequest = ProtocolHandlers.CreateQuickInfoRequest(textReader, javaEditor.TypeRootIdentifier, position);
                var quickInfoResponse = await javaEditor.JavaPkgServer.Send(javaEditor, quickInfoRequest);

                if (quickInfoResponse.responseType == Protocol.Response.ResponseType.QuickInfo &&
                    quickInfoResponse.quickInfoResponse != null)
                {
                    foreach(var element in quickInfoResponse.quickInfoResponse.elements)
                    {
                        QuickInfoContent.Add(element.definition); // TODO: Better javadoc rendering + "\n\n" + element.javaDoc;
                    }
                }
            }
        }