/** * Resolves a interface by a partial name within a given package context, following PB (== C++) * conventions. */ @Nullable public Interface resolveInterface(String inPackage, String name) { for (String cand : nameCandidates(inPackage, name)) { Interface endpointInterface = lookupInterface(cand); if (endpointInterface != null) { return endpointInterface; } } return null; }
/** * Resolves a interface by a partial name within a given package context, following PB (== C++) * conventions. */ @Nullable public Interface resolveInterface(String inPackage, String name) { for (String cand : nameCandidates(inPackage, name)) { Interface endpointInterface = lookupInterface(cand); if (endpointInterface != null) { return endpointInterface; } } return null; }
/** * Returns the candidates for name resolution of a name within a container(e.g. package, message, * enum, service elements) context following PB (== C++) conventions. Iterates those names which * shadow other names first; recognizes and removes a leading '.' for overriding shadowing. Given * a container name {@code a.b.c.M.N} and a type name {@code R.s}, this will deliver in order * {@code a.b.c.M.N.R.s, a.b.c.M.R.s, a.b.c.R.s, a.b.R.s, a.R.s, R.s}. */ public static Iterable<String> nameCandidates(String inContainer, String name) { // TODO(user): we may want to make this a true lazy iterable for performance. if (name.startsWith(".")) { return FluentIterable.from(ImmutableList.of(name.substring(1))); } if (inContainer.length() == 0) { return FluentIterable.from(ImmutableList.of(name)); } else { int i = inContainer.lastIndexOf('.'); return FluentIterable.from(ImmutableList.of(inContainer + "." + name)) .append(nameCandidates(i >= 0 ? inContainer.substring(0, i) : "", name)); } }
/** * Returns the candidates for name resolution of a name within a container(e.g. package, message, * enum, service elements) context following PB (== C++) conventions. Iterates those names which * shadow other names first; recognizes and removes a leading '.' for overriding shadowing. Given * a container name {@code a.b.c.M.N} and a type name {@code R.s}, this will deliver in order * {@code a.b.c.M.N.R.s, a.b.c.M.R.s, a.b.c.R.s, a.b.R.s, a.R.s, R.s}. */ public static Iterable<String> nameCandidates(String inContainer, String name) { // TODO(user): we may want to make this a true lazy iterable for performance. if (name.startsWith(".")) { return FluentIterable.from(ImmutableList.of(name.substring(1))); } if (inContainer.length() == 0) { return FluentIterable.from(ImmutableList.of(name)); } else { int i = inContainer.lastIndexOf('.'); return FluentIterable.from(ImmutableList.of(inContainer + "." + name)) .append(nameCandidates(i >= 0 ? inContainer.substring(0, i) : "", name)); } }
candidateNames = SymbolTable.nameCandidates(element.getFullName(), id); for (String candidateName : candidateNames) { if (protoElemFullNames.contains(candidateName)) {
candidateNames = SymbolTable.nameCandidates(element.getFullName(), id); for (String candidateName : candidateNames) { if (protoElemFullNames.contains(candidateName)) {
/** * Resolves a type by its partial name within a given package context, following PB (== C++) * conventions. If the given name is a builtin type name for a primitive type in the PB * language, a reference for that type will be returned. * * Note that this differs from the proto compiler in that it will continue searching if a * partial resolution fails; see resolveType2 for details. */ @Nullable public TypeRef resolveType(String inPackage, String name) { TypeRef type = TypeRef.fromPrimitiveName(name); if (type != null) { return type; } for (String cand : nameCandidates(inPackage, name)) { type = lookupType(cand); if (type != null) { return type; } } return null; }
/** * Resolves a type by its partial name within a given package context, following PB (== C++) * conventions. If the given name is a builtin type name for a primitive type in the PB * language, a reference for that type will be returned. * * Note that this differs from the proto compiler in that it will continue searching if a * partial resolution fails; see resolveType2 for details. */ @Nullable public TypeRef resolveType(String inPackage, String name) { TypeRef type = TypeRef.fromPrimitiveName(name); if (type != null) { return type; } for (String cand : nameCandidates(inPackage, name)) { type = lookupType(cand); if (type != null) { return type; } } return null; }
return resolveType(inPackage, name); for (String cand : nameCandidates(inPackage, firstComponent)) { TypeRef outerType = lookupType(cand); if (outerType != null) {
return resolveType(inPackage, name); for (String cand : nameCandidates(inPackage, firstComponent)) { TypeRef outerType = lookupType(cand); if (outerType != null) {