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

Expression indexes are wrong #627

Closed
jeffmaury opened this issue Apr 27, 2022 · 0 comments · Fixed by #628
Closed

Expression indexes are wrong #627

jeffmaury opened this issue Apr 27, 2022 · 0 comments · Fixed by #628
Assignees
Labels
bug Something isn't working qute
Milestone

Comments

@jeffmaury
Copy link
Member

Looks expressions indexes are wrongly computed.

eg for the content #for item in items}{/for} I would expect that the index for the expression attached to the third parameter to be the same as the ones of the parameter itself.

The following test is failing:

	@Test
	public void for1() {
		String content = "{#for item in items}" + //
				"{/for}";
		Template template = TemplateParser.parse(content, "test.qute");
		assertEquals(1, template.getChildCount());
		Node first = template.getChild(0);
		assertEquals(NodeKind.Section, first.getKind());
		Section section = (Section) first;
		assertEquals(SectionKind.FOR, section.getSectionKind());
		assertTrue(section.isClosed());

		assertEquals(0, section.getStartTagOpenOffset()); // |{#let
		assertEquals(19, section.getStartTagCloseOffset()); // {#let name=value|}
		assertEquals(20, section.getEndTagOpenOffset());
		assertEquals(25, section.getEndTagCloseOffset());
		
		ForSection forSection = (ForSection) section;
		assertEquals(3, forSection.getParameters().size());
		Parameter parameter = forSection.getParameters().get(0);
		assertEquals(6, parameter.getStart());
		assertEquals(10, parameter.getEnd());
		assertEquals("item", parameter.getName());
		parameter = forSection.getParameters().get(1);
		assertEquals(11, parameter.getStart());
		assertEquals(13, parameter.getEnd());
		assertEquals("in", parameter.getName());
		parameter = forSection.getParameters().get(2);
		assertEquals(14, parameter.getStart());
		assertEquals(19, parameter.getEnd());
		assertEquals("items", parameter.getName());
		assertNotNull(parameter.getJavaTypeExpression());
		Expression expression = parameter.getJavaTypeExpression();
		assertEquals(14, expression.getStart());
		assertEquals(19, expression.getEnd());
	}

@jeffmaury jeffmaury added bug Something isn't working qute labels Apr 27, 2022
@angelozerr angelozerr self-assigned this Apr 27, 2022
angelozerr added a commit to angelozerr/quarkus-ls that referenced this issue Apr 27, 2022
Fixes redhat-developer#627

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/quarkus-ls that referenced this issue Apr 27, 2022
Fixes redhat-developer#627

Signed-off-by: azerr <azerr@redhat.com>
@angelozerr angelozerr added this to the v0.12.0 milestone Apr 27, 2022
angelozerr added a commit that referenced this issue Apr 27, 2022
Fixes #627

Signed-off-by: azerr <azerr@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working qute
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants