java - Custom Eclipse warning on an annotation -
Assume I have an internal method, which should be used only in certain situations.
Does any possibility, in the eclipse, show it as an internal and show a warning when used to stop me or those people who use my API by mistake? Do not know what they are doing. I can not change its visibility because it can also be used in other packages / non-expanded sections.
Something like this:
@Internal Public Zero doSomeInternalStuff () {// ...}
And then, in Eclipse A warning:
( Pluggable annotation processor API ) you custom annotation processor allows you to write that controls the custom annotations And enables you to print errors by using a javax.annotation.processing.messager
Ian or warning. Below is an example.
import java.util.Set; import javax.annotation.processing.AbstractProcessor; 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.Element; import javax.lang.model.element.TypeElement; import javax.tools.Diagnostic; @ Supported Nutrition Type ("Fully Authorized. Names. International Type") @ Supported sources (source Varsian. Arielas 6) public class custom Annoteshnprosesr Abstripprosesr extension {@ Override public boolean process (set & lt; extension type element & gt; annotation, round Annorens round ENV) {for (Element Element: RoundEnv.getElementsAnnotatedWith (internal Anoteshnprkar. Class) ) {Internal Interval Type Internal Annotation = element.getAnnotation (Internal Annotation Type Class); String message = "method" + element.getSimpleName () + "internal is marked and its use has been disappointed"; ProcessingEnv.getMessager (). PrintMessage (diagnostic.cand.warning, message); } Back true; }}
In Eclipse, you can register annotation processor in your Java compiler by right-clicking on your project, then Properties -> Java Compiler -> the annotation processing -> Factory path and tells an interesting post to add the jar containing the custom annotation processor details.
Alternatively , you can put all your "internal" method API inside a dedicated class, and a that class in your Eclipse Build Path Access Rules for , so any code in your project that relies on this class will display a warning.
Comments
Post a Comment