01: package org.acm.seguin.pmd.cpd.cppast;
02:
03: import java.util.Vector;
04:
05: /**
06: * Class scope extends Scope in that its search method also searches all its
07: * superclasses.
08: */
09:
10: public class ClassScope extends Scope {
11: /**
12: * The list of scopes corresponding to classes this class inherits.
13: */
14: Vector super Classes;
15:
16: /**
17: * Add a super class.
18: */
19: public void AddSuper(Scope sc) {
20: if (sc == null)
21: return;
22:
23: if (super Classes == null)
24: super Classes = new Vector();
25:
26: super Classes.addElement(sc);
27: }
28:
29: /**
30: * Overrides the method in Scope. It also searches in the inherited classes'
31: * scopes also.
32: */
33: public boolean IsTypeName(String name) {
34: if (super .IsTypeName(name))
35: return true;
36:
37: if (super Classes == null)
38: return false;
39:
40: for (int i = 0; i < super Classes.size(); i++)
41: if (((Scope) super Classes.elementAt(i)).IsTypeName(name))
42: return true;
43:
44: return false;
45: }
46:
47: /**
48: * Creates a new class scope in a given scope.
49: */
50: public ClassScope(String name, Scope parent) {
51: super (name, true, parent);
52: }
53: }
|