Skip to content

Commit

Permalink
Fix code completion
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon J committed Oct 17, 2024
1 parent 7a5ea3b commit ce8ba77
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class RBladeFileViewProvider(
}

override fun getLanguages(): MutableSet<Language> {
return mutableSetOf(RBladeLanguage.INSTANCE, HTMLLanguage.INSTANCE, RubyLanguage.INSTANCE)
return mutableSetOf(RBladeLanguage.INSTANCE, RubyLanguage.INSTANCE, HTMLLanguage.INSTANCE)
}

override fun getTemplateDataLanguage(): Language {
Expand Down
9 changes: 8 additions & 1 deletion src/main/kotlin/com/mwnciau/rblade/lexer/EmbeddedRuby.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.intellij.lexer.LexerBase
import com.intellij.psi.tree.IElementType
import com.mwnciau.rblade.RBladeLexerAdapter
import com.mwnciau.rblade.psi.RBladeTypes
import com.mwnciau.rblade.psi.RBladeTypes.RBLADE_STATEMENT
import com.mwnciau.rblade.psi.RBladeTypes.RUBY_EXPRESSION
import org.jetbrains.plugins.ruby.ruby.lang.RubyLanguage
import org.jetbrains.plugins.ruby.ruby.lang.lexer.RubyLexer
Expand Down Expand Up @@ -37,8 +38,11 @@ class EmbeddedRuby : LexerBase() {
if (tokenType == RBladeTypes.COMMENT) {
return RubyTokenTypes.TLINE_COMMENT
}
if (tokenType == RBLADE_STATEMENT) {
return RubyTokenTypes.tWHITE_SPACE_WITH_NEWLINE
}
if (tokenType.language != RubyLanguage.INSTANCE) {
return RubyTokenTypes.tBLOCK_COMMENT
return RubyTokenTypes.tWHITE_SPACE_WITH_NEWLINE
}
}

Expand All @@ -62,6 +66,9 @@ class EmbeddedRuby : LexerBase() {
}
} else {
rbladeLexer.advance()
while (rbladeLexer.tokenType != null && rbladeLexer.tokenType != RUBY_EXPRESSION && rbladeLexer.tokenType != RBLADE_STATEMENT) {
rbladeLexer.advance()
}

if (rbladeLexer.tokenType == RUBY_EXPRESSION){
rubyLexer.start(bufferSequence, rbladeLexer.tokenStart, rbladeLexer.tokenEnd)
Expand Down

0 comments on commit ce8ba77

Please sign in to comment.