static void CreateDefaultProjectContentReferences() { IList <string> defaultReferences = AddInTree.BuildItems <string>("/SharpDevelop/Services/ParserService/SingleFileGacReferences", null, false); foreach (string defaultReference in defaultReferences) { ReferenceProjectItem item = new ReferenceProjectItem(null, defaultReference); defaultProjectContent.AddReferencedContent(ParserService.GetProjectContentForReference(item)); } if (WorkbenchSingleton.Workbench != null) { WorkbenchSingleton.Workbench.ActiveViewContentChanged += delegate { if (WorkbenchSingleton.Workbench.ActiveViewContent != null) { string file = WorkbenchSingleton.Workbench.ActiveViewContent.PrimaryFileName; if (file != null) { IParser parser = GetParser(file); if (parser != null && parser.Language != null) { defaultProjectContent.Language = parser.Language; defaultProjectContent.DefaultImports = parser.Language.CreateDefaultImports(defaultProjectContent); } } } }; } }
public static void add_Reference(this DefaultProjectContent projectContent, ProjectContentRegistry pcRegistry, string assemblyToLoad, Action <string> debugMessage) { try { debugMessage("Loading Code Completion Reference: {0}".format(assemblyToLoad)); //if (!assemblyToLoad.fileExists()) // "file doesn't exist".error(); IProjectContent referenceProjectContent = pcRegistry.GetProjectContentForReference(assemblyToLoad, assemblyToLoad); if (referenceProjectContent == null) { "referenceProjectContent was null".error(); } else { projectContent.AddReferencedContent(referenceProjectContent); if (referenceProjectContent is ReflectionProjectContent) { (referenceProjectContent as ReflectionProjectContent).InitializeReferences(); } else { "something when wrong in DefaultProjectContent.add_Reference".error(); } } } catch (Exception ex) { ex.log("in DefaultProjectContent.add_Reference"); } }
static void CreateDefaultProjectContent() { LoggingService.Info("Creating default project content"); //LoggingService.Debug("Stacktrace is:\n" + Environment.StackTrace); defaultProjectContent = new DefaultProjectContent(); defaultProjectContent.AddReferencedContent(AssemblyParserService.DefaultProjectContentRegistry.Mscorlib); }
static void CreateDefaultProjectContent() { LoggingService.Info("Creating default project content"); //LoggingService.Debug("Stacktrace is:\n" + Environment.StackTrace); defaultProjectContent = new DefaultProjectContent(); defaultProjectContent.AddReferencedContent(defaultProjectContentRegistry.Mscorlib); Thread t = new Thread(new ThreadStart(CreateDefaultProjectContentReferences)); t.IsBackground = true; t.Priority = ThreadPriority.BelowNormal; t.Name = "CreateDefaultPC"; t.Start(); }
ICompilationUnit Parse(string code, SupportedLanguage language, params IProjectContent[] references) { DefaultProjectContent pc = new DefaultProjectContent(); foreach (var reference in references) { pc.AddReferencedContent(reference); } NRefactoryASTConvertVisitor visitor = new NRefactoryASTConvertVisitor(pc, language); using (IParser p = ParserFactory.CreateParser(language, new StringReader(code))) { p.ParseMethodBodies = false; p.Parse(); visitor.Specials = p.Lexer.SpecialTracker.CurrentSpecials; visitor.VisitCompilationUnit(p.CompilationUnit, null); } return visitor.Cu; }
ICompilationUnit Parse(string code, SupportedLanguage language, bool referenceMscorlib) { DefaultProjectContent pc = new DefaultProjectContent(); if (referenceMscorlib) { pc.AddReferencedContent(SharedProjectContentRegistryForTests.Instance.Mscorlib); } NRefactoryASTConvertVisitor visitor = new NRefactoryASTConvertVisitor(pc); using (IParser p = ParserFactory.CreateParser(language, new StringReader(code))) { p.ParseMethodBodies = false; p.Parse(); visitor.Specials = p.Lexer.SpecialTracker.CurrentSpecials; visitor.VisitCompilationUnit(p.CompilationUnit, null); } return visitor.Cu; }
public void mapDotNetReferencesForCodeComplete() { statusMessage("Loading Code Complete Reference: MsCorlib"); myProjectContent.AddReferencedContent(pcRegistry.Mscorlib); /*addReference("System.Windows.Forms"); * addReference("System"); * addReference("System.Data"); * addReference("System.Drawing"); * addReference("System.Xml"); * addReference("Microsoft.VisualBasic"); * addReference("PresentationCore"); * addReference("PresentationFramework"); * addReference("WindowsBase"); * addReference("WindowsFormsIntegration");*/ }
ICompilationUnit Parse(string code, SupportedLanguage language, bool referenceMscorlib) { DefaultProjectContent pc = new DefaultProjectContent(); if (referenceMscorlib) { pc.AddReferencedContent(SharedProjectContentRegistryForTests.Instance.Mscorlib); } NRefactoryASTConvertVisitor visitor = new NRefactoryASTConvertVisitor(pc); using (IParser p = ParserFactory.CreateParser(language, new StringReader(code))) { p.ParseMethodBodies = false; p.Parse(); visitor.Specials = p.Lexer.SpecialTracker.CurrentSpecials; visitor.VisitCompilationUnit(p.CompilationUnit, null); } return(visitor.Cu); }
ICompilationUnit Parse(string code, SupportedLanguage language, params IProjectContent[] references) { DefaultProjectContent pc = new DefaultProjectContent(); foreach (var reference in references) { pc.AddReferencedContent(reference); } NRefactoryASTConvertVisitor visitor = new NRefactoryASTConvertVisitor(pc, language); using (IParser p = ParserFactory.CreateParser(language, new StringReader(code))) { p.ParseMethodBodies = false; p.Parse(); visitor.Specials = p.Lexer.SpecialTracker.CurrentSpecials; visitor.VisitCompilationUnit(p.CompilationUnit, null); } return(visitor.Cu); }
void ParserThread() { //BeginInvoke(new MethodInvoker(delegate { parserThreadLabel.Text = "Loading mscorlib..."; })); m_projectcontent.AddReferencedContent(ProjectContentRegistry.Mscorlib); // do one initial parser step to enable code-completion while other // references are loading ParseStep(); foreach (string assemblyName in GetReferences(false)) { string assemblyNameCopy = assemblyName; // copy for anonymous method //BeginInvoke(new MethodInvoker(delegate { parserThreadLabel.Text = "Loading " + assemblyNameCopy + "..."; })); IProjectContent referenceProjectContent = ProjectContentRegistry.GetProjectContentForReference(assemblyName, assemblyName); ProjectContent.AddReferencedContent(referenceProjectContent); if (referenceProjectContent is ReflectionProjectContent) { (referenceProjectContent as ReflectionProjectContent).InitializeReferences(); } } if (SupportedLanguage == ESupportedLanguage.VisualBasic) { ProjectContent.DefaultImports = new DefaultUsing(ProjectContent); ProjectContent.DefaultImports.Usings.Add("System"); ProjectContent.DefaultImports.Usings.Add("System.Text"); ProjectContent.DefaultImports.Usings.Add("Microsoft.VisualBasic"); } //BeginInvoke(new MethodInvoker(delegate { parserThreadLabel.Text = "Ready"; })); // Parse the current file every 2 seconds while (!IsDisposed) { ParseStep(); Thread.Sleep(2000); } }
private void ParserThread() { BeginInvoke(new MethodInvoker(delegate { parserThreadLabel.Text = "Loading mscorlib..."; })); myProjectContent.AddReferencedContent(pcRegistry.Mscorlib); // do one initial parser step to enable code-completion while other // references are loading ParseStep(); try { string appPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\"; //string[] referencedAssemblies = { // "System", "System.Data", "System.Drawing", "System.Xml", "System.Windows.Forms", "Microsoft.VisualBasic", appPath + "Interop.MapWinGIS.dll", appPath + "MapWinInterfaces.dll", appPath + "MapWinGeoProc.dll" //}; string[] referencedAssemblies = { "System", "System.Data", "System.Drawing", "System.Xml", "System.Windows.Forms", "Microsoft.VisualBasic", appPath + "DotSpatial.Controls.dll", appPath + "DotSpatial.Data.dll", appPath + "DotSpatial.Topology.dll" }; foreach (string assemblyName in referencedAssemblies) { string assemblyNameCopy = assemblyName; // copy for anonymous method BeginInvoke(new MethodInvoker(delegate { parserThreadLabel.Text = "Loading " + assemblyNameCopy + "..."; })); IProjectContent referenceProjectContent = pcRegistry.GetProjectContentForReference(assemblyName, assemblyName); //\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ //if (assemblyNameCopy.Contains("Interop.MapWinGIS.dll")) //{ // Dom.DefaultCompilationUnit myDefaultCompilationUnit = new Dom.DefaultCompilationUnit(referenceProjectContent); // foreach (Dom.IClass iClass in referenceProjectContent.Classes) // { // //********* ADD CLASSES TO HIDE HERE ****************** // if (iClass.Name.StartsWith("_")) // myDefaultCompilationUnit.Classes.Add(iClass); // } // referenceProjectContent.RemoveCompilationUnit(myDefaultCompilationUnit); //} //\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ myProjectContent.AddReferencedContent(referenceProjectContent); if (referenceProjectContent is ReflectionProjectContent) { (referenceProjectContent as ReflectionProjectContent).InitializeReferences(); } } } catch (Exception e) { gErrorMsg = e.Message + e; } if (IsVisualBasic) { myProjectContent.DefaultImports = new DefaultUsing(myProjectContent); myProjectContent.DefaultImports.Usings.Add("System"); myProjectContent.DefaultImports.Usings.Add("System.Text"); myProjectContent.DefaultImports.Usings.Add("Microsoft.VisualBasic"); } BeginInvoke(new MethodInvoker(delegate { parserThreadLabel.Text = "Ready"; })); // Parse the current file every 2 seconds while (!IsDisposed) { ParseStep(); Thread.Sleep(2000); } }