Method: getType(ILexLocation)
1: /*
2: * #%~
3: * The Overture Abstract Syntax Tree
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.ast.assistant.pattern;
23:
24: import java.util.Vector;
25:
26: import org.overture.ast.factory.AstFactory;
27: import org.overture.ast.intf.lex.ILexLocation;
28: import org.overture.ast.types.PType;
29: import org.overture.ast.util.Utils;
30:
31: @SuppressWarnings("serial")
32: public class PTypeList extends Vector<PType>
33: {
34:
35:         public PTypeList()
36:         {
37:                 super();
38:         }
39:
40:         public PTypeList(PType act)
41:         {
42:                 add(act);
43:         }
44:
45:         @Override
46:         public boolean add(PType t)
47:         {
48:                 return super.add(t);
49:         }
50:
51:         public PType getType(ILexLocation location)
52:         {
53:                 PType result = null;
54:
55:•                if (this.size() == 1)
56:                 {
57:                         result = iterator().next();
58:                 } else
59:                 {
60:                         result = AstFactory.newAProductType(location, this);
61:                 }
62:
63:                 return result;
64:         }
65:
66:         @Override
67:         public String toString()
68:         {
69:                 return "(" + Utils.listToString(this) + ")";
70:         }
71: }