Java Code Examples for com.sun.tools.javac.util.JCDiagnostic#getArgs()

The following examples show how to use com.sun.tools.javac.util.JCDiagnostic#getArgs() . 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: Hacks.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static void getNestedDiagnostics(Diagnostic<?> d, List<Diagnostic> diags) {
    JCDiagnostic jcd = getJCDiagnostic(d);
    if (jcd == null) {
        return;
    }
    Object[] args = jcd.getArgs();
    if (args == null || args.length == 0) {
        return;
    }
    for (Object o : args) {
        if (o instanceof Diagnostic) {
            diags.add((Diagnostic)o);
            getNestedDiagnostics((Diagnostic)o, diags);
            break;
        }
    }
}
 
Example 2
Source File: NBLog.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void report(JCDiagnostic diagnostic) {
    //XXX: needs testing!
    if (diagnostic.getKind() == Diagnostic.Kind.ERROR &&
        ERR_NOT_IN_PROFILE.equals(diagnostic.getCode())) {
        final JavaFileObject currentFile = currentSourceFile();
        if (currentFile != null) {
            final URI uri = currentFile.toUri();
            Symbol.ClassSymbol type = (Symbol.ClassSymbol) diagnostic.getArgs()[0];
            Collection<Symbol.ClassSymbol> types = notInProfiles.get(uri);
            if (types == null) {
                types = new ArrayList<>();
                notInProfiles.put(uri,types);
            }
            types.add(type);
        }
    }
    super.report(diagnostic);
}
 
Example 3
Source File: ResolveHarness.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
MethodType getSig(Diagnostic<? extends JavaFileObject> diagnostic) {
    JCDiagnostic details = (JCDiagnostic)asJCDiagnostic(diagnostic).getArgs()[2];
    if (details == null) {
        return null;
    } else if (details instanceof JCDiagnostic) {
        return details.getCode().equals("compiler.misc.full.inst.sig") ?
                (MethodType)details.getArgs()[0] : null;
    } else {
        throw new AssertionError("Bad diagnostic arg: " + details);
    }
}
 
Example 4
Source File: Example.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Scan a diagnostic for resource keys.  This will not detect additional
 * sub diagnostics that might be generated by a rich diagnostic formatter.
 */
private static void scanForKeys(JCDiagnostic d, Set<String> keys) {
    keys.add(d.getCode());
    for (Object o: d.getArgs()) {
        if (o instanceof JCDiagnostic) {
            scanForKeys((JCDiagnostic) o, keys);
        }
    }
    for (JCDiagnostic sd: d.getSubdiagnostics())
        scanForKeys(sd, keys);
}
 
Example 5
Source File: ResolveHarness.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
MethodType getSig(Diagnostic<? extends JavaFileObject> diagnostic) {
    JCDiagnostic details = (JCDiagnostic)asJCDiagnostic(diagnostic).getArgs()[2];
    if (details == null) {
        return null;
    } else if (details instanceof JCDiagnostic) {
        return details.getCode().equals("compiler.misc.full.inst.sig") ?
                (MethodType)details.getArgs()[0] : null;
    } else {
        throw new AssertionError("Bad diagnostic arg: " + details);
    }
}
 
Example 6
Source File: Example.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Scan a diagnostic for resource keys.  This will not detect additional
 * sub diagnostics that might be generated by a rich diagnostic formatter.
 */
private static void scanForKeys(JCDiagnostic d, Set<String> keys) {
    keys.add(d.getCode());
    for (Object o: d.getArgs()) {
        if (o instanceof JCDiagnostic) {
            scanForKeys((JCDiagnostic) o, keys);
        }
    }
    for (JCDiagnostic sd: d.getSubdiagnostics())
        scanForKeys(sd, keys);
}
 
Example 7
Source File: ResolveHarness.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
MethodType getSig(Diagnostic<? extends JavaFileObject> diagnostic) {
    JCDiagnostic details = (JCDiagnostic)asJCDiagnostic(diagnostic).getArgs()[2];
    if (details == null) {
        return null;
    } else if (details instanceof JCDiagnostic) {
        return details.getCode().equals("compiler.misc.full.inst.sig") ?
                (MethodType)details.getArgs()[0] : null;
    } else {
        throw new AssertionError("Bad diagnostic arg: " + details);
    }
}
 
Example 8
Source File: Example.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Scan a diagnostic for resource keys.  This will not detect additional
 * sub diagnostics that might be generated by a rich diagnostic formatter.
 */
private static void scanForKeys(JCDiagnostic d, Set<String> keys) {
    keys.add(d.getCode());
    for (Object o: d.getArgs()) {
        if (o instanceof JCDiagnostic) {
            scanForKeys((JCDiagnostic) o, keys);
        }
    }
    for (JCDiagnostic sd: d.getSubdiagnostics())
        scanForKeys(sd, keys);
}
 
Example 9
Source File: ResolveHarness.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
MethodType getSig(Diagnostic<? extends JavaFileObject> diagnostic) {
    JCDiagnostic details = (JCDiagnostic)asJCDiagnostic(diagnostic).getArgs()[2];
    if (details == null) {
        return null;
    } else if (details instanceof JCDiagnostic) {
        return details.getCode().equals("compiler.misc.full.inst.sig") ?
                (MethodType)details.getArgs()[0] : null;
    } else {
        throw new AssertionError("Bad diagnostic arg: " + details);
    }
}
 
Example 10
Source File: Example.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Scan a diagnostic for resource keys.  This will not detect additional
 * sub diagnostics that might be generated by a rich diagnostic formatter.
 */
private static void scanForKeys(JCDiagnostic d, Set<String> keys) {
    keys.add(d.getCode());
    for (Object o: d.getArgs()) {
        if (o instanceof JCDiagnostic) {
            scanForKeys((JCDiagnostic) o, keys);
        }
    }
    for (JCDiagnostic sd: d.getSubdiagnostics())
        scanForKeys(sd, keys);
}
 
Example 11
Source File: ResolveHarness.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
MethodType getSig(Diagnostic<? extends JavaFileObject> diagnostic) {
    JCDiagnostic details = (JCDiagnostic)asJCDiagnostic(diagnostic).getArgs()[2];
    if (details == null) {
        return null;
    } else if (details instanceof JCDiagnostic) {
        return details.getCode().equals("compiler.misc.full.inst.sig") ?
                (MethodType)details.getArgs()[0] : null;
    } else {
        throw new AssertionError("Bad diagnostic arg: " + details);
    }
}
 
Example 12
Source File: Example.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Scan a diagnostic for resource keys.  This will not detect additional
 * sub diagnostics that might be generated by a rich diagnostic formatter.
 */
private static void scanForKeys(JCDiagnostic d, Set<String> keys) {
    keys.add(d.getCode());
    for (Object o: d.getArgs()) {
        if (o instanceof JCDiagnostic) {
            scanForKeys((JCDiagnostic) o, keys);
        }
    }
    for (JCDiagnostic sd: d.getSubdiagnostics())
        scanForKeys(sd, keys);
}
 
Example 13
Source File: ResolveHarness.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
MethodType getSig(Diagnostic<? extends JavaFileObject> diagnostic) {
    JCDiagnostic details = (JCDiagnostic)asJCDiagnostic(diagnostic).getArgs()[2];
    if (details == null) {
        return null;
    } else if (details instanceof JCDiagnostic) {
        return details.getCode().equals("compiler.misc.full.inst.sig") ?
                (MethodType)details.getArgs()[0] : null;
    } else {
        throw new AssertionError("Bad diagnostic arg: " + details);
    }
}
 
Example 14
Source File: Hacks.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Extracts diagnostic params from a diagnostic. Gets under hood of Javac
 * Diagnostic objects and extracts parameters which are otherwise just used
 * to produce a message. <b>Keep in mind that the positions and types of parameters
 * may change in each nbjavac update!</b>
 * @param d diagnostic
 * @param index parameter index to extract
 * @return parameter value, null if index is out of range
 */
public static Object getDiagnosticParam(Diagnostic<?> d, int index) {
    JCDiagnostic jcd = getJCDiagnostic(d);
    if (jcd == null) {
        return null;
    }
    Object[] args = jcd.getArgs();
    if (args == null || args.length <= index) {
        return null;
    }
    return args[index];
}
 
Example 15
Source File: Example.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Scan a diagnostic for resource keys.  This will not detect additional
 * sub diagnostics that might be generated by a rich diagnostic formatter.
 */
private static void scanForKeys(JCDiagnostic d, Set<String> keys) {
    keys.add(d.getCode());
    for (Object o: d.getArgs()) {
        if (o instanceof JCDiagnostic) {
            scanForKeys((JCDiagnostic) o, keys);
        }
    }
    for (JCDiagnostic sd: d.getSubdiagnostics())
        scanForKeys(sd, keys);
}
 
Example 16
Source File: ResolveHarness.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
MethodType getSig(Diagnostic<? extends JavaFileObject> diagnostic) {
    JCDiagnostic details = (JCDiagnostic)asJCDiagnostic(diagnostic).getArgs()[2];
    if (details == null) {
        return null;
    } else if (details instanceof JCDiagnostic) {
        return details.getCode().equals("compiler.misc.full.inst.sig") ?
                (MethodType)details.getArgs()[0] : null;
    } else {
        throw new AssertionError("Bad diagnostic arg: " + details);
    }
}
 
Example 17
Source File: Example.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Scan a diagnostic for resource keys.  This will not detect additional
 * sub diagnostics that might be generated by a rich diagnostic formatter.
 */
private static void scanForKeys(JCDiagnostic d, Set<String> keys) {
    keys.add(d.getCode());
    for (Object o: d.getArgs()) {
        if (o instanceof JCDiagnostic) {
            scanForKeys((JCDiagnostic) o, keys);
        }
    }
    for (JCDiagnostic sd: d.getSubdiagnostics())
        scanForKeys(sd, keys);
}
 
Example 18
Source File: ResolveHarness.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
MethodType getSig(Diagnostic<? extends JavaFileObject> diagnostic) {
    JCDiagnostic details = (JCDiagnostic)asJCDiagnostic(diagnostic).getArgs()[2];
    if (details == null) {
        return null;
    } else if (details instanceof JCDiagnostic) {
        return details.getCode().equals("compiler.misc.full.inst.sig") ?
                (MethodType)details.getArgs()[0] : null;
    } else {
        throw new AssertionError("Bad diagnostic arg: " + details);
    }
}
 
Example 19
Source File: Example.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Scan a diagnostic for resource keys.  This will not detect additional
 * sub diagnostics that might be generated by a rich diagnostic formatter.
 */
private static void scanForKeys(JCDiagnostic d, Set<String> keys) {
    keys.add(d.getCode());
    for (Object o: d.getArgs()) {
        if (o instanceof JCDiagnostic) {
            scanForKeys((JCDiagnostic) o, keys);
        }
    }
    for (JCDiagnostic sd: d.getSubdiagnostics())
        scanForKeys(sd, keys);
}