本文整理汇总了Java中com.sun.mirror.declaration.Declaration.getPosition方法的典型用法代码示例。如果您正苦于以下问题:Java Declaration.getPosition方法的具体用法?Java Declaration.getPosition怎么用?Java Declaration.getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.mirror.declaration.Declaration
的用法示例。
在下文中一共展示了Declaration.getPosition方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ProcessedHttpUrlAnnotation
import com.sun.mirror.declaration.Declaration; //导入方法依赖的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);
}
}
示例2: processHttpExceptionHandlerAnnotation
import com.sun.mirror.declaration.Declaration; //导入方法依赖的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;
}
示例3: compare
import com.sun.mirror.declaration.Declaration; //导入方法依赖的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;
}
}
示例4: reportError
import com.sun.mirror.declaration.Declaration; //导入方法依赖的package包/类
protected void reportError(Declaration declaration, String msg) {
SourcePosition sourceCodePos = declaration.getPosition();
_compilerOutput.printError(sourceCodePos, "[ERROR]" + ERROR_PREFIX +
ErrorMessages.INVALID_MIGRATION_STRATEGY_METHOD + ": " + msg + ERROR_SUFFIX);
}
示例5: reportWarning
import com.sun.mirror.declaration.Declaration; //导入方法依赖的package包/类
protected void reportWarning(Declaration declaration, String msg) {
SourcePosition sourceCodePos = declaration.getPosition();
_compilerOutput.printWarning(sourceCodePos, "[WARNING]" + ERROR_PREFIX + msg + ERROR_SUFFIX);
}
示例6: reportError
import com.sun.mirror.declaration.Declaration; //导入方法依赖的package包/类
protected void reportError(Declaration declaration, String msg) {
SourcePosition sourceCodePos = declaration.getPosition();
_compilerOutput.printError(sourceCodePos, "[ERROR] " + msg);
}
示例7: reportError
import com.sun.mirror.declaration.Declaration; //导入方法依赖的package包/类
protected void reportError(Declaration declaration, String msg) {
SourcePosition classPos = declaration.getPosition();
_compilerOutput.printError(classPos, "[ERROR]" + msg + ERROR_SUFFIX);
}
示例8: reportWarning
import com.sun.mirror.declaration.Declaration; //导入方法依赖的package包/类
protected void reportWarning(Declaration declaration, String msg) {
SourcePosition classPos = declaration.getPosition();
_compilerOutput.printWarning(classPos, "[WARNING]" + msg + ERROR_SUFFIX);
}