本文整理汇总了Java中com.sun.mirror.util.SourcePosition类的典型用法代码示例。如果您正苦于以下问题:Java SourcePosition类的具体用法?Java SourcePosition怎么用?Java SourcePosition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SourcePosition类属于com.sun.mirror.util包,在下文中一共展示了SourcePosition类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: ProcessedHttpUrlAnnotation
import com.sun.mirror.util.SourcePosition; //导入依赖的package包/类
public ProcessedHttpUrlAnnotation(String typeName, Declaration declaration, String value, int weight) {
MethodDeclaration methodDeclaration = (MethodDeclaration) declaration;
String className = methodDeclaration.getDeclaringType().getQualifiedName();
this.methodName = declaration.getSimpleName();
this.docComment = declaration.getDocComment();
this.className = className;
this.value = value;
this.weight = weight;
this.setParams(methodDeclaration.getParameters());
String typeNameShort = typeName.substring(typeName.lastIndexOf("."));
SourcePosition positionInCode = declaration.getPosition();
sourceRef = positionInCode.file().getName() + ":" + positionInCode.line();
if (!(declaration instanceof MethodDeclaration)) {
messager.printWarning(positionInCode, "@" + typeNameShort + " declared on a non-method " + positionInCode);
}
if (showPositionsOfAnnotations) {
messager.printNotice(positionInCode, "@" + typeNameShort + " value " + value + " weight " + weight);
}
}
开发者ID:paultuckey,项目名称:urlrewritefilter,代码行数:20,代码来源:HttpUrlAnnotationProcessor.java
示例2: checkTypeIsFacadable
import com.sun.mirror.util.SourcePosition; //导入依赖的package包/类
private void checkTypeIsFacadable( TypeMirror type, SourcePosition position ) {
if ( type.equals( environment.getTypeUtils().getVoidType() ) ) {
// Annotating with Facadable on void methods is an error.
messager.printError( position, "Methods returning void cannot be marked as @Facadable" );
} else if ( type instanceof PrimitiveType ) {
// Annotating a primitive parameter with Facadable is an error.
messager.printError( position, "Primitive types cannot be marked as @Facadable" );
}
}
开发者ID:randombits-org,项目名称:facade,代码行数:10,代码来源:FacadeAnnotationProcessor.java
示例3: getAnnotationLineNumber
import com.sun.mirror.util.SourcePosition; //导入依赖的package包/类
static int getAnnotationLineNumber (MethodDeclaration method, String className)
{
for (AnnotationMirror mirror : method.getAnnotationMirrors ())
{
if (!className.equals (mirror.getAnnotationType ().getDeclaration ().getQualifiedName ()))
continue;
SourcePosition pos = mirror.getPosition ();
return pos == null ? 0 : pos.line ();
}
return 0;
}
开发者ID:coconut2015,项目名称:cookcc,代码行数:12,代码来源:ClassVisitor.java
示例4: getAnnotationArrayLineNumbers
import com.sun.mirror.util.SourcePosition; //导入依赖的package包/类
static int[] getAnnotationArrayLineNumbers (MethodDeclaration method, String className, String attr)
{
for (AnnotationMirror mirror : method.getAnnotationMirrors ())
{
if (!className.equals (mirror.getAnnotationType ().getDeclaration ().getQualifiedName ()))
continue;
Map<AnnotationTypeElementDeclaration, AnnotationValue> map = mirror.getElementValues ();
for (AnnotationTypeElementDeclaration key : map.keySet ())
{
if (!attr.equals (key.getSimpleName ()))
continue;
@SuppressWarnings ("unchecked")
Collection<AnnotationValue> c = (Collection<AnnotationValue>)map.get (key).getValue ();
if (c == null)
return null;
int[] returnVal = new int[c.size ()];
int i = 0;
for (AnnotationValue v : c)
{
SourcePosition pos = v.getPosition ();
if (pos == null)
returnVal[i++] = 0;
else
returnVal[i++] = pos.line ();
}
return returnVal;
}
}
return null;
}
开发者ID:coconut2015,项目名称:cookcc,代码行数:31,代码来源:ClassVisitor.java
示例5: printError
import com.sun.mirror.util.SourcePosition; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void printError(SourcePosition pos, String msg) {
if (pos instanceof SourcePositionImpl) {
SourcePositionImpl posImpl = (SourcePositionImpl) pos;
JavaFileObject prev = bark.useSource(posImpl.getSource());
bark.aptError(posImpl.getJavacPosition(), "Messager", msg);
bark.useSource(prev);
} else
printError(msg);
}
开发者ID:unktomi,项目名称:form-follows-function,代码行数:13,代码来源:MessagerImpl.java
示例6: printWarning
import com.sun.mirror.util.SourcePosition; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void printWarning(SourcePosition pos, String msg) {
if (pos instanceof SourcePositionImpl) {
SourcePositionImpl posImpl = (SourcePositionImpl) pos;
JavaFileObject prev = bark.useSource(posImpl.getSource());
bark.aptWarning(posImpl.getJavacPosition(), "Messager", msg);
bark.useSource(prev);
} else
printWarning(msg);
}
开发者ID:unktomi,项目名称:form-follows-function,代码行数:13,代码来源:MessagerImpl.java
示例7: printNotice
import com.sun.mirror.util.SourcePosition; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void printNotice(SourcePosition pos, String msg) {
if (pos instanceof SourcePositionImpl) {
SourcePositionImpl posImpl = (SourcePositionImpl) pos;
JavaFileObject prev = bark.useSource(posImpl.getSource());
bark.aptNote(posImpl.getJavacPosition(), "Messager", msg);
bark.useSource(prev);
} else
printNotice(msg);
}
开发者ID:unktomi,项目名称:form-follows-function,代码行数:13,代码来源:MessagerImpl.java
示例8: processHttpExceptionHandlerAnnotation
import com.sun.mirror.util.SourcePosition; //导入依赖的package包/类
private ProcessedHttpExceptionAnnotation processHttpExceptionHandlerAnnotation(Declaration declaration) {
SourcePosition position = declaration.getPosition();
if (!(declaration instanceof MethodDeclaration)) {
messager.printWarning(declaration.getPosition(), "@HttpExceptionHandler declared on a non-method " + position);
return null;
}
MethodDeclaration methodDeclaration = (MethodDeclaration) declaration;
HttpExceptionHandler httpExceptionHandler = declaration.getAnnotation(HttpExceptionHandler.class);
String className = methodDeclaration.getDeclaringType().getQualifiedName();
ProcessedHttpExceptionAnnotation ea = new ProcessedHttpExceptionAnnotation();
ea.exceptionName = httpExceptionHandler.value(); //.getName();
ea.methodName = declaration.getSimpleName();
ea.docComment = declaration.getDocComment();
ea.className = className;
ea.setParams(methodDeclaration.getParameters());
// out exceptionName might not be set
if ("[ unassigned ]".equals(ea.exceptionName) && methodDeclaration.getParameters().size() > 0) {
// use first param
ea.exceptionName = methodDeclaration.getParameters().iterator().next().getType().toString();
}
if (showPositionsOfAnnotations) {
messager.printNotice(position, "@HttpExceptionHandlerUrl value " + ea.value + " weight " + ea.weight);
}
return ea;
}
开发者ID:paultuckey,项目名称:urlrewritefilter,代码行数:30,代码来源:HttpUrlAnnotationProcessor.java
示例9: visitClassDeclaration
import com.sun.mirror.util.SourcePosition; //导入依赖的package包/类
public void visitClassDeclaration(ClassDeclaration d) {
WebService webService = d.getAnnotation(WebService.class);
if (!shouldProcessWebService(webService, d))
return;
if (builder.checkAndSetProcessed(d))
return;
typeDeclSOAPBinding = d.getAnnotation(SOAPBinding.class);
typeDecl = d;
if (serviceImplName == null)
serviceImplName = d.getQualifiedName();
String endpointInterfaceName = webService != null ? webService.endpointInterface() : null;
if (endpointInterfaceName != null && endpointInterfaceName.length() > 0) {
SourcePosition pos = pos = d.getPosition();
checkForInvalidImplAnnotation(d, SOAPBinding.class);
if (webService.name().length() > 0)
annotationError(pos, WebserviceapMessages.localizableWEBSERVICEAP_ENDPOINTINTEFACE_PLUS_ELEMENT("name"));
endpointReferencesInterface = true;
verifyImplAnnotations(d);
inspectEndpointInterface(endpointInterfaceName, d);
serviceImplName = null;
return;
}
processingSEI = false;
preProcessWebService(webService, d);
processWebService(webService, d);
serviceImplName = null;
postProcessWebService(webService, d);
serviceImplName = null;
}
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:30,代码来源:WebServiceVisitor.java
示例10: checkForInvalidSEIAnnotation
import com.sun.mirror.util.SourcePosition; //导入依赖的package包/类
protected void checkForInvalidSEIAnnotation(InterfaceDeclaration d, Class annotationClass) {
Object annotation = d.getAnnotation(annotationClass);
if (annotation != null) {
SourcePosition pos = d.getPosition();
annotationError(pos, WebserviceapMessages.localizableWEBSERVICEAP_INVALID_SEI_ANNOTATION(annotationClass.getName(), d.getQualifiedName()));
}
}
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:8,代码来源:WebServiceVisitor.java
示例11: checkForInvalidImplAnnotation
import com.sun.mirror.util.SourcePosition; //导入依赖的package包/类
protected void checkForInvalidImplAnnotation(Declaration d, Class annotationClass) {
Object annotation = d.getAnnotation(annotationClass);
if (annotation != null) {
SourcePosition pos = d.getPosition();
annotationError(pos, WebserviceapMessages.localizableWEBSERVICEAP_ENDPOINTINTEFACE_PLUS_ANNOTATION(annotationClass.getName()));
}
}
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:8,代码来源:WebServiceVisitor.java
示例12: onError
import com.sun.mirror.util.SourcePosition; //导入依赖的package包/类
public void onError(SourcePosition pos, Localizable msg) throws ModelerException {
if (messager != null) {
messager.printError(pos, localizer.localize(msg));
} else {
throw new ModelerException(msg);
}
}
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:8,代码来源:WebServiceAP.java
示例13: sort
import com.sun.mirror.util.SourcePosition; //导入依赖的package包/类
private <A extends Declaration> List<A> sort(List<A> l) {
if(l.isEmpty()) return l;
// APT supports the operation mode where it creates Declarations from
// a class file, in which case the source position is not available
// use that as a key to sort them correctly. This isn't "correct" in
// the sense that it relies on undocumented behavior of APT where
// it returns declarations in the reverse order, but this makes things work.
SourcePosition pos = l.get(0).getPosition();
if(pos!=null)
Collections.sort(l,SOURCE_POS_COMPARATOR);
else
Collections.reverse(l);
return l;
}
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:16,代码来源:APTNavigator.java
示例14: getLocation
import com.sun.mirror.util.SourcePosition; //导入依赖的package包/类
private Location getLocation(final String name, final SourcePosition sp) {
return new Location() {
public String toString() {
if(sp==null)
return name+" (Unknown Source)";
// just like stack trace, we just print the file name and
// not the whole path. The idea is that the pakage name should
// provide enough clue on which directory it lives.
return name+'('+sp.file().getName()+':'+sp.line()+')';
}
};
}
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:13,代码来源:APTNavigator.java
示例15: compare
import com.sun.mirror.util.SourcePosition; //导入依赖的package包/类
public int compare(Declaration d1, Declaration d2) {
if (d1 == d2)
return 0;
SourcePosition p1 = d1.getPosition();
SourcePosition p2 = d2.getPosition();
if (p1 == null) {
return (p2 == null) ? 0 : 1;
} else {
if (p2 == null)
return -1;
int fileComp = p1.file().compareTo(p2.file());
if (fileComp == 0) {
long diff = (long) p1.line() - (long) p2.line();
if (diff == 0) {
diff = Long.signum((long) p1.column() - (long) p2.column());
if (diff != 0)
return (int) diff;
else {
// declarations may be two
// compiler-generated members with the
// same source position
return (Long.signum((long) System.identityHashCode(d1) -
(long) System.identityHashCode(d2)));
}
} else
return (diff < 0) ? -1 : 1;
} else
return fileComp;
}
}
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:34,代码来源:APTNavigator.java
示例16: getPosition
import com.sun.mirror.util.SourcePosition; //导入依赖的package包/类
public SourcePosition getPosition() {
// Imprecise implementation; just return position of enclosing
// annotation.
return (annotation == null) ? null : annotation.getPosition();
}
开发者ID:unktomi,项目名称:form-follows-function,代码行数:6,代码来源:AnnotationValueImpl.java
示例17: getPosition
import com.sun.mirror.util.SourcePosition; //导入依赖的package包/类
public SourcePosition getPosition() {
// Return position of the declaration on which this annotation
// appears.
return (decl == null) ? null : decl.getPosition();
}
开发者ID:unktomi,项目名称:form-follows-function,代码行数:7,代码来源:AnnotationMirrorImpl.java
注:本文中的com.sun.mirror.util.SourcePosition类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论