summaryrefslogtreecommitdiff
path: root/platform/lang-api/src/com/intellij/lexer/LexerUtil.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/lang-api/src/com/intellij/lexer/LexerUtil.java')
-rw-r--r--platform/lang-api/src/com/intellij/lexer/LexerUtil.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/platform/lang-api/src/com/intellij/lexer/LexerUtil.java b/platform/lang-api/src/com/intellij/lexer/LexerUtil.java
index 7623248e60d1..8abdfa5e79af 100644
--- a/platform/lang-api/src/com/intellij/lexer/LexerUtil.java
+++ b/platform/lang-api/src/com/intellij/lexer/LexerUtil.java
@@ -16,6 +16,8 @@
package com.intellij.lexer;
import com.intellij.util.CharTable;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Nullable;
/**
* @author max
@@ -30,4 +32,12 @@ public class LexerUtil {
public static CharSequence internToken(Lexer lexer, CharTable table) {
return table.intern(getTokenText(lexer));
}
+
+ @Contract("!null->!null")
+ public static Lexer getRootLexer(@Nullable Lexer lexer) {
+ while (lexer instanceof DelegateLexer) {
+ lexer = ((DelegateLexer)lexer).getDelegate();
+ }
+ return lexer;
+ }
}