public AuthoringScope(LanguageService languageService, AuthoringHelper helper){ this.languageService = languageService; this.helper = helper; }
public GenericMethodOverloads(MemberList members, Scope scope, int positionOfSelectedMember, AuthoringHelper helper) : base(members, scope, positionOfSelectedMember, helper, OverloadKind.GenericMethods) { }
public Overloads(MemberList members, Scope scope, int positionOfSelectedMember, AuthoringHelper helper, OverloadKind kind){ this.members = members; this.scope = scope; this.helper = helper; this.positionOfSelectedMember = positionOfSelectedMember; this.OverloadKind = kind; }
public Declarations(MemberList memberList, AuthoringHelper helper, Node node, Scope scope){ this.node = node; this.scope = scope; this.displayTextForLastGetBestMatch = ""; this.helper = helper; if (memberList == null || memberList.Count == 0) { this.members = new Member[0]; this.helper = helper; return; } Identifier tName = null; TypeNode t = memberList[memberList.Count - 1] as TypeNode; if (t != null) tName = (t.Template == null) ? t.Name : t.Template.Name; Member lastMemb = memberList[memberList.Count - 1]; if (lastMemb == null) memberList.RemoveAt(memberList.Count - 1); Member[] members = memberList.ToArray(); Array.Sort(members, this.GetMemberComparer(helper.culture)); //REVIEW: perhaps get it from helper? MemberList memberList1 = new MemberList(); this.overloads = new int[members.Length]; String memberName = null; bool doneAddingPreselection = !((node is Construct) || (node is Identifier)) || lastMemb == null; int j = 0; for (int i = 0; i < members.Length;){ Member mem = members[i]; if (mem == null){ i++; continue;} if (mem.IsSpecialName || mem.FilterPriority == System.ComponentModel.EditorBrowsableState.Never){i++; continue;} memberName = helper.GetMemberName(mem); if (memberName == null || memberName.Length == 0){i++; continue;} if (!doneAddingPreselection && mem.Name != null && tName != null && mem.Name.UniqueIdKey == tName.UniqueIdKey) { this.initialMatch = memberList1.Count; if (t != null && t.Template != null) { // t is implicitly not null since tName is not null but it's safer to check anyway. memberList1.Add(t); doneAddingPreselection = true; if (t == (mem as TypeNode)) { i++; j++; continue; } } } else if (t != null && t == (mem as TypeNode) && t.Template != null) { // TODO: Perhaps check doneAddingPreselection here as well? if (this.initialMatch >= 0) { i++; continue; } this.initialMatch = memberList1.Count; doneAddingPreselection = true; } else if (!doneAddingPreselection && lastMemb == mem) { if (this.initialMatch >= 0) { i++; continue; } this.initialMatch = memberList1.Count; doneAddingPreselection = true; } memberList1.Add(mem); i++; while (i < members.Length && helper.GetMemberName(members[i]) == memberName){ if (t != (members[i] as TypeNode) || (t == null && members[i] != null)) this.overloads[j]++; i++; } j++; } members = memberList1.ToArray(); this.members = members; }
public AuthoringScope(LanguageService languageService, AuthoringHelper helper) : base(languageService, helper){ ErrorHandler errorHandler = new ErrorHandler(new ErrorNodeList(0)); this.typeSystem = new TypeSystem(errorHandler); this.resolver = new Resolver(errorHandler, this.typeSystem); }
/// <summary> /// Updates the state of the drop down bars to match the current contents of the text editor window. Call this initially and every time /// the cursor position changes. /// </summary> /// <param name="textView">The editor window</param> /// <param name="line">The line on which the cursor is now positioned</param> /// <param name="col">The column on which the cursor is now position</param> public void SynchronizeDropdowns(IVsTextView textView, int line, int col) { this.textView = textView; string fname = this.languageService.GetFileName(textView); if (fname == null) { return; } LanguageService.Project proj = this.languageService.GetProjectFor(fname); if (proj == null) { return; } object indx = proj.IndexForFileName[Identifier.For(fname).UniqueKey]; if (!(indx is int)) { return; } int index = (int)indx; if (index >= proj.parseTrees.Length) { return; } CompilationUnit cu = proj.parseTrees[index] as CompilationUnit; if (cu == null) { return; } AuthoringHelper helper = this.languageService.GetAuthoringHelper(); TypeNodeList types = this.dropDownTypes; TypeNodeList sortedTypes = this.sortedDropDownTypes; if (cu != this.currentCompilationUnit) { this.currentCompilationUnit = cu; //Need to reconstruct the type lists. First get the types in text order. types = this.dropDownTypes = new TypeNodeList(); this.PopulateTypeList(types, cu.Namespaces); //Now sort by full text name. int n = types.Length; if (n == 0) { return; } sortedTypes = this.sortedDropDownTypes = new TypeNodeList(n); int[] dropDownTypeGlyphs = this.dropDownTypeGlyphs = new int[n]; for (int i = 0; i < n; i++) { TypeNode t = types[i]; if (t == null) { Debug.Assert(false); continue; } string tName = t.FullName; int glyph = dropDownTypeGlyphs[sortedTypes.Length] = helper.GetGlyph(t); sortedTypes.Add(t); for (int j = i - 1; j >= 0; j--) { if (string.Compare(tName, sortedTypes[j].FullName) >= 0) { break; } sortedTypes[j + 1] = sortedTypes[j]; sortedTypes[j] = t; dropDownTypeGlyphs[j + 1] = dropDownTypeGlyphs[j]; dropDownTypeGlyphs[j] = glyph; } } this.selectedType = -1; } //Find the type matching the given source position int newType = 0; for (int i = 0, n = types.Length; i < n; i++) { TypeNode t = types[i]; if (t.SourceContext.StartLine > line + 1 || (t.SourceContext.StartLine == line + 1 && t.SourceContext.StartColumn > col + 1)) { if (i > 0) { t = types[i - 1]; } } else if (i < n - 1) { continue; } for (int j = 0; j < n; j++) { if (sortedTypes[j] != t) { continue; } newType = j; break; } break; } MemberList members = this.dropDownMembers; MemberList sortedMembers = this.sortedDropDownMembers; if (newType != this.selectedType) { TypeNode t = sortedTypes[newType]; if (t.Members == null) { return; } //Need to reconstruct the member list. First get the members in text order. members = t.Members; int n = members == null ? 0 : members.Length; MemberList newMembers = this.dropDownMembers = new MemberList(n); //Now sort them sortedMembers = this.sortedDropDownMembers = new MemberList(n); string[] memSignatures = this.dropDownMemberSignatures = new string[n]; int[] dropDownMemberGlyphs = this.dropDownMemberGlyphs = new int[n]; for (int i = 0; i < n; i++) { Member mem = members[i]; if (mem == null) { continue; } string memSignature = this.languageService.errorHandler.GetUnqualifiedMemberSignature(mem); if (memSignature == null) { continue; } memSignatures[sortedMembers.Length] = memSignature; int glyph = dropDownMemberGlyphs[sortedMembers.Length] = helper.GetGlyph(mem); newMembers.Add(mem); sortedMembers.Add(mem); for (int j = i - 1; j >= 0; j--) { if (string.Compare(memSignature, memSignatures[j]) >= 0) { break; } memSignatures[j + 1] = memSignatures[j]; memSignatures[j] = memSignature; sortedMembers[j + 1] = sortedMembers[j]; sortedMembers[j] = mem; dropDownMemberGlyphs[j + 1] = dropDownMemberGlyphs[j]; dropDownMemberGlyphs[j] = glyph; } } this.selectedMember = -1; } //Find the member matching the given source position members = this.dropDownMembers; int newMember = 0; for (int i = 0, n = sortedMembers.Length; i < n; i++) { Member mem = members[i]; if (mem == null) { continue; } if (mem.SourceContext.StartLine > line + 1 || (mem.SourceContext.StartLine == line + 1 && mem.SourceContext.StartColumn > col + 1)) { if (i > 0) { mem = members[i - 1]; } } else if (i < n - 1) { continue; } for (int j = 0; j < n; j++) { if (sortedMembers[j] != mem) { continue; } newMember = j; break; } break; } if (this.dropDownBar == null) { return; } if (this.selectedType != newType) { this.selectedType = newType; this.dropDownBar.RefreshCombo(TypeAndMemberDropdownBars.DropClasses, newType); } if (this.selectedMember != newMember) { this.selectedMember = newMember; this.dropDownBar.RefreshCombo(TypeAndMemberDropdownBars.DropMethods, newMember); } }