Package org.jetbrains.plugins.clojure.psi.api

Examples of org.jetbrains.plugins.clojure.psi.api.ClList


    return (ClList) element;
  }

  @NotNull
  public ClList findOrCreateImportClause(@Nullable PsiElement place) {
    final ClList imports = findImportClause(place);
    if (imports != null) return imports;
    return addFreshImportClause();
  }
View Full Code Here


  }

  public ClListLike addImportForClass(PsiElement place, PsiClass clazz) {
    commitDocument();
    final ClojurePsiFactory factory = ClojurePsiFactory.getInstance(getProject());
    final ClList importClause = findOrCreateImportClause(place);
    return factory.findOrCreateJavaImportForClass(clazz, importClause);
  }
View Full Code Here

    final PsiElement anchor = (preamble != null ? preamble :
        nsSymbol != null ? nsSymbol : first);
    assert first != null;

    final ClojurePsiFactory factory = ClojurePsiFactory.getInstance(getProject());
    final ClList list = factory.createListFromText(":import ");
    return (ClList) addAfter(list, anchor);
  }
View Full Code Here

  public PsiClassType[] getImplementsListTypes() {
    return new PsiClassType[0];
  }

  public PsiClass getSuperClass() {
    final ClList ns = getNsElement();
    final ClKeywordImpl key = ClojurePsiUtil.findNamespaceKeyByName(ns, ClojureKeywords.EXTENDS);
    if (key != null) {
      final PsiElement next = ClojurePsiUtil.getNextNonWhiteSpace(key);
      if (next instanceof ClSymbol) {
        ClSymbol symbol = (ClSymbol) next;
View Full Code Here

  private ClList getNsElement() {
    return myFile.getNamespaceElement();
  }

  public PsiClass[] getInterfaces() {
    final ClList ns = getNsElement();
    final ClKeywordImpl key = ClojurePsiUtil.findNamespaceKeyByName(ns, ClojureKeywords.IMPLEMENTS);
    final ArrayList<PsiClass> classes = new ArrayList<PsiClass>();
    final GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());
    final JavaPsiFacade facade = JavaPsiFacade.getInstance(getProject());
    if (key != null) {
View Full Code Here

    if (element instanceof ClSymbol) {
      ClSymbol symbol = (ClSymbol) element;
      final PsiElement parent = symbol.getParent();

      if (parent instanceof ClList) {
        ClList list = (ClList) parent;
        if (FN.equals(list.getHeadText())) return true;
      } else if (parent instanceof ClVector) {
        final PsiElement par = parent.getParent();
        if (par instanceof ClDef && ((ClDef) par).getSecondNonLeafElement() == element) return true;
        if (par instanceof ClList) {
          final String ht = ((ClList) par).getHeadText();
View Full Code Here

    }
    return myClass;
  }

  public void setNamespace(String newNs) {
    final ClList nsElem = getNamespaceElement();
    if (nsElem != null) {
      final ClSymbol first = nsElem.getFirstSymbol();
      final PsiElement second = nsElem.getSecondNonLeafElement();
      if (first != null && second != null) {
        final ClojurePsiFactory factory = ClojurePsiFactory.getInstance(getProject());
        final ASTNode newNode = factory.createSymbolNodeFromText(newNs);
        final ASTNode parentNode = nsElem.getNode();
        if (parentNode != null) {
          parentNode.replaceChild(second.getNode(), newNode);
        }
      }
    }
View Full Code Here

* @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;
View Full Code Here

    StubElement stub = getStub();
    if (stub instanceof ClFileStub) {
      return ((ClFileStub) stub).isClassDefinition();
    }

    final ClList ns = ClojurePsiUtil.findFormByName(this, "ns");
    if (ns == null) return false;
    final ClSymbol first = ns.findFirstChildByClass(ClSymbol.class);
    if (first == null) return false;
    final ClSymbol snd = PsiTreeUtil.getNextSiblingOfType(first, ClSymbol.class);
    if (snd == null) return false;

    return ClojurePsiUtil.findNamespaceKeyByName(ns, ClojureKeywords.GEN_CLASS) != null;
View Full Code Here

    return ClojurePsiUtil.findNamespaceKeyByName(ns, ClojureKeywords.GEN_CLASS) != null;
  }

  public String getNamespace() {
    final ClList ns = getNamespaceElement();
    if (ns == null) return null;
    final ClSymbol first = ns.findFirstChildByClass(ClSymbol.class);
    if (first == null) return null;
    final ClSymbol snd = PsiTreeUtil.getNextSiblingOfType(first, ClSymbol.class);
    if (snd == null) return null;

    return snd.getNameString();
View Full Code Here

TOP

Related Classes of org.jetbrains.plugins.clojure.psi.api.ClList

Copyright © 2018 www.massapicom. 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.