public InputStream getInputStream( boolean isLocal ) { try { return _resourceFile.openInputStream(); } catch (IOException e) { throw new RuntimeException(e); } }
public boolean isConfigFile(IFile file) { final String extension = file.getExtension(); if (extension != null) { return EXTENSIONS.contains(extension); } return false; }
@Override public String getFileName() { return _file.getName(); }
private boolean doesFileMatchCase( String strFileName, IFile file ) throws IOException { // This is primarily for Windows where the file system is case-insensitive return !file.isJavaFile() || file.toJavaFile().getCanonicalPath().endsWith( strFileName ); }
private String parseEnhancedTypeName(RefreshRequest request) { try { return parseEnhancedTypeName(request.file.openInputStream(), request.file.getBaseName()); } catch (IOException e) { return IErrorType.NAME; } }
@Override public boolean handlesFile( IFile file ) { return FILE_EXTENSION.equalsIgnoreCase( file.getExtension() ) && !isDisplayPropertiesFile( file.getName() ); }
@Override public String toString() { return _file.getPath().getPathString(); } }
/** * Reads a pom.xml file into a GosuPathEntry object * * @param moduleFile the pom.xml file to convert to GosuPathEntry * @return an ordered list of GosuPathEntries created based on the algorithm described above */ public static GosuPathEntry createPathEntryForModuleFile(IFile moduleFile) { try { InputStream is = moduleFile.openInputStream(); try { SimpleXmlNode moduleNode = SimpleXmlNode.parse(is); IDirectory rootDir = moduleFile.getParent(); List<IDirectory> sourceDirs = new ArrayList<IDirectory>(); for (String child : new String[] { "gsrc", "gtest" }) { IDirectory dir = rootDir.dir(child); if (dir.exists()) { sourceDirs.add(dir); } } return new GosuPathEntry(rootDir, sourceDirs); } finally { is.close(); } } catch (IOException e) { throw new RuntimeException(e); } } }
public boolean isPathIgnored(String relativePath) { if (relativePath == null) { return true; } final IFile file = CommonServices.getFileSystem().getIFile(new File(relativePath)); // AHK - We use file.getParent().hasChild() instead of file.exists() since we don't want to hit the disk // for the file existence check if we don't have to, and hasChild() will usually work off the cached sub-files // of a given directory if (file != null && file.getParent() != null && file.getParent().hasChildFile(file.getName()) && isConfigFile(file)) { final IModule module = TypeSystem.getExecutionEnvironment().getModule(file); if (module != null) { for (IDirectory dir : module.getSourcePath()) { if ("config".equals(dir.getName()) && file.isDescendantOf(dir)) { return false; } } } //System.out.println("Ignoring: " + relativePath); return true; } // for (String pattern : IGNORE_DIRECTORY_PATTERNS) { // if (relativePath.contains(pattern)) { // return true; // } // } return HASH.matches(relativePath); }
@Override public PropertySet getPropertySet(String name) { IFile file = _filesByTypeName.get().get(name); if (file == null) { throw new IllegalArgumentException(name + " is not the name of a properties file property set"); } PropertySet result = new EmptyPropertySet(name); if (file.exists()) { try { InputStream propertiesStream = file.openInputStream(); Properties properties = new Properties(); try { properties.load(propertiesStream); result = new PropertiesPropertySet(name, properties); } finally { closeSafely(propertiesStream); } } catch (IOException e) { CommonServices.getEntityAccess().getLogger().error(String.format("Could not read property file %s", file), e); } } return result; }
public String getDescription() { return _resourceFile.toURI().toString(); }
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; }
@Override public List<? extends IFile> listFiles() { List<IFile> results = new ArrayList<IFile>(); for (IFile child : _childFiles) { if (child.exists()) { results.add(child); } } return results; }
IFile changedFile = CommonServices.getFileSystem().getIFile(changedFilePath.toFile()); for (IDirectory possibleSourceDir : TypeSystem.getCurrentModule().getSourcePath()) { if (changedFile.isDescendantOf(possibleSourceDir)) { String relativeFilePath = possibleSourceDir.getPath().relativePath(changedFile.getPath(), "/"); String typeName = relativeFilePath.replace('/', '.'); typeName = typeName.substring(0, typeName.lastIndexOf("."));
@Override public String[] getTypesForFile(IFile file) { String type = TypeSystem.getGlobalModule().pathRelativeToRoot(file.getParent()); String packageName = (type.replace('/', '.') + '.' + file.getBaseName()).toLowerCase(); XmlSchemaIndex<?> index = getSchemaForNamespace(packageName); if (index != null) { Set<String> allTypeNames = index.getAllTypeNames(null); return allTypeNames.toArray(new String[allTypeNames.size()]); } // No schema index yet -- must be a new type, need to refresh namespace type at least return new String[] { packageName }; }
@Override public IDirectory getParentFile() { return _file.getParent(); }
@Override public String[] getTypesForFile(IFile file) { List<IDirectory> sourcePath = getModule().getSourcePath(); for (IDirectory src : sourcePath) { if (file.isDescendantOf(src)) { String fqn = src.relativePath(file); fqn = fqn.substring(0, fqn.lastIndexOf('.')).replace('/', '.'); return new String[] {fqn}; } } return new String[0]; }
public boolean isPathIgnored(String relativePath) { final IFile file = CommonServices.getFileSystem().getIFile(new File(relativePath)); if (file != null && file.exists() && isConfigFile(file)) { final IModule module = TypeSystem.getExecutionEnvironment().getModule(file); if (module != null) { for (IDirectory dir : module.getSourcePath()) { if ("config".equals(dir.getName()) && file.isDescendantOf(dir)) { return false; } } } //System.out.println("Ignoring: " + relativePath); return true; } // for (String pattern : IGNORE_DIRECTORY_PATTERNS) { // if (relativePath.contains(pattern)) { // return true; // } // } return HASH.matches(relativePath); }
private void copySourceFile( IFileRepositoryBasedType type, Path outputDir ) { if( !(type instanceof IJavaType) && type.getEnclosingType() == null ) { File file = type.getSourceFileHandle().getFile().toJavaFile(); File toDir = new File( outputDir.toFile(), type.getNamespace().replace( '.', File.separatorChar ) ); //noinspection ResultOfMethodCallIgnored toDir.mkdirs(); StreamUtil.copy( file, toDir ); } }
private IFile getFileMatchCase( IDirectory dir, String strFileName ) { IFile file = dir.file( strFileName ); return file != null && file.exists() && IFileUtil.getBaseName( strFileName ).equals( file.getBaseName() ) ? file : null; }