@Override public String relativePath(IResource resource) { return _delegate.relativePath(resource); }
private String getClassNameFromFile( IDirectory root, IFile file ) { String strQualifiedClassName = root.relativePath(file); if( !isClassFileName( strQualifiedClassName ) ) { throw new IllegalArgumentException( file.getPath() + " is not a legal Java class name. " + "It does not end with " + CLASS_FILE_EXT ); } strQualifiedClassName = strQualifiedClassName.substring( 0, strQualifiedClassName.length() - CLASS_FILE_EXT.length() ); return strQualifiedClassName.replace('/', '.'); }
private String getClassNameFromFile( IDirectory root, IFile file ) { String strQualifiedClassName = root.relativePath(file); if( !isClassFileName( strQualifiedClassName ) ) { throw new IllegalArgumentException( file.getPath() + " is not a legal Java class name. " + "It does not end with " + CLASS_FILE_EXT ); } strQualifiedClassName = strQualifiedClassName.substring( 0, strQualifiedClassName.length() - CLASS_FILE_EXT.length() ); return strQualifiedClassName.replace('/', '.'); }
@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]; }
@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]; }
@Override public String getNamespaceForDirectory(IDirectory dir) { List<IDirectory> sourcePath = getModule().getSourcePath(); for (IDirectory src : sourcePath) { if (dir.isDescendantOf(src)) { return src.relativePath(dir).replace('/', '.'); } } return null; } }
@Override public String getNamespaceForDirectory(IDirectory dir) { List<IDirectory> sourcePath = getModule().getSourcePath(); for (IDirectory src : sourcePath) { if (dir.isDescendantOf(src)) { return src.relativePath(dir).replace('/', '.'); } } return null; } }
@Override public String pathRelativeToRoot(IResource resource) { for (IDirectory root : getSourcePath()) { if (resource.isDescendantOf(root)) { return root.relativePath(resource); } } for (IDirectory root : getRoots()) { if (resource.isDescendantOf(root)) { return root.relativePath(resource); } } return null; } }
public Set<TypeName> getTypeNames(Set<String> extensions, ITypeLoader loader) { Set<TypeName> names = new HashSet<TypeName>(); for (PackageToClassPathEntryTreeMap child : _children.values()) { String name = child._strFullPackageName; name = name.substring(name.lastIndexOf('.') + 1); names.add(new TypeName(name, loader, TypeName.Kind.NAMESPACE, TypeName.Visibility.PUBLIC)); } for (IFileSystemGosuClassRepository.ClassPathEntry classPathEntry : _classPathEntries) { IDirectory entryPath = classPathEntry.getPath().dir(_strFullPackageName.replace('.', '/')); List<? extends IFile> files = entryPath.listFiles(); for (IFile file : files) { String extension = "." + file.getExtension(); if (extensions.contains(extension)) { String fqn = entryPath.relativePath(file).replace('/', '.'); fqn = fqn.substring(0, fqn.lastIndexOf('.')); names.add(new TypeName(_strFullPackageName + "." + fqn, loader, TypeName.Kind.TYPE, TypeName.Visibility.PUBLIC)); } } } return names; } }
public Set<TypeName> getTypeNames(Set<String> extensions, ITypeLoader loader) { Set<TypeName> names = new HashSet<TypeName>(); for (PackageToClassPathEntryTreeMap child : _children.values()) { String name = child._strFullPackageName; name = name.substring(name.lastIndexOf('.') + 1); names.add(new TypeName(name, loader, TypeName.Kind.NAMESPACE, TypeName.Visibility.PUBLIC)); } for (IFileSystemGosuClassRepository.ClassPathEntry classPathEntry : _classPathEntries) { IDirectory entryPath = classPathEntry.getPath().dir(_strFullPackageName.replace('.', '/')); List<? extends IFile> files = entryPath.listFiles(); for (IFile file : files) { String extension = "." + file.getExtension(); if (extensions.contains(extension)) { String fqn = entryPath.relativePath(file).replace('/', '.'); fqn = fqn.substring(0, fqn.lastIndexOf('.')); names.add(new TypeName(_strFullPackageName + "." + fqn, loader, TypeName.Kind.TYPE, TypeName.Visibility.PUBLIC)); } } } return names; } }
private void possiblyAddTest(IFile entry, IDirectory root, TestClassFindType findType, ArrayList<IType> types) { if (shouldConsiderFile(entry, findType)) { String relativeFileName = root.relativePath(entry); String typeName = relativeFileName.replaceFirst("\\..*$", "").replace("/", "."); if (shouldConsiderTypeName(typeName)) { try { IType type = TypeSystem.getByFullName(typeName); if (shouldConsiderType(type)) { types.add(type); } } catch (Exception e) { //Log rather than warn, because invalid resources can exist ILogger logger = CommonServices.getEntityAccess().getLogger(); logger.warn("Could not load type " + typeName); // TODO - AHK // if (isLoggingErrors()) { // logError("Couldn't load "); // logError(GosuExceptionUtil.getStackTraceAsString(e)); // } } } } }
private void processDirectory(PackageToClassPathEntryTreeMap node, IFileSystemGosuClassRepository.ClassPathEntry entry, IDirectory path) { if (_excludedPath.contains(path)) { return; } IDirectory entryPath = entry.getPath(); if (entryPath.equals(path) || !CommonServices.getPlatformHelper().isPathIgnored(entryPath.relativePath(path))) { List<? extends IDirectory> dirs = path.listDirs(); for (IDirectory dir : dirs) { if (isValidDirectory(dir)) { PackageToClassPathEntryTreeMap child = node.createChildForDir(entry, dir.getName()); processDirectory(child, entry, dir); } } } }
private void processDirectory(PackageToClassPathEntryTreeMap node, IFileSystemGosuClassRepository.ClassPathEntry entry, IDirectory path) { IDirectory entryPath = entry.getPath(); if (entryPath.equals(path) || !CommonServices.getPlatformHelper().isPathIgnored(entryPath.relativePath(path))) { List<? extends IDirectory> dirs = path.listDirs(); for (IDirectory dir : dirs) { if (isValidDirectory(dir)) { PackageToClassPathEntryTreeMap child = node.createChildForDir(entry, dir.getName()); processDirectory(child, entry, dir); } } } }
private static void allContainedFilesExcludingIgnored(IDirectory root, IDirectory dir, DynamicArray<IFile> files) { files.addAll(dir.listFiles()); for (IDirectory subDir : dir.listDirs()) { if (!CommonServices.getPlatformHelper().isPathIgnored(root.relativePath(subDir))) { allContainedFilesExcludingIgnored(root, subDir, files); } } }
private static void allContainedFilesExcludingIgnored(IDirectory root, IDirectory dir, DynamicArray<IFile> files) { files.addAll(dir.listFiles()); for (IDirectory subDir : dir.listDirs()) { if (!CommonServices.getPlatformHelper().isPathIgnored(root.relativePath(subDir))) { allContainedFilesExcludingIgnored(root, subDir, files); } } }