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


Java DiagnosticPosition类代码示例

本文整理汇总了Java中com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition的典型用法代码示例。如果您正苦于以下问题:Java DiagnosticPosition类的具体用法?Java DiagnosticPosition怎么用?Java DiagnosticPosition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DiagnosticPosition类属于com.sun.tools.javac.util.JCDiagnostic包,在下文中一共展示了DiagnosticPosition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: attribLazyConstantValue

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; //导入依赖的package包/类
/**
 * Attribute a "lazy constant value".
 *  @param env         The env for the const value
 *  @param variable    The initializer for the const value
 *  @param type        The expected type, or null
 *  @see VarSymbol#setLazyConstValue
 */
public Object attribLazyConstantValue(Env<AttrContext> env,
                                  JCVariableDecl variable,
                                  Type type) {

    DiagnosticPosition prevLintPos
            = deferredLintHandler.setPos(variable.pos());

    final JavaFileObject prevSource = log.useSource(env.toplevel.sourcefile);
    try {
        Type itype = attribExpr(variable.init, env, type);
        if (itype.constValue() != null) {
            return coerce(itype, type).constValue();
        } else {
            return null;
        }
    } finally {
        log.useSource(prevSource);
        deferredLintHandler.setPos(prevLintPos);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:Attr.java

示例2: checkDimension

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; //导入依赖的package包/类
/**
 * Check if the given type is an array with too many dimensions.
 */
private void checkDimension(DiagnosticPosition pos, Type t) {
    switch (t.tag) {
        case METHOD:
            checkDimension(pos, t.getReturnType());
            for (List<Type> args = t.getParameterTypes(); args.nonEmpty(); args = args.tail)
                checkDimension(pos, args.head);
            break;
        case ARRAY:
            if (types.dimensions(t) > ClassFile.MAX_DIMENSIONS) {
                log.error(pos, "limit.dimensions");
                nerrs++;
            }
            break;
        default:
            break;
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:21,代码来源:Gen.java

示例3: checkUnique

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; //导入依赖的package包/类
/** Check that symbol is unique in given scope.
 *  @param pos           Position for error reporting.
 *  @param sym           The symbol.
 *  @param s             The scope.
 */
boolean checkUnique(DiagnosticPosition pos, Symbol sym, Scope s) {
    if (sym.type.isErroneous())
        return true;
    if (sym.owner.name == names.any) return false;
    for (Scope.Entry e = s.lookup(sym.name); e.scope == s; e = e.next()) {
        if (sym != e.sym &&
                (e.sym.flags() & CLASH) == 0 &&
                sym.kind == e.sym.kind &&
                sym.name != names.error &&
                (sym.kind != MTH || types.hasSameArgs(types.erasure(sym.type), types.erasure(e.sym.type)))) {
            if ((sym.flags() & VARARGS) != (e.sym.flags() & VARARGS)) {
                varargsDuplicateError(pos, sym, e.sym);
                return true;
            } else if (sym.kind == MTH && !types.hasSameArgs(sym.type, e.sym.type, false)) {
                duplicateErasureError(pos, sym, e.sym);
                sym.flags_field |= CLASH;
                return true;
            } else {
                duplicateError(pos, e.sym);
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:31,代码来源:Check.java

示例4: getMemberReference

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; //导入依赖的package包/类
Symbol getMemberReference(DiagnosticPosition pos,
        Env<AttrContext> env,
        JCMemberReference referenceTree,
        Type site,
        Name name) {

    site = types.capture(site);

    ReferenceLookupHelper lookupHelper = makeReferenceLookupHelper(
            referenceTree, site, name, List.nil(), null, VARARITY);

    Env<AttrContext> newEnv = env.dup(env.tree, env.info.dup());
    Symbol sym = lookupMethod(newEnv, env.tree.pos(), site.tsym,
            nilMethodCheck, lookupHelper);

    env.info.pendingResolutionPhase = newEnv.info.pendingResolutionPhase;

    return sym;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:Resolve.java

示例5: accepts

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; //导入依赖的package包/类
protected boolean accepts(AttributeKind kind) {
    if (kinds.contains(kind)) {
        if (majorVersion > version.major || (majorVersion == version.major && minorVersion >= version.minor))
            return true;

        if (lintClassfile && !warnedAttrs.contains(name)) {
            JavaFileObject prev = log.useSource(currentClassFile);
            try {
                log.warning(LintCategory.CLASSFILE, (DiagnosticPosition) null, "future.attr",
                        name, version.major, version.minor, majorVersion, minorVersion);
            } finally {
                log.useSource(prev);
            }
            warnedAttrs.add(name);
        }
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:ClassReader.java

示例6: checkEffectivelyFinal

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; //导入依赖的package包/类
@SuppressWarnings("fallthrough")
void checkEffectivelyFinal(DiagnosticPosition pos, VarSymbol sym) {
    if (currentTree != null &&
            sym.owner.kind == MTH &&
            sym.pos < currentTree.getStartPosition()) {
        switch (currentTree.getTag()) {
            case CLASSDEF:
                if (!allowEffectivelyFinalInInnerClasses) {
                    if ((sym.flags() & FINAL) == 0) {
                        reportInnerClsNeedsFinalError(pos, sym);
                    }
                    break;
                }
            case LAMBDA:
                if ((sym.flags() & (EFFECTIVELY_FINAL | FINAL)) == 0) {
                   reportEffectivelyFinalError(pos, sym);
                }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:Flow.java

示例7: checkSymbol

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; //导入依赖的package包/类
private void checkSymbol(DiagnosticPosition pos, Symbol sym) {
    if (sym != null && sym.kind == TYP) {
        Env<AttrContext> classEnv = enter.getEnv((TypeSymbol)sym);
        if (classEnv != null) {
            DiagnosticSource prevSource = log.currentSource();
            try {
                log.useSource(classEnv.toplevel.sourcefile);
                scan(classEnv.tree);
            }
            finally {
                log.useSource(prevSource.getFile());
            }
        } else if (sym.kind == TYP) {
            checkClass(pos, sym, List.nil());
        }
    } else {
        //not completed yet
        partialCheck = true;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:Check.java

示例8: checkAssignable

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; //导入依赖的package包/类
/** Check that variable can be assigned to.
 *  @param pos    The current source code position.
 *  @param v      The assigned varaible
 *  @param base   If the variable is referred to in a Select, the part
 *                to the left of the `.', null otherwise.
 *  @param env    The current environment.
 */
void checkAssignable(DiagnosticPosition pos, VarSymbol v, JCTree base, Env<AttrContext> env) {
    if ((v.flags() & FINAL) != 0 &&
        ((v.flags() & HASINIT) != 0
         ||
         !((base == null ||
           (base.getTag() == JCTree.IDENT && TreeInfo.name(base) == names._this)) &&
           isAssignableAsBlankFinal(v, env)))) {
        if (v.isResourceVariable()) { //TWR resource
            log.error(pos, "try.resource.may.not.be.assigned", v);
        } else {
            log.error(pos, "cant.assign.val.to.final.var", v);
        }
    } else if ((v.flags() & EFFECTIVELY_FINAL) != 0) {
        v.flags_field &= ~EFFECTIVELY_FINAL;
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:24,代码来源:Attr.java

示例9: addOverrideBridgesIfNeeded

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; //导入依赖的package包/类
private List<JCTree> addOverrideBridgesIfNeeded(DiagnosticPosition pos,
                                final ClassSymbol c) {
    ListBuffer<JCTree> buf = ListBuffer.lb();
    if (c.isInterface() || !boundsRestricted(c))
        return buf.toList();
    Type t = types.supertype(c.type);
        Scope s = t.tsym.members();
        if (s.elems != null) {
            for (Symbol sym : s.getElements(new NeedsOverridBridgeFilter(c))) {

                MethodSymbol m = (MethodSymbol)sym;
                MethodSymbol member = (MethodSymbol)m.asMemberOf(c.type, types);
                MethodSymbol impl = m.implementation(c, types, false);

                if ((impl == null || impl.owner != c) &&
                        !types.isSameType(member.erasure(types), m.erasure(types))) {
                    addOverrideBridges(pos, m, member, c, buf);
                }
            }
        }
    return buf.toList();
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:23,代码来源:TransTypes.java

示例10: RecoveryInfo

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; //导入依赖的package包/类
public RecoveryInfo(final DeferredAttr.DeferredAttrContext deferredAttrContext) {
    super(KindSelector.VAL, Type.recoveryType,
          new Check.NestedCheckContext(chk.basicHandler) {
        @Override
        public DeferredAttr.DeferredAttrContext deferredAttrContext() {
            return deferredAttrContext;
        }
        @Override
        public boolean compatible(Type found, Type req, Warner warn) {
            return true;
        }
        @Override
        public void report(DiagnosticPosition pos, JCDiagnostic details) {
            chk.basicHandler.report(pos, details);
        }
    });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:Attr.java

示例11: access

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; //导入依赖的package包/类
/** If `sym' is a bad symbol: report error and return errSymbol
 *  else pass through unchanged,
 *  additional arguments duplicate what has been used in trying to find the
 *  symbol (--> flyweight pattern). This improves performance since we
 *  expect misses to happen frequently.
 *
 *  @param sym       The symbol that was found, or a ResolveError.
 *  @param pos       The position to use for error reporting.
 *  @param site      The original type from where the selection took place.
 *  @param name      The symbol's name.
 *  @param argtypes  The invocation's value arguments,
 *                   if we looked for a method.
 *  @param typeargtypes  The invocation's type arguments,
 *                   if we looked for a method.
 */
Symbol access(Symbol sym,
              DiagnosticPosition pos,
              Symbol location,
              Type site,
              Name name,
              boolean qualified,
              List<Type> argtypes,
              List<Type> typeargtypes) {
    if (sym.kind >= AMBIGUOUS) {
        ResolveError errSym = (ResolveError)sym;
        if (!site.isErroneous() &&
            !Type.isErroneous(argtypes) &&
            (typeargtypes==null || !Type.isErroneous(typeargtypes)))
            logResolveError(errSym, pos, location, site, name, argtypes, typeargtypes);
        sym = errSym.access(name, qualified ? site.tsym : syms.noSymbol);
    }
    return sym;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:34,代码来源:Resolve.java

示例12: getMemberReference

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; //导入依赖的package包/类
Symbol getMemberReference(DiagnosticPosition pos,
        Env<AttrContext> env,
        JCMemberReference referenceTree,
        Type site,
        Name name) {

    site = types.capture(site);

    ReferenceLookupHelper lookupHelper = makeReferenceLookupHelper(
            referenceTree, site, name, List.<Type>nil(), null, VARARITY);

    Env<AttrContext> newEnv = env.dup(env.tree, env.info.dup());
    Symbol sym = lookupMethod(newEnv, env.tree.pos(), site.tsym,
            nilMethodCheck, lookupHelper);

    env.info.pendingResolutionPhase = newEnv.info.pendingResolutionPhase;

    return sym;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:Resolve.java

示例13: validateRepeatable

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; //导入依赖的package包/类
/**
 * Validate the proposed container 'repeatable' on the
 * annotation type symbol 's'. Report errors at position
 * 'pos'.
 *
 * @param s The (annotation)type declaration annotated with a @Repeatable
 * @param repeatable the @Repeatable on 's'
 * @param pos where to report errors
 */
public void validateRepeatable(TypeSymbol s, Attribute.Compound repeatable, DiagnosticPosition pos) {
    Assert.check(types.isSameType(repeatable.type, syms.repeatableType));

    Type t = null;
    List<Pair<MethodSymbol,Attribute>> l = repeatable.values;
    if (!l.isEmpty()) {
        Assert.check(l.head.fst.name == names.value);
        t = ((Attribute.Class)l.head.snd).getValue();
    }

    if (t == null) {
        // errors should already have been reported during Annotate
        return;
    }

    validateValue(t.tsym, s, pos);
    validateRetention(t.tsym, s, pos);
    validateDocumented(t.tsym, s, pos);
    validateInherited(t.tsym, s, pos);
    validateTarget(t.tsym, s, pos);
    validateDefault(t.tsym, pos);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:Check.java

示例14: accepts

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; //导入依赖的package包/类
protected boolean accepts(AttributeKind kind) {
    if (kinds.contains(kind)) {
        if (majorVersion > version.major || (majorVersion == version.major && minorVersion >= version.minor))
            return true;

        if (lintClassfile && !warnedAttrs.contains(name)) {
            JavaFileObject prev = log.useSource(currentClassFile);
            try {
                log.warning(LintCategory.CLASSFILE, (DiagnosticPosition) null,
                            Warnings.FutureAttr(name, version.major, version.minor, majorVersion, minorVersion));
            } finally {
                log.useSource(prev);
            }
            warnedAttrs.add(name);
        }
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:ClassReader.java

示例15: checkSymbol

import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; //导入依赖的package包/类
private void checkSymbol(DiagnosticPosition pos, Symbol sym) {
    if (sym != null && sym.kind == TYP) {
        Env<AttrContext> classEnv = enter.getEnv((TypeSymbol)sym);
        if (classEnv != null) {
            DiagnosticSource prevSource = log.currentSource();
            try {
                log.useSource(classEnv.toplevel.sourcefile);
                scan(classEnv.tree);
            }
            finally {
                log.useSource(prevSource.getFile());
            }
        } else if (sym.kind == TYP) {
            checkClass(pos, sym, List.<JCTree>nil());
        }
    } else {
        //not completed yet
        partialCheck = true;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:Check.java


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