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

ZEN-4367, ZEN-3845 - Resource templates don't populate schema reference correctly #473

Merged
merged 8 commits into from
Sep 18, 2018

Conversation

tfesenko
Copy link
Member

@tfesenko tfesenko commented Sep 2, 2018

Problem

ZEN-3845: Code assist should replace selected text

KZOE doesn't seem to have an option to overwrite the selected text. The CTRL key doesn't seem to have any effect.

I would even go further and say that the idea of an "insert" mode is quite counterintuitive. If I have text selected when I invoke code assist, I would fully expect that whatever I select from the suggestion list will replace the selected text. If it doesn't, it seems like a bug. I would never think to hold down the CTRL key, even if it worked. And I would not think to look for an option in preferences to make code assist replace instead of insert. I would just assume it's a bug. Apparently Andy Lowry make the same assumption in ZEN-4367 .

I think "replace mode" should be at least the default mode, and probably the only mode. It's not worth any extra effort to provide an option key (like Ctrl) or a preference setting for "insert mode" in code assist; I don't see the point.

ZEN-4367: Resource templates don't populate schema reference correctly

I tried inserting and filling in the collection resource code template, and found that there were warnings due to invalid references.
The first $ref variable is between single quotes; the second is within double quotes. After using code assist to choose a valid reference, the second one looks like this:
$ref: "'#/components/schemas/TaxFiling"
There is a stray single quote after the opening double quote.
The Object Resource template has a similar problem.

Changes Overview

The major changes are done in StyledCompletionProposal and ProposalDescriptor

  • Proposal -> ProposalDescriptor with fluent syntax to set all the values, added toString()
  • Simplified creation of StyledCompletionProposal instances
  • StyledCompletionProposal: added new preSelectedRegionLength to address ZEN-3845 Code assist should replace selected text

Tests

JsonReferenceProposalProvider_Quotes_Test provides integration tests for code assist for elements with quotes (references), it also checks the document state after the code assist proposal have been applied.

@tfesenko tfesenko changed the title ZEN-4367 - Resource templates don't populate schema reference correctly (DO NOT MERGE) ZEN-4367, ZEN-3845 - Resource templates don't populate schema reference correctly (DO NOT MERGE) Sep 7, 2018
@tfesenko tfesenko changed the title ZEN-4367, ZEN-3845 - Resource templates don't populate schema reference correctly (DO NOT MERGE) ZEN-4367, ZEN-3845 - Resource templates don't populate schema reference correctly Sep 7, 2018
@tfesenko tfesenko requested review from andylowry and ghillairet and removed request for andylowry September 7, 2018 20:12
@tfesenko
Copy link
Member Author

@ghillairet , this PR is ready for your review


}

/*============ Code below copied from utils.Cursors, otherwise Xtend won't compile ============= */
Copy link
Member

Choose a reason for hiding this comment

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

@tfesenko Any clue why it does not compile for you? I have it working.

Copy link
Member

@ghillairet ghillairet left a comment

Choose a reason for hiding this comment

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

@tfesenko Looks good. It works as expected, although I would prefer we remove the duplicate in the tests.

@tfesenko
Copy link
Member Author

although I would prefer we remove the duplicate in the tests.

Covered by https://modelsolv.atlassian.net/browse/ZEN-4428, will be fixed later.

Merging.

@tfesenko tfesenko merged commit e5b4815 into master Sep 18, 2018
@tfesenko tfesenko deleted the task/ZEN-4367 branch September 18, 2018 15:51
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.

2 participants