-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide basic support for #fragment section
See redhat-developer/vscode-quarkus#563 Signed-off-by: azerr <[email protected]>
- Loading branch information
1 parent
1600156
commit 906a34f
Showing
20 changed files
with
413 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
qute.ls/com.redhat.qute.ls/src/main/java/com/redhat/qute/ls/commons/snippets/Link.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package com.redhat.qute.ls.commons.snippets; | ||
|
||
/** | ||
* Link used for documentation. | ||
* | ||
* @author Angelo ZERR | ||
* | ||
*/ | ||
public class Link { | ||
|
||
private final String url; | ||
private final String label; | ||
|
||
public Link(String url, String label) { | ||
this.url = url; | ||
this.label = label; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ public enum SectionKind { | |
EACH, // | ||
EVAL, // | ||
FOR, // | ||
FRAGMENT, // | ||
IF, // | ||
ELSE, // | ||
INCLUDE, // | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...edhat.qute.ls/src/main/java/com/redhat/qute/parser/template/sections/FragmentSection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package com.redhat.qute.parser.template.sections; | ||
|
||
import java.util.List; | ||
|
||
import com.redhat.qute.parser.template.ASTVisitor; | ||
import com.redhat.qute.parser.template.Parameter; | ||
import com.redhat.qute.parser.template.ParameterInfo; | ||
import com.redhat.qute.parser.template.ParametersInfo; | ||
import com.redhat.qute.parser.template.Section; | ||
import com.redhat.qute.parser.template.SectionKind; | ||
|
||
/** | ||
* Fragment section AST node. | ||
* | ||
* <code> | ||
{#fragment id=item_aliases} | ||
<h2>Aliases</h2> | ||
<ol> | ||
{#for alias in aliases} | ||
<li>{alias}</li> | ||
{/for} | ||
</ol> | ||
{/fragment} | ||
* </code> | ||
* | ||
* @author Angelo ZERR | ||
* | ||
* @see https://quarkus.io/guides/qute-reference#fragments | ||
*/ | ||
public class FragmentSection extends Section { | ||
|
||
public static final String TAG = "fragment"; | ||
|
||
private static final String ID = "id"; | ||
|
||
private static final String RENDERED = "rendered"; | ||
|
||
private static final ParametersInfo PARAMETER_INFOS = ParametersInfo.builder() // | ||
.addParameter(ID) // | ||
.addParameter(new ParameterInfo(RENDERED, null, true)) // | ||
.build(); | ||
|
||
public FragmentSection(int start, int end) { | ||
super(TAG, start, end); | ||
} | ||
|
||
@Override | ||
public SectionKind getSectionKind() { | ||
return SectionKind.FRAGMENT; | ||
} | ||
|
||
@Override | ||
public ParametersInfo getParametersInfo() { | ||
return PARAMETER_INFOS; | ||
} | ||
|
||
@Override | ||
protected void initializeParameters(List<Parameter> parameters) { | ||
parameters.forEach(parameter -> { | ||
parameter.setCanHaveExpression(false); | ||
}); | ||
} | ||
|
||
@Override | ||
protected void accept0(ASTVisitor visitor) { | ||
boolean visitChildren = visitor.visit(this); | ||
if (visitChildren) { | ||
List<Parameter> parameters = getParameters(); | ||
for (Parameter parameter : parameters) { | ||
acceptChild(visitor, parameter); | ||
} | ||
acceptChildren(visitor, getChildren()); | ||
} | ||
visitor.endVisit(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.