Utility method extracted

This commit is contained in:
Andrey Breslav
2011-06-18 16:07:52 +04:00
parent 2c5c92c728
commit 665b59ffd1
2 changed files with 10 additions and 6 deletions
@@ -1,6 +1,5 @@
package org.jetbrains.jet.lang.parsing;
import com.intellij.codeInspection.dataFlow.instructions.ReturnFromSubInstruction;
import com.intellij.lang.PsiBuilder;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
@@ -40,6 +39,15 @@ import static org.jetbrains.jet.lexer.JetTokens.*;
this.myBuilder = builder;
}
protected IElementType getLastToken() {
int i = 1;
int currentOffset = myBuilder.getCurrentOffset();
while (i <= currentOffset && WHITE_SPACE_OR_COMMENT_BIT_SET.contains(myBuilder.rawLookup(-i))) {
i++;
}
return myBuilder.rawLookup(-i);
}
protected boolean expect(JetToken expectation, String message) {
return expect(expectation, message, null);
}
@@ -836,11 +836,7 @@ public class JetParsing extends AbstractJetParsing {
parsePropertyGetterOrSetter();
}
if (!atSet(EOL_OR_SEMICOLON, RBRACE)) {
int i = -1;
while (-i < myBuilder.getCurrentOffset() && WHITE_SPACE_OR_COMMENT_BIT_SET.contains(myBuilder.rawLookup(i))) {
i--;
}
if (myBuilder.rawLookup(i) != SEMICOLON) {
if (getLastToken() != SEMICOLON) {
errorUntil("Property getter or setter expected", TokenSet.create(EOL_OR_SEMICOLON));
}
}