Skip to content

Sort imports using URI and apply edits using workspace edits#2214

Merged
DonJayamanne merged 2 commits into
microsoft:masterfrom
DonJayamanne:issue2137Actions
Sep 6, 2018
Merged

Sort imports using URI and apply edits using workspace edits#2214
DonJayamanne merged 2 commits into
microsoft:masterfrom
DonJayamanne:issue2137Actions

Conversation

@DonJayamanne

@DonJayamanne DonJayamanne commented Jul 21, 2018

Copy link
Copy Markdown

Fixes #2137

Pending manual testing.

  • Title summarizes what is changing
  • Includes a news entry file (remember to thank yourself!)
  • Unit tests & code coverage are not adversely affected (within reason)
  • Works on all actively maintained versions of Python (e.g. Python 2.7 & the latest Python 3 release)
  • Works on Windows 10, macOS, and Linux (e.g. considered file system case-sensitivity)
  • [n/a] Dependencies are pinned (e.g. "1.2.3", not "^1.2.3")
  • [n/a] package-lock.json has been regenerated if dependencies have changed

@codecov

codecov Bot commented Jul 21, 2018

Copy link
Copy Markdown

Codecov Report

Merging #2214 into master will decrease coverage by 4.04%.
The diff coverage is 89.51%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2214      +/-   ##
=========================================
- Coverage   79.84%   75.8%   -4.05%     
=========================================
  Files         310     310              
  Lines       14359   14407      +48     
  Branches     2547    2552       +5     
=========================================
- Hits        11465   10921     -544     
- Misses       2882    3475     +593     
+ Partials       12      11       -1
Flag Coverage Δ
#MacOS 74.06% <89.51%> (+0.1%) ⬆️
#Windows 74.08% <89.51%> (-0.02%) ⬇️
Impacted Files Coverage Δ
src/client/common/application/types.ts 100% <ø> (ø) ⬆️
src/client/common/platform/types.ts 100% <ø> (ø) ⬆️
src/client/common/types.ts 100% <ø> (ø) ⬆️
src/client/common/application/documentManager.ts 61.29% <100%> (+5.73%) ⬆️
src/client/providers/serviceRegistry.ts 100% <100%> (ø)
src/client/common/platform/fileSystem.ts 72.09% <100%> (+0.66%) ⬆️
src/client/common/serviceRegistry.ts 100% <100%> (ø) ⬆️
src/client/extension.ts 95.51% <100%> (+0.08%) ⬆️
src/client/providers/types.ts 100% <100%> (ø)
src/client/common/editor.ts 72.68% <84.84%> (+2.09%) ⬆️
... and 47 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6af8f99...487cfa7. Read the comment docs.

@d3r3kk

d3r3kk commented Jul 24, 2018

Copy link
Copy Markdown

Just needs a rebuild, the Mac agents were updated recently.

@DonJayamanne DonJayamanne reopened this Jul 24, 2018
@d3r3kk d3r3kk self-requested a review August 1, 2018 18:53
@d3r3kk d3r3kk self-assigned this Aug 1, 2018

@d3r3kk d3r3kk left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This change is great, but I think there are some things to resolve:

  • CI is failing on helper tests - knock on effect from this change perhaps.
  • Fix / add logic surrounding trailing-line hack.

Comment thread src/test/index.ts Outdated
// We do this to ensure we only run debugger test, as debugger tests are very flaky on CI.
// So the solution is to run them separately and first on CI.
const grep = IS_CI_SERVER && IS_CI_SERVER_TEST_DEBUGGER ? 'Debug' : undefined;
const grep = IS_CI_SERVER && IS_CI_SERVER_TEST_DEBUGGER ? 'Debug' : 'Sortingx';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not sure we want this left in here...

Comment thread src/client/extension.ts
debugConfigurationRegisterTypes(serviceManager);
debuggerRegisterTypes(serviceManager);
appRegisterTypes(serviceManager);
providersRegisterTypes(serviceManager);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would expect to find all types of providers being registered here (formatProvider, signatureProvider... etc). Is that the intention here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

DI was added later. So we do not have others registered in the container.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That is the intention then, good to know.

return;
}

// Hack, if the document doesn't contain an empty line at the end, then add it

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this hack for the 'inner version' of isort only?

If so, I think we should skip this hack for when the settings.isortPath is set to somthing.

Bonus points if we could remove this hack by correcting our inner version of isort.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Is this hack for the 'inner version' of isort only?

No, we need an empty line for the diff to be genrated correctly.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Will get removed when we change the diffing coding, there's a separate PR to use an npm package for that.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Alright, I'll assume we'll rid ourselves of the hack when that #1950 issue is resolved.

.setup(d => d.activeTextEditor).returns(() => undefined)
.verifiable(TypeMoq.Times.once());
shell
.setup(s => s.showErrorMessage(TypeMoq.It.isValue('Please open a Python file to sort the imports.')))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think it would be important to define messages such as this in a common place (used by both the test and the feature itself). That way we can more be more complete and adept at supporting improvements our localization efforts.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No such functionality available now. Separate PR, we have an issue open for this. I'll try to complete it later.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yep, I see it now: #463. I'm glad that we have an issue for it!

if (!uri) {
const activeEditor = this.documentManager.activeTextEditor;
if (!activeEditor || activeEditor.document.languageId !== PYTHON_LANGUAGE) {
this.shell.showErrorMessage('Please open a Python file to sort the imports.').then(noop, noop);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is there a localization file we can add this string to?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That will be done in a separate PR (bigger change).
There's a separate task for that.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

☑️

shell.verifyAll();
documentManager.verifyAll();
});
test('Ensure empty line is added when line does not end with an empty line', async () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This test may need some updating, see my comment on the subject of the trailing-line hack.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This will become unnecessary when we use an npm package to do the diffing. There's an issue for that.
#1950

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

☑️

@d3r3kk d3r3kk removed their assignment Aug 2, 2018
@DonJayamanne

Copy link
Copy Markdown
Author

@d3r3kk
Please review once again.

@d3r3kk

d3r3kk commented Aug 2, 2018

Copy link
Copy Markdown

Looks good, and for everything I raised we have separate issues tracking them. Now the build just needs to run clean (there are failing tests still).

@brettcannon

Copy link
Copy Markdown
Member

@DonJayamanne anything holding up merging this?

@DonJayamanne DonJayamanne merged commit 7c646db into microsoft:master Sep 6, 2018
@DonJayamanne

DonJayamanne commented Sep 6, 2018

Copy link
Copy Markdown
Author

Interestingly the tests were successful, however there were issues with the merge and compilation issues. Not sure how the tests ran successfully on CI!!!

created PR to resolve merge issues #2508

@DonJayamanne DonJayamanne deleted the issue2137Actions branch October 2, 2018 22:46
@lock lock Bot locked as resolved and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not use the active text editor for running organize imports code actions

3 participants