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

Automatically resolve types across modules #899

Closed
krishnaagarwal1994 opened this issue Feb 8, 2021 · 9 comments
Closed

Automatically resolve types across modules #899

krishnaagarwal1994 opened this issue Feb 8, 2021 · 9 comments
Assignees

Comments

@krishnaagarwal1994
Copy link

I am parsing a method in a class A present in TargetA,
Class A has a method that has a return type of Class B, which is also present in TargetA.
But sourcery is still returning false for

{{ method.returnType }} -> nil
{{ method.returnTypeName }} -> ClassB

The configuration file that I am using

project:
  - file: #path to project file
    target:
      name: TargetA
templates:
    - SourceryTemplates
output: src/Generated
@krishnaagarwal1994
Copy link
Author

@ilyapuchka Can you please help me with this?
Thank You.

@krzysztofzablocki
Copy link
Owner

@krishnaagarwal1994 can you create a sample project reproducing the issue? it would help

@krishnaagarwal1994
Copy link
Author

sourcery0.zip
Hi @krzysztofzablocki , thanks for your response.
I have created a sample project, in which I am able to reproduce the problem.
Please have a look into it, and do let me know in case you have any questions regarding this Sample Project.
Thanks.

@krzysztofzablocki
Copy link
Owner

krzysztofzablocki commented Feb 9, 2021

thanks, I don't think we ever had cross module resolution with not fully qualified names, if you add the target name explicitly to getStudentB() -> CustomTarget.Student then it gets all information,

I'll look into adding this feature

@krishnaagarwal1994
Copy link
Author

@krzysztofzablocki Yeah, I already tried that, if mentioning the target name explicitly then it's identifying correctly.
Also, I would like to share one more finding with you.

If I am mentioning project path, target names then the Sourcery is retuning the returnType as nil
But if you simply provide the target files path using the source attribute in the Sourcery configuration file then it's able to identify the returnType.

@krishnaagarwal1994
Copy link
Author

@krzysztofzablocki
Changing the sourcery.yml file contents to below is giving the right results.

sources:
  - CustomTarget
  - CustomTargetB
templates:
    - SourceryTemplates
output: Generated

@krzysztofzablocki
Copy link
Owner

krzysztofzablocki commented Feb 10, 2021

yeah sources don't run into those kind of issues, that's original implementation and more popular, xcodeproj was contributed later and there are some kinks there to figure out

I'm going to try to implement this either way, but not sure when so if you don't need xcodeproj integration it's easier to use sources approach

@krishnaagarwal1994
Copy link
Author

Actually, I am working on a quite complex project, where I need to support functionality on a module/target level.
At some places the physical path and logical path of files are different. and some files belong to more than one target.
So rather than relying on physical paths for the modules, I would love to use the project-target functionlity of the Sourcery configuration file.
Also thanks for all the help and support.

@krzysztofzablocki krzysztofzablocki changed the title method.returnType not working properly Automatically resolve types across modules Feb 10, 2021
@krzysztofzablocki krzysztofzablocki self-assigned this Feb 10, 2021
@krishnaagarwal1994
Copy link
Author

@krzysztofzablocki Thanks for the fix.

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

No branches or pull requests

2 participants