public XAMLCompletionSource(XAMLCompletionSourceProvider provider, ITextBuffer buffer) { _provider = provider; _buffer = buffer; _fileName = buffer.GetXAMLFile(); _file = buffer.GetFile(); }
public XSharpQuickInfoSource(XSharpQuickInfoSourceProvider provider, ITextBuffer subjectBuffer, IClassificationFormatMapService formatMap, IClassificationTypeRegistryService registry) { _provider = provider; _subjectBuffer = subjectBuffer; _file = _subjectBuffer.GetFile(); _formatMap = formatMap; _registry = registry; }
public XSharpQuickInfoSource(XSharpQuickInfoSourceProvider provider, ITextBuffer subjectBuffer, IClassificationFormatMapService formatMap, IClassificationTypeRegistryService registry) { _provider = provider; _subjectBuffer = subjectBuffer; _file = _subjectBuffer.GetFile(); _formatMap = formatMap; _registry = registry; var package = XSharpProjectPackage.Instance; _optionsPage = package.GetIntellisenseOptionsPage(); }
internal void DetermineSubType() { // Parse the contents of the file and see if we have a windows form or a windows control XSharpProjectNode projectNode = ProjectMgr as XSharpProjectNode; XSharpModel.XFile xfile = projectNode.ProjectModel.FindFullPath(this.Url); if (xfile != null) { xfile.WaitParsing(); } // (something that inherits from system.windows.forms.form or system.windows.forms.usercontrol // We should do this with proper parsing. For now we simply test the first word after the INHERIT keyword // and then parse and bind to see if we can find the first type in the file. if (this.FileType == XFileType.SourceCode && this.Url.IndexOf(".designer.", StringComparison.OrdinalIgnoreCase) == -1) { string SubType = ""; string token = "INHERIT"; string source = System.IO.File.ReadAllText(this.Url); int pos = source.IndexOf(token, StringComparison.OrdinalIgnoreCase); if (pos > 0) { source = source.Substring(pos + token.Length); var words = source.Split(";\t \r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (words.Length > 0) { var parentclass = words[0].ToLower(); switch (parentclass) { case "form": case "system.windows.forms.form": SubType = ProjectFileAttributeValue.Form; break; case "usercontrol": case "system.windows.forms.usercontrol": SubType = ProjectFileAttributeValue.UserControl; break; } if (SubType != null && this.ItemNode.GetMetadata(ProjectFileConstants.SubType) != SubType) { this.ItemNode.SetMetadata(ProjectFileConstants.SubType, SubType); this.ItemNode.RefreshProperties(); this.UpdateHasDesigner(); this.ReDraw(UIHierarchyElement.Icon); } } } } return; }
public CompletionType(XVariable var, string defaultNS) { // We know the context // var.Parent // We know the Type Name // var.TypeName // We need to lookup for the XType or System.Type // To check, we will need to know also "imported" types XTypeMember member = var.Parent as XTypeMember; this._file = var.File; if (member != null) { if (!String.IsNullOrEmpty(member.Parent.NameSpace)) { defaultNS = member.Parent.NameSpace; } CheckType(var.TypeName, member.File, defaultNS); } }
private void BuildMemberList(SnapshotSpan span) { // ITrackingSpan trackingSpan = span.Snapshot.CreateTrackingSpan(span, SpanTrackingMode.EdgeInclusive); // Get the Name of the File XSharpModel.XFile file = this.m_textView.TextBuffer.GetFile(); if (file != null) { // ITextSnapshotLine line = span.Start.GetContainingLine(); int lineNumber = line.LineNumber; int columnNumber = span.Start.Position - line.Start.Position; // XTypeDefinition classDef = null; foreach (KeyValuePair <String, XTypeDefinition> kvp in file.TypeList) { if (kvp.Value.Range.ContainsInclusive(lineNumber, columnNumber)) { classDef = kvp.Value; break; } } if (classDef != null) { // Get the Interfaces // classDef.Implement DOESN'T exist currently :( string[] interfaces = { }; // Clr Types // Our own types XTypeDefinition ti = null; IList <string> Usings = file.Usings; // Search already implemented Members bool FoundAll = true; string FullName = ""; // Let's build a list of Elements to add to implement the Interface List <XMemberDefinition> toAdd = new List <XMemberDefinition>(); CompletionType temp; // foreach (string iface in interfaces) { String iFace = iface.Trim(); // Search The interface // --> Default NameSpace temp = new CompletionType(iFace, file, ""); if (!temp.IsEmpty()) { if (temp.XTypeDef != null) { ti = temp.XTypeDef; if (ti.Kind == Kind.Interface) { FullName = ti.Name; // Everything is here ? FoundAll = true; foreach (XMemberDefinition mbr in ti.Members) { if (!classDef.Members.Contains(mbr)) { // No toAdd.Add(mbr); } } FoundAll = (toAdd.Count == 0); } } } // } } } // Sorry, nothing to do.... return; }
internal void DetermineSubType() { // Parse the contents of the file and see if we have a windows form or a windows control XSharpProjectNode projectNode = ProjectMgr as XSharpProjectNode; XSharpModel.XFile xfile = projectNode.ProjectModel.FindFullPath(this.Url); if (xfile == null) { projectNode.ProjectModel.AddFile(this.Url); xfile = projectNode.ProjectModel.FindFullPath(this.Url); } if (xfile != null) { xfile.WaitParsing(); } // (something that inherits from system.windows.forms.form or system.windows.forms.usercontrol // We should do this with proper parsing. For now we simply test the first word after the INHERIT keyword // and then parse and bind to see if we can find the first type in the file. if (this.FileType == XFileType.SourceCode && this.Url.IndexOf(".designer.", StringComparison.OrdinalIgnoreCase) == -1) { string SubType = ""; string token = "INHERIT"; string source = System.IO.File.ReadAllText(this.Url); int pos = source.IndexOf(token, StringComparison.OrdinalIgnoreCase); if (pos > 0) { source = source.Substring(pos + token.Length); var words = source.Split(";\t \r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (words.Length > 0) { var parentclass = words[0].ToLower(); SubType = typeNameToSubtype(parentclass); if (string.IsNullOrEmpty(SubType)) { var usings = new List <string>(); if (xfile != null) { usings.AddRange(xfile.Usings); } var mgr = this.ProjectMgr as XSharpProjectNode; var type = mgr.ResolveType(parentclass, usings); if (type != null) { while (type.BaseType != null) { var bt = type.BaseType; SubType = typeNameToSubtype(bt.Name); if (!String.IsNullOrEmpty(SubType)) { break; } type = bt; } } else { var xtype = mgr.ResolveXType(parentclass, usings); if (xtype != null) { while (xtype != null && !String.IsNullOrEmpty(xtype.ParentName)) { var parent = xtype.ParentName; SubType = typeNameToSubtype(parent); if (!String.IsNullOrEmpty(SubType)) { break; } xtype = mgr.ResolveXType(parent, usings); } } } } if (SubType != null && this.ItemNode.GetMetadata(ProjectFileConstants.SubType) != SubType) { this.ItemNode.SetMetadata(ProjectFileConstants.SubType, SubType); this.ItemNode.RefreshProperties(); this.UpdateHasDesigner(); this.ReDraw(UIHierarchyElement.Icon); } } } } return; }
public XSharpModelDiscoverWithLocals(XFile file, XSharpParser.SourceContext ctx, IEnumerable <XError> errors) : base(file, ctx, errors) { this._localDecls = new Stack <XSharpParser.LocalvarContext>(); }
public XSharpQuickInfoSource(XSharpQuickInfoSourceProvider provider, ITextBuffer subjectBuffer) { _provider = provider; _subjectBuffer = subjectBuffer; _file = _subjectBuffer.GetFile(); }
public void WalkFile(XFile file) { ModelWalker walker = ModelWalker.GetWalker(); walker.FileWalk(file); }
public bool AddFile(string filePath) { XFile file = new XFile(filePath); return(this.AddFile(file)); }
private void OnSelectionChanged(object sender, object e) { try { String selectedText = this.View.Selection.StreamSelectionSpan.GetText(); if (!string.IsNullOrEmpty(selectedText) && !string.IsNullOrWhiteSpace(selectedText)) { // where are we SnapshotPoint currentRequest = this.View.Selection.Start.Position; List <SnapshotSpan> wordSpans = new List <SnapshotSpan>(); // Search for me please TextExtent word = TextStructureNavigator.GetExtentOfWord(currentRequest); bool foundWord = true; // if (!WordExtentIsValid(currentRequest, word)) { //Same context ? if (word.Span.Start != currentRequest || currentRequest == currentRequest.GetContainingLine().Start || char.IsWhiteSpace((currentRequest - 1).GetChar())) { foundWord = false; } else { // Move back, and start again word = TextStructureNavigator.GetExtentOfWord(currentRequest - 1); //If the word still isn't valid, we're done if (!WordExtentIsValid(currentRequest, word)) { foundWord = false; } } } if (!foundWord) { //If we couldn't find a word, clear out the existing markers SynchronousUpdate(new NormalizedSnapshotSpanCollection()); return; } SnapshotSpan currentWord = word.Span; selectedWord = this.View.Selection.StreamSelectionSpan.SnapshotSpan; //If this is the current word, and the caret moved within a word, we're done. if (!(selectedWord.HasValue && currentWord == selectedWord)) { return; } //Find the new spans FindData findData = new FindData(currentWord.GetText(), currentWord.Snapshot); findData.FindOptions = FindOptions.WholeWord | FindOptions.MatchCase; // Values are zero-based SnapshotPoint point = View.Caret.Position.BufferPosition; // Retrieve the XFile XSharpModel.XFile xFile = this.View.TextBuffer.GetFile(); if (xFile != null) { // Now, retrieve the current member XSharpModel.XMemberDefinition member = XSharpTokenTools.FindMemberAtPosition(point.Position, xFile); if (member == null) { return; } // Ok, so we now have the "range" of the Member, and will only select text in THIS member SnapshotSpan memberSpan = new SnapshotSpan(currentWord.Snapshot, member.Interval.Start, member.Interval.Width); // Get all the corresponding Words Collection <SnapshotSpan> allFound = TextSearchService.FindAll(findData); Collection <SnapshotSpan> memberFound = new Collection <SnapshotSpan>(); foreach (SnapshotSpan ssp in allFound) { // Inside the Member ? if (memberSpan.Contains(ssp)) { memberFound.Add(ssp); } } // wordSpans.AddRange(memberFound); // Show please SynchronousUpdate(new NormalizedSnapshotSpanCollection(wordSpans)); } } } catch (Exception ex) { XSettings.DisplayOutputMessage("HighlightWordTag Exception: " + ex.Message); } }
public SourceWalker(XFile file, ITextSnapshot snapshot) { _file = file; _prjNode = _file?.Project?.ProjectNode; Snapshot = snapshot; }
public CompletionType(String typeName, XFile xFile, IReadOnlyList <String> usings) { CheckType(typeName, xFile, usings); }
public CompletionType(String typeName, XFile xFile, string defaultNS) { CheckType(typeName, xFile, defaultNS); }