当前位置: 首页>>代码示例>>Java>>正文


Java Declaration.getPosition方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:paultuckey,项目名称:urlrewritefilter,代码行数:20,代码来源:HttpUrlAnnotationProcessor.java

示例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;
}
 
开发者ID:paultuckey,项目名称:urlrewritefilter,代码行数:30,代码来源:HttpUrlAnnotationProcessor.java

示例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;
    }
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:34,代码来源:APTNavigator.java

示例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);
}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:6,代码来源:OnDepartureVisitorAPT.java

示例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);
}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:5,代码来源:OnDepartureVisitorAPT.java

示例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);
}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:5,代码来源:NodeAttachmentCallbackVisitorAPT.java

示例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);
}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:5,代码来源:ActiveObjectVisitorAPT.java

示例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);
}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:5,代码来源:ActiveObjectVisitorAPT.java


注:本文中的com.sun.mirror.declaration.Declaration.getPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。