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

Fix "IllegalArgumentException: Invalid range specified: (1, -1)" when editing style attribute in Jelly files #115

Merged
merged 2 commits into from
Oct 10, 2022

Conversation

jgreffe
Copy link
Contributor

@jgreffe jgreffe commented Oct 8, 2022

Fixes #103
Issue reproduced:

  • use IDEA ultimate edition, which contains the CSS plugin (only for ultimate)
  1. open any jelly file, and start typing:
error occurs

Changes:

  • updated IDE versions (2022.2.3) in build.gradle
  • added type attribute in build.gradle in order to be able to use ultimate edition during tests
  • checked condition of value.getTextLength()

To test:

  • runIde -PideaVersion=<some version> -PideaType=IU -> will run ultimate edition which contains CSS plugin

  • reproduce steps, and see no exception, and completion works when syntax correctly fomed

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!

  • Ensure that the pull request title represents the desired changelog entry

  • Please describe what you did

  • Link to relevant issues in GitHub or Jira

  • Link to relevant pull requests, esp. upstream and downstream changes

  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@@ -103,7 +105,7 @@ runPluginVerifier {
// Rather arbitrarily chosen first releases of last three year.
// Product version in use statistics say last 3 major releases. It does not define "major release" though but
// but educated guess is that `year.version` is what is considered major.
ideVersions = ["2020.3.2", "2021.3.3", "2022.1"]
ideVersions = ["2020.3.4", "2021.3.3", "2022.2.3"]
Copy link
Member

Choose a reason for hiding this comment

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

These are only used by the Plugin Verifier. IMO, not relevant to the fix but OK to have.

registrar.doneInjecting();
} catch (IllegalArgumentException ignored) {
// occurs when syntax is malformed, like style==""
}
Copy link
Member

Choose a reason for hiding this comment

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

Why rely on exceptions to handle this? It is, after all, an exception about this plugin not preparing the parameters correctly for an API. We can probably just add another if checking that textLength is greater than 2, i.e. there are two quotes and something in them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right @duemir , pushed another commit!

Copy link
Member

@duemir duemir left a comment

Choose a reason for hiding this comment

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

Tested locally.
CSS language injection into the style attribute works for well-formed attributes. For not well-formed, there is no IllegalArgumentException.

@duemir duemir changed the title Bug 103: IllegalArgumentException: Invalid range specified: (1, -1); Fix "IllegalArgumentException: Invalid range specified: (1, -1)" when editing style attribute in Jelly files Oct 10, 2022
@duemir duemir merged commit fac7270 into jenkinsci:master Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IllegalArgumentException: Invalid range specified: (1, -1);
2 participants