<repo_name>JonnoFTW/OpenCL-Support-Plugin<file_sep>/src/com/jonathanmackenzie/opencl/plugin/psi/OpenClElementType.java
package com.jonathanmackenzie.opencl.plugin.psi;

import com.intellij.psi.tree.IElementType;
import com.jonathanmackenzie.opencl.plugin.OpenClLanguage;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

/**
 * Created by mack0242 on 3/03/17.
 */
public class OpenClElementType extends IElementType {
    public OpenClElementType(@NotNull @NonNls String debugName) {
        super(debugName, OpenClLanguage.INSTANCE);
    }
}
<file_sep>/src/com/jonathanmackenzie/opencl/plugin/OpenClStructureViewModel.java
package com.jonathanmackenzie.opencl.plugin;

import com.intellij.ide.structureView.*;
import com.intellij.ide.util.treeView.smartTree.Sorter;
import com.intellij.psi.PsiFile;
import com.jonathanmackenzie.opencl.plugin.psi.OpenClFile;
import org.jetbrains.annotations.NotNull;

public class OpenClStructureViewModel extends StructureViewModelBase implements
    StructureViewModel.ElementInfoProvider {
  public OpenClStructureViewModel(PsiFile psiFile) {
    super(psiFile, new OpenClStructureViewElement(psiFile));
  }

  @NotNull
  public Sorter[] getSorters() {
    return new Sorter[]{Sorter.ALPHA_SORTER};
  }


  @Override
  public boolean isAlwaysShowsPlus(StructureViewTreeElement element) {
    return false;
  }

  @Override
  public boolean isAlwaysLeaf(StructureViewTreeElement element) {
    return element instanceof OpenClFile;
  }
}<file_sep>/src/com/jonathanmackenzie/opencl/plugin/psi/impl/OpenClPsiImplUtil.java
package com.jonathanmackenzie.opencl.plugin.psi.impl;

import com.intellij.lang.ASTNode;
import com.intellij.navigation.ItemPresentation;
import com.intellij.psi.*;
import com.jonathanmackenzie.opencl.plugin.OpenClIcons;
import com.jonathanmackenzie.opencl.plugin.psi.*;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;

public class OpenClPsiImplUtil {
    public static String getKey(OpenClProperty element) {
        ASTNode keyNode = element.getNode().findChildByType(OpenClTypes.KEY);
        if (keyNode != null) {
            // IMPORTANT: Convert embedded escaped spaces to simple spaces
            return keyNode.getText().replaceAll("\\\\ ", " ");
        } else {
            return null;
        }
    }

    public static String getValue(OpenClProperty element) {
        ASTNode valueNode = element.getNode().findChildByType(OpenClTypes.VALUE);
        if (valueNode != null) {
            return valueNode.getText();
        } else {
            return null;
        }
    }

    public static String getName(OpenClProperty element) {
        return getKey(element);
    }

    public static PsiElement setName(OpenClProperty element, String newName) {
        ASTNode keyNode = element.getNode().findChildByType(OpenClTypes.KEY);
        if (keyNode != null) {
            OpenClProperty property = OpenClElementFactory.createProperty(element.getProject(), newName);
            ASTNode newKeyNode = property.getFirstChild().getNode();
            element.getNode().replaceChild(keyNode, newKeyNode);
        }
        return element;
    }

    public static PsiElement getNameIdentifier(OpenClProperty element) {
        ASTNode keyNode = element.getNode().findChildByType(OpenClTypes.KEY);
        if (keyNode != null) {
            return keyNode.getPsi();
        } else {
            return null;
        }
    }

    public static ItemPresentation getPresentation(final OpenClProperty element) {
        return new ItemPresentation() {
            @Nullable
            @Override
            public String getPresentableText() {
                return element.getKey();
            }

            @Nullable
            @Override
            public String getLocationString() {
                PsiFile containingFile = element.getContainingFile();
                return containingFile == null ? null : containingFile.getName();
            }

            @Nullable
            @Override
            public Icon getIcon(boolean unused) {
                return OpenClIcons.FILE;
            }
        };
    }
}<file_sep>/src/com/jonathanmackenzie/opencl/plugin/OpenClLanguage.java
package com.jonathanmackenzie.opencl.plugin;

import com.intellij.lang.Language;

/**
 *
 */
public class OpenClLanguage extends Language {

    public static final OpenClLanguage INSTANCE = new OpenClLanguage();

    private OpenClLanguage() {
        super("OpenCl");
    }
}
<file_sep>/src/com/jonathanmackenzie/opencl/plugin/psi/OpenClTokenType.java
package com.jonathanmackenzie.opencl.plugin.psi;

import com.intellij.lang.Language;
import com.intellij.psi.tree.IElementType;
import com.jonathanmackenzie.opencl.plugin.OpenClLanguage;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * Created by mack0242 on 3/03/17.
 */
public class OpenClTokenType extends IElementType {
    public OpenClTokenType(@NotNull @NonNls String debugName) {
        super(debugName, OpenClLanguage.INSTANCE);
    }

    @Override
    public String toString() {
        return OpenClTokenType.class.getOpenClName() + "." + super.toString();
    }
}
<file_sep>/README.md
# OpenCL Plugin
A plugin for IntelliJ family of IDE's to provide features for OpenCL files. Provides:

* Syntax highlighting
* Error highlighting
* Lint and other compiler output

# Configuration
* Build options are used for each kernel file in your project.
* Path to opencl compiler
<file_sep>/src/com/jonathanmackenzie/opencl/plugin/OpenClTodoIndexer.java
package com.jonathanmackenzie.opencl.plugin;

import com.intellij.lexer.Lexer;
import com.intellij.psi.impl.cache.impl.OccurrenceConsumer;
import com.intellij.psi.impl.cache.impl.todo.LexerBasedTodoIndexer;

public class OpenClTodoIndexer extends LexerBasedTodoIndexer {
  @Override
  public Lexer createLexer(OccurrenceConsumer consumer) {
    return OpenClIdIndexer.createIndexingLexer(consumer);
  }
}
