1 2 29 package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify; 30 31 35 36 37 38 public class BaseScope extends DefaultScope { 39 private SymbolTable table; 40 41 public BaseScope( SymbolTable symbolTable ) { 42 super("~BASE~", null, null); 43 this.table = symbolTable; 44 } 45 46 public boolean isBaseScope() { 47 return true; 48 } 49 50 public void addDefinition(IPackage def) { 51 elements.put(def.getName(), def); 52 } 53 54 61 public IPackage getPackageDefinition(String fullyQualifiedName) { 62 return (IPackage)(table.getPackages().get(fullyQualifiedName)); 63 } 64 65 public IClass getClassDefinition(String name) { 66 IClass result = null; 67 68 result = LiteralResolver.getDefinition(name); 69 70 if (result == null) { 71 int lastDot = name.lastIndexOf("."); 72 if (lastDot > 0) { 73 String packageName = name.substring(0, lastDot); 74 String className = name.substring(lastDot + 1); 75 76 IPackage pkg = getPackageDefinition(packageName); 77 if (pkg != null) { 78 result = pkg.getClass(className); 79 } 80 } 81 } 82 83 if (result == null) { 84 Class theClass = null; 85 try { 86 theClass = ClassManager.getClassLoader().loadClass(name); 87 result = new ExternalClass(theClass); 88 } 89 catch (ClassNotFoundException e) { 90 } 92 catch (NoClassDefFoundError e) { 93 } 95 } 96 97 return result; 98 } 99 } 100 101 | Popular Tags |