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() {
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ fun ff() {
|
||||
val <!UNUSED_VARIABLE!>c<!> = <!TOO_MANY_CHARACTERS_IN_CHARACTER_LITERAL!>'23'<!>
|
||||
val <!UNUSED_VARIABLE!>d<!> = <!INCORRECT_CHARACTER_LITERAL!>'a<!>
|
||||
val <!UNUSED_VARIABLE!>e<!> = <!INCORRECT_CHARACTER_LITERAL!>'ab<!>
|
||||
val <!UNUSED_VARIABLE!>f<!> = <!ILLEGAL_ESCAPE!>'\'<!>
|
||||
val <!UNUSED_VARIABLE!>f<!> = '<!ILLEGAL_ESCAPE!>\<!>'
|
||||
}
|
||||
|
||||
fun test() {
|
||||
@@ -19,19 +19,19 @@ fun test() {
|
||||
<!UNUSED_EXPRESSION!>'\''<!>
|
||||
<!UNUSED_EXPRESSION!>'\\'<!>
|
||||
<!UNUSED_EXPRESSION!>'\$'<!>
|
||||
<!ILLEGAL_ESCAPE, UNUSED_EXPRESSION!>'\x'<!>
|
||||
<!ILLEGAL_ESCAPE, UNUSED_EXPRESSION!>'\123'<!>
|
||||
<!ILLEGAL_ESCAPE, UNUSED_EXPRESSION!>'\ra'<!>
|
||||
<!ILLEGAL_ESCAPE, UNUSED_EXPRESSION!>'\000'<!>
|
||||
<!ILLEGAL_ESCAPE, UNUSED_EXPRESSION!>'\000'<!>
|
||||
<!UNUSED_EXPRESSION!>'<!ILLEGAL_ESCAPE!>\x<!>'<!>
|
||||
<!UNUSED_EXPRESSION!>'<!ILLEGAL_ESCAPE!>\123<!>'<!>
|
||||
<!UNUSED_EXPRESSION!>'<!ILLEGAL_ESCAPE!>\ra<!>'<!>
|
||||
<!UNUSED_EXPRESSION!>'<!ILLEGAL_ESCAPE!>\000<!>'<!>
|
||||
<!UNUSED_EXPRESSION!>'<!ILLEGAL_ESCAPE!>\000<!>'<!>
|
||||
<!UNUSED_EXPRESSION!>'\u0000'<!>
|
||||
<!UNUSED_EXPRESSION!>'\u000a'<!>
|
||||
<!UNUSED_EXPRESSION!>'\u000A'<!>
|
||||
<!ILLEGAL_ESCAPE, UNUSED_EXPRESSION!>'\u'<!>
|
||||
<!ILLEGAL_ESCAPE, UNUSED_EXPRESSION!>'\u0'<!>
|
||||
<!ILLEGAL_ESCAPE, UNUSED_EXPRESSION!>'\u00'<!>
|
||||
<!ILLEGAL_ESCAPE, UNUSED_EXPRESSION!>'\u000'<!>
|
||||
<!ILLEGAL_ESCAPE, UNUSED_EXPRESSION!>'\u000z'<!>
|
||||
<!ILLEGAL_ESCAPE, UNUSED_EXPRESSION!>'\\u000'<!>
|
||||
<!ILLEGAL_ESCAPE, UNUSED_EXPRESSION!>'\'<!>
|
||||
<!UNUSED_EXPRESSION!>'<!ILLEGAL_ESCAPE!>\u<!>'<!>
|
||||
<!UNUSED_EXPRESSION!>'<!ILLEGAL_ESCAPE!>\u0<!>'<!>
|
||||
<!UNUSED_EXPRESSION!>'<!ILLEGAL_ESCAPE!>\u00<!>'<!>
|
||||
<!UNUSED_EXPRESSION!>'<!ILLEGAL_ESCAPE!>\u000<!>'<!>
|
||||
<!UNUSED_EXPRESSION!>'<!ILLEGAL_ESCAPE!>\u000z<!>'<!>
|
||||
<!UNUSED_EXPRESSION!>'<!ILLEGAL_ESCAPE!>\\u000<!>'<!>
|
||||
<!UNUSED_EXPRESSION!>'<!ILLEGAL_ESCAPE!>\<!>'<!>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user