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

Added similar text suggestion Code Action(s) for UndefinedObject and UndefinedNamespace #670

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@
<html>
<head>
<meta charset="UTF-8">
<title>Qute Hello World</title>
<title>Qute Hello World</title>
</head>
<body>
<p>Hello {name ?: "world"}!</p>
</body>
</html>
</html>

{#set name=item.name age=10 long=10L negDouble=-10D isActive=true simpleQuote='abcd' doubleQuote="efgh"}
{true}
{name}
{negDouble}
{isActive}
{simpleQuote}
{doubleQuote}
{/set}
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@

/**
* Simple Qute expression
*
*
* <p>
* {foo}
* </p>
*
*
* <p>
* {foo ?: foo : 'bar'}
* </p>
*
*
* @author Angelo ZERR
*
*/
Expand All @@ -51,13 +51,14 @@ public NodeKind getKind() {
return NodeKind.Expression;
}

@Override
public String getNodeName() {
return "#expression";
}

/**
* Returns the start offset of the expression content (after '{')
*
*
* @return the start offset of the expression content (after '{')
*/
public int getStartContentOffset() {
Expand All @@ -66,7 +67,7 @@ public int getStartContentOffset() {

/**
* Returns the end offset of the expression content (before '}')
*
*
* @return the end offset of the expression content (before '}')
*/
public int getEndContentOffset() {
Expand Down Expand Up @@ -96,7 +97,7 @@ public List<Node> getExpressionContent() {

/**
* Returns the object part of the expression and null otherwise.
*
*
* @return the object part of the expression and null otherwise.
*/
public ObjectPart getObjectPart() {
Expand All @@ -110,7 +111,7 @@ public ObjectPart getObjectPart() {

/**
* Returns the namespace part of the expression and null otherwise.
*
*
* @return the namespace part of the expression and null otherwise.
*/
public NamespacePart getNamespacePart() {
Expand All @@ -124,7 +125,7 @@ public NamespacePart getNamespacePart() {

/**
* Returns the last part of the expression and null otherwise.
*
*
* @return the last part of the expression and null otherwise.
*/
public Part getLastPart() {
Expand All @@ -138,7 +139,7 @@ public Part getLastPart() {

/**
* Returns the Java type of the expression if it's a literal and null otherwise.
*
*
* @return the Java type of the expression if it's a literal and null otherwise.
*/
public String getLiteralJavaType() {
Expand Down Expand Up @@ -174,11 +175,11 @@ public boolean canSupportInfixNotation() {
/**
* Returns true if the last part of the expression is optional (ends with ??)
* and false otherwise.
*
*
* <p>
* {foo??}
* </p>
*
*
* @return true if the last part of the expression is optional (ends with ??)
* and false otherwise.
*/
Expand All @@ -189,9 +190,9 @@ public boolean isOptional() {

/**
* Returns the owner parameter of the expression and null otherwise.
*
*
* For expression like {foo}, the owner parameter is null.
*
*
* @return the owner parameter of the expression and null otherwise.
*/
public Parameter getOwnerParameter() {
Expand All @@ -200,9 +201,9 @@ public Parameter getOwnerParameter() {

/**
* Returns the owner section of the expression and null otherwise.
*
*
* For expression like {foo}, the owner section is null.
*
*
* @return the owner section of the expression and null otherwise.
*/
public Section getOwnerSection() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public CompletableFuture<List<UserTagInfo>> getUserTags(QuteUserTagParams params
/**
* Returns the Java member (field or method) from the given Java base type with
* the given property and null otherwise.
*
*
* @param baseType the Java base type.
* @param property the member property (field name or getter method name).
* @param projectUri the project Uri used to search in the extended Java type.
Expand Down Expand Up @@ -419,11 +419,11 @@ public JavaMemberResult findProperty(ResolvedJavaTypeInfo baseType, String prope
/**
* Returns the Java member from the given base type wich matches the given
* property by using Java reflection and null otherwise.
*
*
* @param baseType the Java type.
* @param property the property member.
* @param projectUri the project Uri.
*
*
* @return the Java member from the given base type wich matches the given
* property by using Java reflection and null otherwise.
*/
Expand Down Expand Up @@ -504,7 +504,7 @@ protected static JavaFieldInfo findField(ResolvedJavaTypeInfo baseType, String f
/**
* Returns the member method retrieved by the given property or method name and
* null otherwise.
*
*
* @param baseType the Java base type.
* @param methodName property or method name.
* @param getterMethodName the getter method name.
Expand Down Expand Up @@ -668,7 +668,9 @@ private boolean isMatchParameters(JavaMethodInfo method, List<ResolvedJavaTypeIn
boolean virtualMethod = method.isVirtual();
int nbParameters = method.getParameterslength();
int declaredNbParameters = parameterTypes.size();
JavaParameterInfo lastParameter = method.hasParameters() ? method.getParameterAt(method.getParameters().size() - 1) : null;
JavaParameterInfo lastParameter = method.hasParameters()
? method.getParameterAt(method.getParameters().size() - 1)
: null;
boolean varargs = lastParameter != null && lastParameter.isVarargs();
if (varargs) {
if (declaredNbParameters == 0) {
Expand Down Expand Up @@ -821,7 +823,14 @@ public boolean hasNamespace(String namespace, String projectUri) {
return getAllNamespaces(projectUri).contains(namespace);
}

private Set<String> getAllNamespaces(String projectUri) {
/**
* Return all namespaces from the given Qute project Uri.
*
* @param projectUri the Qute project Uri
*
* @return all namespace from the given Qute project Uri.
*/
public Set<String> getAllNamespaces(String projectUri) {
AlexXuChen marked this conversation as resolved.
Show resolved Hide resolved
if (StringUtils.isEmpty(projectUri)) {
return Collections.emptySet();
}
Expand Down Expand Up @@ -1104,10 +1113,10 @@ private CompletableFuture<List<ValueResolver>> getGlobalVariablesValueResolvers(
/**
* Returns the java type filter according the given root java type and the
* native mode.
*
*
* @param rootJavaType the Java root type.
* @param nativeImagesSettings the native images settings.
*
*
* @return the java type filter according the given root java type and the
* native mode.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package com.redhat.qute.project.datamodel;

import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;

Expand Down Expand Up @@ -89,7 +90,7 @@ private CompletableFuture<ResolvedJavaTypeInfo> resolveJavaType(Parts parts, int
boolean nullIfDontMatchWithIterable) {
CompletableFuture<ResolvedJavaTypeInfo> future = null;
for (int i = 0; i < partIndex + 1; i++) {
Part current = ((Part) parts.getChild(i));
Part current = (parts.getChild(i));
switch (current.getPartKind()) {
case Object:
ObjectPart objectPart = (ObjectPart) current;
Expand Down Expand Up @@ -272,6 +273,10 @@ public boolean hasNamespace(String namespace, String projectUri) {
return projectRegistry.hasNamespace(namespace, projectUri);
}

public Set<String> getAllNamespaces(String projectUri) {
return projectRegistry.getAllNamespaces(projectUri);
}

public CompletableFuture<JavaElementInfo> findJavaElementWithNamespace(String namespace, String partName,
String projectUri) {
return projectRegistry.findJavaElementWithNamespace(namespace, partName, projectUri);
Expand All @@ -297,10 +302,10 @@ public JavaMemberResult findMethod(ResolvedJavaTypeInfo baseType, String namespa
/**
* Returns the java type filter according the given root java type and the
* native mode.
*
*
* @param rootJavaType the Java root type.
* @param nativeImagesSettings the native images settings.
*
*
* @return the java type filter according the given root java type and the
* native mode.
*/
Expand Down
Loading