-
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.
fix: False-positive error on let-defined variable
Fixes #993 Signed-off-by: azerr <[email protected]>
- Loading branch information
1 parent
29a810a
commit 2e221e9
Showing
16 changed files
with
853 additions
and
6 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
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
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
68 changes: 68 additions & 0 deletions
68
....ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/project/qute_web/QuteWebProject.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,68 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 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.project.qute_web; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.redhat.qute.commons.ProjectInfo; | ||
import com.redhat.qute.commons.ResolvedJavaTypeInfo; | ||
import com.redhat.qute.commons.datamodel.DataModelParameter; | ||
import com.redhat.qute.commons.datamodel.DataModelProject; | ||
import com.redhat.qute.commons.datamodel.DataModelTemplate; | ||
import com.redhat.qute.commons.datamodel.resolvers.NamespaceResolverInfo; | ||
import com.redhat.qute.commons.datamodel.resolvers.ValueResolverInfo; | ||
import com.redhat.qute.project.BaseQuteProject; | ||
import com.redhat.qute.project.QuteProjectRegistry; | ||
|
||
/** | ||
* Qute Web project. | ||
*/ | ||
public class QuteWebProject extends BaseQuteProject { | ||
|
||
public static final String PROJECT_URI = "qute-web"; | ||
|
||
private DataModelProject<DataModelTemplate<?>> dataModel; | ||
|
||
public QuteWebProject(ProjectInfo projectInfo, QuteProjectRegistry projectRegistry) { | ||
super(projectInfo, projectRegistry); | ||
} | ||
|
||
@Override | ||
protected void fillResolvedJavaTypes(List<ResolvedJavaTypeInfo> resolvedJavaTypes) { | ||
super.fillResolvedJavaTypes(resolvedJavaTypes); | ||
loadResolvedJavaType("HttpServletRequest.json", resolvedJavaTypes, QuteWebProject.class); | ||
} | ||
|
||
@Override | ||
protected void fillTemplates(List<DataModelTemplate<DataModelParameter>> templates) { | ||
|
||
} | ||
|
||
@Override | ||
protected void fillValueResolvers(List<ValueResolverInfo> valueResolvers) { | ||
valueResolvers.addAll(getDataModel().getValueResolvers()); | ||
} | ||
|
||
private DataModelProject<DataModelTemplate<?>> getDataModel() { | ||
if (dataModel == null) { | ||
dataModel = loadDataModel("QuteWebDataModel.json", QuteWebProject.class); | ||
} | ||
return dataModel; | ||
} | ||
|
||
@Override | ||
protected void fillNamespaceResolverInfos(Map<String, NamespaceResolverInfo> namespaces) { | ||
|
||
} | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
...s/src/test/java/com/redhat/qute/services/completions/qute_web/QuteWebCompletionsTest.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,56 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 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.services.completions.qute_web; | ||
|
||
import static com.redhat.qute.QuteAssert.c; | ||
import static com.redhat.qute.QuteAssert.r; | ||
|
||
import org.eclipse.lsp4j.CompletionItem; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import com.redhat.qute.QuteAssert; | ||
import com.redhat.qute.project.qute_web.QuteWebProject; | ||
|
||
/** | ||
* Test completion with Qute Web Quarkus extension. | ||
* | ||
* @author Angelo ZERR | ||
* | ||
*/ | ||
public class QuteWebCompletionsTest { | ||
|
||
@Test | ||
public void http_param() throws Exception { | ||
String template = "{#let name=http:param('name', 'Qute')}\r\n" + // | ||
"{name.|}"; | ||
testCompletionFor(template, // | ||
// - resolvers | ||
c("orEmpty(base : T) : List<T>", "orEmpty", r(1, 6, 1, 6)), | ||
c("ifTruthy(base : T, arg : Object) : T", "ifTruthy(${1:arg})$0", r(1, 6, 1, 6)), | ||
c("or(base : T, arg : Object) : T", "or(${1:arg})$0", r(1, 6, 1, 6)), | ||
// - String Java fields | ||
c("UTF16 : byte", "UTF16", r(1, 6, 1, 6)), | ||
// - String Java methods | ||
c("getBytes() : byte[]", "getBytes", r(1, 6, 1, 6)), | ||
c("getBytes(charsetName : String) : byte[]", "getBytes(${1:charsetName})$0", r(1, 6, 1, 6)), | ||
c("charAt(index : int) : char", "charAt(${1:index})$0", r(1, 6, 1, 6))); | ||
} | ||
|
||
public static void testCompletionFor(String value, | ||
CompletionItem... expectedItems) throws Exception { | ||
QuteAssert.testCompletionFor(value, true, QuteAssert.FILE_URI, null, QuteWebProject.PROJECT_URI, | ||
QuteAssert.TEMPLATE_BASE_DIR, | ||
null, | ||
expectedItems); | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
...s/src/test/java/com/redhat/qute/services/diagnostics/qute_web/QuteWebDiagnosticsTest.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,45 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 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.services.diagnostics.qute_web; | ||
|
||
import org.eclipse.lsp4j.Diagnostic; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import com.redhat.qute.QuteAssert; | ||
import com.redhat.qute.project.qute_web.QuteWebProject; | ||
|
||
/** | ||
* Test diagnostics with Qute Web Quarkus extension. | ||
* | ||
* @author Angelo ZERR | ||
* | ||
*/ | ||
public class QuteWebDiagnosticsTest { | ||
|
||
@Test | ||
public void noError() throws Exception { | ||
String template = "{#let name=http:param('name', 'Qute')}\r\n" + // | ||
"<!DOCTYPE html>\r\n" + // | ||
"<html>\r\n" + // | ||
"<body>\r\n" + // | ||
"<h1>Hello {name}</h1>\r\n" + // | ||
"</body>\r\n" + // | ||
"</html>"; | ||
testDiagnosticsFor(template); | ||
} | ||
|
||
private static void testDiagnosticsFor(String value, Diagnostic... expected) { | ||
QuteAssert.testDiagnosticsFor(value, QuteAssert.FILE_URI, null, QuteWebProject.PROJECT_URI, | ||
QuteAssert.TEMPLATE_BASE_DIR, true, null, expected); | ||
} | ||
|
||
} |
Oops, something went wrong.