use of com.webcohesion.enunciate.javac.decorations.SourcePosition in project enunciate by stoicflame.
the class JavaJSONClientModule method copyServerSideType.
protected void copyServerSideType(File sourceDir, TypeElement type) throws IOException {
SourcePosition source = this.context.getProcessingEnvironment().findSourcePosition(type);
JavaFileObject sourceFile = source.getSourceFile();
File destFile = getServerSideDestFile(sourceDir, sourceFile, type);
FileWriter writer = new FileWriter(destFile);
debug("Writing server-side java type to %s.", destFile);
writer.write(sourceFile.getCharContent(false).toString());
writer.flush();
writer.close();
}
use of com.webcohesion.enunciate.javac.decorations.SourcePosition in project enunciate by stoicflame.
the class JavaXMLClientModule method copyServerSideType.
protected void copyServerSideType(File sourceDir, TypeElement type) throws IOException {
SourcePosition source = this.context.getProcessingEnvironment().findSourcePosition(type);
JavaFileObject sourceFile = source.getSourceFile();
File destFile = getServerSideDestFile(sourceDir, sourceFile, type);
FileWriter writer = new FileWriter(destFile);
debug("Writing server-side java type to %s.", destFile);
writer.write(sourceFile.getCharContent(false).toString());
writer.flush();
writer.close();
}
use of com.webcohesion.enunciate.javac.decorations.SourcePosition in project enunciate by stoicflame.
the class MemberComparator method compare.
// Inherited.
public int compare(Member accessor1, Member accessor2) {
if (isSameId(accessor1, accessor2)) {
// if the elements have the same identifier.
return 0;
}
// they're not the same, so now determine relative order:
String propertyName1 = accessor1.getSimpleName().toString();
String propertyName2 = accessor2.getSimpleName().toString();
if (this.propOrder != null && this.propOrder.length > 0) {
// apply the specified property order
int propertyIndex1 = find(this.propOrder, propertyName1);
int propertyIndex2 = find(this.propOrder, propertyName2);
if (propertyIndex1 < 0) {
// not in the property list; just use the hash.
propertyIndex1 = Math.abs(propertyName1.hashCode());
}
if (propertyIndex2 < 0) {
// not in the property list; just use the hash.
propertyIndex2 = Math.abs(propertyName2.hashCode());
}
return propertyIndex1 - propertyIndex2;
} else if (this.alphabetical) {
return propertyName1.compareTo(propertyName2);
}
// If no order is specified, it's undefined. We'll put it in source order.
SourcePosition position1 = this.env.findSourcePosition(accessor1);
SourcePosition position2 = this.env.findSourcePosition(accessor2);
if (position1 != null && position2 != null) {
return position1.compareTo(position2);
} else {
// don't have source positions... just provide a random sort order.
return accessor1.hashCode() - accessor2.hashCode();
}
}
use of com.webcohesion.enunciate.javac.decorations.SourcePosition in project enunciate by stoicflame.
the class BasicGeneratingModule method findSourceTimestamp.
public long findSourceTimestamp(DecoratedProcessingEnvironment env, Element apiElement) {
SourcePosition sp = env.findSourcePosition(apiElement);
URI uri = sp == null ? null : sp.getPath() == null ? null : sp.getPath().getCompilationUnit() == null ? null : sp.getPath().getCompilationUnit().getSourceFile() == null ? null : sp.getPath().getCompilationUnit().getSourceFile().toUri();
if (uri != null && "file".equalsIgnoreCase(uri.getScheme())) {
// it's a file uri.
return new File(uri.getPath()).lastModified();
}
return 0;
}
use of com.webcohesion.enunciate.javac.decorations.SourcePosition in project enunciate by stoicflame.
the class ElementComparator method compare.
// Inherited.
public int compare(Element accessor1, Element accessor2) {
if (isSameId(accessor1, accessor2)) {
// if the elements have the same identifier.
return 0;
}
// they're not the same, so now determine relative order:
String propertyName1 = accessor1.getSimpleName().toString();
String propertyName2 = accessor2.getSimpleName().toString();
if (this.propOrder != null) {
// apply the specified property order
int propertyIndex1 = find(this.propOrder, propertyName1);
int propertyIndex2 = find(this.propOrder, propertyName2);
if (propertyIndex1 < 0) {
throw new EnunciateException("Property '" + propertyName1 + "' isn't included in the specified property order.");
}
if (propertyIndex2 < 0) {
throw new EnunciateException("Property '" + propertyName2 + "' isn't included in the specified property order.");
}
return propertyIndex1 - propertyIndex2;
} else if (accessOrder == XmlAccessOrder.ALPHABETICAL) {
return propertyName1.compareTo(propertyName2);
}
// If no order is specified, it's undefined. We'll put it in source order.
SourcePosition position1 = this.env.findSourcePosition(accessor1);
SourcePosition position2 = this.env.findSourcePosition(accessor2);
if (position1 != null && position2 != null) {
return position1.compareTo(position2);
} else {
// don't have source positions... just provide a random sort order.
return accessor1.hashCode() - accessor2.hashCode();
}
}
Aggregations