private void ParseProjects(ParserOptions parserOptions) { var projects = parserOptions.CodeSolution.Projects.ToList(); for (int i = 0; i < projects.Count; i++) { var project = projects[i]; ExecuteOnStepMessage(string.Format(_parserStrings.CompilingAndParsing, project.Name)); ExecuteOnStepProgress((int)((double)i / projects.Count * 50)); var projectCompilation = project.GetCompilationAsync().Result; var targetFx = _targetFxParser.GetTargetFx(project.FilePath); var sdRepository = parserOptions.SDSolution.GetExistingOrNew(targetFx); parserOptions.SDRepository = sdRepository; var nparser = new NamespaceParser(parserOptions); nparser.ParseProjectNamespacesRecursively(projectCompilation.Assembly.GlobalNamespace); if (!_seeTokens.ContainsKey(targetFx)) { _seeTokens.Add(targetFx, new List <SDToken>()); } _seeTokens[targetFx].AddRange(parserOptions.SeeTokens); } ExecuteOnStepProgress(40); }
public void Initialize() { _tokenizer = new Tokenizer(); _parser = new NamespaceParser(new List <string>() { "ns" }); }
private void ParseNamespaces(CSharpProject project, SDRepository sdRepository, ICoreConfigSection sharpDoxConfig, Dictionary <string, string> tokens) { var namespaceParser = new NamespaceParser(sdRepository, sharpDoxConfig, sharpDoxConfig.InputFile, tokens); namespaceParser.OnDocLanguageFound += ExecuteOnDocLanguageFound; namespaceParser.OnItemParseStart += (n) => { PostParseMessage(_parserStrings.ParsingNamespace + ": " + n); }; namespaceParser.ParseProjectNamespaces(project); }
private void ParseNamespaces() { var pi = 0; var namespaceParser = new NamespaceParser(_repository, _excludedIdentifiers, _coreConfigSection); namespaceParser.OnItemParseStart += (n, i, t) => { PostProgress(_sdBuildStrings.ParsingNamespace + ": " + n, i, t, pi, _solution.Projects.Count); }; for (int i = 0; i < _solution.Projects.Count; i++) { pi = i; namespaceParser.ParseProjectNamespaces(_solution.Projects[i]); } }
private List <MenuCommand> CreateMenuCommands(Process replProcess, TextBox interactiveText, Entity <ReplState> replEntity) { var dte = (DTE2)_serviceProvider.GetService(typeof(DTE)); var loadSelectedFilesIntoRepl = new LoadFilesIntoRepl( new ReplWriter(replProcess, new TextBoxWriter(interactiveText, replEntity)), new SelectedFilesProvider(dte.ToolWindows.SolutionExplorer), ReplToolWindow); var loadSelectedProjectIntoRepl = new LoadFilesIntoRepl( new ReplWriter(replProcess, new TextBoxWriter(interactiveText, replEntity)), new ProjectFilesProvider( new SelectedProjectProvider(dte.Solution, dte.ToolWindows.SolutionExplorer)), ReplToolWindow); var loadActiveFileIntoRepl = new LoadFilesIntoRepl( new ReplWriter(replProcess, new TextBoxWriter(interactiveText, replEntity)), new ActiveFileProvider(dte), ReplToolWindow); var componentModel = (IComponentModel)_serviceProvider.GetService(typeof(SComponentModel)); var namespaceParser = new NamespaceParser(NamespaceParser.NamespaceSymbols); var activeTextBufferStateProvider = new ActiveTextBufferStateProvider( componentModel.GetService <IVsEditorAdaptersFactoryService>(), (IVsTextManager)_serviceProvider.GetService(typeof(SVsTextManager))); var changeReplNamespace = new ChangeReplNamespace(new ReplWriter(replProcess, new TextBoxWriter(interactiveText, replEntity))); var menuCommands = new List <MenuCommand>(); menuCommands.Add(new MenuCommand((sender, args) => loadSelectedProjectIntoRepl.Execute(), CommandIDs.LoadProjectIntoActiveRepl)); menuCommands.Add(new MenuCommand((sender, args) => loadSelectedFilesIntoRepl.Execute(), CommandIDs.LoadFileIntoActiveRepl)); menuCommands.Add(new MenuCommand((sender, args) => loadActiveFileIntoRepl.Execute(), CommandIDs.LoadActiveDocumentIntoRepl)); menuCommands.Add(new MenuCommand((sender, args) => changeReplNamespace.Execute(namespaceParser.Execute(activeTextBufferStateProvider.Get())), CommandIDs.SwitchReplNamespaceToActiveDocument)); menuCommands.Add(new MenuCommand((sender, args) => new ReplWriter(replProcess, new TextBoxWriter(interactiveText, replEntity)).WriteBehindTheSceneExpressionToRepl((string)(dte.ActiveDocument.Selection as dynamic).Text), CommandIDs.LoadSelectedTextIntoRepl)); return(menuCommands); }
private void ParseProjects(ParserOptions parserOptions) { var projects = parserOptions.CodeSolution.Projects.ToList(); for (int i = 0; i < projects.Count; i++) { var project = projects[i]; ExecuteOnStepMessage(string.Format(_parserStrings.CompilingAndParsing, project.Name)); ExecuteOnStepProgress((int)((double)i / projects.Count * 50)); var projectCompilation = project.GetCompilationAsync().Result; var targetFx = _targetFxParser.GetTargetFx(project.FilePath); var sdRepository = parserOptions.SDSolution.GetExistingOrNew(targetFx); parserOptions.SDRepository = sdRepository; var nparser = new NamespaceParser(parserOptions); nparser.ParseProjectNamespacesRecursively(projectCompilation.Assembly.GlobalNamespace); if (!_seeTokens.ContainsKey(targetFx)) { _seeTokens.Add(targetFx, new List<SDToken>()); } _seeTokens[targetFx].AddRange(parserOptions.SeeTokens); } ExecuteOnStepProgress(40); }
public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets) { if (_metadata == null) { return; } var caretPosition = session.TextView.Caret.Position.BufferPosition.Position; var tokenTriggeringIntellisense = _tokenizedBuffer.CurrentState.FindTokenAtIndex(caretPosition); if (caretPosition == tokenTriggeringIntellisense.IndexToken.StartIndex) { tokenTriggeringIntellisense = tokenTriggeringIntellisense.Previous(); } var numberOfCharactersBeforeCursor = caretPosition - tokenTriggeringIntellisense.IndexToken.StartIndex; var textFromSymbolBeforeCursor = tokenTriggeringIntellisense.IndexToken.Token.Text.Substring(0, numberOfCharactersBeforeCursor); if (string.IsNullOrWhiteSpace(textFromSymbolBeforeCursor)) { return; } var completions = new List <Completion>(); //todo: convert current file being edited to constantly try to compile in background thread & update metadatacache (allowing Clojure commands to present intellisense for file being edited) //todo: add context sensitivity to filter for functions/variables depending on 1st argument to list or not & whether list is quoted or list starts with .. or -> NamespaceParser namespaceParser = new NamespaceParser(NamespaceParser.NamespaceSymbols); string namespaceOfFile = ""; try { namespaceOfFile = namespaceParser.Execute(_tokenizedBuffer.CurrentState); } catch { } var currentIndexToken = _tokenizedBuffer.CurrentState.FindTokenAtIndex(0); while (currentIndexToken != null) { if (currentIndexToken.IndexToken.StartIndex != tokenTriggeringIntellisense.IndexToken.StartIndex) { if (currentIndexToken.Node.Value.Type == TokenType.Symbol && currentIndexToken.Node.Value.Text.StartsWith(textFromSymbolBeforeCursor)) { if (completions.Find(c => c.DisplayText == currentIndexToken.Node.Value.Text) == null) { completions.Add(new Completion(currentIndexToken.Node.Value.Text)); } } } currentIndexToken = currentIndexToken.Next(); } completions.AddRange(_metadata.LoadCoreCompletionsMatchingString(textFromSymbolBeforeCursor)); //todo: load assemblies in separate appDomain List <Reference> references = GetAllProjectReferences(); List <Assembly> referencedAssemblies = references.Select(x => Assembly.LoadFrom(x.Path)).ToList(); completions.AddRange(referencedAssemblies.SelectMany(x => _metadata.LoadCompletionsInAssemblyMatchingString(x, textFromSymbolBeforeCursor))); //completions.AddRange(_metadata.LoadCompletionsInCljFileMatchingString(, textFromSymbolBeforeCursor)); var snapshot = session.TextView.TextSnapshot; var start = new SnapshotPoint(snapshot, tokenTriggeringIntellisense.IndexToken.StartIndex); var end = new SnapshotPoint(snapshot, start.Position + tokenTriggeringIntellisense.IndexToken.Token.Text.Length); var applicableTo = snapshot.CreateTrackingSpan(new SnapshotSpan(start, end), SpanTrackingMode.EdgeInclusive); completionSets.Add(new CompletionSet("All", "All", applicableTo, completions, new List <Completion>())); }