Java源码示例:org.gradle.api.file.EmptyFileVisitor
示例1
public Set<? extends LocallyAvailableResource> search(String pattern) {
if (!getBaseDir().exists()) {
return Collections.emptySet();
}
final Set<LocallyAvailableResource> entries = new HashSet<LocallyAvailableResource>();
findFiles(pattern).visit(new EmptyFileVisitor() {
public void visitFile(FileVisitDetails fileDetails) {
final File file = fileDetails.getFile();
// We cannot clean in progress markers, or in progress files here because
// the file system visitor stuff can't handle the file system mutating while visiting
if (!isInProgressMarkerFile(file) && !isInProgressFile(file)) {
entries.add(entryAt(file));
}
}
});
return entries;
}
示例2
public Set<? extends LocallyAvailableResource> search(String pattern) {
if (!getBaseDir().exists()) {
return Collections.emptySet();
}
final Set<LocallyAvailableResource> entries = new HashSet<LocallyAvailableResource>();
findFiles(pattern).visit(new EmptyFileVisitor() {
public void visitFile(FileVisitDetails fileDetails) {
final File file = fileDetails.getFile();
// We cannot clean in progress markers, or in progress files here because
// the file system visitor stuff can't handle the file system mutating while visiting
if (!isInProgressMarkerFile(file) && !isInProgressFile(file)) {
entries.add(entryAt(file));
}
}
});
return entries;
}
示例3
public Set<? extends LocallyAvailableResource> search(String pattern) {
if (!getBaseDir().exists()) {
return Collections.emptySet();
}
final Set<LocallyAvailableResource> entries = new HashSet<LocallyAvailableResource>();
findFiles(pattern).visit(new EmptyFileVisitor() {
public void visitFile(FileVisitDetails fileDetails) {
final File file = fileDetails.getFile();
// We cannot clean in progress markers, or in progress files here because
// the file system visitor stuff can't handle the file system mutating while visiting
if (!isInProgressMarkerFile(file) && !isInProgressFile(file)) {
entries.add(entryAt(file));
}
}
});
return entries;
}
示例4
public Set<? extends LocallyAvailableResource> search(String pattern) {
if (!getBaseDir().exists()) {
return Collections.emptySet();
}
final Set<LocallyAvailableResource> entries = new HashSet<LocallyAvailableResource>();
findFiles(pattern).visit(new EmptyFileVisitor() {
public void visitFile(FileVisitDetails fileDetails) {
final File file = fileDetails.getFile();
// We cannot clean in progress markers, or in progress files here because
// the file system visitor stuff can't handle the file system mutating while visiting
if (!isInProgressMarkerFile(file) && !isInProgressFile(file)) {
entries.add(entryAt(file));
}
}
});
return entries;
}
示例5
@NonNull
private Pair<Collection<CompilationUnitDeclaration>, INameEnvironment> parseSources() {
final List<ICompilationUnit> sourceUnits = Lists.newArrayListWithExpectedSize(100);
getSource().visit(new EmptyFileVisitor() {
@Override
public void visitFile(FileVisitDetails fileVisitDetails) {
File file = fileVisitDetails.getFile();
String path = file.getPath();
if (path.endsWith(DOT_JAVA) && file.isFile()) {
char[] contents = new char[0];
try {
contents = Util.getFileCharContent(file, encoding);
ICompilationUnit unit = new CompilationUnit(contents, path, encoding);
sourceUnits.add(unit);
} catch (IOException e) {
e.printStackTrace();
}
}
}
});
Map<ICompilationUnit, CompilationUnitDeclaration> outputMap = Maps.newHashMapWithExpectedSize(((ArrayList<ICompilationUnit>) sourceUnits).size());
List<String> jars = Lists.newArrayList();
if (bootClasspath != null) {
((ArrayList<String>) jars).addAll(bootClasspath);
}
if (getClasspath() != null) {
for (File jar : getClasspath()) {
((ArrayList<String>) jars).add(jar.getPath());
}
}
CompilerOptions options = EcjParser.createCompilerOptions();
options.docCommentSupport = true;// So I can find @hide
// Note: We can *not* set options.ignoreMethodBodies=true because it disables
// type attribution!
long level = getLanguageLevel(getSourceCompatibility());
options.sourceLevel = level;
options.complianceLevel = options.sourceLevel;
// We don't generate code, but just in case the parser consults this flag
// and makes sure that it's not greater than the source level:
options.targetJDK = options.sourceLevel;
options.originalComplianceLevel = options.sourceLevel;
options.originalSourceLevel = options.sourceLevel;
options.inlineJsrBytecode = true;// >= 1.5
INameEnvironment environment = EcjParser.parse(options, sourceUnits, jars, outputMap, null);
Collection<CompilationUnitDeclaration> parsedUnits = ((HashMap<ICompilationUnit, CompilationUnitDeclaration>) outputMap).values();
return Pair.of(parsedUnits, environment);
}