use of sharpen.xobotos.config.LocationFilter.Match in project XobotOS by xamarin.
the class XobotBuilder method checkFileList.
private void checkFileList() {
final IPath sourcePath = _sourceFolder.getLocation();
final IPath outputPath = _outputFolder.getLocation();
final URI outputURI = outputPath.toFile().toURI();
final SourceInfo sourceInfo = _configFile.getSourceInfo();
final List<LocationFilter> excludeFilters = sourceInfo.getLocationFilters();
ArrayList<String> extraCSharpSources = new ArrayList<String>();
for (final String dir : sourceInfo.getExtraCSharpSources()) {
File path = _project.getLocation().append(dir).toFile();
collectAllFiles(extraCSharpSources, path.toURI(), path, ".cs");
}
for (final Entry<ICompilationUnit, Boolean> entry : _sources.entrySet()) {
final ICompilationUnit unit = entry.getKey();
String unitName = getUnitName(unit);
String sourceName = unitName.replace('.', '/') + ".java";
File sourceFile = sourcePath.append(sourceName).toFile();
String outputName = unitName.replace('.', '/') + ".cs";
File outputFile = outputPath.append(outputName).toFile();
URI uri = outputURI.relativize(outputFile.toURI());
if (_api.compilationUnitDefinesBindings(unitName)) {
/*
* This CompilationUnit defines bindings. We
* must always parse it, but don't need to
* regenerate it if the output is up-to-date.
*/
_mustParse.put(unit, true);
}
if (extraCSharpSources.contains(uri.getPath())) {
entry.setValue(false);
continue;
}
if (outputFile.exists() && (outputFile.lastModified() >= sourceFile.lastModified())) {
entry.setValue(false);
continue;
}
/*
* Check location filters.
*/
Match match = Match.NO_MATCH;
for (final LocationFilter filter : excludeFilters) {
match = filter.matches(unitName);
if (match != Match.NO_MATCH)
break;
}
if (match != Match.NO_MATCH) {
entry.setValue(match == Match.POSITIVE);
continue;
}
/*
* Default to building.
*/
entry.setValue(true);
}
}
use of sharpen.xobotos.config.LocationFilter.Match in project XobotOS by xamarin.
the class NamespaceTemplate method visit.
public boolean visit(TemplateVisitor visitor, String name, VisitMode mode) {
final String[] elements = name.split("\\.");
String part = "";
String rest = name;
boolean found = false;
if (!isRoot()) {
for (int i = 0; i < elements.length - 1; i++) {
part = buildName(elements, 0, i);
rest = buildName(elements, i + 1, elements.length - 1);
Match match = matches(part);
if (match == Match.NO_MATCH)
continue;
else if (match == Match.NEGATIVE)
return false;
found = true;
break;
}
if (!found)
return false;
} else {
Match match = matches(name);
if (match != Match.POSITIVE)
return false;
}
found = false;
if (isRoot() || isRecursive() || (rest.indexOf('.') < 0)) {
List<CompilationUnitTemplate> unitList = getCompilationUnits();
if (unitList != null) {
for (final CompilationUnitTemplate template : unitList) {
Match match = template.matches(rest);
if (match == Match.NO_MATCH)
continue;
else if (match == Match.NEGATIVE)
return false;
template.visit(visitor, mode);
found = true;
if (mode == VisitMode.FirstMatch)
break;
}
} else {
found = true;
}
if (isRoot() && !found) {
return false;
}
if (!isRecursive() && (mode == VisitMode.FirstMatch)) {
visitor.accept(this);
return true;
}
}
if (found && (mode == VisitMode.FirstMatch)) {
visitor.accept(this);
return true;
}
for (final NamespaceTemplate template : getNamespaces()) {
if (!template.visit(visitor, rest, mode))
continue;
found = true;
if (mode == VisitMode.FirstMatch)
break;
}
if (found)
visitor.accept(this);
return found;
}
use of sharpen.xobotos.config.LocationFilter.Match in project XobotOS by xamarin.
the class MemberAction method apply.
@Override
public void apply(ITypeBuilder parent, CSTypeDeclaration type) {
final Class<T> nodeType = getNodeType();
final Class<W> builderType = getBuilderType();
for (final T member : parent.getBodyDeclarations(nodeType)) {
Match match = matchesFilter(member);
if (match == Match.NEGATIVE)
return;
else if (match != Match.POSITIVE)
continue;
W builder = parent.getMemberBuilder(member, builderType);
if (builder == null)
continue;
apply(parent, builder, member, builder.getMember());
}
}
use of sharpen.xobotos.config.LocationFilter.Match in project XobotOS by xamarin.
the class AbstractTemplate method visit.
protected <T extends ASTNode, U extends CSNode, V extends AbstractMemberTemplate<T, U>> boolean visit(TemplateVisitor visitor, List<V> list, T member) {
if (list == null)
return true;
for (final V template : list) {
Match match = template.matches(member);
if (match == Match.NO_MATCH)
continue;
else if (match == Match.NEGATIVE)
return false;
OutputType output = template.getOutputType();
if ((output != null) && (output.getModeForMember(member) == OutputMode.NOTHING))
return false;
visitor.accept(template);
return true;
}
return true;
}
Aggregations