RepreZen / KaiZen-OpenAPI-Editor

Eclipse Editor for the Swagger-OpenAPI Description Language
Eclipse Public License 1.0
115 stars 12 forks source link

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

Closed tfesenko closed 6 years ago

tfesenko commented 6 years ago

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

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 commented 6 years ago

@ghillairet , this PR is ready for your review

tfesenko commented 6 years ago

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.