source: java/FramclipsePlugin/src/main/java/com/framsticks/framclipse/internal/parser/ASTFunction.java @ 193

Last change on this file since 193 was 193, checked in by Maciej Komosinski, 10 years ago

Set svn:eol-style native for all textual files

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/plain
File size: 1.7 KB
Line 
1/* Generated By:JJTree: Do not edit this line. ASTFunction.java */
2
3package com.framsticks.framclipse.internal.parser;
4
5import java.util.List;
6
7import org.eclipse.jface.text.IDocument;
8
9public class ASTFunction extends ElementWithOffset {
10
11  public ASTFunction(int id) {
12    super(id);
13  }
14
15  public ASTFunction(FramclipseNonScriptParser p, int id) {
16    super(p, id);
17  }
18 
19  public String getPrimaryName()
20  {
21          if(this.children != null && this.children.length > 0 && this.children[0] instanceof ASTIdentList)
22          {
23                  List<String> aliases = ((ASTIdentList)children[0]).getIdents();
24                  if(aliases.size() > 0)
25                          return aliases.get(0);
26          }
27         
28          return "[unnamed]";
29  }
30 
31  public int getNumArguments()
32  {
33          if(this.children != null && this.children.length > 1 && this.children[1] instanceof ASTIdentList)
34          {
35                  return ((ASTIdentList)children[1]).getIdents().size();
36          }
37
38          return 0;
39  }
40 
41        @Override
42        public String toString() {
43                return getPrimaryName() + ": Function"; // [" + getNumArguments() + "]";
44        }
45
46        @Override
47        public boolean isEquivalent(ElementWithOffset element, IDocument document) {
48                if(!(element instanceof ASTFunction))
49                        return false;
50               
51                if(getEndOffset() - getBeginOffset() != element.getEndOffset() - element.getBeginOffset())
52                        return false;
53               
54                ASTFunction func = (ASTFunction)element;
55               
56                if(func.getNumArguments() != getNumArguments())
57                        return false;
58               
59                if(jjtGetNumChildren() != func.jjtGetNumChildren())
60                        return false;
61               
62                if(jjtGetNumChildren() > 0)
63                {
64                        List<String> ownAliases = ((ASTIdentList)children[0]).getIdents();
65                        List<String> otherAliases = ((ASTIdentList)func.children[0]).getIdents();
66                       
67                        if(!ownAliases.equals(otherAliases))
68                                return false;
69                }
70               
71                return true;
72        }
73       
74       
75 
76}
Note: See TracBrowser for help on using the repository browser.