當前位置: 首頁>>代碼示例>>Java>>正文


Java RoundEnvironment類代碼示例

本文整理匯總了Java中javax.annotation.processing.RoundEnvironment的典型用法代碼示例。如果您正苦於以下問題:Java RoundEnvironment類的具體用法?Java RoundEnvironment怎麽用?Java RoundEnvironment使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RoundEnvironment類屬於javax.annotation.processing包,在下文中一共展示了RoundEnvironment類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: process

import javax.annotation.processing.RoundEnvironment; //導入依賴的package包/類
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {

    try {
        ToolingProvider.setTooling(processingEnv);

        Set<? extends Element> set = roundEnv.getElementsAnnotatedWith(TestAnnotation.class);

        if (set.size() == 1) {
            testCase((TypeElement) set.iterator().next());
        }

    } finally {
        ToolingProvider.clearTooling();
    }
    return false;
}
 
開發者ID:toolisticon,項目名稱:annotation-processor-toolkit,代碼行數:18,代碼來源:AbstractUnitTestAnnotationProcessorClass.java

示例2: process

import javax.annotation.processing.RoundEnvironment; //導入依賴的package包/類
@Override
public boolean process(Set<? extends TypeElement> typeElements, RoundEnvironment env) {
    List<ValidationClass> validationClasses = findAndParseValidations(env);

    // Generate validation classes source code
    for (ValidationClass validationClass : validationClasses) {
        try {
            JavaFile javaFile = JavaFiler.cookJava(validationClass);
            javaFile.writeTo(this.filer);
        } catch (IOException e) {
            error(validationClass.getTypeElement(), "Unable to write validation for type %s: %s", validationClass.getTypeElement(), e.getMessage());
        }
    }

    return false;
}
 
開發者ID:WellingtonCosta,項目名稱:convalida,代碼行數:17,代碼來源:ConvalidaProcessor.java

示例3: process

import javax.annotation.processing.RoundEnvironment; //導入依賴的package包/類
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {

  if (roundEnv.processingOver()) {
    return false;
  }

  Set<? extends Element> elementsAnnotatedWith =
      roundEnv.getElementsAnnotatedWith(Annotation1.class);

  if (elementsAnnotatedWith.size() != 1) {
    throw new IllegalStateException(
        "There must be exactly one element to process. Actual=" + elementsAnnotatedWith.size());
  }

  for (Element element : elementsAnnotatedWith) {
    inputTypeForElement = inputTypeFinder.findInputTypeForElement(element);
  }

  return false;
}
 
開發者ID:gradle,項目名稱:incap,代碼行數:22,代碼來源:InputTypeFinderAnnotationTestProcessor.java

示例4: processRound

import javax.annotation.processing.RoundEnvironment; //導入依賴的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();
	}
}
 
開發者ID:commsen,項目名稱:EM,代碼行數:21,代碼來源:ActivatorAnnotationProcessor.java

示例5: getMethodToFieldNameMap

import javax.annotation.processing.RoundEnvironment; //導入依賴的package包/類
private Map<ExecutableElement, String> getMethodToFieldNameMap(RoundEnvironment roundEnvironment) {
    final Map<ExecutableElement, String> methodToFieldNameMap = new HashMap<>();

    for (Element byElement : roundEnvironment.getElementsAnnotatedWith(By.class)) {
        if (byElement.getKind() != ElementKind.FIELD) {
            continue;
        }
        VariableElement byField = (VariableElement) byElement;
        for (Element element : typeUtils.asElement(byField.asType()).getEnclosedElements()) {
            if (element.getKind() != ElementKind.METHOD) {
                continue;
            }
            ExecutableElement method = (ExecutableElement) element;
            methodToFieldNameMap.put(method, byField.getSimpleName().toString());
        }
    }

    return methodToFieldNameMap;
}
 
開發者ID:srym,項目名稱:cuckoo,代碼行數:20,代碼來源:DelegationProcessor.java

示例6: incrementalProcess

import javax.annotation.processing.RoundEnvironment; //導入依賴的package包/類
@Override
public boolean incrementalProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
  for (TypeElement annotation : annotations) {
    System.out.println("Processing annotation:" + annotation);
  }

  if (isProcessingDone) {
    return false;
  }

  // generates a class with a constant that contains the name of all classes containing an annotation.
  Set<? extends Element> annotatedElements = roundEnv.getElementsAnnotatedWith(Annotation1.class);
  Map<String, Set<? extends Element>> mapGeneratedFileNameToOriginatingElements = processElements(annotatedElements);
  generateFiles(incrementalProcessingEnvironment.getFiler(), mapGeneratedFileNameToOriginatingElements);
  isProcessingDone = true;
  return false;
}
 
開發者ID:gradle,項目名稱:incap,代碼行數:18,代碼來源:M1_OneToOneAP.java

示例7: process

import javax.annotation.processing.RoundEnvironment; //導入依賴的package包/類
@Override public boolean process(Set<? extends TypeElement> elements, RoundEnvironment env) {
  Map<TypeElement, BindingSet> bindingMap = findAndParseTargets(env);

  for (Map.Entry<TypeElement, BindingSet> entry : bindingMap.entrySet()) {
    TypeElement typeElement = entry.getKey();
    BindingSet binding = entry.getValue();

    JavaFile javaFile = binding.brewJava(sdk);
    try {
      javaFile.writeTo(filer);
    } catch (IOException e) {
      error(typeElement, "Unable to write binding for type %s: %s", typeElement, e.getMessage());
    }
  }

  return false;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:ButterKnifeProcessor.java

示例8: process

import javax.annotation.processing.RoundEnvironment; //導入依賴的package包/類
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (roundEnv.processingOver() || written++ > 0) {
        return false;
    }
    messager.printMessage(Diagnostic.Kind.NOTE, "writing Generated.java");
    try {
        Writer w = processingEnv.getFiler().createSourceFile("p.Generated").openWriter();
        try {
            w.write("package p; public class Generated { public static void m() { } }");
        } finally {
            w.close();
        }
    } catch (IOException x) {
        messager.printMessage(Diagnostic.Kind.ERROR, x.toString());
    }
    return true;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:T7159016.java

示例9: prepareGlobalConfig

import javax.annotation.processing.RoundEnvironment; //導入依賴的package包/類
/**
 * Prepare global config
 *
 * @param roundEnv annotation processor environment
 */
private Element prepareGlobalConfig(RoundEnvironment roundEnv) {
    Element sqlFirstApcConfigElement = null;

    //TODO read with filer for the case of partial compilation
    Set<? extends Element> annotatedElements = roundEnv.getElementsAnnotatedWith(SqlFirstApcConfig.class);
    for (Element element : annotatedElements) {
        if (sqlFirstApcConfigElement == null) {
            sqlFirstApcConfigElement = element;
        } else {
            processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "SqlFirstApcConfig annotation must be declared only once ", element);
        }
    }
    return sqlFirstApcConfigElement;
    
}
 
開發者ID:nds842,項目名稱:sql-first-mapper,代碼行數:21,代碼來源:SqlFirstAnnotationProcessor.java

示例10: process

import javax.annotation.processing.RoundEnvironment; //導入依賴的package包/類
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
	if (annotations.isEmpty()) {
		return false;
	}

	try {
		return throwableProcess(roundEnv);
	} catch (RuntimeException e) {
		getMessager().printMessage(Diagnostic.Kind.OTHER, "Moxy compilation failed. Could you copy stack trace above and write us (or make issue on Githhub)?");
		e.printStackTrace();
		getMessager().printMessage(Diagnostic.Kind.ERROR, "Moxy compilation failed; see the compiler error output for details (" + e + ")");
	}

	return true;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:MvpCompiler.java

示例11: process

import javax.annotation.processing.RoundEnvironment; //導入依賴的package包/類
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (processingEnv.getElementUtils().getModuleElement("m1x") == null) {
        throw new AssertionError("No m1x module found.");
    }

    Messager messager = processingEnv.getMessager();

    for (TypeElement clazz : ElementFilter.typesIn(roundEnv.getRootElements())) {
        for (VariableElement field : ElementFilter.fieldsIn(clazz.getEnclosedElements())) {
            messager.printMessage(Kind.NOTE, "field: " + field.getSimpleName());
        }
    }

    return false;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:AnnotationProcessing.java

示例12: process

import javax.annotation.processing.RoundEnvironment; //導入依賴的package包/類
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (round++ == 0) {
        try (Writer out = processingEnv.getFiler()
                                             .createSourceFile("Anno.java")
                                             .openWriter()) {
            String target = processingEnv.getOptions().get("target");
            String code = "import java.lang.annotation.ElementType;\n" +
                          "import java.lang.annotation.Target;\n" +
                          "@Target(ElementType." + target + ")\n" +
                          "@interface Anno { public String value(); }\n";
            out.write(code);
        } catch (IOException exc) {
            throw new IllegalStateException(exc);
        }
    }
    return true;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:Processor.java

示例13: process

import javax.annotation.processing.RoundEnvironment; //導入依賴的package包/類
@Override
public boolean process(Set<? extends TypeElement> set, RoundEnvironment roundEnvironment) {

    try {
        if (!findAnnotatedViewModels(roundEnvironment)) {
            return true;
        }

        for (TypeElement viewModelElement : viewModels) {
            generateViewModelFactory(viewModelElement);
        }

    } catch (IOException e) {
        error("An error has occurred.");
        e.printStackTrace();
    }

    return true;
}
 
開發者ID:kakai248,項目名稱:AutoViewModelFactory,代碼行數:20,代碼來源:AutoViewModelFactoryProcessor.java

示例14: process

import javax.annotation.processing.RoundEnvironment; //導入依賴的package包/類
@Override
public final boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {

  if (roundEnv.processingOver()) {
    return false;
  }

  for (ProcessorPipeline processorPipeline : processorPipelines) {
    try {
      processorPipeline.process(annotations, roundEnv);
    } catch (Throwable e) {
      errorReporter.reportError(
          String.format(
              Locale.getDefault(),
              "Fatal error running %s processor: %s",
              processorPipeline.getAnnotationType().getSimpleName(),
              e.getMessage()));
    }
  }
  return false;
}
 
開發者ID:uber,項目名稱:RIBs,代碼行數:22,代碼來源:RibProcessor.java

示例15: process

import javax.annotation.processing.RoundEnvironment; //導入依賴的package包/類
public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
    try {
        if (renv.processingOver())
            createSymbols();
    } catch (IOException e) {
        processingEnv.getMessager()
                .printMessage(Diagnostic.Kind.ERROR, e.getLocalizedMessage());
    } catch (Throwable t) {
        Throwable cause = t.getCause();
        if (cause == null)
            cause = t;
        processingEnv.getMessager()
                .printMessage(Diagnostic.Kind.ERROR, cause.getLocalizedMessage());
    }
    return true;
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:17,代碼來源:CreateSymbols.java


注:本文中的javax.annotation.processing.RoundEnvironment類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。