01: // Transmogrify License
02: //
03: // Copyright (c) 2001, ThoughtWorks, Inc.
04: // All rights reserved.
05: // Redistribution and use in source and binary forms, with or without
06: // modification, are permitted provided that the following conditions
07: // are met:
08: // - Redistributions of source code must retain the above copyright notice,
09: // this list of conditions and the following disclaimer.
10: // - Redistributions in binary form must reproduce the above copyright
11: // notice, this list of conditions and the following disclaimer in the
12: // documentation and/or other materials provided with the distribution.
13: // Neither the name of the ThoughtWorks, Inc. nor the names of its
14: // contributors may be used to endorse or promote products derived from this
15: // software without specific prior written permission.
16: // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17: // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18: // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19: // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20: // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21: // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22: // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23: // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24: // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25: // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26: // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27:
28: package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
29:
30: public class DefaultScope extends Scope {
31: public DefaultScope(String name, Scope parentScope, SymTabAST node) {
32: super (name, parentScope, node);
33: }
34:
35: public void addDefinition(IPackage def) {
36: throw new UnsupportedOperationException(getClass().getName());
37: }
38:
39: public IClass getClassDefinition(String name) {
40: IClass result = (ClassDef) classes.get(name);
41:
42: if (result == null && getParentScope() != null) {
43: result = getParentScope().getClassDefinition(name);
44: }
45:
46: return result;
47: }
48:
49: public IMethod getMethodDefinition(String name, ISignature signature) {
50: IMethod result = null;
51: if (getParentScope() != null) {
52: result = getParentScope().getMethodDefinition(name,
53: signature);
54: }
55:
56: return result;
57: }
58:
59: public IVariable getVariableDefinition(String name) {
60: IVariable result = (VariableDef) elements.get(name);
61:
62: if (result == null && getParentScope() != null) {
63: result = getParentScope().getVariableDefinition(name);
64: }
65:
66: return result;
67: }
68:
69: public LabelDef getLabelDefinition(String name) {
70: LabelDef result = (LabelDef) labels.get(name);
71:
72: if (result == null && getParentScope() != null) {
73: result = getParentScope().getLabelDefinition(name);
74: }
75:
76: return result;
77: }
78: }
|