Examples of PsiElement


Examples of com.intellij.psi.PsiElement

          continue;
        }
        child.accept(this);
      }
    } else {
      final PsiElement head = functionCall.getHead();
      if (head instanceof Symbol) {
        myUnboundSymbols.add((Symbol) head);
      } else {
        // situations like this a[p:b, c, d] ^:= ... where the patterns or something else is involved.
        head.accept(this);
      }
    }
  }
View Full Code Here

Examples of com.intellij.psi.PsiElement

  /**
   * Need this for situations like <code>p:f[x_]:=x^2</code>
   */
  @Override
  public void visitPattern(final Pattern pattern) {
    final PsiElement lastChild = pattern.getLastChild();
    if (lastChild != null) {
      lastChild.accept(this);
    }
  }
View Full Code Here

Examples of com.intellij.psi.PsiElement

    return myAssignmentType;
  }

  @Override
  public void visitCondition(Condition condition) {
    PsiElement firstChild = condition.getFirstChild();
    if (firstChild != null) {
      firstChild.accept(this);
    }
  }
View Full Code Here

Examples of com.intellij.psi.PsiElement

    super(node);
  }

  @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

Examples of com.intellij.psi.PsiElement

    }
  }

  @Override
  public void visitFunctionCall(FunctionCall functionCall) {
    final PsiElement head = functionCall.getHead();
    if (head instanceof Symbol) {
      // The next set are symbols that are just ignored and we have to check their first argument for a symbol
      // which is defined
      if (functionCall.matchesHead("HoldPattern|Longest|Shortest|Repeated")) {
        final PsiElement arg1 = functionCall.getArgument(1);
        if (arg1 != null) {
          arg1.accept(this);
        }
      }
      // check if we have an assignment of the form Options[sym] = {...}
      if (functionCall.equals(myStartElement) && functionCall.matchesHead("Options|Attributes|MessageName|Default|Format|N|SyntaxInformation")) {
        if (myFoundAssignmentType) {
          // we already saw eg Options[..] and this cannot be handled any further
          return;
        }
        setMyAssignmentType(functionCall.getHead().getText());
        myFoundAssignmentType = true;
        PsiElement arg1 = functionCall.getArgument(1);
        if (arg1 != null) {
          if (functionCall.matchesHead("Options|Attributes|MessageName|Default|SyntaxInformation")) {
            if (arg1 instanceof Symbol) myUnboundSymbols.add((Symbol) arg1);
          } else {
            //if we have for instance  N[e : poly[cp_], pa_] := ... where the argument itself can be a complicated
            // patter, then we just go on with the visitor, but we remember that we already know the assignment type
            arg1.accept(this);
          }
        }
      } else {
        myUnboundSymbols.add((Symbol) head);
      }
View Full Code Here

Examples of com.intellij.psi.PsiElement

  /**
   * Need this for situations like <code>p:f[x_]:=x^2</code>
   */
  @Override
  public void visitPattern(final Pattern pattern) {
    final PsiElement lastChild = pattern.getLastChild();
    if (lastChild != null) {
      lastChild.accept(this);
    }
  }
View Full Code Here

Examples of com.intellij.psi.PsiElement

    MathematicaPsiElementFactory factory = new MathematicaPsiElementFactory(project);
    CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);

    Expression parExpr = factory.createExpressionFromText(myOpener + element.getText() + myCloser);
    parExpr = (Expression) codeStyleManager.reformat(parExpr);
    final PsiElement replace = element.replace(parExpr);
    return TextRange.from(replace.getTextOffset() + replace.getTextLength(), 0);
  }
View Full Code Here

Examples of com.intellij.psi.PsiElement

  @Nullable
  @Override
  public TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, @NotNull PsiElement[] elements) throws IncorrectOperationException {
    assert (elements.length == 1 && elements[0] != null) || PsiTreeUtil.findCommonParent(elements) == elements[0].getParent();
    final PsiElement e = elements[0];

    final PsiFileFactory factory = PsiFileFactory.getInstance(project);
    final StringBuilder stringBuilder = new StringBuilder("f[");
    stringBuilder.append(e.getText());
    stringBuilder.append("]");

    final PsiFile file = factory.createFileFromText("dummy.m", MathematicaFileType.INSTANCE, stringBuilder);
    final FunctionCall[] func = PsiTreeUtil.getChildrenOfType(file, FunctionCall.class);
    assert func != null && func[0] != null;
    PsiElement newElement = e.replace(func[0]);
    final PsiElement head = newElement.getFirstChild();
    return head == null ? null : head.getTextRange();
  }
View Full Code Here

Examples of com.intellij.psi.PsiElement

  @Nullable
  @Override
  public TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, @NotNull PsiElement[] elements) throws IncorrectOperationException {
    assert (elements.length == 1 && elements[0] != null) || PsiTreeUtil.findCommonParent(elements) == elements[0].getParent();
    final PsiElement e = elements[0];
    CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);

    final PsiFileFactory factory = PsiFileFactory.getInstance(project);
    final StringBuilder stringBuilder = new StringBuilder(myHead + "[{},\n");
    stringBuilder.append(e.getText());
    stringBuilder.append("\n]");

    final PsiFile file = factory.createFileFromText("dummy.m", MathematicaFileType.INSTANCE, stringBuilder);
    final FunctionCall[] func = PsiTreeUtil.getChildrenOfType(file, FunctionCall.class);
    assert func != null && func[0] != null;
    func[0] = (FunctionCall) codeStyleManager.reformat(func[0]);
    PsiElement newElement = e.replace(func[0]);

    final List<PsiElement> arguments = MathematicaPsiUtilities.getArguments(newElement);
    if (arguments.isEmpty()) {
      return null;
    }
View Full Code Here

Examples of com.intellij.psi.PsiElement

  @Nullable
  @Override
  public TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, @NotNull PsiElement[] elements) throws IncorrectOperationException {
    assert (elements.length == 1 && elements[0] != null) || PsiTreeUtil.findCommonParent(elements) == elements[0].getParent();
    final PsiElement e = elements[0];

    final PsiFileFactory factory = PsiFileFactory.getInstance(project);
    final StringBuilder stringBuilder = new StringBuilder("(");
    stringBuilder.append(e.getText());
    stringBuilder.append(")&");

    final PsiFile file = factory.createFileFromText("dummy.m", MathematicaFileType.INSTANCE, stringBuilder);
    final Function[] func = PsiTreeUtil.getChildrenOfType(file, Function.class);
    assert func != null && func[0] != null;
    e.replace(func[0]);
    return null;
  }
View Full Code Here
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.