public String getGlobal() { return importDescr.getTarget(); }
protected ImportDescrBuilderImpl(PackageDescrBuilder parent, boolean function) { super( parent, function ? new FunctionImportDescr() : new ImportDescr() ); }
@Override public String getNamespace() { return importDescr.getNamespace(); }
public void postCompileAddFunction(FunctionDescr functionDescr, TypeResolver typeResolver) { final String functionClassName = this.pkg.getName() + "." + StringUtils.ucFirst( functionDescr.getName() ); ImportDescr importDescr = new ImportDescr(functionClassName + "." + functionDescr.getName()); importDescr.setResource(functionDescr.getResource()); importDescr.setNamespace(functionDescr.getNamespace()); this.packageRegistry.addStaticImport( importDescr ); }
public int hashCode() { final int PRIME = 31; int result = 1; result = PRIME * result + ((this.target == null) ? 0 : this.target.hashCode()); result = PRIME * result + this.getStartCharacter(); return result; }
public ImportDescrBuilder target( String target ) { descr.setTarget( target ); return this; }
public ImportError(final ImportDescr importDescr, final int line) { super(importDescr.getResource()); this.importDescr = importDescr; this.line = new int[] { line }; }
if (!currentImports.contains(descr)) { addImport(descr); descr.setResource(resource);
public boolean equals(final Object obj) { if ( this == obj ) { return true; } if ( obj == null ) { return false; } if ( getClass() != obj.getClass() ) { return false; } final ImportDescr other = (ImportDescr) obj; if ( this.target == null ) { if ( other.target != null ) { return false; } } else if ( !this.target.equals( other.target ) ) { return false; } return this.getStartCharacter() == other.getStartCharacter(); }
private String processImportsList(final List imports) { String importList = ""; for ( final Iterator iterator = imports.iterator(); iterator.hasNext(); ) { final String importString = ((ImportDescr) iterator.next()).getTarget(); final String importTemplate = "<import name=\"" + importString + "\" /> " + XmlDumper.eol; importList += importTemplate; } return importList + XmlDumper.eol; }
parser.getLocator() ); packageDescr.addImport( new ImportDescr( importEntry ) );
String className = importDescr.getTarget(); try { addImport( className ,typeResolver);
this.src = new MemoryResourceReader(); if ( this.pkg != null ) { this.addImport( new ImportDescr( this.pkg.getName() + ".*" ) ); this.addImport( new ImportDescr( "java.lang.*" ) );
String className = importDescr.getTarget(); try { addImport( className ,typeResolver);
private PackageRegistry newPackage( final PackageDescr packageDescr ) { Package pkg; if (this.ruleBase == null || ( pkg = this.ruleBase.getPackage( packageDescr.getName() ) ) == null) { // there is no rulebase or it does not define this package so define it pkg = new Package( packageDescr.getName() ); pkg.setClassFieldAccessorCache( new ClassFieldAccessorCache( this.rootClassLoader ) ); // if there is a rulebase then add the package. if (this.ruleBase != null) { // Must lock here, otherwise the assumption about addPackage/getPackage behavior below might be violated this.ruleBase.lock(); try { this.ruleBase.addPackage( pkg ); pkg = this.ruleBase.getPackage( packageDescr.getName() ); } finally { this.ruleBase.unlock(); } } else { // the RuleBase will also initialise the pkg.getDialectRuntimeRegistry().onAdd( this.rootClassLoader ); } } PackageRegistry pkgRegistry = new PackageRegistry( this, pkg ); // add default import for this namespace pkgRegistry.addImport( new ImportDescr( packageDescr.getNamespace() + ".*" ) ); this.pkgRegistryMap.put( packageDescr.getName(), pkgRegistry ); return pkgRegistry; }
private List<TypeDeclarationDescr> getDeclaredTypeHierachy(TypeDeclarationDescr td, List< ? > jars) { List<TypeDeclarationDescr> th = new ArrayList<TypeDeclarationDescr>(); th.add( td ); TypeDeclarationDescr std; while ( (std = getDeclaredSuperType( td )) != null ) { th.add( std ); td = std; } //If the super-most class has been imported attempt to make a pseudo TypeDeclaration for the imported class if ( this.pkgDescr.getImports().size() > 0 ) { for ( ImportDescr imp : this.pkgDescr.getImports() ) { if ( imp.getTarget().endsWith( "." + td.getTypeName() ) ) { TypeDeclarationDescr pseudoTypeDeclr = makePseudoTypeDeclarationDescrFromSuperClassType( imp.getTarget(), jars ); if ( pseudoTypeDeclr != null ) { th.add( pseudoTypeDeclr ); } } } } return th; }
private List<TypeDeclarationDescr> getDeclaredTypeHierachy(TypeDeclarationDescr td, List< ? > jars) { List<TypeDeclarationDescr> th = new ArrayList<TypeDeclarationDescr>(); th.add( td ); TypeDeclarationDescr std; while ( (std = getDeclaredSuperType( td )) != null ) { th.add( std ); td = std; } //If the super-most class has been imported attempt to make a pseudo TypeDeclaration for the imported class if ( this.pkgDescr.getImports().size() > 0 ) { for ( ImportDescr imp : this.pkgDescr.getImports() ) { if ( imp.getTarget().endsWith( "." + td.getTypeName() ) ) { TypeDeclarationDescr pseudoTypeDeclr = makePseudoTypeDeclarationDescrFromSuperClassType( imp.getTarget(), jars ); if ( pseudoTypeDeclr != null ) { th.add( pseudoTypeDeclr ); } } } } return th; }
public void addStaticPackageImport(ImportDescr importDescr) { String staticImportEntry = importDescr.getTarget(); int index = staticImportEntry.lastIndexOf( '.' ); String className = staticImportEntry.substring(0, index); Class cls = null; try { cls = pkgBuilder.getRootClassLoader().loadClass( className ); } catch ( ClassNotFoundException e ) { } if ( cls == null ) { results.add( new ImportError( importDescr, -1 ) ); return; } for (Method method : cls.getDeclaredMethods()) { if ((method.getModifiers() | Modifier.STATIC) > 0) { this.data.addImport(method.getName(), method); } } for (Field field : cls.getFields()) { if (field.isAccessible() && (field.getModifiers() | Modifier.STATIC) > 0) { this.data.addImport(field.getName(), field); return; } } }
public void addImport(ImportDescr importDescr) { String importEntry = importDescr.getTarget(); if ( importEntry.endsWith( ".*" ) ) { importEntry = importEntry.substring( 0, importEntry.length() - 2 ); data.addPackageImport( importEntry ); } else { try { Class cls = this.packageRegistry.getTypeResolver().resolveType( importEntry ); data.addImport( cls.getSimpleName(), cls ); } catch ( ClassNotFoundException e ) { this.results.add( new ImportError( importDescr, 1 ) ); } } }
public void addStaticImport(ImportDescr importDescr) { String staticImportEntry = importDescr.getTarget(); if ( staticImportEntry.endsWith( "*" ) ) { addStaticPackageImport(importDescr);