private void parseAnnotationValues(PropertyAnnotation annotation, String contents) { if(contents==null) return; Matcher matcher = ANNOTATION_VALUE_PARSER.matcher(contents); while(matcher.find()) { annotation.getValues().put(matcher.group(1), matcher.group(2)); } }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public PropertyAnnotation findAnnotation(String name) { for (PropertyAnnotation annotation : getAnnotations()) { if(name.equals(annotation.getName())) return annotation; } return null; }
annotation.setName(PropertyAnnotations.ANNOTATION_LANGUAGE); annotation.getValues().put(PropertyAnnotations.SOURCE_LANGUAGE, normalizeLanguage(srcLanguage)); annotation.getValues().put(PropertyAnnotations.TARGET_LANGUAGE, normalizeLanguage(targetLanguage)); current.getAnnotations().add(annotation); file.getProperties().add(current);
/** * parses a comment for annotations * @param newComment */ private String parseAnnotations(String string) { getAnnotations().clear(); if(string==null) return string; Matcher matcher = ANNOTATION_PARSER.matcher(string); String remainder = string; while(matcher.find()) { PropertyAnnotation annotation = PropertiesFactory.eINSTANCE.createPropertyAnnotation(); parseAnnotationValues(annotation,matcher.group(3)); annotation.setName(matcher.group(1)); getAnnotations().add(annotation); } return remainder; }
/** * extracts the target locale from a property annotation. * @param property * @return */ private Locale extractTargetLocale(Property property) { PropertyAnnotation annotation = property.findAnnotation(PropertyAnnotations.ANNOTATION_LANGUAGE); if(annotation==null) return null; String localeString = annotation.getValues().get(PropertyAnnotations.TARGET_LANGUAGE); if(localeString==null) return null; return (Locale) PropertiesFactory.eINSTANCE.createFromString(PropertiesPackage.Literals.LOCALE, localeString); }