Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Merge branch 'next' into dataelement-imports
Browse files Browse the repository at this point in the history
  • Loading branch information
dbluhm committed Aug 7, 2020
2 parents d2049dd + b620bc1 commit 018fb04
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 11 deletions.
Expand Up @@ -106,6 +106,7 @@
<groupId>com.cosium.logging</groupId>
<artifactId>annotation-processor-logger</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down
@@ -1,3 +1,14 @@
/*******************************************************************************
* Copyright (c) 2020- UT-Battelle, LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Daniel Bluhm - Initial implementation
*******************************************************************************/

package org.eclipse.ice.dev.annotations.processors;

import java.io.IOException;
Expand All @@ -10,6 +21,7 @@
import java.util.List;
import java.util.Set;

import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Messager;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.Processor;
Expand All @@ -27,7 +39,6 @@
import org.eclipse.ice.dev.annotations.DataElement;
import org.eclipse.ice.dev.annotations.Persisted;

import com.cosium.logging.annotation_processor.AbstractLoggingProcessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.auto.service.AutoService;

Expand All @@ -46,7 +57,7 @@
})
@SupportedSourceVersion(SourceVersion.RELEASE_11)
@AutoService(Processor.class)
public class DataElementProcessor extends AbstractLoggingProcessor {
public class DataElementProcessor extends AbstractProcessor {
/**
* Return stack trace as string.
* @param e subject exception
Expand All @@ -73,7 +84,7 @@ public void init(final ProcessingEnvironment env) {
}

@Override
public boolean doProcess(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) {
public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) {
// Iterate over all elements with DataElement Annotation
for (final Element elem : roundEnv.getElementsAnnotatedWith(DataElement.class)) {
try {
Expand Down
Expand Up @@ -11,7 +11,6 @@

package org.eclipse.ice.dev.annotations.processors;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -46,8 +45,7 @@ class VelocityProperties extends Properties {
* Construct VelocityProperties, loading from resource file.
*/
private VelocityProperties() {
String propertyFile = getClass().getClassLoader().getResource(FILENAME).getPath();
try (InputStream propertyStream = new FileInputStream(propertyFile)) {
try (InputStream propertyStream = getClass().getClassLoader().getResourceAsStream(FILENAME)) {
super.load(propertyStream);
} catch (FileNotFoundException e) {
logger.error("velocity.properties could not be found");
Expand Down
Expand Up @@ -19,12 +19,9 @@
import javax.tools.Diagnostic;
import javax.tools.JavaFileObject;

import org.eclipse.ice.dev.annotations.processors.DataElementProcessor;

import com.google.testing.compile.Compilation;

import static com.google.testing.compile.Compiler.*;
import static com.google.testing.compile.CompilationSubject.*;

/**
* Helper class for testing DataElement related annotations.
Expand Down Expand Up @@ -88,7 +85,7 @@ public Compilation compile(JavaFileObject... sources) {
Compilation compilation = javac()
.withProcessors(
getLombokAnnotationProcessor(),
new DataElementProcessor()
new LoggingDataElementProcessor()
).compile(sources);
if (showDiagnostics) {
printDiagnostics(compilation);
Expand Down
@@ -0,0 +1,56 @@
/*******************************************************************************
* Copyright (c) 2020- UT-Battelle, LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Daniel Bluhm - Initial implementation
*******************************************************************************/

package org.eclipse.ice.tests.dev.annotations.processors;

import java.util.Set;

import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;

import org.eclipse.ice.dev.annotations.processors.DataElementProcessor;

import com.cosium.logging.annotation_processor.AbstractLoggingProcessor;

/**
* Wrapper around DataElementProcessor used to catch warnings that would
* normally be missed.
* @author Daniel Bluhm
*/
@SupportedAnnotationTypes({
"org.eclipse.ice.dev.annotations.DataElement",
"org.eclipse.ice.dev.annotations.DataField",
"org.eclipse.ice.dev.annotations.DataField.Default",
"org.eclipse.ice.dev.annotations.Persisted"
})
@SupportedSourceVersion(SourceVersion.RELEASE_11)
public class LoggingDataElementProcessor extends AbstractLoggingProcessor {

/**
* Wrapped processor.
*/
private DataElementProcessor wrappedProcessor = new DataElementProcessor();

@Override
public void init(final ProcessingEnvironment env) {
wrappedProcessor.init(env);
super.init(env);
}

@Override
protected boolean doProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
return wrappedProcessor.process(annotations, roundEnv);
}
}
Expand Up @@ -34,7 +34,7 @@
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.ice.dev</groupId>
<groupId>org.eclipse.ice</groupId>
<artifactId>org.eclipse.ice.dev.annotations</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
Expand Down

0 comments on commit 018fb04

Please sign in to comment.