Additional improvements for PT-140709005
For missing properties in toplevel nodes, place the error marker at the end of the document.
This commit is contained in:
@@ -283,4 +283,11 @@ public class DocumentRegion implements CharSequence {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a document region of lenght 0 at the every end of the document.
|
||||
*/
|
||||
public static DocumentRegion endOf(IDocument doc) {
|
||||
return new DocumentRegion(doc, doc.getLength(), doc.getLength());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -123,6 +123,8 @@ public class YamlSchemaProblems {
|
||||
return problem(MISSING_PROPERTY, msg, underline);
|
||||
}
|
||||
}
|
||||
} else if (parent==null) {
|
||||
return problem(MISSING_PROPERTY, msg, DocumentRegion.endOf(doc));
|
||||
}
|
||||
return problem(MISSING_PROPERTY, msg, map);
|
||||
}
|
||||
|
||||
@@ -619,4 +619,15 @@ public class Editor {
|
||||
return languageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a given Range corresponds with the end of the document in the editor.
|
||||
*/
|
||||
public void assertIsEndOfFile(Range range) {
|
||||
int documentLen = document.getText().length();
|
||||
int start = document.toOffset(range.getStart());
|
||||
int end = document.toOffset(range.getEnd());
|
||||
assertEquals(documentLen, start);
|
||||
assertEquals(documentLen, end);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2268,7 +2268,10 @@ public class ConcourseEditorTest {
|
||||
editor = harness.newEditor(LanguageIds.CONCOURSE_TASK,
|
||||
"image: some-image"
|
||||
);
|
||||
editor.assertProblems("image: some-image|[platform, run] are required");
|
||||
List<Diagnostic> problems = editor.assertProblems("|[platform, run] are required");
|
||||
for (Diagnostic p : problems) {
|
||||
editor.assertIsEndOfFile(p.getRange());
|
||||
}
|
||||
|
||||
editor = harness.newEditor(LanguageIds.CONCOURSE_TASK,
|
||||
"platform: a-platform\n" +
|
||||
|
||||
Reference in New Issue
Block a user