netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

Better implementation of PSR-4 Namespace rules

Open aleferri opened this issue 4 years ago • 16 comments

Consider src to be the base directory (PSR-4 definition) and the "surplus" leading segments as parts of the namespace prefix. Implementation is rough. For it to be better, i would need to add a configuration options in the project to let the user set the namespace prefix; fetch the configuration in this Checker and remove the appropriate leading part of the namespace. Unfortunately i don't know how to do that.

aleferri avatar Sep 26 '21 01:09 aleferri

Can you submit it to the JIRA and attach an example project there? See also: https://netbeans.apache.org/participate/submit-pr.html

junichi11 avatar Oct 19 '21 11:10 junichi11

I registered in JIRA, should i open it as "bug" or "improved feature"?

aleferri avatar Oct 24 '21 08:10 aleferri

Maybe, improvement.

junichi11 avatar Oct 28 '21 04:10 junichi11

Did create the issue as improvements https://issues.apache.org/jira/browse/NETBEANS-6180

aleferri avatar Nov 07 '21 16:11 aleferri

Anything missing?

aleferri avatar May 31 '22 12:05 aleferri

@aleferri I'm sorry I'm late... Maybe, I overlooked the notification.

src is hardcoded. So, I think we should get the source directory. Unit tests are missing.

junichi11 avatar Jun 02 '22 06:06 junichi11

Agreed, some unit test(s) would be fine. Thanks.

tmysik avatar Jun 02 '22 11:06 tmysik

@junichi11 How do i get the environment inside the Hint? My original idea was to search for the top folder, but i couldn't figure how to get objects outside of the current file.

aleferri avatar Jun 02 '22 16:06 aleferri

I would get the source directory like the following:

PhpModule phpModule = PhpModule.Factory.forFileObject(fileObject);
if (phpModule != null) {
    FileObject sourceDirectory = phpModule.getSourceDirectory();
}

junichi11 avatar Jun 03 '22 05:06 junichi11

BTW, you should create a PR with not the master branch but the new branch.

junichi11 avatar Jun 03 '22 05:06 junichi11

@junichi11 Good catch.

@aleferri Please, create a branch in your clone, containing the number of the ticket and ideally also a few words, from the ticket title, typically (e.g. 1234-fix-npe).

Thanks.

tmysik avatar Jun 06 '22 14:06 tmysik

Ok, i am going to open a new PR then

aleferri avatar Jun 07 '22 13:06 aleferri

Sorry to ask, but how i can run the tests? -Dcluster.config=php build netbeans, but the tests didn't run.

aleferri avatar Jun 15 '22 13:06 aleferri

Either from the UI Kontextmenu of the project or on CLI: ant -f php/php.editor/build.xml test.

matthiasblaesing avatar Jun 15 '22 15:06 matthiasblaesing

Tests went in timeout

aleferri avatar Jun 17 '22 22:06 aleferri

@aleferri which tests timeout? Your local run? Which test.

With flaky tests I regularly run the tests before my change, note which fail and run after. I consider my changes "sane" if the same set of tests succeeds and fails (and yes in perfect world this would not be necessary, but...)

matthiasblaesing avatar Jun 20 '22 17:06 matthiasblaesing

@junichi11 @tmysik marked stale and removed from NB16 milestone for now. Please follow up as you see fit - re-add, re-review or close.

neilcsmith-net avatar Oct 11 '22 13:10 neilcsmith-net

It seems to me that (all?) the comments are still valid.

tmysik avatar Oct 11 '22 15:10 tmysik

The implementation doesn't work, as it simply disable the warning even when the thing is wrong. I did that test by building the whole thing and opening my test project and also a should-fail one (aka i did a manual test). Unfortunately i am out of ideas on how to fix it and automated tests still don't run (not even one of them, all of them go in timeout).

aleferri avatar Oct 11 '22 15:10 aleferri

I hadn't noticed how small the actual proposed changes were either - busy going through closing or marking stale PRs with milestones that hadn't been completed. Closing for discussion elsewhere then.

neilcsmith-net avatar Oct 11 '22 15:10 neilcsmith-net

Please submit it as a new PR with a new branch. Thanks!

junichi11 avatar Oct 11 '22 16:10 junichi11