-
Notifications
You must be signed in to change notification settings - Fork 846
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
[PHP] Multiple default namespace navigator fix, FixImports for the whole file #5681
[PHP] Multiple default namespace navigator fix, FixImports for the whole file #5681
Conversation
php/php.editor/src/org/netbeans/modules/php/editor/actions/ImportDataCreator.java
Outdated
Show resolved
Hide resolved
php/php.editor/src/org/netbeans/modules/php/editor/model/ModelUtils.java
Outdated
Show resolved
Hide resolved
php/php.editor/test/unit/data/testfiles/actions/testNB4978/01/testNB4978_01.php.fixUses
Outdated
Show resolved
Hide resolved
php/php.editor/test/unit/data/testfiles/actions/testNB4978/02/testNB4978_02.php
Outdated
Show resolved
Hide resolved
@rossluk This PR contains some fixes as one commit at the same time. So, you should separate to some commits(or separate to PRs). |
86acaaa
to
c4e8be0
Compare
php/php.editor/src/org/netbeans/modules/php/editor/model/impl/ModelBuilder.java
Outdated
Show resolved
Hide resolved
.../unit/data/testfiles/structure/php53/bracketed_multiple_namespaces_with_multiple_default.php
Outdated
Show resolved
Hide resolved
.../test/unit/data/testfiles/structure/php53/multiple_namespaces_with_elements_from_default.php
Outdated
Show resolved
Hide resolved
c4e8be0
to
97de183
Compare
php/php.editor/test/unit/src/org/netbeans/modules/php/editor/actions/FixUsesPerformerTest.java
Show resolved
Hide resolved
d49732a
to
75aa022
Compare
....editor/test/unit/data/testfiles/actions/testWholeFileUse/02/testWholeFileUse_02.php.fixUses
Outdated
Show resolved
Hide resolved
php/php.editor/src/org/netbeans/modules/php/editor/actions/FixUsesPerformer.java
Outdated
Show resolved
Hide resolved
75aa022
to
8786049
Compare
Removing trailing whitespaces: It's OK only with your changed parts. (because If there are many changes for that, it makes it harder to review :)) Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your work.
@@ -570,7 +614,7 @@ public void visit(DeclareStatement node) { | |||
if (CancelSupport.getDefault().isCancelled()) { | |||
return; | |||
} | |||
declareStatements.add(node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @junichi11 wrote, please, avoid changes in unrelated files and lines. The reason is that the Git history is then more difficult to read/follow, thanks. I think that the IDE can be configured to format/change only the changed lines (see IDE Options dialog).
@@ -143,10 +106,14 @@ private boolean existsUseForTypeName(final Collection<? extends UseScope> declar | |||
|
|||
private static class NamespaceNameVisitor extends DefaultVisitor { | |||
private final OffsetRange offsetRange; | |||
private final Map<String, List<UsedNamespaceName>> existingNames = new HashMap<>(); | |||
private final NamespaceScope namespaceScope; | |||
private NamespaceScope currentScope; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: we usually put final
fields before the non-final ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a small change, perfectly done! Thanks a lot!
Guys, I added just 2 nitpicks, I am fine if we merge this PR as it is now. So, Junichi, please, feel free to resolve all the comments and merge this PR. Thank you both for your work! |
…pdate to fix imports in whole file, fix ModelUtils multiple default namespace detection
8786049
to
1bda109
Compare
… for use statements - apache#5681 - Avoid changing the file state if the created string is the same as the existing use statments
… for use statements - apache#5681 - Avoid changing the file state if the created string is the same as the existing use statements
… for use statements - apache#5681 - Avoid changing the file state if the created string is the same as the existing use statements
This PR fixes next issues:
-- before fix it shows classes without namespace, and USE from second default namespace is showed as first one
-- after fix
-- initial state
-- before fix, it gets all uses from all default namespaces and inserts it in the first one
-- after fix
-- before fix before fix import action (see tab)
-- before fix after fix import action (see tab)
Also with the fixes I've changed Fix Imports logic. Previously when you use Fix Imports outside bracketed namespace it was changing first available namespace uses, but now if you in global scope it fixes all the file, see below:
-- initial state
-- after Fix Imports
To have Fix Imports working for the whole file I had to add scope to UsedNamesCollector's names and it also affected some tests, because for now it is important that DataItems from ImportDataCreator were paired with Selections, but previously Selection could be imported without real DataItem.