Package org.jetbrains.plugins.clojure.psi.impl.symbols

Source Code of org.jetbrains.plugins.clojure.psi.impl.symbols.SymbolUtils

package org.jetbrains.plugins.clojure.psi.impl.symbols;

import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.plugins.clojure.ClojureIcons;
import org.jetbrains.plugins.clojure.psi.api.ClList;
import org.jetbrains.plugins.clojure.psi.api.symbols.ClSymbol;
import org.jetbrains.plugins.clojure.psi.impl.list.ListDeclarations;

import javax.swing.*;

/**
* @author nik
* @since 02.11.12
*/
public class SymbolUtils {
  public static Icon getIcon(ClSymbol symbol, int flags) {
    ClList list = PsiTreeUtil.getParentOfType(symbol, ClList.class);
    if (list == null) return null;
    if (!symbol.equals(list.getSecondNonLeafElement())) return null;
    PsiElement firstNonLeafElement = list.getFirstNonLeafElement();
    if (firstNonLeafElement instanceof ClSymbol) {
      String nameString = ((ClSymbol) firstNonLeafElement).getNameString();
      if (nameString.equals(ListDeclarations.FN)) return ClojureIcons.FUNCTION;
      else if (nameString.equals(ListDeclarations.DEFN) || nameString.equals(ListDeclarations.DEFN_)) return ClojureIcons.FUNCTION;
      else return null;
    } else return null;
  }
}
TOP

Related Classes of org.jetbrains.plugins.clojure.psi.impl.symbols.SymbolUtils

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.