forked from redhat-developer/quarkus-ls
-
Notifications
You must be signed in to change notification settings - Fork 0
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 redhat-developer#993 Signed-off-by: azerr <[email protected]>
- Loading branch information
1 parent
29a810a
commit e537bcf
Showing
15 changed files
with
797 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) { | ||
|
||
} | ||
|
||
} |
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); | ||
} | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
...te.ls/src/test/java/com/redhat/qute/services/inlayhint/qute_web/QuteWebInlayHintTest.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.services.inlayhint.qute_web; | ||
|
||
import static com.redhat.qute.QuteAssert.ih; | ||
import static com.redhat.qute.QuteAssert.ihLabel; | ||
import static com.redhat.qute.QuteAssert.p; | ||
|
||
import org.eclipse.lsp4j.Command; | ||
import org.eclipse.lsp4j.InlayHint; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import com.redhat.qute.QuteAssert; | ||
import com.redhat.qute.project.qute_web.QuteWebProject; | ||
import com.redhat.qute.services.inlayhint.InlayHintASTVistor; | ||
|
||
/** | ||
* Tests for Qute inlay hint in Qute Web project. | ||
* | ||
* @author Angelo ZERR | ||
* | ||
*/ | ||
public class QuteWebInlayHintTest { | ||
|
||
@Test | ||
public void http_request() throws Exception { | ||
// http:request | ||
String template = "{#let name=http:request}"; | ||
testInlayHintFor(template, // | ||
ih(p(0, 10), ihLabel(":"), | ||
ihLabel("HttpServerRequest", "Open `io.vertx.core.http.HttpServerRequest` Java type.", | ||
cd("io.vertx.core.http.HttpServerRequest")))); | ||
|
||
// http:request() | ||
template = "{#let name=http:request()}"; | ||
testInlayHintFor(template, // | ||
ih(p(0, 10), ihLabel(":"), | ||
ihLabel("HttpServerRequest", "Open `io.vertx.core.http.HttpServerRequest` Java type.", | ||
cd("io.vertx.core.http.HttpServerRequest")))); | ||
} | ||
|
||
@Test | ||
public void http_param() throws Exception { | ||
String template = "{#let name=http:param('name', 'Qute')}"; | ||
testInlayHintFor(template, // | ||
ih(p(0, 10), ihLabel(":"), ihLabel("String", "Open `java.lang.String` Java type.", cd("java.lang.String")))); | ||
|
||
} | ||
|
||
public static void testInlayHintFor(String value, InlayHint... expected) | ||
throws Exception { | ||
QuteAssert.testInlayHintFor(value, QuteAssert.FILE_URI, null, QuteWebProject.PROJECT_URI, | ||
QuteAssert.TEMPLATE_BASE_DIR, null, expected); | ||
} | ||
|
||
private static Command cd(String javaType) { | ||
return InlayHintASTVistor.createOpenJavaTypeCommand(javaType, QuteWebProject.PROJECT_URI); | ||
} | ||
} |
Oops, something went wrong.