com.sun.tools.javac.comp.Resolve.MethodResolutionDiagHelper.DiagnosticRewriter Java Examples

The following examples show how to use com.sun.tools.javac.comp.Resolve.MethodResolutionDiagHelper.DiagnosticRewriter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Resolve.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
JCDiagnostic getDiagnostic(JCDiagnostic.DiagnosticType dkind,
        DiagnosticPosition pos,
        Symbol location,
        Type site,
        Name name,
        List<Type> argtypes,
        List<Type> typeargtypes) {
    if (name == names.error)
        return null;

    if (syms.operatorNames.contains(name)) {
        boolean isUnaryOp = argtypes.size() == 1;
        String key = argtypes.size() == 1 ?
            "operator.cant.be.applied" :
            "operator.cant.be.applied.1";
        Type first = argtypes.head;
        Type second = !isUnaryOp ? argtypes.tail.head : null;
        return diags.create(dkind, log.currentSource(), pos,
                key, name, first, second);
    }
    else {
        Pair<Symbol, JCDiagnostic> c = errCandidate();
        if (compactMethodDiags) {
            for (Map.Entry<Template, DiagnosticRewriter> _entry :
                    MethodResolutionDiagHelper.rewriters.entrySet()) {
                if (_entry.getKey().matches(c.snd)) {
                    JCDiagnostic simpleDiag =
                            _entry.getValue().rewriteDiagnostic(diags, pos,
                                log.currentSource(), dkind, c.snd);
                    simpleDiag.setFlag(DiagnosticFlag.COMPRESSED);
                    return simpleDiag;
                }
            }
        }
        Symbol ws = c.fst.asMemberOf(site, types);
        return diags.create(dkind, log.currentSource(), pos,
                  "cant.apply.symbol",
                  kindName(ws),
                  ws.name == names.init ? ws.owner.name : ws.name,
                  methodArguments(ws.type.getParameterTypes()),
                  methodArguments(argtypes),
                  kindName(ws.owner),
                  ws.owner.type,
                  c.snd);
    }
}
 
Example #2
Source File: Resolve.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
JCDiagnostic getDiagnostic(JCDiagnostic.DiagnosticType dkind,
        DiagnosticPosition pos,
        Symbol location,
        Type site,
        Name name,
        List<Type> argtypes,
        List<Type> typeargtypes) {
    if (name == names.error)
        return null;

    if (syms.operatorNames.contains(name)) {
        boolean isUnaryOp = argtypes.size() == 1;
        String key = argtypes.size() == 1 ?
            "operator.cant.be.applied" :
            "operator.cant.be.applied.1";
        Type first = argtypes.head;
        Type second = !isUnaryOp ? argtypes.tail.head : null;
        return diags.create(dkind, log.currentSource(), pos,
                key, name, first, second);
    }
    else {
        Pair<Symbol, JCDiagnostic> c = errCandidate();
        if (compactMethodDiags) {
            for (Map.Entry<Template, DiagnosticRewriter> _entry :
                    MethodResolutionDiagHelper.rewriters.entrySet()) {
                if (_entry.getKey().matches(c.snd)) {
                    JCDiagnostic simpleDiag =
                            _entry.getValue().rewriteDiagnostic(diags, pos,
                                log.currentSource(), dkind, c.snd);
                    simpleDiag.setFlag(DiagnosticFlag.COMPRESSED);
                    return simpleDiag;
                }
            }
        }
        Symbol ws = c.fst.asMemberOf(site, types);
        return diags.create(dkind, log.currentSource(), pos,
                  "cant.apply.symbol",
                  kindName(ws),
                  ws.name == names.init ? ws.owner.name : ws.name,
                  methodArguments(ws.type.getParameterTypes()),
                  methodArguments(argtypes),
                  kindName(ws.owner),
                  ws.owner.type,
                  c.snd);
    }
}
 
Example #3
Source File: Resolve.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
JCDiagnostic getDiagnostic(JCDiagnostic.DiagnosticType dkind,
        DiagnosticPosition pos,
        Symbol location,
        Type site,
        Name name,
        List<Type> argtypes,
        List<Type> typeargtypes) {
    if (name == names.error)
        return null;

    if (syms.operatorNames.contains(name)) {
        boolean isUnaryOp = argtypes.size() == 1;
        String key = argtypes.size() == 1 ?
            "operator.cant.be.applied" :
            "operator.cant.be.applied.1";
        Type first = argtypes.head;
        Type second = !isUnaryOp ? argtypes.tail.head : null;
        return diags.create(dkind, log.currentSource(), pos,
                key, name, first, second);
    }
    else {
        Pair<Symbol, JCDiagnostic> c = errCandidate();
        if (compactMethodDiags) {
            for (Map.Entry<Template, DiagnosticRewriter> _entry :
                    MethodResolutionDiagHelper.rewriters.entrySet()) {
                if (_entry.getKey().matches(c.snd)) {
                    JCDiagnostic simpleDiag =
                            _entry.getValue().rewriteDiagnostic(diags, pos,
                                log.currentSource(), dkind, c.snd);
                    simpleDiag.setFlag(DiagnosticFlag.COMPRESSED);
                    return simpleDiag;
                }
            }
        }
        Symbol ws = c.fst.asMemberOf(site, types);
        return diags.create(dkind, log.currentSource(), pos,
                  "cant.apply.symbol",
                  kindName(ws),
                  ws.name == names.init ? ws.owner.name : ws.name,
                  methodArguments(ws.type.getParameterTypes()),
                  methodArguments(argtypes),
                  kindName(ws.owner),
                  ws.owner.type,
                  c.snd);
    }
}
 
Example #4
Source File: Resolve.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
JCDiagnostic getDiagnostic(JCDiagnostic.DiagnosticType dkind,
        DiagnosticPosition pos,
        Symbol location,
        Type site,
        Name name,
        List<Type> argtypes,
        List<Type> typeargtypes) {
    if (name == names.error)
        return null;

    if (syms.operatorNames.contains(name)) {
        boolean isUnaryOp = argtypes.size() == 1;
        String key = argtypes.size() == 1 ?
            "operator.cant.be.applied" :
            "operator.cant.be.applied.1";
        Type first = argtypes.head;
        Type second = !isUnaryOp ? argtypes.tail.head : null;
        return diags.create(dkind, log.currentSource(), pos,
                key, name, first, second);
    }
    else {
        Pair<Symbol, JCDiagnostic> c = errCandidate();
        if (compactMethodDiags) {
            for (Map.Entry<Template, DiagnosticRewriter> _entry :
                    MethodResolutionDiagHelper.rewriters.entrySet()) {
                if (_entry.getKey().matches(c.snd)) {
                    JCDiagnostic simpleDiag =
                            _entry.getValue().rewriteDiagnostic(diags, pos,
                                log.currentSource(), dkind, c.snd);
                    simpleDiag.setFlag(DiagnosticFlag.COMPRESSED);
                    return simpleDiag;
                }
            }
        }
        Symbol ws = c.fst.asMemberOf(site, types);
        return diags.create(dkind, log.currentSource(), pos,
                  "cant.apply.symbol",
                  kindName(ws),
                  ws.name == names.init ? ws.owner.name : ws.name,
                  methodArguments(ws.type.getParameterTypes()),
                  methodArguments(argtypes),
                  kindName(ws.owner),
                  ws.owner.type,
                  c.snd);
    }
}
 
Example #5
Source File: Resolve.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
JCDiagnostic getDiagnostic(JCDiagnostic.DiagnosticType dkind,
        DiagnosticPosition pos,
        Symbol location,
        Type site,
        Name name,
        List<Type> argtypes,
        List<Type> typeargtypes) {
    if (name == names.error)
        return null;

    if (syms.operatorNames.contains(name)) {
        boolean isUnaryOp = argtypes.size() == 1;
        String key = argtypes.size() == 1 ?
            "operator.cant.be.applied" :
            "operator.cant.be.applied.1";
        Type first = argtypes.head;
        Type second = !isUnaryOp ? argtypes.tail.head : null;
        return diags.create(dkind, log.currentSource(), pos,
                key, name, first, second);
    }
    else {
        Pair<Symbol, JCDiagnostic> c = errCandidate();
        if (compactMethodDiags) {
            for (Map.Entry<Template, DiagnosticRewriter> _entry :
                    MethodResolutionDiagHelper.rewriters.entrySet()) {
                if (_entry.getKey().matches(c.snd)) {
                    JCDiagnostic simpleDiag =
                            _entry.getValue().rewriteDiagnostic(diags, pos,
                                log.currentSource(), dkind, c.snd);
                    simpleDiag.setFlag(DiagnosticFlag.COMPRESSED);
                    return simpleDiag;
                }
            }
        }
        Symbol ws = c.fst.asMemberOf(site, types);
        return diags.create(dkind, log.currentSource(), pos,
                  "cant.apply.symbol",
                  kindName(ws),
                  ws.name == names.init ? ws.owner.name : ws.name,
                  methodArguments(ws.type.getParameterTypes()),
                  methodArguments(argtypes),
                  kindName(ws.owner),
                  ws.owner.type,
                  c.snd);
    }
}
 
Example #6
Source File: Resolve.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
JCDiagnostic getDiagnostic(JCDiagnostic.DiagnosticType dkind,
        DiagnosticPosition pos,
        Symbol location,
        Type site,
        Name name,
        List<Type> argtypes,
        List<Type> typeargtypes) {
    if (name == names.error)
        return null;

    if (syms.operatorNames.contains(name)) {
        boolean isUnaryOp = argtypes.size() == 1;
        String key = argtypes.size() == 1 ?
            "operator.cant.be.applied" :
            "operator.cant.be.applied.1";
        Type first = argtypes.head;
        Type second = !isUnaryOp ? argtypes.tail.head : null;
        return diags.create(dkind, log.currentSource(), pos,
                key, name, first, second);
    }
    else {
        Pair<Symbol, JCDiagnostic> c = errCandidate();
        if (compactMethodDiags) {
            for (Map.Entry<Template, DiagnosticRewriter> _entry :
                    MethodResolutionDiagHelper.rewriters.entrySet()) {
                if (_entry.getKey().matches(c.snd)) {
                    JCDiagnostic simpleDiag =
                            _entry.getValue().rewriteDiagnostic(diags, pos,
                                log.currentSource(), dkind, c.snd);
                    simpleDiag.setFlag(DiagnosticFlag.COMPRESSED);
                    return simpleDiag;
                }
            }
        }
        Symbol ws = c.fst.asMemberOf(site, types);
        return diags.create(dkind, log.currentSource(), pos,
                  "cant.apply.symbol",
                  kindName(ws),
                  ws.name == names.init ? ws.owner.name : ws.name,
                  methodArguments(ws.type.getParameterTypes()),
                  methodArguments(argtypes),
                  kindName(ws.owner),
                  ws.owner.type,
                  c.snd);
    }
}
 
Example #7
Source File: Resolve.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
JCDiagnostic getDiagnostic(JCDiagnostic.DiagnosticType dkind,
        DiagnosticPosition pos,
        Symbol location,
        Type site,
        Name name,
        List<Type> argtypes,
        List<Type> typeargtypes) {
    if (name == names.error)
        return null;

    if (syms.operatorNames.contains(name)) {
        boolean isUnaryOp = argtypes.size() == 1;
        String key = argtypes.size() == 1 ?
            "operator.cant.be.applied" :
            "operator.cant.be.applied.1";
        Type first = argtypes.head;
        Type second = !isUnaryOp ? argtypes.tail.head : null;
        return diags.create(dkind, log.currentSource(), pos,
                key, name, first, second);
    }
    else {
        Pair<Symbol, JCDiagnostic> c = errCandidate();
        if (compactMethodDiags) {
            for (Map.Entry<Template, DiagnosticRewriter> _entry :
                    MethodResolutionDiagHelper.rewriters.entrySet()) {
                if (_entry.getKey().matches(c.snd)) {
                    JCDiagnostic simpleDiag =
                            _entry.getValue().rewriteDiagnostic(diags, pos,
                                log.currentSource(), dkind, c.snd);
                    simpleDiag.setFlag(DiagnosticFlag.COMPRESSED);
                    return simpleDiag;
                }
            }
        }
        Symbol ws = c.fst.asMemberOf(site, types);
        return diags.create(dkind, log.currentSource(), pos,
                  "cant.apply.symbol",
                  kindName(ws),
                  ws.name == names.init ? ws.owner.name : ws.name,
                  methodArguments(ws.type.getParameterTypes()),
                  methodArguments(argtypes),
                  kindName(ws.owner),
                  ws.owner.type,
                  c.snd);
    }
}