public void AddListMemberAsExpected() { Assert.Empty(_memberList); _memberList.Add(_fieldA); Assert.Single(_memberList); Assert.Contains(_fieldA, _memberList); }
public void ResolveDotContext_issue750(string sourceText, MemberModel code) { ((HaXeSettings)ASContext.Context.Settings).CompletionMode = HaxeCompletionModeEnum.FlashDevelop; SetSrc(sci, sourceText); var expr = ASComplete.GetExpression(sci, sci.CurrentPos); var list = ASContext.Context.ResolveDotContext(sci, expr, false); if (code == null) { Assert.IsNull(list); } else { var members = ASContext.Context.ResolveType(ASContext.Context.Features.stringKey, ASContext.Context.CurrentModel) .Members.Items.Where(it => !it.Flags.HasFlag(FlagType.Static) && it.Access.HasFlag(Visibility.Public)) .ToArray(); var expectedList = new MemberList(); foreach (var member in members) { expectedList.Add(member); } expectedList.Add(code); expectedList.Sort(); Assert.AreEqual(expectedList, list); } }
protected MemberList GetPrivateClasses() { MemberList list = new MemberList(); // private classes foreach (ClassModel model in cFile.Classes) { if (model.Access == Visibility.Private) { MemberModel item = model.ToMemberModel(); item.Type = item.Name; item.Access = Visibility.Private; list.Add(item); } } // 'Class' members if (cClass != null) { foreach (MemberModel member in cClass.Members) { if (member.Type == "Class") { list.Add(member); } } } return(list); }
public override MemberList Process(WebClient client) { MemberList ml = new MemberList(); String content = client.DownloadString(GetUrl()); MatchCollection mc = Regex.Matches(content, "<a href=\"http://baki\\.info/subcat/(\\d+)\" class=\"sc_listone\">.*?<span class=\"csc_sub_name\"><div class=\"title_inner\">(.+?)</div>", RegexOptions.Singleline); if (mc.Count > 0) { // process sub categories foreach (Match m in mc) { CategorySub c = new CategorySub(); c.Id = m.Groups[1].Value; c.Name = m.Groups[2].Value.Replace(" ", " ").Replace("&", "&").Trim(); Children.Add(c); ml.Add(c); } Unprocessed = false; } else { // process products content = client.DownloadString(ProductsUrl(page)); MatchCollection mc1 = Regex.Matches(content, "<div class=\"cop_title\"><h3><a href=\"(.+?)\">(.+?)</a></h3></div>"); foreach (Match m in mc1) { Product p = new Product(); p.Name = m.Groups[2].Value.Replace(" ", " ").Replace("&", "&").Trim(); p.Url = m.Groups[1].Value; Children.Add(p); ml.Add(p); } MatchCollection mc2 = Regex.Matches(content, "new Paginator\\('paginator1', (\\d+?), \\d+, (\\d+?), \"#\"\\);"); String total = mc2[0].Groups[1].Value; String current = mc2[0].Groups[2].Value; if (page < Int16.Parse(total)) { Page++; ml.Add(this); } else { Unprocessed = false; } } return ml; }
public override void VisitConstruct(Construct cons) { if ((cons.Type.IsDelegateType())) { UnaryExpression ue = cons.Operands[1] as UnaryExpression; if (ue != null) { MemberBinding mb = ue.Operand as MemberBinding; if (mb != null) { Method m = (Method)mb.BoundMember; if (HelperMethods.IsClosureMethod(this.containingType, m)) { if (HelperMethods.IsClosureType(this.containingType, m.DeclaringType)) { // Roslyn-based compiler changed non-capturing lambda caching. // Instead of storing delegate in a field like CS$<>9_CachedAnonymousMethodDelegate1 // Roslyn-based compiler generates a closure class called <>c with a set of instance // methods and a singleton instance. // This change allows to duplicate this new closure type if (HelperMethods.IsRoslynBasedStaticClosure(m.DeclaringType)) { TryAddTypeToMembersToDuplicate(m.DeclaringType); } } else { // Logic for pre-Roslyn compiler. // then there is no closure class, m is just a method the compiler // added to the class itself // we record the instance here, although we will eventually make a copy of the // template by making the method generic in its parent type type-parameters. MembersToDuplicate.Add(m); } } else { //Console.WriteLine("Not atomic closure part: {0}", m.FullName); var declaringTypeName = m.DeclaringType.Name.Name; var name = m.Name.Name; string message = String.Format( "DeclaringName should contain 'DisplayClass', <>c or Name should not have '__'. \r\nDeclaringTypeName: {0}, Name: {1}", declaringTypeName, name); Debug.Assert( declaringTypeName.Contains("DisplayClass") || declaringTypeName.Contains("<>c") || !name.Contains("__"), message); } } } } base.VisitConstruct(cons); }
// Returns true if it succeeds, false if there was a name conflict. public bool AddMember(string name, ITypeDef typeDef, IExpr initializer = null, bool isStatic = false, bool isFunctionVariable = false, bool isGetonly = false) { // Fail if a member with that name already exists. if (DoesFieldExist(name, SEARCH.EITHER)) { return(false); } var member = new ClassMember(name, typeDef, initializer, isGetonly); // This logic is weird but works because the language currently // doesn't allow static member functions. if (isStatic) { member.index = _statics.Add(member.name, member); staticVars.Add(new Variable(member.name, typeDef, null)); } else if (!isFunctionVariable && typeDef is TypeDef_Function) { member.index = _memberFuncs.Add(member.name, member); } else { member.index = _fields.Add(member.name, member); } return(true); }
public void ShowOrHidePoducts() { try { List <AnniversaryModel> memberList = null; Task.Factory.StartNew(() => { ISyncServices syncService = new SyncServices(); memberList = syncService.GetAnniversaryList(); }).ContinueWith((obj) => { Device.BeginInvokeOnMainThread(() => { if (memberList != null) { foreach (var item in memberList) { if (!string.Equals(item.merrageAnyver, "0000-00-00")) { MemberList.Add(item); } } CreateGroupList(); } }); }); } catch (Exception ex) { } }
private void GetMembers(string galleryId) { List <GalleryModel> memberList = null; Task.Factory.StartNew(() => { ISyncServices syncService = new SyncServices(); memberList = syncService.GetGalleryDetails(galleryId); }).ContinueWith((obj) => { Device.BeginInvokeOnMainThread(() => { if (memberList != null) { //MvvmTest.Helpers.CommonHelpers.ShowAlert("circular success"); foreach (var item in memberList) { if (string.IsNullOrEmpty(item.galleryPhoto)) { item.galleryPhoto = "demo"; } MemberList.Add(item); } //CircularList = new ObservableCollection<CircularModel>(circularList); } }); }); }
/// <summary> /// Room初始化 /// </summary> /// <param name="players"></param> public void Init(Player[] players) { MaxWaitLoadingTime = 90000; LoadingBroadcastTime = 1000; WaitRightTime = 30000; TimeInit(); for (int i = 0; i < players.Length; i++) { if (players[i] == null) { continue; } players[i].Room = this; MemberList.Add(players[i].Openid, players[i]); RoomPlayer roomPlayer = new RoomPlayer { Openid = players[i].Openid, Nickname = players[i].UserData.NickNeam, HeadImageUrl = players[i].UserData.NickWebPath, Right = false }; players[i].TempData.PlayerGameInfo = roomPlayer; } GoToConfirmStage(); }
public override MemberList Process(WebClient client) { MemberList ml = new MemberList(); String content = client.DownloadString(GetUrl()); MatchCollection mc = Regex.Matches(content, "<option value=\"(\\d+)\">(.+?)</option>"); foreach (Match m in mc) { String id = m.Groups[1].Value; String name = m.Groups[2].Value; if (id != "0") { CategoryTop c = new CategoryTop(); c.Name = name; c.Id = id; Children.Add(c); ml.Add(c); } } Unprocessed = false; return ml; }
public void ShowOrHidePoducts() { try { List <BloodGroupModel> memberList = null; Task.Factory.StartNew(() => { ISyncServices syncService = new SyncServices(); memberList = syncService.GetBloodGroupList(); }).ContinueWith((obj) => { Device.BeginInvokeOnMainThread(() => { if (memberList != null) { // var sorted = memberList.OrderBy(d => Convert.ToDateTime(d.memBG)).ToList(); foreach (var item in memberList) { if (!string.IsNullOrEmpty(item.memBG)) { MemberList.Add(item); } } //CircularList = new ObservableCollection<CircularModel>(circularList); } CreateGroupList(); }); }); } catch (Exception ex) { } }
public override void AddMember(IMember member) { // if the member is a Message or Packet we will include them // in a pair. if (member is Message || member is Packet) { if (!TryFindMember(member.Name, out var existing)) { existing = new ProtocolPair { Name = member.Name, Parent = this }; MemberList.Add(existing); } var pair = (ProtocolPair)existing; var message = member as Message; if (message != null) { pair.Message = message; } else { pair.Packet = (Packet)member; } } else { MemberList.Add(member); } }
public virtual void AcceptLobby(User user) { if (!this.InvitedList.Remove(user)) { return; } MemberList.Add(user); }
public virtual MemberList GetNestedNamespaces(Identifier name, Scope scope) { MemberList fullList = this.GetNestedNamespacesAndTypes(name, scope); MemberList result = new MemberList(); for (int i = 0, n = fullList == null ? 0 : fullList.Count; i < n; i++){ Namespace ns = fullList[i] as Namespace; if (ns == null) continue; result.Add(ns); } return result; }
public GoEmptyBlock(GoBoard goBoard) : base(goBoard, Color.Empty) { Members.AddAll(); for (int i = 0; i < Board.Coord.BoardArea; i++) { MemberList.Add(i); } }
public async Task <IActionResult> Create([Bind("ID,StudNum,FullName,Age,Address")] Member member) { if (ModelState.IsValid) { _context.Add(member); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(member)); }
/// <summary> /// Return the full project classes list /// </summary> /// <returns></returns> public override MemberList GetAllProjectClasses() { // from cache if (!completionCache.IsDirty && completionCache.AllTypes != null) { return(completionCache.AllTypes); } MemberList fullList = new MemberList(); MemberModel item; // public classes foreach (PathModel aPath in classPath) { if (aPath.IsValid && !aPath.Updating) { aPath.ForeachFile((aFile) => { foreach (ClassModel aClass in aFile.Classes) { if (!aClass.IsVoid() && aClass.IndexType == null && aClass.Access == Visibility.Public) { item = aClass.ToMemberModel(); item.Name = item.Type; fullList.Add(item); } } return(true); }); } } // void fullList.Add(new MemberModel(features.voidKey, features.voidKey, FlagType.Class | FlagType.Intrinsic, 0)); // in cache fullList.Sort(); completionCache.AllTypes = fullList; return(fullList); }
public override MemberList GetMembersNamed(Identifier name) { MemberList returnList = new MemberList(); IDebugSymbol container = this.debugEnv.context.GetContainer(); CDebugMethodSymbol methodSymbol = null; if ((methodSymbol = container as CDebugMethodSymbol) != null) { if (name.Name == "this") { returnList.Add(new DebugFieldNode(this.debugEnv, methodSymbol.GetThis(), name, null, null, 0)); } else { IEnumSymbol param = methodSymbol.GetParameters(); if (param != null) { for (int i = 1; ; i++) { if (param.Current == null) { break; } if (param.Current.Name == name.Name) { DebugParameterField paramField = new DebugParameterField(this.debugEnv, param.Current, name, null, this); paramField.DeclaringType = this; paramField.Parameter = this.DeclaringMethod.Parameters[i]; returnList.Add(paramField); break; } param.MoveNext(); } } } } return(returnList); }
public override MemberList GetMembersNamed(Identifier name) { MemberList returnList = new MemberList(); IDebugSymbol container = this.debugEnv.context.GetContainer(); CDebugMethodSymbol methodSymbol = null; if ((methodSymbol = container as CDebugMethodSymbol) != null) { if (name.Name == "this") { returnList.Add(new DebugFieldNode(this.debugEnv, methodSymbol.GetThis(), name, null, null, 0)); } else { IEnumSymbol locals = methodSymbol.GetLocals(); if (locals != null) { for (int i = 0; ; i++) { if (locals.Current == null) { break; } if (locals.Current.Name == name.Name) { Field localField = new DebugFieldNode(this.debugEnv, locals.Current, name, null, this, i); localField.DeclaringType = this; returnList.Add(localField); break; } locals.MoveNext(); } } } } return(returnList); }
void ProcessMembers(XmlTextReader reader) { Members = new MemberList(); MemberModel member = null; while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement) { switch (reader.Name) { case "list": return; case "i": member = null; break; } continue; } else if (reader.NodeType != XmlNodeType.Element) { continue; } switch (reader.Name) { case "i": member = ExtractMember(reader); break; case "d": if (member == null) { continue; } member.Comments = ReadValue(reader); break; case "t": if (member == null) { continue; } ExtractType(reader, member); if (!IsOverload(member)) { Members.Add(member); } break; } } }
public void AddStone(int index) { MemberList.Add(index); Members.Add(index); Liberties.Remove(index); foreach (int lIndex in Board.Coord.GetNeighbors(index)) { if (Board.Cells[lIndex].Color.IsEmpty) { Liberties.Add(lIndex); } } }
/// <summary> /// Gets a new member for the list. /// </summary> /// <param name="m">The member to add. The message denotes how it is added. /// "Update" replaces at the specified index, "Add" adds it to the list.</param> public void ReceiveMember(MessageMember m) { if (m.Message == "Update") { var i = MemberList.IndexOf(selectedMember); MemberList[i] = new Member(m.FirstName, m.LastName, m.Email); database.SaveMemberships(MemberList); } else if (m.Message == "Add") { MemberList.Add(new Member(m.FirstName, m.LastName, m.Email)); database.SaveMemberships(MemberList); } }
/// <summary> /// Gets a new member for the list. /// </summary> /// <param name="m">The member to add. The message denotes how it is added. /// "Update" replaces at the specified index, "Add" adds it to the list.</param> public void ReceiveMember(MessageMember m) { if (m.Message == "Update") { MemberList.Remove(SelectedMember); MemberList.Add(m); database.SaveMemberships(); } else if (m.Message == "Add") { MemberList.Add(m); database.SaveMemberships(); } }
/// <summary> /// Return imported classes list (not null) /// </summary> /// <param name="package">Package to explore</param> /// <param name="inFile">Current file</param> public override MemberList ResolveImports(FileModel inFile) { bool filterImports = (inFile == cFile) && inFile.Classes.Count > 1; int lineMin = (filterImports && inPrivateSection) ? inFile.PrivateSectionIndex : 0; int lineMax = (filterImports && inPrivateSection) ? int.MaxValue : inFile.PrivateSectionIndex; MemberList imports = new MemberList(); foreach (MemberModel item in inFile.Imports) { if (filterImports && (item.LineFrom < lineMin || item.LineFrom > lineMax)) { continue; } ClassModel type = ResolveType(item.Type, null); if (!type.IsVoid()) { imports.Add(type); } else { // package-level declarations FileModel matches = ResolvePackage(item.Type, false); if (matches != null) { foreach (MemberModel import in matches.Imports) { imports.Add(import); } foreach (MemberModel member in matches.Members) { imports.Add(member); } } } } return(imports); }
private void SaveMember(Member objMember) { //Do validation if (!Validator.IsPresent("First Name", objMember.FirstName) || !Validator.IsPresent("Last Name", objMember.LastName) || !Validator.IsPresent("Email", objMember.Email) || !Validator.IsValidEmail("Email", objMember.Email)) { return; } MemberList.Add(objMember); MembershipData.SaveMemberships(MemberList); Messenger.Default.Send(new NotificationMessage(objMember.DisplayText + " is added successfully.")); CloseWindow(objMembershipAdd); }
/// <summary> /// Gets a new member for the list. /// </summary> /// <param name="m">The member to add. The message denotes how it is added. /// "Update" replaces at the specified index, "Add" adds it to the list.</param> public void ReceiveMember(MessageMember m) { if (m.Message == "Update") { // (Missing) -> Update the Members implementation var i = MemberList.IndexOf(selectedMember); MemberList[i] = new Member(m.FirstName, m.LastName, m.Email); database.SaveMemberships(); } else if (m.Message == "Add") { // (Missing) -> Add the Members implementation MemberList.Add(new Member(m.FirstName, m.LastName, m.Email)); database.SaveMemberships(); } }
public override MemberList GetMembersNamed(Identifier name) { MemberList returnList = new MemberList(); CDebugClassType classType = this.GetDebugType as CDebugClassType; if (classType != null) { IEnumSymbol members = classType.GetMembers(name.Name, true, SymbolKind.Field | SymbolKind.Property, SymbolModifiers.All); if (members != null) { while (members.Current != null) { if (members.Current.Name == name.Name) { Field fieldMember = new DebugFieldNode(this.debugEnv, members.Current, name, this.Value, this, 0); SymbolModifiers modifier = members.Current.Modifiers; if ((modifier & SymbolModifiers.Abstract) != 0) { fieldMember.Flags |= FieldFlags.None; } if ((modifier & SymbolModifiers.Final) != 0) { fieldMember.Flags |= FieldFlags.None; } if ((modifier & SymbolModifiers.Private) != 0) { fieldMember.Flags |= FieldFlags.Private; } if ((modifier & SymbolModifiers.Public) != 0) { fieldMember.Flags |= FieldFlags.Public; } if ((modifier & SymbolModifiers.Static) != 0) { fieldMember.Flags |= FieldFlags.Static; } returnList.Add(fieldMember); break; } members.MoveNext(); } } } return(returnList); }
public void GenerateContentPython(string file) { try { var code = File.ReadAllLines(file); MemberList.Clear(); for (int i = 0; i < code.Length; i++) { var line = code[i].TrimStart(); if (line.StartsWithAny("def ", "class ")) { var info = new MemberInfo(); info.ContentIndent = new string(' ', (code[i].Length - line.Length)); info.Line = i; if (line.StartsWith("class ")) { if (MemberList.Any()) { MemberList.Add(new MemberInfo { Line = -1 }); } info.ContentType = "class"; info.Content = line.Substring("class ".Length).TrimEnd(); } else { info.ContentType = "def"; info.Content = line.Substring("def ".Length).TrimEnd(); } MemberList.Add(info); } } ErrorMessage = null; } catch (Exception e) { ErrorMessage = e.Message; } }
/// <summary> /// Returns parameters string as member list /// </summary> /// <param name="parameters">Method parameters</param> /// <returns>Member list</returns> static private MemberList ParseMethodParameters(string parameters) { MemberList list = new MemberList(); if (parameters == null) { return(list); } int p = parameters.IndexOf('('); if (p >= 0) { parameters = parameters.Substring(p + 1, parameters.IndexOf(')') - p - 1); } parameters = parameters.Trim(); if (parameters.Length == 0) { return(list); } string[] sparam = parameters.Split(','); string[] parType; MemberModel param; char[] toClean = new char[] { ' ', '\t', '\n', '\r', '*', '?' }; foreach (string pt in sparam) { parType = pt.Split(':'); param = new MemberModel(); param.Name = parType[0].Trim(toClean); if (param.Name.Length == 0) { continue; } if (parType.Length == 2) { param.Type = parType[1].Trim(); } else { param.Type = ASContext.Context.Features.objectKey; } param.Flags = FlagType.Variable | FlagType.Dynamic; list.Add(param); } return(list); }
// Only called by the context. public void Initialize() { if (null != _fields) { return; } // 1) fields. _fields = new MemberList(); if (null != parent) { for (int ii = 0; ii < parent._fields.Count; ++ii) { ClassMember member = parent._fields.Get(ii); bool modified = false; ITypeDef resolvedType = parent.IsGeneric() ? member.typeDef.ResolveTemplateTypes(typeDef.genericTypes, ref modified) : member.typeDef; ClassMember newMember = new ClassMember(member.name, resolvedType, member.initializer, member.isGetonly); newMember.index = _fields.Add(member.name, newMember); } } // 2) Functions _memberFuncs = new MemberList(); if (null != parent) { for (int ii = 0; ii < parent._memberFuncs.Count; ++ii) { ClassMember member = parent._memberFuncs.Get(ii); bool modified = false; ITypeDef resolvedType = parent.IsGeneric() ? member.typeDef.ResolveTemplateTypes(typeDef.genericTypes, ref modified) : member.typeDef; ClassMember newMember = new ClassMember(member.name, resolvedType, member.initializer, member.isGetonly); newMember.index = _memberFuncs.Add(member.name, newMember); } vftableVars = new List <Variable>(parent.vftableVars); } else { vftableVars = new List <Variable>(); } // 3) Statics aren't copied. _statics = new MemberList(); staticVars = new List <Variable>(); }
private void addMemberButtonClick() { if (MemberNameData != null && MemberMoneyData != null && Helper.HelperFunctions.isNumericString(MemberMoneyData) == true) { MemberInTripModel temp = new MemberInTripModel(); if (MemberID == -1) { temp.ID = -1; } else { temp.ID = AllMember[MemberID].ID; } temp.Name = MemberNameData; if (MemberMoneyData != null) { temp.MoneyPaid = Int32.Parse(MemberMoneyData); } else { temp.MoneyPaid = 0; } MemberList.Add(temp); if (MemberID >= 0) { AllMember.RemoveAt(MemberID); } } else if (Helper.HelperFunctions.isNumericString(MemberMoneyData) == false) { MessageBox.Show("Số tiền chỉ nhận giá trị số"); } else { MessageBox.Show("Vui lòng nhập đủ thông tin trước khi thêm!!!"); } MemberID = -1; MemberNameData = null; MemberMoneyData = null; OnPropertyChanged(nameof(MemberList)); OnPropertyChanged(nameof(AllMember)); OnPropertyChanged(nameof(MemberNameData)); OnPropertyChanged(nameof(MemberMoneyData)); }
public static void ReloadMembers() { if (MemberList.Count > 0) { MemberList.RemoveAll(v => true); } JObject config = JObject.Parse(File.ReadAllText("permissions.json")); foreach (JProperty userId in ((JObject)config.SelectToken("Members")).Properties()) { Member newMember = new Member(userId.Name); foreach (JToken role in config.SelectToken($"Members.{userId.Name}")) { newMember.Roles.Add(role.ToString()); } MemberList.Add(newMember); } }
public bool AddMember(Member memberAdd) { int i = 0; foreach (Member member in MemberList) { if (member.CompareTo(memberAdd) == 0) { return(false); } if (member.CompareTo(memberAdd) < 0) { MemberList.Insert(i, memberAdd); return(true); } i++; } MemberList.Add(memberAdd); return(true); }
public override MemberList Process(WebClient client) { MemberList ml = new MemberList(); String content = client.DownloadString(GetUrl()); MatchCollection mc = Regex.Matches(content, "<a href=\"http://baki\\.info/subcat/(\\d+)\" class=\"sc_listone\">.*?<span class=\"csc_sub_name\"><div class=\"title_inner\">(.+?)</div>", RegexOptions.Singleline); foreach (Match m in mc) { CategorySub c = new CategorySub(); c.Id = m.Groups[1].Value; c.Name = m.Groups[2].Value; Children.Add(c); ml.Add(c); } Unprocessed = false; return ml; }
/// <summary> /// Return the elements (package, types, etc) visible from the current file /// </summary> /// <param name="typesOnly">Return only packages & types</param> /// <returns></returns> public override MemberList GetVisibleExternalElements(bool typesOnly) { MemberList visibleElements = new MemberList(); if (!IsFileValid) return visibleElements; // top-level elements if (!typesOnly && topLevel != null) { if (topLevel.OutOfDate) InitTopLevelElements(); visibleElements.Add(topLevel.Members); } if (completionCache.IsDirty) { MemberList elements = new MemberList(); // root types & packages FileModel baseElements = ResolvePackage(null, false); if (baseElements != null) { elements.Add(baseElements.Imports); elements.Add(baseElements.Members); } elements.Add(new MemberModel(features.voidKey, features.voidKey, FlagType.Class | FlagType.Intrinsic, 0)); bool qualify = Settings.CompletionShowQualifiedTypes && settings.GenerateImports; // other classes in same package if (features.hasPackages && cFile.Package != "") { FileModel packageElements = ResolvePackage(cFile.Package, false); if (packageElements != null) { foreach (MemberModel member in packageElements.Imports) { if (member.Flags != FlagType.Package) { if (qualify) member.Name = member.Type; elements.Add(member); } } foreach (MemberModel member in packageElements.Members) { string pkg = member.InFile.Package; if (qualify && pkg != "") member.Name = pkg + "." + member.Name; elements.Add(member); } } } // other classes in same file if (cFile.PrivateSectionIndex > 0) { if (inPrivateSection && cFile.Classes.Count > 1) { ClassModel mainClass = cFile.GetPublicClass(); if (!mainClass.IsVoid()) { MemberModel toRemove = elements.Search(mainClass.Name, 0, 0); if (toRemove != null && toRemove.Type == mainClass.QualifiedName) elements.Remove(toRemove); } } MemberModel member; foreach (ClassModel aClass in cFile.Classes) { if (features.hasMultipleDefs || aClass.Access == Visibility.Private) { member = aClass.ToMemberModel(); elements.Add(member); } } } // imports elements.Add(ResolveImports(CurrentModel)); // in cache elements.Sort(); completionCache = new CompletionCache(this, elements); // known classes colorization if (!CommonSettings.DisableKnownTypesColoring && !settings.LazyClasspathExploration && CurSciControl != null) { try { CurSciControl.KeyWords(1, completionCache.Keywords); // additional-keywords index = 1 CurSciControl.Colourise(0, -1); // re-colorize the editor } catch (AccessViolationException){} // catch memory errors } } visibleElements.Merge(completionCache.Elements); return visibleElements; }
private void PopulatePackageEntries(string package, string path, MemberList memberList) { string[] dirEntries = null; try { dirEntries = System.IO.Directory.GetDirectories(path); } catch { } if (dirEntries == null) return; string mname; string type; foreach (string entry in dirEntries) { mname = GetLastStringToken(entry, dirSeparator); if (mname.Length > 0 && memberList.Search(mname, 0, 0) == null && re_token.IsMatch(mname)) { type = mname; if (package.Length > 0) type = package + "." + mname; memberList.Add(new MemberModel(mname, type, FlagType.Package, Visibility.Public)); } } }
/// <summary> /// Return the full project classes list /// </summary> /// <returns></returns> public override MemberList GetAllProjectClasses() { // from cache if (!completionCache.IsDirty && completionCache.AllTypes != null) return completionCache.AllTypes; MemberList fullList = new MemberList(); ClassModel aClass; MemberModel item; // public classes foreach (PathModel aPath in classPath) if (aPath.IsValid && !aPath.Updating) { aPath.ForeachFile((aFile) => { aClass = aFile.GetPublicClass(); if (!aClass.IsVoid() && aClass.IndexType == null && aClass.Access == Visibility.Public) { item = aClass.ToMemberModel(); item.Name = item.Type; fullList.Add(item); } return true; }); } // void fullList.Add(new MemberModel(features.voidKey, features.voidKey, FlagType.Class | FlagType.Intrinsic, 0)); // in cache fullList.Sort(); completionCache.AllTypes = fullList; return fullList; }
public override MemberList GetVisibleExternalElements(bool typesOnly) { MemberList visibleElements = new MemberList(); if (!IsFileValid) return visibleElements; // top-level elements if (!typesOnly && topLevel != null) { if (topLevel.OutOfDate) InitTopLevelElements(); visibleElements.Add(topLevel.Members); } if (completionCache.IsDirty || !typesOnly) { MemberList elements = new MemberList(); // root types & packages FileModel baseElements = ResolvePackage(null, false); if (baseElements != null) { elements.Add(baseElements.Imports); foreach(MemberModel decl in baseElements.Members) if ((decl.Flags & (FlagType.Class | FlagType.Enum | FlagType.TypeDef | FlagType.Abstract)) > 0) elements.Add(decl); } elements.Add(new MemberModel(features.voidKey, features.voidKey, FlagType.Class | FlagType.Intrinsic, 0)); bool qualify = Settings.CompletionShowQualifiedTypes && settings.GenerateImports; // other classes in same package if (features.hasPackages && cFile.Package != "") { int pLen = cFile.Package.Length; FileModel packageElements = ResolvePackage(cFile.Package, false); if (packageElements != null) { foreach (MemberModel member in packageElements.Imports) { if (member.Flags != FlagType.Package && member.Type.LastIndexOf('.') == pLen) { if (qualify) member.Name = member.Type; elements.Add(member); } } foreach (MemberModel member in packageElements.Members) { string pkg = member.InFile.Package; if (qualify && pkg != "") member.Name = pkg + "." + member.Name; elements.Add(member); } } } // other types in same file if (cFile.Classes.Count > 1) { ClassModel mainClass = cFile.GetPublicClass(); foreach (ClassModel aClass in cFile.Classes) { if (mainClass == aClass) continue; elements.Add(aClass.ToMemberModel()); if (!typesOnly && aClass.IsEnum()) elements.Add(aClass.Members); } } // imports MemberList imports = ResolveImports(CurrentModel); elements.Add(imports); if (!typesOnly) foreach (MemberModel import in imports) { if (import is ClassModel) { ClassModel aClass = import as ClassModel; if (aClass.IsEnum()) elements.Add(aClass.Members); } } elements.Sort(); // in cache if (typesOnly) { completionCache = new CompletionCache(this, elements); // known classes colorization if (!CommonSettings.DisableKnownTypesColoring && !settings.LazyClasspathExploration && CurSciControl != null) { try { CurSciControl.KeyWords(1, completionCache.Keywords); // additional-keywords index = 1 CurSciControl.Colourise(0, -1); // re-colorize the editor } catch (AccessViolationException) { } // catch memory errors } } visibleElements.Merge(elements); } else visibleElements.Merge(completionCache.Elements); return visibleElements; }
public virtual Method ChooseMethodMatchingDelegate(MemberList members, DelegateNode dt, TypeNodeList typeArguments){ if (members == null) return null; TypeNode drt = dt.ReturnType; ParameterList paramList = dt.Parameters; int numPars = paramList == null ? 0 : paramList.Count; MemberList eligibleMethods = new MemberList(); for (int i = 0, n = members.Count; i < n; i++){ Method m = members[i] as Method; if (m == null) continue; if (m.Parameters == null || m.Parameters.Count != numPars) continue; if (typeArguments != null){ if (m.TemplateParameters == null || m.TemplateParameters.Count == 0) continue; m = m.GetTemplateInstance(this.currentType, typeArguments); } if (numPars > 0 && m.TemplateParameters != null && m.TemplateParameters.Count > 0){ Method mti = this.InferMethodTemplateArgumentsAndReturnTemplateInstance(m, dt.Parameters); if (mti != null) m = mti; } if (this.NotEligible(m)) continue; if (!m.ParametersMatchStructurallyIncludingOutFlag(paramList, true)) continue; if (m.ReturnType == null || !(m.ReturnType.IsStructurallyEquivalentTo(drt) || (!m.ReturnType.IsValueType && this.GetTypeView(m.ReturnType).IsAssignableTo(drt)))) continue; eligibleMethods.Add(m); } if (eligibleMethods.Count == 0) return null; if (eligibleMethods.Count == 1) return (Method)eligibleMethods[0]; ExpressionList dummyArgs = new ExpressionList(dt.Parameters.Count); for (int i = 0, n = dt.Parameters.Count; i < n; i++) { Parameter par = dt.Parameters[i]; if (par == null || par.Type == null) continue; dummyArgs.Add(new Expression(NodeType.Nop, par.Type)); } return (Method)this.ResolveOverload(eligibleMethods, dummyArgs); }
internal MemberList GetSortedMembersList() { MemberList items = new MemberList(); foreach (MemberModel item in Members) if ((item.Flags & FlagType.Constructor) == 0) items.Add(item); items.Sort(); return items; }
/// <summary> /// Return a sorted list of the file /// </summary> /// <returns></returns> internal MemberList GetSortedMembersList() { MemberList items = new MemberList(); items.Add(Members); items.Sort(); return items; }
/// <summary> /// Return imported classes list (not null) /// </summary> /// <param name="package">Package to explore</param> /// <param name="inFile">Current file</param> public override MemberList ResolveImports(FileModel inFile) { if (inFile == cFile && completionCache.Imports != null) return completionCache.Imports; MemberList imports = new MemberList(); if (inFile == null) return imports; foreach (MemberModel item in inFile.Imports) { if (item.Name != "*") ResolveImport(item, imports); else { string cname = item.Type.Substring(0, item.Type.Length - 2); // classes matching wildcard FileModel matches = ResolvePackage(cname, false); if (matches != null) { foreach (MemberModel import in matches.Imports) imports.Add(import); foreach (MemberModel member in matches.Members) imports.Add(member); } else { var model = ResolveType(cname, null); if (!model.IsVoid()) { foreach (MemberModel member in model.Members) { if ((member.Flags & FlagType.Static) > 0) { member.InFile = model.InFile; imports.Add(member); } } } } } } if (inFile == cFile) { if (cClass != null && cClass != ClassModel.VoidClass) ResolveImport(cClass, imports); } else { foreach (ClassModel aClass in inFile.Classes) if (aClass.Access != Visibility.Private) ResolveImport(aClass, imports); } // haxe3: type resolution from bottom to top imports.Items.Reverse(); if (inFile == cFile) completionCache.Imports = imports; return imports; }
/// <summary> /// Find folder and classes in classpath /// </summary> /// <param name="folder">Path to eval</param> /// <param name="completeContent">Return package content</param> /// <returns>Package folders and classes</returns> public override MemberList FindPackage(string folder, bool completeContent) { if ((folder == null) || (folder.Length == 0)) return null; MemberList package = new MemberList(); MemberModel pathMember; string[] dirEntries; string cname; foreach(string path in classPath) try { if (System.IO.Directory.Exists(path+folder)) { // continue parsing? if (!completeContent) return package; // add sub packages dirEntries = System.IO.Directory.GetDirectories(path+folder); if (dirEntries != null) foreach(string entry in dirEntries) { cname = GetLastStringToken(entry, dirSeparator); if ((cname.Length > 0) && !cname.StartsWith("_") && (cname.IndexOf(' ') < 0) && (cname.IndexOf('.') < 0) && (package.Search(cname, 0) == null)) { pathMember = new MemberModel(); pathMember.Flags = FlagType.Package; pathMember.Type = folder.Replace(dirSeparatorChar, '.')+"."+cname; pathMember.Name = cname; package.Add(pathMember); } } // add sub classes dirEntries = System.IO.Directory.GetFiles(path+folder); if (dirEntries != null) foreach(string entry in dirEntries) if (entry.EndsWith(".as")) { cname = GetLastStringToken(entry, dirSeparator); cname = cname.Substring(0, cname.LastIndexOf(".")); pathMember = package.Search(cname, 0); if ((pathMember == null) && (cname.Length > 0) && (cname.IndexOf(' ') < 0) && (cname.IndexOf('.') < 0)) { pathMember = new MemberModel(); pathMember.Flags = 0; pathMember.Type = folder.Replace(dirSeparatorChar,'.')+"."+cname; pathMember.Name = cname; package.Add(pathMember); } } } } catch(Exception ex) { ErrorHandler.ShowError(ex.Message+"\n"+path+folder, ex); } // result if (package.Count > 0) { package.Sort(); return package; } else return null; }
/// <summary> /// Return the full project classes list /// </summary> /// <returns></returns> public override MemberList GetAllProjectClasses() { // from cache if (!completionCache.IsDirty && completionCache.AllTypes != null) return completionCache.AllTypes; MemberList fullList = new MemberList(); MemberModel item; // public & internal classes string package = CurrentModel.Package; foreach (PathModel aPath in classPath) if (aPath.IsValid && !aPath.Updating) { aPath.ForeachFile((aFile) => { string module = aFile.Module; bool needModule = true; if (aFile.Classes.Count > 0 && !aFile.Classes[0].IsVoid()) foreach (ClassModel aClass in aFile.Classes) { string tpackage = aClass.InFile.Package; if (aClass.IndexType == null && (aClass.Access == Visibility.Public || (aClass.Access == Visibility.Internal && tpackage == package))) { if (aClass.Name == module) needModule = false; item = aClass.ToMemberModel(); //if (tpackage != package) if (item.Type != null) item.Name = item.Type; fullList.Add(item); } } // HX files correspond to a "module" which should appear in code completion // (you don't import classes defined in modules but the module itself) if (needModule) { string qmodule = aFile.FullPackage; if (qmodule != null) { item = new MemberModel(qmodule, qmodule, FlagType.Class | FlagType.Module, Visibility.Public); fullList.Add(item); } } return true; }); } // display imported classes and classes declared in imported modules MemberList imports = ResolveImports(cFile); FlagType mask = FlagType.Class | FlagType.Enum; foreach (MemberModel import in imports) { if ((import.Flags & mask) > 0) { /*if (import is ClassModel) { MemberModel cmodel = (import as ClassModel).ToMemberModel(); cmodel.Name = cmodel.Type; fullList.Add(cmodel); } else*/ fullList.Add(import); } } foreach(ClassModel aClass in cFile.Classes) fullList.Add(aClass.ToMemberModel()); // in cache fullList.Sort(); completionCache.AllTypes = fullList; return fullList; }
/// <summary> /// Return the visible elements (types, package-level declarations) visible from the current file /// </summary> /// <returns></returns> public override MemberList GetVisibleExternalElements() { if (!IsFileValid) return new MemberList(); if (completionCache.IsDirty) { MemberList elements = new MemberList(); MemberList other = new MemberList(); // root types & packages FileModel baseElements = ResolvePackage(null, false); if (baseElements != null) { elements.Add(baseElements.Imports); foreach(MemberModel decl in baseElements.Members) if ((decl.Flags & (FlagType.Class | FlagType.Enum | FlagType.TypeDef | FlagType.Abstract)) > 0) elements.Add(decl); } elements.Add(new MemberModel(features.voidKey, features.voidKey, FlagType.Class | FlagType.Intrinsic, 0)); // other classes in same package (or parent packages!) if (features.hasPackages && cFile.Package != "") { string package = cFile.Package; do { int pLen = package.Length; FileModel packageElements = ResolvePackage(package, false); if (packageElements != null) { foreach (MemberModel member in packageElements.Imports) { if (member.Flags != FlagType.Package && member.Type.LastIndexOf('.') == pLen) { //if (qualify) member.Name = member.Type; elements.Add(member); } } foreach (MemberModel member in packageElements.Members) { string pkg = member.InFile.Package; //if (qualify && pkg != "") member.Name = pkg + "." + member.Name; member.Type = pkg != "" ? pkg + "." + member.Name : member.Name; elements.Add(member); } } int p = package.LastIndexOf('.'); // parent package if (p < 0) break; package = package.Substring(0, p); } while (true); } // other types in same file if (cFile.Classes.Count > 1) { ClassModel mainClass = cFile.GetPublicClass(); foreach (ClassModel aClass in cFile.Classes) { if (mainClass == aClass) continue; elements.Add(aClass.ToMemberModel()); if (aClass.IsEnum()) other.Add(aClass.Members); } } // imports MemberList imports = ResolveImports(CurrentModel); elements.Add(imports); foreach (MemberModel import in imports) { if (import is ClassModel) { ClassModel aClass = import as ClassModel; if (aClass.IsEnum()) other.Add(aClass.Members); } } // in cache elements.Sort(); other.Sort(); completionCache = hxCompletionCache = new HaxeCompletionCache(this, elements, other); // known classes colorization if (!CommonSettings.DisableKnownTypesColoring && !settings.LazyClasspathExploration && CurSciControl != null) { try { CurSciControl.KeyWords(1, completionCache.Keywords); // additional-keywords index = 1 CurSciControl.Colourise(0, -1); // re-colorize the editor } catch (AccessViolationException) { } // catch memory errors } } return completionCache.Elements; }
private void ResolveImport(MemberModel item, MemberList imports) { if (settings.LazyClasspathExploration) { imports.Add(item); return; } // HX files are "modules": when imported all the classes contained are available string fileName = item.Type.Replace(".", dirSeparator) + ".hx"; if (fileName.StartsWithOrdinal("flash" + dirSeparator)) { if (HaxeTarget != "flash" || majorVersion > 8) // flash9 remap fileName = FLASH_NEW + fileName.Substring(5); else fileName = FLASH_OLD + fileName.Substring(5); } bool matched = false; foreach (PathModel aPath in classPath) if (aPath.IsValid && !aPath.Updating) { string path; path = aPath.Path + dirSeparator + fileName; FileModel file = null; // cached file if (aPath.HasFile(path)) { file = aPath.GetFile(path); if (file.Context != this) { // not associated with this context -> refresh file.OutOfDate = true; file.Context = this; } } if (file != null) { // add all public classes of Haxe modules foreach (ClassModel c in file.Classes) if (c.IndexType == null && c.Access == Visibility.Public) imports.Add(c); matched = true; } } if (!matched) // add anyway imports.Add(new MemberModel(item.Name, item.Type, FlagType.Class, Visibility.Public)); }
public virtual MemberList GetOperatorOverloadsNamed(Identifier id, TypeNode t){ while (t != null){ MemberList members = this.GetTypeView(t).GetMembersNamed(id); int n = members == null ? 0 : members.Count; if (n > 0){ int eligibleMembers = 0; for (int i = 0; i < n; i++){ Method m = members[i] as Method; if (m == null || !m.IsSpecialName) continue; eligibleMembers++; } if (eligibleMembers == n) return members; if (eligibleMembers > 0){ MemberList filteredMembers = new MemberList(eligibleMembers); for (int i = 0; i < n; i++){ Method m = members[i] as Method; if (m == null || !m.IsSpecialName) continue; filteredMembers.Add(m); } return filteredMembers; } } t = t.BaseType; } return null; }
public virtual MemberList GetMembers(Expression expression){ MemberList backupReturn = new MemberList(0); switch(expression.NodeType){ case NodeType.Composition: Composition c = (Composition)expression; return this.GetMembers(c.Expression); case NodeType.Indexer: Indexer indxr = (Indexer)expression; Expression obj = this.VisitExpression(indxr.Object); indxr.Operands = this.VisitExpressionList(indxr.Operands); if (obj != null){ TypeNode t = this.typeSystem.Unwrap(obj.Type); if (t != null) return this.GetTypeView(t).DefaultMembers; } break; case NodeType.MemberBinding:{ MemberBinding mb = (MemberBinding)expression; mb.TargetObject = this.VisitExpression(mb.TargetObject); MemberList members = new MemberList(1); if (mb.BoundMember != null && mb.BoundMember.Name != Looker.NotFound) members.Add(mb.BoundMember); return members;} case NodeType.TemplateInstance:{ TemplateInstance instance = (TemplateInstance)expression; MemberList templates = this.GetMembers(instance.Expression); MemberList instances = new MemberList(); TypeNodeList tArgs = this.VisitTypeReferenceList(instance.TypeArguments); int numtArgs = tArgs == null ? 0 : tArgs.Count; for (int i = 0, n = templates == null ? 0 : templates.Count; i < n; i++) { Method meth = templates[i] as Method; if (meth == null) continue; if (meth.TemplateParameters == null || meth.TemplateParameters.Count != numtArgs) continue; instances.Add(meth.GetTemplateInstance(this.currentType, tArgs)); } if (instances.Count != 0) return instance.BoundMembers = instances; if (templates != null) templates = (MemberList)templates.Clone(); for (int i = 0, n = templates == null ? 0 : templates.Count; i < n; i++){ Method meth = templates[i] as Method; if (meth == null) continue; if (meth.TemplateParameters == null || meth.TemplateParameters.Count == 0) continue; templates[i] = meth.GetTemplateInstance(this.currentType, tArgs); } return instance.BoundMembers = templates;} case NodeType.NameBinding: return ((NameBinding)expression).BoundMembers; case NodeType.QualifiedIdentifer: QualifiedIdentifier qual = (QualifiedIdentifier)expression; Identifier id = qual.Identifier; Identifier prefix = id.Prefix; qual.Qualifier = this.VisitExpression(qual.Qualifier); if (qual.Qualifier == null) break; TypeNode qualifierType = TypeNode.StripModifiers(qual.Qualifier.Type); TypeNode lookupType = qualifierType; if (lookupType == SystemTypes.Type) { Literal literal = qual.Qualifier as Literal; if (literal != null) lookupType = (TypeNode)literal.Value; } lookupType = this.typeSystem.UnwrapForMemberLookup(lookupType); Interface iface = lookupType as Interface; if (iface != null) return ((Interface)this.GetTypeView(iface)).GetAllMembersNamed(id); ClassParameter cp = lookupType as ClassParameter; if (cp != null) return ((ClassParameter)this.GetTypeView(cp)).GetAllMembersNamed(id); while (lookupType != null){ lookupType = this.typeSystem.UnwrapForMemberLookup(lookupType); MemberList result = this.GetTypeView(lookupType).GetMembersNamed(id); if (result != null){ int n = result.Count; if (n > 0 && backupReturn.Count == 0) backupReturn = result; if (prefix != null){ for (int i = 0, m = n; i < m; i++){ Member mem = result[i]; Identifier uri = this.GetUriNamespaceFor(mem); if (uri == null || uri.UniqueIdKey != prefix.UniqueIdKey) n--; } } for (int i = 0, m = n; i < m; i++) { Member mem = result[i]; TypeNode tn = qualifierType; Reference rtn = tn as Reference; if (rtn != null) { tn = rtn.ElementType; } if (!(mem is InstanceInitializer) && Checker.NotAccessible(mem, ref tn, this.currentModule, this.currentType, this.TypeViewer)) { n--; continue; } Method meth = mem as Method; if (meth != null && meth.ImplementedTypeExpressions != null && meth.ImplementedTypeExpressions.Count > 0) n--; else { Property prop = mem as Property; if (prop != null && prop.ImplementedTypeExpressions != null && prop.ImplementedTypeExpressions.Count > 0) n--; } } if (n > 0) return result; } lookupType = lookupType.BaseType; } break; } return backupReturn; }
/// <summary> /// Return imported classes list (not null) /// </summary> /// <param name="package">Package to explore</param> /// <param name="inFile">Current file</param> public override MemberList ResolveImports(FileModel inFile) { if (inFile == cFile && completionCache.Imports != null) return completionCache.Imports; MemberList imports = new MemberList(); if (inFile == null) return imports; bool filterImports = (inFile == cFile) && inFile.Classes.Count > 1; int lineMin = (filterImports && inPrivateSection) ? inFile.PrivateSectionIndex : 0; int lineMax = (filterImports && inPrivateSection) ? int.MaxValue : inFile.PrivateSectionIndex; foreach (MemberModel item in inFile.Imports) { if (filterImports && (item.LineFrom < lineMin || item.LineFrom > lineMax)) continue; if (item.Name != "*") { if (settings.LazyClasspathExploration) imports.Add(item); else { ClassModel type = ResolveType(item.Type, null); if (!type.IsVoid()) imports.Add(type); else { // package-level declarations int p = item.Type.LastIndexOf('.'); if (p < 0) continue; string package = item.Type.Substring(0, p); string token = item.Type.Substring(p+1); FileModel pack = ResolvePackage(package, false); if (pack == null) continue; MemberModel member = pack.Members.Search(token, 0, 0); if (member != null) imports.Add(member); } } } else { // classes matching wildcard FileModel matches = ResolvePackage(item.Type.Substring(0, item.Type.Length - 2), false); if (matches != null) { foreach (MemberModel import in matches.Imports) imports.Add(import); foreach (MemberModel member in matches.Members) imports.Add(member); } } } if (inFile == cFile) completionCache.Imports = imports; return imports; }
/// <summary> /// Search all base packages (com, net, org,...) in classpath /// </summary> /// <returns>Base packages list as members</returns> public override MemberList GetBasePackages() { MemberList packages = new MemberList(); MemberModel package; string[] dirEntries; string[] fileEntries; string cname; string upPath; string mmCP = MMClassPath.ToUpper(); string mtascCP = mtascRootFolder.ToUpper(); bool notMacromedia; bool notMTASC; foreach(string path in classPath) try { upPath = path.ToUpper(); notMacromedia = (mmCP.Length == 0) || !upPath.StartsWith(mmCP); notMTASC = (mtascCP.Length == 0) || !upPath.StartsWith(mtascCP); // base classes if (notMacromedia && notMTASC) { fileEntries = System.IO.Directory.GetFiles(path, "*.as"); if (fileEntries != null) foreach(string entry in fileEntries) { cname = GetLastStringToken(entry, dirSeparator); int p = cname.LastIndexOf('.'); cname = cname.Substring(0,p); if (!cname.StartsWith("_") && (cname.IndexOf('.') < 0) && (cname.IndexOf(' ') < 0) && (packages.Search(cname, 0) == null)) { //DebugConsole.Trace("Base class "+cname); package = new MemberModel(); package.Flags = 0; package.Type = package.Name = cname; packages.Add(package); } } } // base packages if (notMacromedia) { dirEntries = System.IO.Directory.GetDirectories(path); if (dirEntries != null) foreach(string entry in dirEntries) { cname = GetLastStringToken(entry, dirSeparator); if (!cname.StartsWith("_") && (cname.IndexOf(' ') < 0) && (cname.IndexOf('.') < 0) && (packages.Search(cname, 0) == null)) { //DebugConsole.Trace("Base package "+cname); package = new MemberModel(); package.Flags = FlagType.Package; package.Type = package.Name = cname; packages.Add(package); } } } else if (packages.Search("mx", 0) == null) { package = new MemberModel(); package.Flags = FlagType.Package; package.Type = package.Name = "mx"; packages.Add(package); } } catch(Exception ex) { ErrorHandler.ShowError(ex.Message+"\n"+path, ex); } packages.Sort(); return packages; }
/// <summary> /// Return imported classes list (not null) /// </summary> /// <param name="package">Package to explore</param> /// <param name="inFile">Current file</param> public override MemberList ResolveImports(FileModel inFile) { bool filterImports = (inFile == cFile) && inFile.Classes.Count > 1; int lineMin = (filterImports && inPrivateSection) ? inFile.PrivateSectionIndex : 0; int lineMax = (filterImports && inPrivateSection) ? int.MaxValue : inFile.PrivateSectionIndex; MemberList imports = new MemberList(); foreach (MemberModel item in inFile.Imports) { if (filterImports && (item.LineFrom < lineMin || item.LineFrom > lineMax)) continue; ClassModel type = ResolveType(item.Type, null); if (!type.IsVoid()) imports.Add(type); else { // package-level declarations FileModel matches = ResolvePackage(item.Type, false); if (matches != null) { foreach (MemberModel import in matches.Imports) imports.Add(import); foreach (MemberModel member in matches.Members) imports.Add(member); } } } return imports; }
/// <summary> /// Return the full project classes list /// </summary> /// <returns></returns> public override MemberList GetAllProjectClasses() { // from cache if (!completionCache.IsDirty && completionCache.AllTypes != null) return completionCache.AllTypes; MemberList fullList = new MemberList(); MemberModel item; // public & internal classes string package = CurrentModel.Package; foreach (PathModel aPath in classPath) if (aPath.IsValid && !aPath.Updating) { aPath.ForeachFile((aFile) => { if (!aFile.HasPackage) return true; // skip foreach(ClassModel aClass in aFile.Classes) if (!aClass.IsVoid() && aClass.IndexType == null) { if (aClass.Access == Visibility.Public || (aClass.Access == Visibility.Internal && aFile.Package == package)) { item = aClass.ToMemberModel(); item.Name = item.Type; fullList.Add(item); } } if (aFile.Package.Length > 0 && aFile.Members.Count > 0) { foreach (MemberModel member in aFile.Members) { item = member.Clone() as MemberModel; item.Name = aFile.Package + "." + item.Name; fullList.Add(item); } } else if (aFile.Members.Count > 0) { foreach (MemberModel member in aFile.Members) { item = member.Clone() as MemberModel; fullList.Add(item); } } return true; }); } // void fullList.Add(new MemberModel(features.voidKey, features.voidKey, FlagType.Class | FlagType.Intrinsic, 0)); // private classes fullList.Add(GetPrivateClasses()); // in cache fullList.Sort(); completionCache.AllTypes = fullList; return fullList; }
/// <summary> /// Returns parameters string as member list /// </summary> /// <param name="parameters">Method parameters</param> /// <returns>Member list</returns> static private MemberList ParseMethodParameters(string parameters) { MemberList list = new MemberList(); if (parameters == null) return list; int p = parameters.IndexOf('('); if (p >= 0) parameters = parameters.Substring(p + 1, parameters.IndexOf(')') - p - 1); parameters = parameters.Trim(); if (parameters.Length == 0) return list; string[] sparam = parameters.Split(','); string[] parType; MemberModel param; char[] toClean = new char[] { ' ', '\t', '\n', '\r', '*', '?' }; foreach (string pt in sparam) { parType = pt.Split(':'); param = new MemberModel(); param.Name = parType[0].Trim(toClean); if (param.Name.Length == 0) continue; if (parType.Length == 2) param.Type = parType[1].Trim(); else param.Type = ASContext.Context.Features.objectKey; param.Flags = FlagType.Variable | FlagType.Dynamic; list.Add(param); } return list; }
internal void OnDotCompletionResult(HaXeCompletion hc, ArrayList al) { resolvingDot = false; if (al == null || al.Count == 0) return; // haxe.exe not found ScintillaNet.ScintillaControl sci = hc.sci; MemberList list = new MemberList(); string outputType = al[0].ToString(); if (outputType == "error") { string err = al[1].ToString(); TraceManager.AddAsync(err, -3); //sci.CallTipShow(sci.CurrentPos, err); //sci.CharAdded += new ScintillaNet.CharAddedHandler(removeTip); // show default completion tooltip if (!hxsettings.DisableMixedCompletion) return; } else if (outputType == "list") { foreach (ArrayList i in al[1] as ArrayList) { string var = i[0].ToString(); string type = i[1].ToString(); string desc = i[2].ToString(); FlagType flag = FlagType.Variable; MemberModel member = new MemberModel(); member.Name = var; member.Access = Visibility.Public; member.Comments = desc; var p1 = desc.IndexOf('\r'); var p2 = desc.IndexOf('\n'); // Package or Class if (type == "") { string bl = var.Substring(0, 1); if (bl == bl.ToLower()) flag = FlagType.Package; else flag = FlagType.Class; } // Function or Variable else { Array types = type.Split(new string[] { "->" }, StringSplitOptions.RemoveEmptyEntries); // Function if (types.Length > 1) { flag = FlagType.Function; // Function's arguments member.Parameters = new List<MemberModel>(); int j = 0; while (j < types.Length - 1) { MemberModel param = new MemberModel(types.GetValue(j).ToString(), "", FlagType.ParameterVar, Visibility.Public); member.Parameters.Add(param); j++; } // Function's return type member.Type = types.GetValue(types.Length - 1).ToString(); } // Variable else { flag = FlagType.Variable; // Variable's type member.Type = type; } } member.Flags = flag; list.Add(member); } } // update completion if (list.Count > 0) { list.Sort(); ASComplete.DotContextResolved(sci, hc.expr, list, hc.autoHide); } }
public virtual Differences VisitMemberList(MemberList list1, MemberList list2, out MemberList changes, out MemberList deletions, out MemberList insertions){ changes = list1 == null ? null : list1.Clone(); deletions = list1 == null ? null : list1.Clone(); insertions = list1 == null ? new MemberList() : list1.Clone(); //^ assert insertions != null; Differences differences = new Differences(); //Compare definitions that have matching key attributes TrivialHashtable matchingPosFor = new TrivialHashtable(); TrivialHashtable matchedNodes = new TrivialHashtable(); for (int j = 0, n = list2 == null ? 0 : list2.Count; j < n; j++){ //^ assert list2 != null; Member nd2 = list2[j]; if (nd2 == null || nd2.Name == null) continue; string fullName = nd2.FullName; if (fullName == null) continue; matchingPosFor[Identifier.For(fullName).UniqueIdKey] = j; insertions.Add(null); } for (int i = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){ //^ assert list1 != null && changes != null && deletions != null; Member nd1 = list1[i]; if (nd1 == null || nd1.Name == null) continue; string fullName = nd1.FullName; if (fullName == null) continue; object pos = matchingPosFor[Identifier.For(fullName).UniqueIdKey]; if (!(pos is int)) continue; //^ assert pos != null; //^ assume list2 != null; //since there was entry int matchingPosFor int j = (int)pos; Member nd2 = list2[j]; //^ assume nd2 != null; //nd1 and nd2 have the same key attributes and are therefore treated as the same entity matchedNodes[nd1.UniqueKey] = nd1; matchedNodes[nd2.UniqueKey] = nd2; //nd1 and nd2 may still be different, though, so find out how different Differences diff = this.VisitMember(nd1, nd2); if (diff == null){Debug.Assert(false); continue;} if (diff.NumberOfDifferences != 0){ changes[i] = diff.Changes as Member; deletions[i] = diff.Deletions as Member; insertions[i] = diff.Insertions as Member; insertions[n+j] = nd1; //Records the position of nd2 in list2 in case the change involved a permutation Debug.Assert(diff.Changes == changes[i] && diff.Deletions == deletions[i] && diff.Insertions == insertions[i]); differences.NumberOfDifferences += diff.NumberOfDifferences; differences.NumberOfSimilarities += diff.NumberOfSimilarities; if ((nd1.DeclaringType != null && nd1.DeclaringType.DeclaringModule == this.OriginalModule) || (nd1 is TypeNode && ((TypeNode)nd1).DeclaringModule == this.OriginalModule)){ if (this.MembersThatHaveChanged == null) this.MembersThatHaveChanged = new MemberList(); this.MembersThatHaveChanged.Add(nd1); } continue; } changes[i] = null; deletions[i] = null; insertions[i] = null; insertions[n+j] = nd1; //Records the position of nd2 in list2 in case the change involved a permutation } //Find deletions for (int i = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){ //^ assert list1 != null && changes != null && deletions != null; Member nd1 = list1[i]; if (nd1 == null) continue; if (matchedNodes[nd1.UniqueKey] != null) continue; changes[i] = null; deletions[i] = nd1; insertions[i] = null; differences.NumberOfDifferences += 1; if ((nd1.DeclaringType != null && nd1.DeclaringType.DeclaringModule == this.OriginalModule) || (nd1 is TypeNode && ((TypeNode)nd1).DeclaringModule == this.OriginalModule)){ if (this.MembersThatHaveChanged == null) this.MembersThatHaveChanged = new MemberList(); this.MembersThatHaveChanged.Add(nd1); } } //Find insertions for (int j = 0, n = list1 == null ? 0 : list1.Count, m = list2 == null ? 0 : list2.Count; j < m; j++){ //^ assert list2 != null; Member nd2 = list2[j]; if (nd2 == null) continue; if (matchedNodes[nd2.UniqueKey] != null) continue; insertions[n+j] = nd2; //Records nd2 as an insertion into list1, along with its position in list2 differences.NumberOfDifferences += 1; //REVIEW: put the size of the tree here? } if (differences.NumberOfDifferences == 0){ changes = null; deletions = null; insertions = null; } return differences; }
private void PopulateClassesEntries(string package, string path, MemberList memberList) { string[] fileEntries = null; try { fileEntries = System.IO.Directory.GetFiles(path, "*" + settings.DefaultExtension); } catch { } if (fileEntries == null) return; string mname; string type; FlagType flag = FlagType.Class | ((package == null) ? FlagType.Intrinsic : 0); foreach (string entry in fileEntries) { mname = GetLastStringToken(entry, dirSeparator); mname = mname.Substring(0, mname.LastIndexOf(".")); if (mname.Length > 0 && memberList.Search(mname, 0, 0) == null && re_token.IsMatch(mname)) { type = mname; if (package.Length > 0) type = package + "." + mname; memberList.Add(new MemberModel(mname, type, flag, Visibility.Public)); } } }
protected virtual void GetDataMembers(TypeNode type, MemberList list){ if (type == null) return; if (type.BaseType != SystemTypes.Object) this.GetDataMembers(type.BaseType, list); MemberList tMembers = type.Members; for (int i = 0, n = tMembers == null ? 0 : tMembers.Count; i < n; i++ ){ Member m = tMembers[i]; if ((m is Field || m is Property) && m.IsPublic) list.Add(m); } }
protected MemberList GetPrivateClasses() { MemberList list = new MemberList(); // private classes foreach(ClassModel model in cFile.Classes) if (model.Access == Visibility.Private) { MemberModel item = model.ToMemberModel(); item.Type = item.Name; item.Access = Visibility.Private; list.Add(item); } // 'Class' members if (cClass != null) foreach (MemberModel member in cClass.Members) if (member.Type == "Class") list.Add(member); return list; }
/// <summary> /// Return imported classes list (not null) /// </summary> /// <param name="package">Package to explore</param> /// <param name="inFile">Current file</param> public override MemberList ResolveImports(FileModel inFile) { if (inFile == cFile && completionCache.Imports != null) return completionCache.Imports; MemberList imports = new MemberList(); if (inFile == null) return imports; foreach (MemberModel item in inFile.Imports) { if (settings.LazyClasspathExploration) { imports.Add(item); continue; } // HX files are "modules": when imported all the classes contained are available string fileName = item.Type.Replace(".", dirSeparator) + ".hx"; if (fileName.StartsWith("flash" + dirSeparator)) { if (!IsFlashTarget || majorVersion > 8) // flash9 remap fileName = FLASH_NEW + fileName.Substring(5); else fileName = FLASH_OLD + fileName.Substring(5); } bool matched = false; foreach (PathModel aPath in classPath) if (aPath.IsValid && !aPath.Updating) { string path; try { path = Path.Combine(aPath.Path, fileName); } catch { continue; } FileModel file = null; // cached file if (aPath.HasFile(path)) { file = aPath.GetFile(path); if (file.Context != this) { // not associated with this context -> refresh file.OutOfDate = true; file.Context = this; } } else if (File.Exists(path)) { file = GetFileModel(path); if (file != null) aPath.AddFile(file); } if (file != null) { // add all classes (Haxe module) foreach (ClassModel c in file.Classes) if (c.IndexType == null) imports.Add(c); matched = true; } } if (!matched) // add anyway imports.Add(new MemberModel(item.Name, item.Type, FlagType.Class, Visibility.Public)); } // haxe3: type resolution from bottom to top imports.Items.Reverse(); if (inFile == cFile) completionCache.Imports = imports; return imports; }
private static MemberList GetMembers(List<MemberInfo> abcMembers, FlagType baseFlags, QName instName) { MemberList list = new MemberList(); string package = instName.uri; string protect = instName.ToString(); foreach (MemberInfo info in abcMembers) { MemberModel member = GetMember(info, baseFlags); if (member == null) continue; string uri = info.name.uri ?? ""; if (uri.Length > 0) { if (uri == "private" || package == "private") { continue; } else if (uri == protect) { member.Access = Visibility.Protected; member.Namespace = "protected"; } else if (uri == package) { member.Access = Visibility.Internal; member.Namespace = "internal"; } else if (uri == "http://adobe.com/AS3/2006/builtin") { member.Access = Visibility.Public; member.Namespace = "AS3"; } else if (uri == "http://www.adobe.com/2006/flex/mx/internal") { continue; } else if (uri == "http://www.adobe.com/2006/actionscript/flash/proxy") { member.Access = Visibility.Public; member.Namespace = "flash_proxy"; } else if (uri == "http://www.adobe.com/2006/actionscript/flash/objectproxy") { member.Access = Visibility.Public; member.Namespace = "object_proxy"; } else // unknown namespace { member.Access = Visibility.Public; member.Namespace = "internal"; } } if (thisDocs != null) GetMemberDoc(member); list.Add(member); } return list; }