Skip to content

Commit

Permalink
Add annotator
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed Apr 18, 2018
1 parent 6da7b84 commit 0455667
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/com/tang/intellij/devkt/lua/lang/LuaLanguage.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

package com.tang.intellij.devkt.lua.lang;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.com.intellij.lang.Language;
import org.jetbrains.kotlin.com.intellij.openapi.fileTypes.LanguageFileType;

/**
* Created by TangZhiXu on 2015/11/15.
Expand All @@ -28,6 +30,12 @@ public class LuaLanguage extends Language {

public static final LuaLanguage INSTANCE = new LuaLanguage();

@Override
public @NotNull
LanguageFileType getAssociatedFileType() {
return LuaFileType.INSTANCE;
}

public LuaLanguage() {
super("Lua");
}
Expand Down
21 changes: 17 additions & 4 deletions src/com/tang/intellij/devkt/lua/lua-devkt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package com.tang.intellij.devkt.lua
import com.tang.intellij.devkt.lua.highlighting.*
import com.tang.intellij.devkt.lua.lang.LuaLanguage
import com.tang.intellij.devkt.lua.lang.LuaParserDefinition
import com.tang.intellij.devkt.lua.psi.LuaStringTypes
import com.tang.intellij.devkt.lua.psi.LuaTypes
import org.ice1000.devkt.openapi.ColorScheme
import org.ice1000.devkt.openapi.ExtendedDevKtLanguage
import com.tang.intellij.devkt.lua.psi.*
import org.ice1000.devkt.openapi.*
import org.jetbrains.kotlin.com.intellij.psi.PsiElement
import org.jetbrains.kotlin.com.intellij.psi.tree.IElementType

class EmmyLua<T> : ExtendedDevKtLanguage<T>(
Expand Down Expand Up @@ -41,5 +40,19 @@ class EmmyLua<T> : ExtendedDevKtLanguage<T>(
else -> super.attributesOf(type, colorScheme)
}

override fun annotate(element: PsiElement, document: AnnotationHolder<T>, colorScheme: ColorScheme<T>) {
super.annotate(element, document, colorScheme)
when (element) {
is LuaFuncDef -> function(element, document, colorScheme)
is LuaLocalDef -> {
element.nameList?.run { nameDefList.forEach {
document.highlight(it, colorScheme.variable)
} }
}
}
}

private fun function(element: LuaFuncDef, document: AnnotationHolder<T>, colorScheme: ColorScheme<T>) {
element.id?.let { document.highlight(it, colorScheme.function) }
}
}

0 comments on commit 0455667

Please sign in to comment.