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

add quickfix fn to handle composite annotations #513

Merged
merged 2 commits into from
Feb 27, 2024
Merged

Conversation

ajm01
Copy link
Contributor

@ajm01 ajm01 commented Feb 1, 2024

fixes #190

@ajm01 ajm01 requested a review from mezarin February 1, 2024 22:22
Copy link
Contributor

@mezarin mezarin left a comment

Choose a reason for hiding this comment

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

Hi @ajm01, the code works great. I just had a few comments.

}
}
if (a instanceof SingleMemberAnnotation) {
// this type of annotation contains a single valuie which may be a list of other annotations,
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: "valuie"

@@ -19,19 +19,27 @@
import java.util.List;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IAnnotation;
Copy link
Contributor

Choose a reason for hiding this comment

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

Update copyright year to 2024 in this file and others.


newSingleMemberAnnotation.setTypeName(
ast.newName(imports.addImport(annotationToProcess.getTypeName().toString(), importRWCtx)));
List<NormalAnnotation> newCompositeAnnotationContents = newAIInstance.expressions();
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like you populate this: newCompositeAnnotationContents, but it is never used.

}

// add new String attributes
//values = addNewAttributes(ast, values);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this commented line.

}

// process methods now?
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove: // process methods now?


@Resource(type = Object.class, name = "aa")
@Resources ({ @Resource(name = "aaa"), @Resource(type = Object.class) })
Copy link
Contributor

Choose a reason for hiding this comment

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

A couple of things here:

  1. You may want to format this file.
  2. Why replace @resource for @Resources? That could be used for a positive test where we check that no diagnostics are generated because everything looks fine.
  3. I would suggest that you create a ResourcesAnnotation class and add a similar set of code for a similar set of diagnostics/code-action tests including a positive test.

@ajm01 ajm01 force-pushed the issue-190 branch 2 times, most recently from e2240f8 to 14793a0 Compare February 14, 2024 00:25
Copy link
Contributor

@mezarin mezarin left a comment

Choose a reason for hiding this comment

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

Andy, you missed a few copyrights.

@@ -28,6 +28,7 @@ public enum JakartaCodeActionId implements ICodeActionId {
ChangeReturnTypeToVoid,
InsertResourceAnnotationTypeAttribute,
InsertResourceAnnotationNameAttribute,
Copy link
Contributor

Choose a reason for hiding this comment

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

Update Copyright year to 2024

@@ -30,6 +30,10 @@ public class Constants {
public static final String RESOURCE = "Resource";
public static final String RESOURCE_FQ_NAME = "jakarta.annotation.Resource";

/* @Resources */
Copy link
Contributor

Choose a reason for hiding this comment

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

Update Copyright year to 2024

@@ -18,6 +18,7 @@ MethodMustNotHaveParameters = A method with the {0} annotation must not have any
MethodMustBeVoid = A method with the {0} annotation must be void.
MethodMustNotBeStatic = A method with the {0} annotation must not be static.
MethodMustNotThrow = A method with the {0} annotation must not throw checked exceptions.
ResourcesAnnotationMustDefineResourceAnnotation = The {0} annotation must define at least one sub-annotation ''{1}''.
Copy link
Contributor

Choose a reason for hiding this comment

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

Update Copyright year to 2024

@@ -0,0 +1,78 @@
/*******************************************************************************
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is a new file the first like should be:
Copyright (c) 2024 IBM Corporation and others.

@ajm01 ajm01 merged commit 2ca7a71 into eclipse:main Feb 27, 2024
2 checks passed
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.

Add support for jakarta.annotation.Resources
2 participants