/*
 * Copyright 2011 Jon S Akhtar (Sylvanaar)
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

package com.sylvanaar.idea.Lua.lang.template;

import com.intellij.codeInsight.template.TemplateContextType;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.psi.PsiFile;
import com.sylvanaar.idea.Lua.LuaFileType;
import com.sylvanaar.idea.Lua.editor.highlighter.LuaSyntaxHighlighter;
import com.sylvanaar.idea.Lua.lang.psi.LuaPsiFile;
import org.jetbrains.annotations.NotNull;

/**
 * Created by IntelliJ IDEA.
 * User: Jon S Akhtar
 * Date: 2/22/11
 * Time: 10:45 PM
 */
public class LuaTemplateContextType extends TemplateContextType {
    protected LuaTemplateContextType() {
        super("LUA", "Lua");
    }

    public boolean isInContext(@NotNull PsiFile file, int offset) {
        return file instanceof LuaPsiFile;
    }

    @Override
    public SyntaxHighlighter createHighlighter() {
        return new LuaSyntaxHighlighter();
    }
}


@@ -722,35 +722,17 @@
 emplate.
-TemplateContextType
+*
 ;%0D%0Aimpor
@@ -764,24 +764,17 @@
 leTypes.
-FileType
+*
 ;%0D%0Aimpor
@@ -792,43 +792,13 @@
 lij.
-openapi.fileTypes.SyntaxHighlighter
+psi.*
 ;%0D%0Ai
@@ -820,23 +820,22 @@
 lij.psi.
-PsiFile
+util.*
 ;%0D%0Aimpor
@@ -863,19 +863,9 @@
 Lua.
-LuaFileType
+*
 ;%0D%0Ai
@@ -916,80 +916,9 @@
 ter.
-LuaSyntaxHighlighter;%0D%0Aimport com.sylvanaar.idea.Lua.lang.psi.LuaPsiFile
+*
 ;%0D%0Ai
@@ -949,23 +949,17 @@
 tations.
-NotNull
+*
 ;%0D%0A%0D%0A/**
@@ -1284,40 +1284,278 @@
     
-return file instanceof LuaPsiFil
+if (PsiUtilBase.getLanguageAtOffset(file, offset).isKindOf(LuaFileType.LUA_LANGUAGE)) %7B%0D%0A          PsiElement element = file.findElementAt(offset);%0D%0A          return PsiTreeUtil.getParentOfType(element, PsiComment.class, false) == null;%0D%0A        %7D%0D%0A%0D%0A        return fals
 e;%0D%0A

fix #103