TypeInfo: a way to reach the anonymous and local classes declared in a type's bodies
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 49/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- java
- Área
- developer-experience, tooling
Línea de trabajo
Start by tracing how ParseConstructorCall and ParseTypeDeclaration create TypeInfo for anonymous and local classes, then inspect TypeInfo.subTypes() and recursiveSubTypeStream(). The issue proposes storing those classes in declaration order or exposing a body-walking stream; choose an approach that preserves subTypes() as member types only. Done when callers can discover nested anonymous and local classes recursively, including the example loop, without each writing its own body walk.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What is missing
TypeInfo.subTypes() returns the member types, and recursiveSubTypeStream() is built on it. Anonymous classes (new T() { … }) and local classes (declared in a method body) are not in either: ParseConstructorCall and ParseTypeDeclaration give them a TypeInfo with an enclosing type and a stable index (getAndIncrementAnonymousTypes), but nothing adds them to the enclosing type, so the only way to find them is to visit every method body and field initializer for ConstructorCall.anonymousClass() and LocalTypeDeclaration.typeInfo(), recursively.
Every tool that wants "all the code in this compilation unit" (a search over methods, a rewrite of loop bodies, a census of calls) rediscovers this the hard way: a loop inside
return new HttpResponse() {
@Override
public void generateResponse(StaplerRequest2 req, StaplerResponse2 rsp, Object node) {
for (Map.Entry<String, String> header : headers.entrySet()) {
rsp.setHeader(header.getKey(), header.getValue());
}
}
};
is simply never seen when the tool walks primary.recursiveSubTypeStream().flatMap(TypeInfo::constructorAndMethodStream). In a large code base (Jenkins core) this hid a few percent of the sites of one rewrite.
Proposal
Either of:
TypeInfo.localTypes(): the anonymous and local classes whose enclosing type this is, in declaration order, filled by the parser at the two places that mint them; and arecursiveSubTypeStreamIncludingLocal()(or a boolean parameter) that descends into them as it does into member types; or- a documented
TypeInfo.anonymousAndLocalTypeStream()that performs the body walk once, in the API, so that callers do not each write it.
The first is cheaper for callers and keeps subTypes() as it is (member types only), which some callers surely depend on.
Workaround used
A helper that walks constructorAndMethodStream() bodies and field initializers with Element.visit, collecting ConstructorCall.anonymousClass() and LocalTypeDeclaration.typeInfo() into a queue, deduplicated by identity, until the queue is empty.
Seen on 0.9.5-alpha.13.
- Lenguaje dominante
- Java
- Estrellas
- 1
- Forks
- 1
- Merge medio
- 1 h 13 min
- PR fusionados (30 d)
- 6
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de CodeLaser/maddi
-
Javadoc warnings are the only noise on an otherwise clean CI runPosiblemente ocupada @jayeshamundkar06-bit la tomó hace 5 días. Abiertobuild/ci good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
CodeLaser/maddi#4 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
front-end:csharp
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 61/100
CodeLaser/maddi#185 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 14/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
Todos los issues de CodeLaser/maddi
Issues similares
-
bug subsystem:agent-harness triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
ShaftHQ/SHAFT_ENGINE#7797 ·
Los mantenedores suelen responder en 1 día
-
ARM: Q flag should be stickyAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
NationalSecurityAgency/ghidra#10155 ·
Los mantenedores suelen responder en 2 días
-
bug web-ui
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
jenkinsci/jenkins#27705 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
"item-tooltip-keyboard-fix" crashes the game when opening the Items tab of the statistics menuAbiertomod bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
elmital/FixMCStats#65 · 3 comentarios ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
QuranHub/quranhub-android#354 ·
Los mantenedores suelen responder en 2 días