diff --git a/python/rest/src/com/jetbrains/rest/RestBundle.properties b/python/rest/src/com/jetbrains/rest/RestBundle.properties index 192f44308c13..7238abc402e5 100644 --- a/python/rest/src/com/jetbrains/rest/RestBundle.properties +++ b/python/rest/src/com/jetbrains/rest/RestBundle.properties @@ -9,7 +9,7 @@ QFIX.ignore.role=Ignore undefined role ''{0}'' ### Annotators ### ANN.unknown.target=Unknown target name ''{0}'' ANN.duplicate.target=Duplicate explicit target name ''{0}'' -ANN.title.length=Title length must match the underline +ANN.title.length=Overline length must match the underline ANN.unusable.anonymous.target=Anonymous hyperlink target has no reference ANN.inline.block=Blank line is required after a literal block diff --git a/python/rest/src/com/jetbrains/rest/psi/RestTitle.java b/python/rest/src/com/jetbrains/rest/psi/RestTitle.java index bcebf0de9af7..fc2a6058ed08 100644 --- a/python/rest/src/com/jetbrains/rest/psi/RestTitle.java +++ b/python/rest/src/com/jetbrains/rest/psi/RestTitle.java @@ -66,6 +66,22 @@ public class RestTitle extends RestElement { return text.substring(start, finish).trim(); } + @Nullable + public String getOverline() { + final String text = getNode().getText().trim(); + final Pair adornments = getAdornments(); + final Character overlineChar = adornments.getFirst(); + if (overlineChar == null) return null; + int end = 0; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) != overlineChar) { + end = i; + break; + } + } + return text.substring(0, end); + } + @Nullable public String getUnderline() { final String text = getNode().getText().trim(); diff --git a/python/rest/src/com/jetbrains/rest/validation/RestTitleAnnotator.java b/python/rest/src/com/jetbrains/rest/validation/RestTitleAnnotator.java index c906e311af83..7d6ae4c30e61 100644 --- a/python/rest/src/com/jetbrains/rest/validation/RestTitleAnnotator.java +++ b/python/rest/src/com/jetbrains/rest/validation/RestTitleAnnotator.java @@ -23,9 +23,9 @@ public class RestTitleAnnotator extends RestAnnotator { public void visitTitle(final RestTitle node) { final String name = node.getName(); if (name == null) return; - int nameLen = name.length(); final String underline = node.getUnderline(); - if (underline != null && nameLen != underline.length()) { + final String overline = node.getOverline(); + if (underline != null && overline != null && overline.length() != underline.length()) { getHolder().createWarningAnnotation(node, RestBundle.message("ANN.title.length")); } }