本文整理汇总了Java中javax.tools.Diagnostic.Kind类的典型用法代码示例。如果您正苦于以下问题:Java Kind类的具体用法?Java Kind怎么用?Java Kind使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Kind类属于javax.tools.Diagnostic包,在下文中一共展示了Kind类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processRound
import javax.tools.Diagnostic.Kind; //导入依赖的package包/类
private void processRound(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
loop: for (TypeElement annotation : annotations) {
for (Element element : roundEnv.getElementsAnnotatedWith(annotation)) {
switch (element.getAnnotation(RuntimeExtension.class).value()) {
case FRAMEWORK:
entry = "Fragment-Host: system.bundle; extension:=framework";
break loop;
case BOOTCLASSPATH:
entry = "Fragment-Host: system.bundle; extension:=bootclasspath";
break loop;
}
}
}
try {
generateFile();
} catch (IOException e) {
messager.printMessage(Kind.ERROR, "IOException while generating file with contracts! " + e.getMessage());
e.printStackTrace();
}
}
示例2: processRound
import javax.tools.Diagnostic.Kind; //导入依赖的package包/类
private void processRound(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
loop: for (TypeElement annotation : annotations) {
for (Element element : roundEnv.getElementsAnnotatedWith(annotation)) {
if (element.getAnnotation(Activator.class).extension()) {
extensionActivator = element.asType().toString();
} else {
activator = element.asType().toString();
}
if (activator != null && extensionActivator != null) {
break loop;
}
}
}
try {
generateFile();
} catch (IOException e) {
messager.printMessage(Kind.ERROR, "IOException while generating file with contracts! " + e.getMessage());
e.printStackTrace();
}
}
示例3: process
import javax.tools.Diagnostic.Kind; //导入依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
for (Element element : roundEnv.getElementsAnnotatedWith(ParameterNames.class)) {
ParameterNames names = element.getAnnotation(ParameterNames.class);
if (names == null) {
continue;
}
List<String> expected = Arrays.asList(names.value());
List<String> actual =
((ExecutableElement) element)
.getParameters()
.stream()
.map(p -> p.getSimpleName().toString())
.collect(toCollection(ArrayList::new));
if (!expected.equals(actual)) {
String message =
String.format(
"bad parameter names for %s#%s; expected: %s, was: %s",
element, element, expected, actual);
messager.printMessage(Kind.ERROR, message);
}
}
return false;
}
示例4: flush
import javax.tools.Diagnostic.Kind; //导入依赖的package包/类
private void flush(RoundEnvironment roundEnv) {
if (!originatingElements.isEmpty()) {
try (OutputStream os = processingEnv.getFiler().createResource(
StandardLocation.CLASS_OUTPUT,
"", "META-INF/.bytecodePatched",
originatingElements.toArray(new Element[originatingElements.size()])).openOutputStream()) {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
for (Map.Entry<String, String> exEntry : superclasses.entrySet()) {
String api = exEntry.getKey();
String sup = exEntry.getValue();
bw.append("extend.").append(api).append("=").append(sup);
bw.newLine();
}
bw.flush();
} catch (IOException x) {
processingEnv.getMessager().printMessage(Kind.ERROR, x.getMessage());
}
}
}
示例5: getImplFor
import javax.tools.Diagnostic.Kind; //导入依赖的package包/类
private TypeElement getImplFor() {
implForElement = processingEnv.getElementUtils().getTypeElement(IMPL_FOR_NAME);
if (implForElement == null) {
if (!reported) {
processingEnv.getMessager().printMessage(Kind.ERROR, "Cannot find @ImplementationFor annotation");
reported = true;
}
return null;
}
for (Element e : implForElement.getEnclosedElements()) {
if (e.getKind() == ElementKind.METHOD && e.getSimpleName().contentEquals("value")) {
valueElement = e;
break;
}
}
return implForElement;
}
示例6: parseBeanMethod
import javax.tools.Diagnostic.Kind; //导入依赖的package包/类
private boolean parseBeanMethod(ExecutableElement beanMethod, String[] beanNames, Messager messager) {
boolean valid = true;
if (beanNames.length == 0) {
valid = false;
messager.printMessage(Kind.ERROR, "All @Bean annotations must define at least one name for a bean.", beanMethod);
}
if (beanMethod.getReturnType().getKind() != TypeKind.DECLARED) {
valid = false;
messager.printMessage(Kind.ERROR, "@Bean methods must return an Object", beanMethod);
}
if (!beanMethod.getModifiers().contains(Modifier.PUBLIC)) {
valid = false;
messager.printMessage(Kind.ERROR, "@Bean methods must be marked public", beanMethod);
}
List<Modifier> illegalModifiers = getIllegalModifiers(beanMethod.getModifiers(), DISALLOWED_ON_METHOD);
if (illegalModifiers.size() != 0) {
valid = false;
messager.printMessage(Kind.ERROR, "Illegal modifiers found on spring @Bean method: "
+ illegalModifiers.stream().map(m -> m.name()).collect(Collectors.joining(", ")),
beanMethod);
}
return valid;
}
示例7: parse
import javax.tools.Diagnostic.Kind; //导入依赖的package包/类
public final M parse(RoundEnvironment env, Element element) {
this.roundEnv = env;
M model = null;
try {
AnnotationMirror mirror = null;
if (getAnnotationType() != null) {
mirror = Utils.findAnnotationMirror(processingEnv, element.getAnnotationMirrors(), getAnnotationType());
}
if (!context.getTruffleTypes().verify(context, element, mirror)) {
return null;
}
model = parse(element, mirror);
if (model == null) {
return null;
}
model.emitMessages((TypeElement) element, log);
return filterErrorElements(model);
} catch (CompileErrorException e) {
log.message(Kind.WARNING, element, null, null, "The truffle processor could not parse class due to error: %s", e.getMessage());
return null;
} finally {
this.roundEnv = null;
}
}
示例8: TruffleTypes
import javax.tools.Diagnostic.Kind; //导入依赖的package包/类
public TruffleTypes(ProcessorContext context) {
node = getRequired(context, Node.class);
nodeArray = context.getEnvironment().getTypeUtils().getArrayType(node);
unexpectedValueException = getRequired(context, UnexpectedResultException.class);
frame = getRequired(context, VirtualFrame.class);
childAnnotation = getRequired(context, Child.class);
childrenAnnotation = getRequired(context, Children.class);
compilerDirectives = getRequired(context, CompilerDirectives.class);
compilerAsserts = getRequired(context, CompilerAsserts.class);
assumption = getRequired(context, Assumption.class);
invalidAssumption = getRequired(context, InvalidAssumptionException.class);
nodeInfoAnnotation = getRequired(context, NodeInfo.class);
nodeInfoKind = getRequired(context, NodeInfo.Kind.class);
slowPath = getRequired(context, SlowPath.class);
truffleOptions = getRequired(context, TruffleOptions.class);
}
示例9: checkInputType
import javax.tools.Diagnostic.Kind; //导入依赖的package包/类
private void checkInputType(TypeElement nodeClass, TypeMirror returnType, Element element, AnnotationMirror annotation) {
InputType inputType = getInputType(returnType, element, annotation);
if (inputType != InputType.Value) {
boolean allowed = false;
InputType[] allowedTypes = nodeClass.getAnnotation(NodeInfo.class).allowedUsageTypes();
for (InputType allowedType : allowedTypes) {
if (inputType == allowedType) {
allowed = true;
break;
}
}
if (!allowed) {
env.getMessager().printMessage(Kind.ERROR, String.format("@NodeIntrinsic returns input type %s, but only %s is allowed.", inputType, Arrays.toString(allowedTypes)), element,
annotation);
}
}
}
示例10: printMessage
import javax.tools.Diagnostic.Kind; //导入依赖的package包/类
private void printMessage(Kind kind, Element element, String message, Object[] args) {
if (args.length > 0) {
message = String.format(message, args);
}
processingEnv.getMessager().printMessage(kind, message, element);
}
示例11: complete
import javax.tools.Diagnostic.Kind; //导入依赖的package包/类
void complete() {
try {
writeFile();
} catch (Exception ex) {
StaticEnvironment.processing().getMessager().printMessage(
Diagnostic.Kind.MANDATORY_WARNING,
"Cannot write service files: " + key + ex.toString());
}
}
示例12: process
import javax.tools.Diagnostic.Kind; //导入依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
for (Element root : roundEnv.getRootElements()) {
processingEnv.getMessager().printMessage(Kind.ERROR, "error1", root);
processingEnv.getMessager().printMessage(Kind.ERROR, "error2", root);
Trees trees = Trees.instance(processingEnv);
TreePath path = trees.getPath(root);
trees.printMessage(Kind.ERROR, "error3", path.getLeaf(), path.getCompilationUnit());
trees.printMessage(Kind.ERROR, "error4", path.getLeaf(), path.getCompilationUnit());
}
return true;
}
示例13: report
import javax.tools.Diagnostic.Kind; //导入依赖的package包/类
@Override
public void report(Diagnostic<? extends JavaFileObject> message) {
if (partialReparseErrors != null) {
if (this.jfo != null && this.jfo == message.getSource()) {
partialReparseErrors.add(message);
if (message.getKind() == Kind.ERROR) {
partialReparseRealErrors = true;
}
}
} else {
Diagnostics errors = getErrors(message.getSource());
errors.add((int) message.getPosition(), message);
}
}
示例14: warnUndocumented
import javax.tools.Diagnostic.Kind; //导入依赖的package包/类
private void warnUndocumented(int i, Element e, String key) {
AnnotationMirror mirror = null;
AnnotationValue value = null;
if (e != null) {
for (AnnotationMirror _mirror : e.getAnnotationMirrors()) {
if (_mirror.getAnnotationType().toString().equals(NbBundle.Messages.class.getCanonicalName())) {
mirror = _mirror;
for (Map.Entry<? extends ExecutableElement,? extends AnnotationValue> entry : mirror.getElementValues().entrySet()) {
if (entry.getKey().getSimpleName().contentEquals("value")) {
// SimpleAnnotationValueVisitor6 unusable here since we need to determine the AnnotationValue in scope when visitString is called:
Object v = entry.getValue().getValue();
if (v instanceof String) {
if (((String) v).startsWith(key + "=")) {
value = entry.getValue();
}
} else {
for (AnnotationValue subentry : NbCollections.checkedListByCopy((List<?>) v, AnnotationValue.class, true)) {
v = subentry.getValue();
if (v instanceof String) {
if (((String) v).startsWith(key + "=")) {
value = subentry;
break;
}
}
}
}
break;
}
}
break;
}
}
}
processingEnv.getMessager().printMessage(Kind.WARNING, "Undocumented format parameter {" + i + "}", e, mirror, value);
}
示例15: process
import javax.tools.Diagnostic.Kind; //导入依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (!roundEnv.processingOver()) {
for (Element e : roundEnv.getElementsAnnotatedWith(RandomlyFails.class)) {
Element typeEl = e.getKind() == ElementKind.METHOD ? e.getEnclosingElement() : e;
TypeMirror nbTestCaseType = processingEnv.getElementUtils().
getTypeElement(NbTestCase.class.getName()).asType();
if (!processingEnv.getTypeUtils().isAssignable(typeEl.asType(), nbTestCaseType)) {
processingEnv.getMessager().printMessage(Kind.ERROR, "@RandomlyFails must be used on NbTestCase subclasses", e);
}
}
return true;
}
return false;
}