Exemple #1
0
 public static void m(Iterable<string> s) {
     var query = s.where(e => e.Length > 0);
 }
        public static ICompletionProposal[] createCompletionProposals(int offset, int length, String prefix, Iterable <String> packages,
                                                                      Iterable <MemberInfo> members, Iterable <String> texts)
        {
            var proposals = new ArrayList <ICompletionProposal>();

            foreach (var pkg in packages.where (p => p.startsWith(prefix)))
            {
                proposals.add(createPackage(offset, length, pkg.substring(prefix.length()), pkg));
            }

            foreach (var member in members)
            {
                switch (member.MemberKind)
                {
                case Type:
                    var Type = member.Type;
                    if (Type.Name.startsWith(prefix))
                    {
                        proposals.add(createType(offset, length, Type.Name.substring(prefix.length()), Type));
                    }
                    break;

                case Field:
                    var Field = member.Field;
                    if (Field.Name.startsWith(prefix))
                    {
                        proposals.add(createField(offset, length, Field.Name.substring(prefix.length()), Field));
                    }
                    break;

                case Property:
                    if (member.Name.startsWith(prefix))
                    {
                        proposals.add(createProperty(offset, length, member.Name.substring(prefix.length()), member));
                    }
                    break;

                case Method:
                    var Method = member.Method;
                    if (Method.Name.startsWith(prefix))
                    {
                        proposals.add(createMethod(offset, length, Method.Name.substring(prefix.length()), Method));
                    }
                    break;

                case Local:
                    if (member.Name.startsWith(prefix))
                    {
                        proposals.add(createLocal(offset, length, member.Name.substring(prefix.length()), member));
                    }
                    break;
                }
            }

            foreach (var text in texts.where (p => p.startsWith(prefix)))
            {
                proposals.add(createText(offset, length, text.substring(prefix.length()), text));
            }

            if (proposals.size() == 0)
            {
                return(createEmpty());
            }
            Collections.sort(proposals, completionProposalComparator);
            return(proposals.toArray(new ICompletionProposal[proposals.size()]));
        }