-
Notifications
You must be signed in to change notification settings - Fork 107
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
Use annotations for operation descriptions #851
Use annotations for operation descriptions #851
Conversation
Codecov Report
@@ Coverage Diff @@
## master #851 +/- ##
============================================
+ Coverage 51.45% 51.71% +0.25%
- Complexity 1146 1158 +12
============================================
Files 247 247
Lines 7956 7812 -144
Branches 531 533 +2
============================================
- Hits 4094 4040 -54
+ Misses 3677 3592 -85
+ Partials 185 180 -5 |
As an FYI the branch for CUDA support will be based on this for dependency injection |
* Creates an operation description from a {@link Description @Description} annotation on | ||
* an operation subclass. | ||
*/ | ||
public static OperationDescription from(Description description) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think (and I'm totally okay with being wrong) but I think this code could go inside of Description
because it is a fully qualified class and can have its own logic inside it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No can do. Annotation interfaces can't have methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, thats fine.
@Parameters(name = "{index}: Operation({0})") | ||
public static Collection<Object[]> data() { | ||
EventBus eventBus = new EventBus(); | ||
System.out.println("data()"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did PMD not find this...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think PMD runs on test files
Re-enable CompatibilityTest. Fix some backwards compatbility issues. Not really a fan of injecting the Injector into the Operations class. Need to see if there's a better solution
5f1d0c6
to
aaed76b
Compare
|
||
import com.google.common.collect.ImmutableList; | ||
import com.google.inject.Inject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use javax.inject.Inject
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer JSR-330's annotations and Provider interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. That's going to be a lot of code changed because both are used everywhere. Should probably add a checkstyle rule for this in a different PR
@@ -11,6 +11,7 @@ | |||
* {@link Size}s are converted into this. | |||
*/ | |||
@Immutable | |||
@PublishableProxy({Point.class, Size.class}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to use the constructor parameter to get the type?
Any reason why the type should be specified in the parameter and in the annotation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could iterate over all public constructors, but I like how this specifies exactly what's being proxied. It could also run into issues with publicly accessible helper constructors eg Vector2D(double, double)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine. This makes sense.
// @Parameters is called before @BeforeClass, so we call it manually in a static initializer block | ||
// @BeforeClass | ||
public static void setUpClass() { | ||
System.out.println("setUpClass"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still needs to be addressed.
|
||
@AfterClass | ||
public static void tearDownClass() { | ||
System.out.println("tearDownClass()"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still needs to be addressed.
OperationsFactory.create(eventBus).addOperations(); | ||
//CVOperations.addOperations(eventBus); | ||
OperationsFactory.create(eventBus, injector).addOperations(); | ||
OperationsFactory.createCV(eventBus).addOperations(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this commented out before?
@@ -405,9 +405,6 @@ | |||
<grip:Input step="34" socket="1"> | |||
<value>COLOR_BGR2GRAY</value> | |||
</grip:Input> | |||
<grip:Input step="34" socket="2"> | |||
<value>0.0</value> | |||
</grip:Input> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was incompatible with the new version of the operation. I think the compatibility test was disabled for so long that it was never picked up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😱
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So somewhere along the way we had a breaking change that we never did a major version bump for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any update on this?
@JLLeitschuh want to revisit this? |
|
||
/** | ||
* The name of the icon to use to display the operation. If empty ({@code ""}), no icon will be | ||
* shown. The icon should be located in {@code /edu/wpi/grip/ui/icons/}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the right use of this javadoc annotation? Does it render correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's just a shortcut for <code>...</code>
@@ -125,7 +136,7 @@ public void convert(J javaType, Message message, MessageFactory messageFactory) | |||
} | |||
|
|||
private abstract static class SimpleConverter<J, M extends Message> extends | |||
JavaToMessageConverter<J, M> { | |||
JavaToMessageConverter<J, M> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this whitespace diff here?
@@ -61,7 +62,12 @@ public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext co | |||
.getOperationByName(operationName); | |||
|
|||
if (!operationMetaData.isPresent()) { | |||
throw new ConversionException("Unknown operation: " + operationName); | |||
throw new ConversionException(String.format("Unknown operation: %s. Known operations: %s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps "Unknown operation: %s. did not match any known operations: %s"
@@ -27,7 +27,8 @@ public CoreSanityTest() { | |||
ManualPipelineRunner.class, | |||
SubtractionOperation.class, | |||
Main.class, | |||
CoreCommandLineHelper.class | |||
CoreCommandLineHelper.class, | |||
OperationDescription.class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you adding this class? Why not simply make it pass?
@Named("ntManager") MapNetworkPublisherFactory ntManager, | ||
@Named("httpManager") MapNetworkPublisherFactory httpManager, | ||
@Named("rosManager") ROSNetworkPublisherFactory rosManager, | ||
Injector injector, | ||
FileManager fileManager, | ||
InputSocket.Factory isf, | ||
OutputSocket.Factory osf) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the OutputSocket.Factory
still get used anymore?
I cleared up my own review comments and I'll merge this if the CI passes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me after making my own changes to the PR. Great work @SamCarlberg I know that this was a significant amount of rewrite work. Thanks for your dedication.
Operations are created via the Guice
Injector
, making it much easier to use dependency injection in operations. Operations are also discovered at startup as long as they have an@Description
annotation on the class