MCPcopy Index your code
hub / github.com/beanshell/beanshell / getTypeDescriptor

Method getTypeDescriptor

src/bsh/BSHType.java:76–132  ·  view source on GitHub ↗

Returns a class descriptor for this type. If the type is an ambiguous name (object type) evaluation is attempted through the namespace in order to resolve imports. If it is not found and the name is non-compound we assume the default package for the name.

( 
		CallStack callstack, Interpreter interpreter, String defaultPackage )

Source from the content-addressed store, hash-verified

74 package for the name.
75 */
76 public String getTypeDescriptor(
77 CallStack callstack, Interpreter interpreter, String defaultPackage )
78 {
79 // return cached type if available
80 if ( descriptor != null )
81 return descriptor;
82
83 String descriptor;
84 // first node will either be PrimitiveType or AmbiguousName
85 SimpleNode node = getTypeNode();
86 if ( node instanceof BSHPrimitiveType )
87 descriptor = getTypeDescriptor( ((BSHPrimitiveType)node).type );
88 else
89 {
90 String clasName = ((BSHAmbiguousName)node).text;
91 BshClassManager bcm = interpreter.getClassManager();
92 // Note: incorrect here - we are using the hack in bsh class
93 // manager that allows lookup by base name. We need to eliminate
94 // this limitation by working through imports. See notes in class
95 // manager.
96 String definingClass = bcm.getClassBeingDefined( clasName );
97
98 Class clas = null;
99 if ( definingClass == null )
100 {
101 try {
102 clas = ((BSHAmbiguousName)node).toClass(
103 callstack, interpreter );
104 } catch ( EvalError e ) {
105 //throw new InterpreterError("unable to resolve type: "+e);
106 // ignore and try default package
107 //System.out.println("BSHType: "+node+" class not found");
108 }
109 } else
110 clasName = definingClass;
111
112 if ( clas != null )
113 {
114 //System.out.println("found clas: "+clas);
115 descriptor = getTypeDescriptor( clas );
116 }else
117 {
118 if ( defaultPackage == null || Name.isCompound( clasName ) )
119 descriptor = "L" + clasName.replace('.','/') + ";";
120 else
121 descriptor =
122 "L"+defaultPackage.replace('.','/')+"/"+clasName + ";";
123 }
124 }
125
126 for(int i=0; i<arrayDims; i++)
127 descriptor = "["+descriptor;
128
129 this.descriptor = descriptor;
130 //System.out.println("BSHType: returning descriptor: "+descriptor);
131 return descriptor;
132 }
133

Callers 3

getTypeDescriptorsMethod · 0.95
generateClassMethod · 0.45

Calls 7

getTypeNodeMethod · 0.95
getClassBeingDefinedMethod · 0.95
isCompoundMethod · 0.95
replaceMethod · 0.80
getClassManagerMethod · 0.45
toClassMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected