Package com.intellij.psi

Examples of com.intellij.psi.PsiElement


      endOffset = startOffset;
      startOffset = tmp;
    }

    // adjust start/end
    PsiElement element1 = file.findElementAt(startOffset);
    PsiElement element2 = file.findElementAt(endOffset - 1);
    if (element1 instanceof PsiWhiteSpace) {
      startOffset = element1.getTextRange().getEndOffset();
    }
    if (element2 instanceof PsiWhiteSpace) {
      endOffset = element2.getTextRange().getStartOffset();
    }
    final PsiElement elementAtStart = file.findElementAt(startOffset);
    final PsiElement elementAtEnd = file.findElementAt(endOffset - 1);
    if (elementAtStart != null && elementAtEnd != null) {

      if (elementAtStart == elementAtEnd && !(elementAtStart instanceof Expression)) {
        final PsiElement elementToSurround = elementAtStart.getParent();
        if (elementToSurround instanceof Expression) {
          return new PsiElement[]{elementToSurround};
        }
      } else {

        final PsiElement commonContext = PsiTreeUtil.findCommonParent(elementAtStart, elementAtEnd);
        if (commonContext != null && !(commonContext instanceof PsiFile))
          return new PsiElement[]{commonContext};
      }
    }
    return PsiElement.EMPTY_ARRAY;
View Full Code Here


  private class CollectorVisitor extends MathematicaRecursiveVisitor {

    @Override
    public void visitSetDelayed(final SetDelayed setDelayed) {
      final PsiElement lhs = setDelayed.getFirstChild();
      SetDefinitionSymbolVisitor visitor = new SetDefinitionSymbolVisitor(lhs, SET_DELAYED_ASSIGNMENT);
      lhs.accept(visitor);
      final java.util.Set<Symbol> unboundSymbols = visitor.getUnboundSymbols();
      for (Symbol symbol : unboundSymbols) {
        addAssignment(symbol, lhs, visitor.getAssignmentType());
      }
    }
View Full Code Here

      }
    }

    @Override
    public void visitSet(final Set set) {
      final PsiElement lhs = set.getFirstChild();
      SetDefinitionSymbolVisitor visitor = new SetDefinitionSymbolVisitor(lhs, SET_ASSIGNMENT);
      lhs.accept(visitor);
      final java.util.Set<Symbol> unboundSymbols = visitor.getUnboundSymbols();
      for (Symbol symbol : unboundSymbols) {
        PsiElement context = lhs;
        if (visitor.getAssignmentType() == ATTRIBUTES_ASSIGNMENT || visitor.getAssignmentType() == OPTIONS_ASSIGNMENT) {
          context = set.getLastChild();
        }
        addAssignment(symbol, context, visitor.getAssignmentType());
      }
View Full Code Here

      }
    }

    @Override
    public void visitTagSet(final TagSet tagSet) {
      final PsiElement symbol = tagSet.getFirstChild();
      if (symbol instanceof Symbol) {
        addAssignment((Symbol) symbol, tagSet, TAG_SET_ASSIGNMENT);
      }
    }
View Full Code Here

      }
    }

    @Override
    public void visitTagSetDelayed(final TagSetDelayed tagSetDelayed) {
      final PsiElement symbol = tagSetDelayed.getFirstChild();
      if (symbol instanceof Symbol) {
        addAssignment(((Symbol) symbol), tagSetDelayed, TAG_SET_DELAYED_ASSIGNMENT);
      }
    }
View Full Code Here

      }
    }

    @Override
    public void visitUpSet(final UpSet upSet) {
      final PsiElement lhs = upSet.getFirstChild();
      if (lhs != null) {
        UpSetDefinitionSymbolVisitor visitor = new UpSetDefinitionSymbolVisitor();
        lhs.accept(visitor);
        final java.util.Set<Symbol> unboundSymbols = visitor.getUnboundSymbols();
        for (Symbol symbol : unboundSymbols) {
          addAssignment(symbol, lhs, UP_SET_ASSIGNMENT);
        }
      }
View Full Code Here

      }
    }

    @Override
    public void visitUpSetDelayed(final UpSetDelayed upSetDelayed) {
      final PsiElement lhs = upSetDelayed.getFirstChild();
      if (lhs != null) {
        UpSetDefinitionSymbolVisitor visitor = new UpSetDefinitionSymbolVisitor();
        lhs.accept(visitor);
        final java.util.Set<Symbol> unboundSymbols = visitor.getUnboundSymbols();
        for (Symbol symbol : unboundSymbols) {
          addAssignment(symbol, lhs, UP_SET_DELAYED_ASSIGNMENT);
        }
      }
View Full Code Here

      }
    }

    @Override
    public void visitFunctionCall(final FunctionCall functionCall) {
      final PsiElement arg1 = functionCall.getArgument(1);
      if (arg1 != null) {
        if (functionCall.matchesHead("Set|SetDelayed")) {
          SetDefinitionSymbolVisitor visitor = new SetDefinitionSymbolVisitor(arg1);
          arg1.accept(visitor);
          final java.util.Set<Symbol> symbols = visitor.getUnboundSymbols();
          for (Symbol symbol : symbols) {
            addAssignment(symbol, arg1,functionCall.matchesHead("Set") ? SET_ASSIGNMENT : SET_DELAYED_ASSIGNMENT);
          }
        } else if (functionCall.matchesHead("TagSet|TagSetDelayed")) {
          if (arg1 instanceof Symbol) {
            addAssignment((Symbol) arg1, functionCall,
                functionCall.matchesHead("TagSet") ? TAG_SET_ASSIGNMENT : TAG_SET_DELAYED_ASSIGNMENT);
          }
        } else if (functionCall.matchesHead("UpSet|UpSetDelayed")) {
          UpSetDefinitionSymbolVisitor visitor = new UpSetDefinitionSymbolVisitor();
          arg1.accept(visitor);
          for (Symbol symbol : visitor.getUnboundSymbols()) {
            addAssignment(symbol, arg1, functionCall.matchesHead("UpSet") ? UP_SET_ASSIGNMENT : UP_SET_DELAYED_ASSIGNMENT);
          }
        } else if (functionCall.matchesHead("SetAttributes")) {
          if (arg1 instanceof Symbol) {
View Full Code Here

    return MathematicaFileType.INSTANCE;
  }

  @Override
  public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) {
    PsiElement children[] = getChildren();
    for (PsiElement child : children) {
      if (child.equals(lastParent)) {
        continue;
      }
      if (!child.processDeclarations(processor, state, this, place)) return false;
View Full Code Here

    myIsUpToDate = false;
  }

  @Override
  public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) {
    final PsiElement head = getFirstChild();
    if (head instanceof Symbol) {
      // In a tree-up-walk, we only consider declarations of Module, Block, .. when we come from inside this Module.
      // Therefore, we need to check whether our last position was inside and if not, we don't consider the declarations
      // of this.
      if (lastParent.getParent() != this) {
View Full Code Here

TOP

Related Classes of com.intellij.psi.PsiElement

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.