added positioning for 'ILLEGAL_ESCAPE' error
This commit is contained in:
@@ -468,7 +468,7 @@ public interface Errors {
|
||||
DiagnosticFactory0<JetConstantExpression> INCORRECT_CHARACTER_LITERAL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetConstantExpression> EMPTY_CHARACTER_LITERAL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<JetConstantExpression, JetConstantExpression> TOO_MANY_CHARACTERS_IN_CHARACTER_LITERAL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetElement, JetElement> ILLEGAL_ESCAPE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetElement, JetElement> ILLEGAL_ESCAPE = DiagnosticFactory1.create(ERROR, CUT_CHAR_QUOTES);
|
||||
DiagnosticFactory1<JetConstantExpression, JetType> NULL_FOR_NONNULL_TYPE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<JetEscapeStringTemplateEntry> ILLEGAL_ESCAPE_SEQUENCE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiNameIdentifierOwner;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lexer.JetKeywordToken;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
@@ -433,6 +434,21 @@ public class PositioningStrategies {
|
||||
}
|
||||
};
|
||||
|
||||
public static final PositioningStrategy<JetElement> CUT_CHAR_QUOTES = new PositioningStrategy<JetElement>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public List<TextRange> mark(@NotNull JetElement element) {
|
||||
if (element instanceof JetConstantExpression) {
|
||||
if (element.getNode().getElementType() == JetNodeTypes.CHARACTER_CONSTANT) {
|
||||
TextRange elementTextRange = element.getTextRange();
|
||||
return Collections.singletonList(
|
||||
TextRange.create(elementTextRange.getStartOffset() + 1, elementTextRange.getEndOffset() - 1));
|
||||
}
|
||||
}
|
||||
return super.mark(element);
|
||||
}
|
||||
};
|
||||
|
||||
private PositioningStrategies() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user