public URL getBlueprintURL() { try { return _resourceFile.toURI().toURL(); } catch ( MalformedURLException ex ) { throw new RuntimeException( ex ); } }
public String getDescription() { return _resourceFile.toURI().toString(); }
private URL getResource( IFileSystemGosuClassRepository.ClassPathEntry root, String strFileName ) { try { IFile possibleFile = getFile(root, strFileName); return possibleFile == null ? null : possibleFile.toURI().toURL(); } catch (IOException ex) { throw new RuntimeException(ex); } }
private URL getResource( IFileSystemGosuClassRepository.ClassPathEntry root, String strFileName ) { try { IFile possibleFile = getFile(root, strFileName); return possibleFile == null ? null : possibleFile.toURI().toURL(); } catch (IOException ex) { throw new RuntimeException(ex); } }
private static URL getUrlForNamespace( String namespaceURI, IModule module ) { XmlSchemaDefaultSchemaLocations locations = getDefaultSchemaLocations( module ); IFile iFile = locations.getLocalResourcePathByXmlNamespace().get( namespaceURI ); if ( iFile == null ) { return null; } try { return iFile.toURI().toURL(); } catch (MalformedURLException e) { throw new RuntimeException( e ); } }
public static URL getUrlForExternalLocation( String externalLocation, IModule module ) { XmlSchemaDefaultSchemaLocations locations = getDefaultSchemaLocations( module ); IFile iFile = locations.getLocalResourcePathsByExternalLocation().get( externalLocation ); if ( iFile == null ) { throw new RuntimeException( "External location " + externalLocation + " is not configured in schemalocations.xml." ); } try { return iFile.toURI().toURL(); } catch (MalformedURLException e) { throw new RuntimeException( e ); } }
@Override public List<String> verifyResources() throws Exception { List<String> errorMessages = new ArrayList<String>(); for ( Map.Entry<String, IFile> entry : loadAllSchemaNamespaces().entrySet() ) { IFile schemaSourceFile = entry.getValue(); URL url = schemaSourceFile.toURI().toURL(); String resourceName = getModule().getFileRepository().getResourceName( url ); verifySchemaSourceFile( entry.getKey(), schemaSourceFile, errorMessages, resourceName, url ); } return errorMessages; }
public IFile get( String fqn ) { FqnCacheNode<Object> node = _cache.getNode( fqn ); if( node == null ) { return null; } Object value = node.getUserData(); if( value instanceof IFile ) { if( _bStableFiles ) { // Files are assumed stable outside an IDE return (IFile)value; } try { // Lazily compute and cache the URL, it can be an expensive native file system call value = ((IFile)value).toURI().toURL(); node.setUserData( value ); } catch( MalformedURLException e ) { throw new RuntimeException( e ); } } //## todo: it'd be better if ClassPath could listen to FS changes and not query the FS for every // Get the file *fresh* from the abstract file system return _fs.getIFile( (URL)value ); }
public IFile get( String fqn ) { FqnCacheNode<Object> node = _cache.getNode( fqn ); if( node == null ) { return null; } Object value = node.getUserData(); if( value instanceof IFile ) { if( _bStableFiles ) { // Files are assumed stable outside an IDE return (IFile)value; } try { // Lazily compute and cache the URL, it can be an expensive native file system call value = ((IFile)value).toURI().toURL(); node.setUserData( value ); } catch( MalformedURLException e ) { throw new RuntimeException( e ); } } //## todo: it'd be better if ClassPath could listen to FS changes and not query the FS for every // Get the file *fresh* from the abstract file system return _fs.getIFile( (URL)value ); }
throw new XmlException( "Unable to resolve resource with location '" + systemId + "' relative to '" + baseURL + "' with namespace '" + namespaceURI + "'" ); url = foundFile.toURI().toURL();
public ILocationInfo getLocationInfo() { if( _location != null ) { return _location; } int startPos = getStartPosition(); int endPos = getEndPosition(); try { ISourceFileHandle sfh = getDeclaringClass().getSourceFileHandle(); if( sfh != null ) { _location = new LocationInfo( startPos, endPos - startPos, -1, -1, sfh.getFile().toURI().toURL() ); } return _location; } catch( MalformedURLException e ) { throw new RuntimeException( e ); } }
private static List<Pair<String, String>> readTaskListingFromAntlib(IFile resource) { URL url; try { url = resource.toURI().toURL(); } catch (MalformedURLException e) { throw GosuExceptionUtil.forceThrow(e); } URLResource antlibResource = new URLResource(url); ProjectHelperRepository helperRepository = ProjectHelperRepository.getInstance(); ProjectHelper parser = helperRepository.getProjectHelperForAntlib(antlibResource); UnknownElement ue = parser.parseAntlibDescriptor(AntlibTypeLoader.NULL_PROJECT, antlibResource); if (!ue.getTag().equals(Antlib.TAG)) { throw new BuildException("Unexpected tag " + ue.getTag() + " expecting " + Antlib.TAG, ue.getLocation()); } List<Pair<String, String>> listing = new ArrayList<Pair<String, String>>(); for (Object childObj : ue.getChildren()) { UnknownElement child = (UnknownElement) childObj; if (child.getTag().equals("taskdef")) { Map attributes = child.getWrapper().getAttributeMap(); listing.add(new Pair<String, String>((String) attributes.get("name"), (String) attributes.get("classname"))); } } return listing; }
public AsmClass findClass( String fqn, IFile file ) { AsmClass asmClass = _cache.get( fqn ); if( asmClass == null ) { asmClass = _cache.get( fqn ); if( asmClass == null ) { try { asmClass = new AsmClass( _module, file.toURI() ); _cache.add( fqn, asmClass ); asmClass.init( getContent( file.openInputStream() ) ); } catch( IOException e ) { throw new RuntimeException( e ); } } } return asmClass; }
public static void doGoTo( String strQualifedType ) { EditorUtilities.showWaitCursor( true ); try { IType type = TypeSystem.getByFullNameIfValid( strQualifedType ); if( type == null ) { return; } IFile[] sourceFiles = type.getSourceFiles(); if( sourceFiles != null && sourceFiles.length > 0 ) { //## todo: maybe support multiple files here? IFile sourceFile = sourceFiles[0]; LabFrame.instance().openFile( PathUtil.create( sourceFile.toURI() ) ); } } catch( Exception e ) { throw new RuntimeException( e ); } finally { EditorUtilities.showWaitCursor( false ); } }
public static FileTree find( String fqn ) { FileTree fileTree = FileTreeUtil.getRoot().find( fqn ); if( fileTree == null ) { IType type = TypeSystem.getByFullNameIfValid( fqn ); if( type != null ) { IFile[] sourceFiles = type.getSourceFiles(); if( sourceFiles != null && sourceFiles.length > 0 ) { IFile sourceFile = sourceFiles[0]; fileTree = find( PathUtil.create( sourceFile.toURI() ), fqn ); } } } return fileTree; }
@SuppressWarnings( { "UnusedDeclaration" } ) public void addSchemas( List<IFile> resourceFiles ) { HashMap<Pair<URL, String>, XmlSchema> caches = new HashMap<Pair<URL, String>, XmlSchema>(); List<XmlSchemaIndex> schemaIndexes = new ArrayList<XmlSchemaIndex>(); for ( IFile resourceFile : resourceFiles ) { try { String relativePath = TypeSystem.getGlobalModule().getFileRepository().getResourceName(resourceFile.toURI().toURL()); String packageName = convertPathToPackage( relativePath ); String schemaNamespace = XmlSchemaIndex.normalizeSchemaNamespace( packageName, relativePath ); XmlSchemaIndex<T> schemaIndex = addSchemaToCacheIfNeeded( schemaNamespace, resourceFile, caches ); if ( schemaIndex != null ) { schemaIndexes.add( schemaIndex ); addAllNamespacesForSchema( true, this, _allNamespaces.get(), schemaNamespace, getAdditionalSubPackages() ); addAllNamespacesForSchema( false, this, _allSchemaNamespacesAndSubNamespaces.get(), schemaNamespace, getAdditionalSubPackages() ); } } catch ( MalformedURLException e ) { throw GosuExceptionUtil.forceThrow( e ); } } clearTypeNames(); for ( XmlSchemaIndex schemaIndex : schemaIndexes ) { schemaIndex.validate( caches ); } }