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

Include dir support for diagnostics #238

Merged
merged 13 commits into from
Dec 5, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public class LibertyDiagnosticParticipant implements IDiagnosticsParticipant {
public static final String IMPLICIT_NOT_OPTIONAL_MESSAGE = "The specified resource cannot be skipped. Check location value or add optional attribute.";
public static final String IMPLICIT_NOT_OPTIONAL_CODE = "implicit_not_optional";

public static final String SPECIFIED_DIR_IS_FILE = "Path specified a directory, but resource exists as a file.";
public static final String SPECIFIED_FILE_IS_DIR = "Path specified a file, but resource exists as a directory.";
public static final String SPECIFIED_DIR_IS_FILE = "Path specified a directory, but resource exists as a file. Please remove the trailing slash.";
public static final String SPECIFIED_FILE_IS_DIR = "Path specified a file, but resource exists as a directory. Please add a trailing slash.";
evie-lau marked this conversation as resolved.
Show resolved Hide resolved
public static final String FILETYPE_MISMATCH_CODE = "filetype_mismatch";

public static final String INCORRECT_FEATURE_CODE = "incorrect_feature";
Expand Down Expand Up @@ -161,7 +161,7 @@ private void validateIncludeLocation(DOMDocument domDocument, List<Diagnostic> d
Range range = XMLPositionUtility.createRange(locNode.getStart(), locNode.getEnd(), domDocument);
if (!locAttribute.endsWith(".xml")
&& !isLibertyDirectory) {
String message = "The specified resource is not an XML file or directory.";
String message = "The specified resource is not an XML file. If it is a directory, it must end with a trailing slash.";
evie-lau marked this conversation as resolved.
Show resolved Hide resolved
evie-lau marked this conversation as resolved.
Show resolved Hide resolved
diagnosticsList.add(new Diagnostic(range, message, DiagnosticSeverity.Warning, LIBERTY_LEMMINX_SOURCE));
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ public void testDiagnosticsForInclude() throws IOException {

Diagnostic not_xml = new Diagnostic();
not_xml.setRange(r(3, 29, 3, 52));
not_xml.setMessage("The specified resource is not an XML file or directory.");
not_xml.setMessage("The specified resource is not an XML file. If it is a directory, it must end with a trailing slash.");

Diagnostic multi_liner = new Diagnostic();
multi_liner.setRange(r(5, 28, 5, 50));
multi_liner.setMessage("The specified resource is not an XML file or directory.");
multi_liner.setMessage("The specified resource is not an XML file. If it is a directory, it must end with a trailing slash.");

Diagnostic not_optional = new Diagnostic();
not_optional.setRange(r(6, 13, 6, 29));
Expand All @@ -201,12 +201,12 @@ public void testDiagnosticsForInclude() throws IOException {
Diagnostic dirIsFile = new Diagnostic();
dirIsFile.setRange(r(8, 13, 8, 42));
dirIsFile.setCode("filetype_mismatch");
dirIsFile.setMessage("Path specified a directory, but resource exists as a file.");
dirIsFile.setMessage("Path specified a directory, but resource exists as a file. Please remove the trailing slash.");

Diagnostic fileIsDir = new Diagnostic();
fileIsDir.setRange(r(9, 13, 9, 36));
fileIsDir.setCode("filetype_mismatch");
fileIsDir.setMessage("Path specified a file, but resource exists as a directory.");
fileIsDir.setMessage("Path specified a file, but resource exists as a directory. Please add a trailing slash.");

XMLAssert.testDiagnosticsFor(serverXML, null, null, serverXMLFile.toURI().toString(),
not_xml, multi_liner, not_optional, missing_xml, optional_not_defined, missing_xml2,
Expand Down