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

Updated TypeProvider to support different method/function parameters #67

Merged
merged 1 commit into from
Jun 11, 2017

Conversation

CarsonF
Copy link
Contributor

@CarsonF CarsonF commented Jun 3, 2017

Updated TypeProvider to support different method/function parameters besides the first with "index" parameter.

Fixes #20

This is my first PR for an idea plugin, so advice is very much appreciated.

It seems like when creating the signature, we don't know the class name. So we need to add the types of all indexes that could be needed and match it later in getBySignature. I did that by concatenating each index and its type and joining those with the trimKey and then joining that to the refSignature with two of the trimKey chars. This breaks if the index wanted is greater than 9 but I figured that was an ok risk. I'm happy to change it to another kind of pattern, I'm just not sure what I can use to delineate on here.

I don't know what kind of BC we are trying to provide here. This does break BC for PhpTypeProviderUtil if it was called directly. Nothing has changed with PhpToolboxTypeProviderInterface which I figure is the one everyone is using.

Copy link
Owner

@Haehnchen Haehnchen left a comment

Choose a reason for hiding this comment

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

welcome to the club. ;)

a test would be nice. also you broken some function type tests


PsiElement parameter = parameters[0];
HashMap<Integer, String> parameterSignatures = new HashMap<>();
Copy link
Owner

Choose a reason for hiding this comment

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

switch HashMap to Map for variable declaration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

.map(entry -> entry.getKey() + entry.getValue())
.collect(Collectors.joining(String.valueOf(trimKey)));

return refSignature + trimKey + trimKey + parametersSignature;
Copy link
Owner

Choose a reason for hiding this comment

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

why are you using a double trimKey?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So it can be split on in getBySignature. I know this is weird. I'm joining multiple parameter pairs with the trim key as well, so I couldn't split on that one character alone.

This doThing('Foo', 'Bar') looks like this {refSignature} ƕƕ 0Foo ƕ 1Bar (added spaces for clarity).

As I said in the PR description, I'm happy to do it another way. I'm just not sure which characters would be allowed that wouldn't mess up other things.

Copy link
Owner

Choose a reason for hiding this comment

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

whats about this solution?

{refSignature}ƕ0#Fooƕ1#Bar

Find first special char and then split it. in additional we support +9 parameter also, as you extracting just the first char for parameter index

@CarsonF
Copy link
Contributor Author

CarsonF commented Jun 4, 2017

a test would be nice. also you broken some function type tests

I'm struggling to get the tests running locally.

ERROR: Problems found loading plugins:<p/>
Plugin "PHP" was not loaded: required plugin "com.intellij.java-i18n" not installed.<p/>
Plugin "PHP Toolbox" was not loaded: required plugin "com.intellij.java-i18n" not installed.<p/>
<br><a href="disable">Disable not loaded plugins</a><p/><a href="edit">Open plugin manager</a>

I've add java-i18n from IntelliJ but something else must be wrong. I can run/debug the plugin so I've got at least some of the other dependencies right.

screen shot 2017-06-04 at 11 06 07 am

@Haehnchen
Copy link
Owner

So my project configuration about testing

screenshot from 2017-06-06 18-00-14
screenshot from 2017-06-06 18-01-35
screenshot from 2017-06-06 18-02-27

@@ -16,46 +17,66 @@

@Nullable
public static String getReferenceSignature(FunctionReference methodReference, char trimKey) {
return getReferenceSignature(methodReference, trimKey, 1);
return getReferenceSignature(methodReference, trimKey, 0);
Copy link
Owner

Choose a reason for hiding this comment

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

i think current tests failing because of this change. as index starts by 0

@CarsonF
Copy link
Contributor Author

CarsonF commented Jun 10, 2017

Ah ok so adding those to the SDK fixed it...but I'm not sure that's correct. The SDK makes them like global dependencies, right? This leaves me wondering what the java-i18n, properties, junit, css, php dependencies are for if they are specified in the SDK.

Anyways I can work on the tests now, and I'll keep playing with the dependencies. Glad I don't have to be the one to make sure the compilation is correct ;)

@CarsonF CarsonF force-pushed the return-type-index branch 2 times, most recently from 4d50be6 to 24d22cb Compare June 10, 2017 16:59
@CarsonF
Copy link
Contributor Author

CarsonF commented Jun 10, 2017

Ok tests caught a bug I had, fixed that and added tests for new functionality. Tests pass locally, Travis is just being derpy.

@Haehnchen
Copy link
Owner

@CarsonF travis build environment fixed in master please rebase. in additional a simple example with the new index key inside README.md would be nice, then we are ready to merge and release this 👍

@Haehnchen
Copy link
Owner

i also dont know why dependencies must declared in this way. but its working ;)

@CarsonF CarsonF force-pushed the return-type-index branch from 24d22cb to dc76fe1 Compare June 11, 2017 15:42
@CarsonF CarsonF force-pushed the return-type-index branch from dc76fe1 to 68c468f Compare June 11, 2017 15:43
@CarsonF
Copy link
Contributor Author

CarsonF commented Jun 11, 2017

Done! 😄

@Haehnchen Haehnchen merged commit 5f0500a into Haehnchen:master Jun 11, 2017
@Haehnchen
Copy link
Owner

thx! will build new release soon

@CarsonF CarsonF deleted the return-type-index branch June 11, 2017 17:16
@Koc
Copy link
Contributor

Koc commented Jun 11, 2017

Nice to see new contributor

@CarsonF
Copy link
Contributor Author

CarsonF commented Jun 16, 2017

@Haehnchen thanks for 2faefdb. I thought removeIf(Objects::isNull) would be enough, but clearly not :)

@Haehnchen
Copy link
Owner

problem was:

part -> Integer.parseInt(part.substring(0, 1)),
part -> PhpTypeProviderUtil.getResolvedParameter(phpIndex, part.substring(1))

empty string provided, had no idea why, but lesson learned in all plugins: try to validate everything ;)

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.

3 participants