Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

javadoc for gestalt-inject-java #158

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

javadoc for gestalt-inject-java #158

wants to merge 1 commit into from

Conversation

soloturn
Copy link
Contributor

No description provided.

@soloturn soloturn requested a review from BenjaminAmos January 19, 2025 14:31
Copy link
Contributor

@BenjaminAmos BenjaminAmos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a first-pass review. I have not looked over everything yet and will carry-on another time. It should be enough to start with.

@@ -12,22 +12,38 @@
import java.util.HashSet;
import java.util.Map;

/**
* Class to write annotation types.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AnnotationTypeWriter class is responsible for writing to files under META-INF/annotations listing which classes are annotated with a particular annotation. For example, types annotated with @IndexInherited would be listed in META-INF/annotations/org.terasology.context.annotation.IndexInherited.

public class AnnotationTypeWriter {
private static final String META_INF = "META-INF/annotations";

private final Filer filer;
private final Map<String, HashSet<String>> results = new HashMap<>();
private final Map<String, FileObject> files = new HashMap<>();

/**
* Creates a AnnotationTypeWriter to write an annotation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Creates a AnnotationTypeWriter to write an annotation.
* Creates an AnnotationTypeWriter.

Short and not very useful but this constructor doesn't do much anyway. This is probably enough.

Comment on lines +34 to +36
* Writes an annotation to a service.
* @param service the service to write.
* @param target the target.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not actually do any writing to files yet, so I will admit that the name is misleading. What it does is register that a given class should be associated as being annotated by a given annotation (aka. service).

In this instance, a service refers to a particular annotation type. So, the service parameter would be the fully-qualified type name of the annotation.

The target is the target class that was annotated with that annotation.

public void writeAnnotation(String service, String target) {
results.putIfAbsent(service, new HashSet<>());
results.get(service).add(target);
}

/**
* Writes class to file.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Writes class to file.
* Writes out annotation-class mappings to files.

@@ -66,13 +69,23 @@ public class BeanDefinitionProcessor extends AbstractProcessor {
};
private final Set<String> processed = new HashSet<>();
private final Set<String> beanDefinitions = new HashSet<>();
/**
* the elements.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elements refers to javax.lang.model.util.Elements. It is a set of utilities for manipulating Java syntax elements, not a collection of elements, as the name might misleadingly suggest.

@@ -86,11 +99,19 @@ public synchronized void init(ProcessingEnvironment processingEnvironment) {
this.utility = new ElementUtility(processingEnvironment.getElementUtils(), processingEnvironment.getTypeUtils());
}

/**
* {@return the supported annotation types.}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* {@return the supported annotation types.}
* {@inheritDoc}

This is an override from an already well-documented base method, so we might as well inherit that.

Comment on lines +111 to +113
* {@return true if bean definitions could be processes, fals otherwise.}
* @param annotations the annotations.
* @param environment the environment.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* {@return true if bean definitions could be processes, fals otherwise.}
* @param annotations the annotations.
* @param environment the environment.
* {@inheritDoc}

This is an override from an already well-documented base method, so we might as well inherit that.

@@ -20,6 +20,9 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
* Annotation processor to create resources for types.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Annotation processor to create resources for types.
* Annotation processor to list resources for types.

This processor does not create the resources, it just lists the resources that are there. We need to do this because listing resources packed in an APK on Android is prohibitively expensive.

@@ -11,23 +11,41 @@
import javax.lang.model.util.Types;
import java.util.List;

/**
* BenjaminAmos, pls proper description.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* BenjaminAmos, pls proper description.
* Utilities for discovering and distinguishing element types.

This is a utility class: convenient but just a mixture of related useful routines. Most projects have one somewhere, even if it's not considered the best programming practice sometimes.

@@ -24,6 +24,9 @@
import java.util.Queue;
import java.util.Set;

/**
* BenjaminAmos pls description which makes sense.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* BenjaminAmos pls description which makes sense.
* Records all types annotated with `@Index` or `@IndexInherited`, as well as all descendants of a type annotated with `@IndexInherited`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants