use of dyvil.util.MarkerLevel in project Dyvil by Dyvil.
the class Deprecation method checkUsageInfo.
private static void checkUsageInfo(IMember member, SourcePosition position, MarkerList markers, Annotation annotation) {
final ArgumentList arguments = annotation.getArguments();
final MarkerLevel markerLevel = AnnotationUtil.getEnumValue(arguments, INF_LEVEL_PARAM, MarkerLevel.class);
if (markerLevel == null || markerLevel == MarkerLevel.IGNORE) {
return;
}
String value = AnnotationUtil.getStringValue(arguments, INF_VALUE_PARAM);
final String description = AnnotationUtil.getStringValue(arguments, INF_DESC_PARAM);
value = replaceMember(member, value);
final Marker marker = Markers.withText(position, markerLevel, value);
assert marker != null;
// Description
if (description != null && !description.isEmpty()) {
marker.addInfo(Markers.getSemantic("experimental.description", description));
}
markers.add(marker);
}
use of dyvil.util.MarkerLevel in project Dyvil by Dyvil.
the class Deprecation method checkExperimental.
private static void checkExperimental(IMember member, SourcePosition position, MarkerList markers, Annotation annotation) {
final ArgumentList arguments = annotation.getArguments();
final MarkerLevel markerLevel = AnnotationUtil.getEnumValue(arguments, EXP_LEVEL_PARAM, MarkerLevel.class);
if (markerLevel == null || markerLevel == MarkerLevel.IGNORE) {
return;
}
String value = AnnotationUtil.getStringValue(arguments, EXP_VALUE_PARAM);
final String description = AnnotationUtil.getStringValue(arguments, EXP_DESC_PARAM);
final Stage stage = AnnotationUtil.getEnumValue(arguments, EXP_STAGE_PARAM, Stage.class);
assert stage != null;
final String stageName = Markers.getSemantic("experimental.stage." + stage.name());
value = replaceMember(member, value).replace("{stage}", stageName);
final Marker marker = Markers.withText(position, markerLevel, value);
assert marker != null;
// Description
if (description != null && !description.isEmpty()) {
marker.addInfo(Markers.getSemantic("experimental.description", description));
}
// Stage
marker.addInfo(Markers.getSemantic("experimental.stage", stageName));
markers.add(marker);
}
use of dyvil.util.MarkerLevel in project Dyvil by Dyvil.
the class Deprecation method checkDeprecation.
private static void checkDeprecation(IMember member, SourcePosition position, MarkerList markers) {
Annotation annotation = member.getAnnotation(DEPRECATED_CLASS);
if (annotation == null) {
annotation = new ExternalAnnotation(DEPRECATED);
}
final ArgumentList arguments = annotation.getArguments();
final MarkerLevel markerLevel = AnnotationUtil.getEnumValue(arguments, DEP_LEVEL_PARAM, MarkerLevel.class);
if (markerLevel == null || markerLevel == MarkerLevel.IGNORE) {
return;
}
String value = AnnotationUtil.getStringValue(arguments, DEP_VALUE_PARAM);
final String description = AnnotationUtil.getStringValue(arguments, DEP_DESC_PARAM);
final String since = AnnotationUtil.getStringValue(arguments, DEP_SINCE_PARAM);
final String forRemoval = AnnotationUtil.getStringValue(arguments, DEP_UNTIL_PARAM);
value = replaceMember(member, value);
if (since != null) {
value = value.replace("{since}", since);
}
if (forRemoval != null) {
value = value.replace("{forRemoval}", forRemoval);
}
final Marker marker = Markers.withText(position, markerLevel, value);
assert marker != null;
// Description
if (description != null && !description.isEmpty()) {
marker.addInfo(Markers.getSemantic("deprecated.description", description));
}
// Since
if (since != null && !since.isEmpty()) {
marker.addInfo(Markers.getSemantic("deprecated.since", since));
}
if (forRemoval != null && !forRemoval.isEmpty()) {
marker.addInfo(Markers.getSemantic("deprecated.forRemoval", forRemoval));
}
// Until
// Reasons
final Reason[] reasons = getReasons(arguments);
if (reasons != null) {
final int reasonCount = reasons.length;
// more than one reason
if (reasonCount == 1) {
marker.addInfo(Markers.getSemantic("deprecated.reason", reasonName(reasons[0])));
} else if (reasonCount > 0) {
final StringBuilder builder = new StringBuilder(reasonName(reasons[0]));
for (int i = 1; i < reasonCount; i++) {
builder.append(", ").append(reasonName(reasons[i]));
}
marker.addInfo(Markers.getSemantic("deprecated.reasons", builder.toString()));
}
}
// Replacements
final String[] replacements = getReplacements(arguments);
if (replacements != null) {
for (String replacement : replacements) {
marker.addInfo("\t\t" + replacement);
}
marker.addInfo(Markers.getSemantic("deprecated.replacements"));
}
markers.add(marker);
}
use of dyvil.util.MarkerLevel in project Dyvil by Dyvil.
the class Markers method getMarkerLevel.
private static MarkerLevel getMarkerLevel(String key) {
MarkerLevel level = MARKER_LEVEL_MAP.get(key);
if (level != null) {
return level;
}
if (!MARKER_LEVEL_BUNDLE.containsKey(key)) {
MARKER_LEVEL_MAP.put(key, MarkerLevel.ERROR);
return MarkerLevel.ERROR;
}
try {
level = MarkerLevel.valueOf(MARKER_LEVEL_BUNDLE.getString(key).toUpperCase());
} catch (MissingResourceException ex) {
// Should never happen - we check for 'containsKey' above
}
if (level == null) {
level = MarkerLevel.ERROR;
}
MARKER_LEVEL_MAP.put(key, level);
return level;
}
Aggregations