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 support for indexing of impacts of changes on fields on downstream dependencies #221

Merged
merged 59 commits into from
Dec 28, 2023

Conversation

nimakarimipour
Copy link
Member

@nimakarimipour nimakarimipour commented Dec 20, 2023

This PR adds support for indexing impact of changes on fields on downstream dependencies. Prior to this PR, Annotator might make a field @Nullable that can trigger errors on downstream dependencies, with this PR, Annotator is aware of these impacts and if changes on fields, create an unresolvable error on downstream dependencies, the containing fix tree is rejected.

See example below:

On Target

public class Foo {

  public Object f0;

  public Object f1;

  public Object f2 = new Object();
}

On Dependency (Dep)

package test.depa;

import test.target.Foo;

public class Dep {

    public void directAccess(Foo foo){
         // making f0 will create an unresolvable error here.
         foo.f0.toString();
    }

    public void flowF1BackToF2(Foo foo) {
      // If f1 is annotated as @Nullable, the corresponding error on f2 can be resolved on target.
      foo.f2 = foo.f1;
    }
}

Prior to this PR, Annotator would have made f0 @Nullable even thought it causes an unresolvable error in Dep module. With this PR,

  • Annotator is aware of this impact and will avoid making f0 @Nullable
  • Annotator is aware that the triggered error by making f1 @Nullable is resolvable by making f2 @Nullable, therefore it includes the corresponding fix (f2) in any tree containing f1.

@nimakarimipour nimakarimipour changed the base branch from nimak/update-library-model-loader to nimak/v1.3.10 December 21, 2023 17:04
@nimakarimipour nimakarimipour changed the base branch from nimak/v1.3.10 to nimak/update-library-model-loader December 21, 2023 17:09
Copy link
Member

@msridhar msridhar left a comment

Choose a reason for hiding this comment

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

Overall looks really good! Just a couple of comment

Comment on lines 86 to 87
// Collect public methods with non-primitive return types.
// Used to collect callers of each method.
Copy link
Member

Choose a reason for hiding this comment

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

Should this comment be before line 90?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for catching this. Fixed it in 15c8e1e

@@ -96,6 +96,16 @@ public void addFieldDeclaration(FieldDeclaration fieldDeclaration) {
this.fields.add(new FieldDeclarationRecord(fieldDeclaration));
}

/**
* Checks if the class contains a field with the given name.
Copy link
Member

Choose a reason for hiding this comment

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

This method is doing something different than the docs. It seems to look for a single field declaration that declares all the names in the Set given as a parameter. We should update the docs and consider renaming the method.

Copy link
Member Author

Choose a reason for hiding this comment

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

@msridhar Yes, I agree. Regarding field declarations (or OnFIeld instances) we have to document somewhere how they are created. Throughout the entire core module, every OnField instance contains all inline field names for the declaration, for instance for a declaration Foo a, b, c, all OnField instances targeting this declaration, contain all a, b and c on their variables property. This has been done at deserializing fixes here. That is the reason why I used equals instead of checking if it contains it. Will change the name and the documentation now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated javadoc for this method 71b901d.
Will work on a more detailed documentation with revisiting all methods working on fields in a followup PR.

try {
Files.deleteIfExists(path);
Files.createDirectories(path.getParent());
Files.createFile(path);
Copy link
Member

Choose a reason for hiding this comment

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

I think this is modifying logic introduced in #220. Still not sure why we are creating an empty file here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this is fixed in #220 now.

Base automatically changed from nimak/update-library-model-loader to master December 28, 2023 00:21
Copy link
Member

@msridhar msridhar left a comment

Choose a reason for hiding this comment

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

LGTM! Just one very minor comment, can land after that

@nimakarimipour nimakarimipour merged commit 46a8597 into master Dec 28, 2023
6 checks passed
@nimakarimipour nimakarimipour deleted the nimak/add-support-field-downstream branch December 28, 2023 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants