From abe7b931d16d26ac038754bf69359700551b863f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Dinis=20Ferreira?= Date: Mon, 6 Apr 2026 22:23:02 +0200 Subject: [PATCH] refactor: convert log calls to parameterized logging in DDK core Replaces string concatenation, `NLS.bind`, and `MessageFormat.format` in `LOGGER.x(...)` calls with parameterized `{}` placeholders, using `Supplier`/method-refs for lazy argument evaluation. Extracts duplicate format strings to constants where they appear twice. Adds `org.apache.logging.log4j.util` to the `xtext` bundle's OSGi manifest for the `Supplier` import. Modules touched: `xtext`, `typesystem`. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../ddk/typesystem/AbstractTypeProvider.java | 12 +++------- .../typesystem/BuiltInTypeModelAccess.java | 4 ++-- .../META-INF/MANIFEST.MF | 3 ++- .../ExtendedFormattingConfigBasedStream.java | 4 ++-- .../linking/DefaultCrossReferenceHelper.java | 2 +- .../xtext/linking/LazyLinkingResource2.java | 9 ++++---- .../ddk/xtext/linking/LinkingService.java | 2 +- .../ExtendableInferredModelAssociator.java | 2 +- .../InferredModelAssociator.java | 2 +- ...ractCachingResourceDescriptionManager.java | 18 ++++++--------- .../resource/XtextGMFLazyLinkingResource.java | 2 +- .../xtext/resource/XtextGMFResourceUtil.java | 2 +- .../AbstractPolymorphicScopeProvider.java | 3 +-- .../ddk/xtext/scoping/DelegatingScope.java | 2 +- .../ddk/xtext/scoping/INameFunction.java | 4 ++-- .../ddk/xtext/scoping/NameFunctions.java | 23 ++++++++----------- .../util/BuilderParticipantSettings.java | 2 +- .../tools/ddk/xtext/util/EmfResourceUtil.java | 2 +- 18 files changed, 41 insertions(+), 57 deletions(-) diff --git a/com.avaloq.tools.ddk.typesystem/src/com/avaloq/tools/ddk/typesystem/AbstractTypeProvider.java b/com.avaloq.tools.ddk.typesystem/src/com/avaloq/tools/ddk/typesystem/AbstractTypeProvider.java index 6d3308c72c..7a2ecfd091 100644 --- a/com.avaloq.tools.ddk.typesystem/src/com/avaloq/tools/ddk/typesystem/AbstractTypeProvider.java +++ b/com.avaloq.tools.ddk.typesystem/src/com/avaloq/tools/ddk/typesystem/AbstractTypeProvider.java @@ -154,14 +154,10 @@ public E get(final Object key, final Resource resource, final Provider pr @SuppressWarnings("unchecked") ImmutableLinkedItem linkedItem = (ImmutableLinkedItem) key; if (!(linkedItem.object instanceof EObject)) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("cache skip: " + element); //$NON-NLS-1$ - } + LOGGER.debug("cache skip: {}", element); //$NON-NLS-1$ return element; } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("cache: " + element); //$NON-NLS-1$ - } + LOGGER.debug("cache: {}", element); //$NON-NLS-1$ adapter.set(composedKey, element); } else { cacheHit(adapter); @@ -263,9 +259,7 @@ public IType get() { return doComputation(t); } }); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("cache hit: " + hit[0] + " for: " + t); //$NON-NLS-1$ //$NON-NLS-2$ - } + LOGGER.debug("cache hit: {} for: {}", hit[0], t); //$NON-NLS-1$ return result; } else { if (computationData.resourceLeftOrCyclic) { diff --git a/com.avaloq.tools.ddk.typesystem/src/com/avaloq/tools/ddk/typesystem/BuiltInTypeModelAccess.java b/com.avaloq.tools.ddk.typesystem/src/com/avaloq/tools/ddk/typesystem/BuiltInTypeModelAccess.java index 5486f464ae..1cce042c72 100644 --- a/com.avaloq.tools.ddk.typesystem/src/com/avaloq/tools/ddk/typesystem/BuiltInTypeModelAccess.java +++ b/com.avaloq.tools.ddk.typesystem/src/com/avaloq/tools/ddk/typesystem/BuiltInTypeModelAccess.java @@ -117,7 +117,7 @@ private synchronized void load() { // We *do* want to catch any exception here because we are in construction and need to initialize with something } catch (Exception ex) { // CHECKSTYLE:CHECK-ON IllegalCatch - LOGGER.error("Error loading metamodel from " + modelURI, ex); //$NON-NLS-1$ + LOGGER.error("Error loading metamodel from {}", modelURI, ex); //$NON-NLS-1$ // Create an empty model... model = BuiltInTypeModelPackage.eINSTANCE.getBuiltInTypeModelFactory().createBuiltInTypeModel(); } @@ -128,7 +128,7 @@ private synchronized void load() { if (!Strings.isEmpty(typeName)) { internalTypesByName.put(typeName, type); } else { - LOGGER.error("incomplete internal type in " + MODEL_LOCATION); //$NON-NLS-1$ + LOGGER.error("incomplete internal type in {}", MODEL_LOCATION); //$NON-NLS-1$ } } } diff --git a/com.avaloq.tools.ddk.xtext/META-INF/MANIFEST.MF b/com.avaloq.tools.ddk.xtext/META-INF/MANIFEST.MF index 2e198eaa9d..913a435a8f 100644 --- a/com.avaloq.tools.ddk.xtext/META-INF/MANIFEST.MF +++ b/com.avaloq.tools.ddk.xtext/META-INF/MANIFEST.MF @@ -45,6 +45,7 @@ Export-Package: com.avaloq.tools.ddk.xtext.build, com.avaloq.tools.ddk.xtext.tracing, com.avaloq.tools.ddk.xtext.util, com.avaloq.tools.ddk.xtext.validation -Import-Package: org.apache.logging.log4j +Import-Package: org.apache.logging.log4j, + org.apache.logging.log4j.util Automatic-Module-Name: com.avaloq.tools.ddk.xtext diff --git a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/formatting/ExtendedFormattingConfigBasedStream.java b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/formatting/ExtendedFormattingConfigBasedStream.java index b84e8cf3f4..8af6d5bfcb 100644 --- a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/formatting/ExtendedFormattingConfigBasedStream.java +++ b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/formatting/ExtendedFormattingConfigBasedStream.java @@ -366,7 +366,7 @@ private List handleParametrizedLocators(final List refInfo = getEncoder().decode(this, uriFragment); EReference reference = refInfo.getSecond(); EObject context = refInfo.getFirst(); - LOGGER.debug("Failed unexpected attempt to resolve reference during indexing " + context.eClass().getName() + "#" //$NON-NLS-1$ //$NON-NLS-2$ - + reference.getName() + " for object " + EcoreUtil.getURI(context), new RuntimeException()); //$NON-NLS-1$ + LOGGER.debug("Failed unexpected attempt to resolve reference during indexing {}#{} for object {}", //$NON-NLS-1$ + context.eClass().getName(), reference.getName(), EcoreUtil.getURI(context), new RuntimeException()); } rs.getLoadOptions().put(MARK_UNRESOLVABLE_XREFS, Boolean.TRUE); } @@ -172,8 +172,7 @@ public synchronized EObject getEObject(final String uriFragment) { Triple triple = getEncoder().decode(this, uriFragment); INode node = triple.getThird(); final String nodeName = getLinkingHelper().getCrossRefNodeAsString(node, true); - LOGGER.error("Resolution of uriFragment '" + uriFragment + "' in the resource '" + this.getURI() + "' node_name " + nodeName //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - + " line " + node.getStartLine() + " offset " + node.getOffset() + " failed.", e); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + LOGGER.error("Resolution of uriFragment '{}' in the resource '{}' node_name {} line {} offset {} failed.", uriFragment, this.getURI(), nodeName, node.getStartLine(), node.getOffset(), e); //$NON-NLS-1$ logged = true; } // CHECKSTYLE:OFF @@ -182,7 +181,7 @@ public synchronized EObject getEObject(final String uriFragment) { // ignore } if (!logged) { - LOGGER.error("Resolution of uriFragment '" + uriFragment + "' in the resource '" + this.getURI() + "' failed.", e); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + LOGGER.error("Resolution of uriFragment '{}' in the resource '{}' failed.", uriFragment, this.getURI(), e); //$NON-NLS-1$ } throw e; } diff --git a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/linking/LinkingService.java b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/linking/LinkingService.java index 855f0db57d..8a1df42e7f 100644 --- a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/linking/LinkingService.java +++ b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/linking/LinkingService.java @@ -199,7 +199,7 @@ private IEObjectDescription safeGetSingleElement(final EObject context, final ER try { return getSingleElement(context, ref, qualifiedLinkName); } catch (Exception e) { // IllegalCatchCheck OFF - LOGGER.error("Exception in getSingleElement for " + qualifiedLinkName.toString() + " at " + EObjectUtil.getLocationString(context), e); //$NON-NLS-1$ //$NON-NLS-2$ + LOGGER.error("Exception in getSingleElement for {} at {}", qualifiedLinkName, EObjectUtil.getLocationString(context), e); //$NON-NLS-1$ } return null; } diff --git a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/modelinference/ExtendableInferredModelAssociator.java b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/modelinference/ExtendableInferredModelAssociator.java index 3300c60396..08e28c9eee 100644 --- a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/modelinference/ExtendableInferredModelAssociator.java +++ b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/modelinference/ExtendableInferredModelAssociator.java @@ -39,7 +39,7 @@ protected void inferTargetModel(final EObject eObject, final IAcceptor // CHECKSTYLE:OFF } catch (RuntimeException e) { // CHECKSTYLE:ON - LOGGER.error("Failed to install additional derived state for resource " + eObject.eResource().getURI(), e); //$NON-NLS-1$ + LOGGER.error("Failed to install additional derived state for resource {}", eObject.eResource().getURI(), e); //$NON-NLS-1$ } } diff --git a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/modelinference/InferredModelAssociator.java b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/modelinference/InferredModelAssociator.java index 6a2374b98c..54b9ccc02f 100644 --- a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/modelinference/InferredModelAssociator.java +++ b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/modelinference/InferredModelAssociator.java @@ -206,7 +206,7 @@ public final void installDerivedState(final DerivedStateAwareResource resource, // CHECKSTYLE:OFF } catch (RuntimeException e) { // CHECKSTYLE:ON - LOGGER.error("Failed to install derived state for resource " + resource.getURI(), e); //$NON-NLS-1$ + LOGGER.error("Failed to install derived state for resource {}", resource.getURI(), e); //$NON-NLS-1$ } finally { inferenceStack.pop(); } diff --git a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/resource/AbstractCachingResourceDescriptionManager.java b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/resource/AbstractCachingResourceDescriptionManager.java index 2a1f1afb9d..5d4f701098 100644 --- a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/resource/AbstractCachingResourceDescriptionManager.java +++ b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/resource/AbstractCachingResourceDescriptionManager.java @@ -61,6 +61,8 @@ public abstract class AbstractCachingResourceDescriptionManager extends DerivedS /** Class-wide logger. */ private static final Logger LOGGER = LogManager.getLogger(AbstractCachingResourceDescriptionManager.class); + private static final String LOG_AFFECTED_BY = "{} is affected by {}"; //$NON-NLS-1$ + /** Cache key for the resource description of a resource. */ public static final String CACHE_KEY = DefaultResourceDescriptionManager.class.getName() + "#getResourceDescription"; //$NON-NLS-1$ @@ -154,9 +156,7 @@ public boolean isAffected(final Collection deltas, final IResourceDescrip final URI deltaURI = delta.getUri();// NOPMD - potentially could be lost due to call on getNew() after // deleted resources are no longer visible resources so we test them, too. if (delta.getNew() == null && isReferencedBy(delta, candidate, context)) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug(candidate.getURI() + " is affected by " + delta.getUri()); //$NON-NLS-1$ - } + LOGGER.debug(LOG_AFFECTED_BY, candidate::getURI, delta::getUri); return true; } @@ -165,9 +165,7 @@ public boolean isAffected(final Collection deltas, final IResourceDescrip for (IContainer container : containers) { if (container.getResourceDescription(deltaURI) != null) { if (isReferencedBy(delta, candidate, context)) { - if (LOGGER.isDebugEnabled()) { // NOPMD AvoidDeeplyNestedIfStmts - LOGGER.debug(candidate.getURI() + " is affected by " + delta.getUri()); //$NON-NLS-1$ - } + LOGGER.debug(LOG_AFFECTED_BY, candidate::getURI, delta::getUri); return true; } break; @@ -370,9 +368,7 @@ public boolean isAffected(final Delta delta, final IResourceDescription candidat if (delta.getUri().equals(candidate.getURI())) { // If the delta is for ourselves, we're always affected; otherwise the dirty state manager may omit to update the editor // state. - if (LOGGER.isDebugEnabled()) { - LOGGER.debug(delta.getUri() + " is the same as " + candidate.getURI()); //$NON-NLS-1$ - } + LOGGER.debug("{} is the same as {}", delta::getUri, candidate::getURI); //$NON-NLS-1$ return true; } if (!delta.haveEObjectDescriptionsChanged()) { @@ -396,7 +392,7 @@ public boolean isAffected(final Delta delta, final IResourceDescription candidat boolean disjointResolved = Collections.disjoint(resolvedNames, resolvedAndUnresolvedNames.getFirst()); if (!disjointResolved && LOGGER.isDebugEnabled()) { resolvedNames.retainAll(getImportedNames(candidate)); - LOGGER.debug("resolved names imported by " + candidate.getURI() + " are exported by " + delta.getUri() + " intersection:" + resolvedNames.toString()); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ + LOGGER.debug("resolved names imported by {} are exported by {} intersection:{}", candidate::getURI, delta::getUri, resolvedNames::toString); //$NON-NLS-1$ } if (!disjointResolved) { return true; @@ -404,7 +400,7 @@ public boolean isAffected(final Delta delta, final IResourceDescription candidat boolean disjointUnresolved = Collections.disjoint(unresolvedNames, resolvedAndUnresolvedNames.getSecond()); if (!disjointUnresolved && LOGGER.isDebugEnabled()) { unresolvedNames.retainAll(getImportedNames(candidate)); - LOGGER.debug("unrevolved names imported by " + candidate.getURI() + " are exported by " + delta.getUri() + " intersection:" + unresolvedNames.toString()); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ + LOGGER.debug("unresolved names imported by {} are exported by {} intersection:{}", candidate::getURI, delta::getUri, unresolvedNames::toString); //$NON-NLS-1$ } return !disjointUnresolved; } diff --git a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/resource/XtextGMFLazyLinkingResource.java b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/resource/XtextGMFLazyLinkingResource.java index e65074bf00..9bbbae241c 100644 --- a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/resource/XtextGMFLazyLinkingResource.java +++ b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/resource/XtextGMFLazyLinkingResource.java @@ -116,7 +116,7 @@ public String getDiagramText() { result.append(new String(diagramBuffer, encoding)); } } catch (UnsupportedEncodingException e) { - LOGGER.error("Strange, encoding: " + encoding + " was OK when resource loaded"); //$NON-NLS-1$ //$NON-NLS-2$ + LOGGER.error("Strange, encoding: {} was OK when resource loaded", encoding); //$NON-NLS-1$ return EMPTY_STRING; } return result.toString(); diff --git a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/resource/XtextGMFResourceUtil.java b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/resource/XtextGMFResourceUtil.java index 0879f1867e..26e95b6449 100644 --- a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/resource/XtextGMFResourceUtil.java +++ b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/resource/XtextGMFResourceUtil.java @@ -51,7 +51,7 @@ public static byte[] getSeparator(final String encoding) { try { return SEPARATOR.getBytes(encoding != null ? encoding : DEFAULT_ENCODING); } catch (UnsupportedEncodingException e) { - LOGGER.error("unsupported encoding: " + encoding, e); //$NON-NLS-1$ + LOGGER.error("unsupported encoding: {}", encoding, e); //$NON-NLS-1$ return SEPARATOR.getBytes(); // NOPMD RelianceOnDefaultCharset } } diff --git a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/scoping/AbstractPolymorphicScopeProvider.java b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/scoping/AbstractPolymorphicScopeProvider.java index 5d7d24624b..014e356e81 100644 --- a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/scoping/AbstractPolymorphicScopeProvider.java +++ b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/scoping/AbstractPolymorphicScopeProvider.java @@ -10,7 +10,6 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.scoping; // NOPMD ExcessiveImports -import java.text.MessageFormat; import java.util.Collections; import java.util.List; @@ -322,7 +321,7 @@ protected List getVisibleContainers(final EObject context, final Res // complexity...) final Resource resource = originalResource == null ? context.eResource() : originalResource; if (!(resource instanceof XtextResource)) { - LOGGER.error(MessageFormat.format("Context {0} is not in an Xtext resource: {1}", context, resource != null ? resource.getURI() : "null")); //$NON-NLS-1$ //$NON-NLS-2$ + LOGGER.error("Context {} is not in an Xtext resource: {}", context, resource != null ? resource.getURI() : "null"); //$NON-NLS-1$ //$NON-NLS-2$ throw new IllegalStateException(); } return getVisibleContainers((XtextResource) resource); diff --git a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/scoping/DelegatingScope.java b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/scoping/DelegatingScope.java index c15f3fbd1f..c874f1f36b 100644 --- a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/scoping/DelegatingScope.java +++ b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/scoping/DelegatingScope.java @@ -92,7 +92,7 @@ public String[] getUserDataKeys() { } private void logError() { - LOGGER.error("Cyclic delegate detected in scope \"" + stackOverflowScopeId + "\"."); //$NON-NLS-1$ //$NON-NLS-2$ + LOGGER.error("Cyclic delegate detected in scope \"{}\".", stackOverflowScopeId); //$NON-NLS-1$ } }; diff --git a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/scoping/INameFunction.java b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/scoping/INameFunction.java index 91340b350d..3b8e2b7e77 100644 --- a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/scoping/INameFunction.java +++ b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/scoping/INameFunction.java @@ -32,8 +32,8 @@ public interface INameFunction extends Function { * @return The name. */ default QualifiedName apply(final IEObjectDescription from) { - LogManager.getLogger(INameFunction.class).warn("No explicit name function for description " + from.getEObjectURI() + " of type " //$NON-NLS-1$ //$NON-NLS-2$ - + EcoreUtil.getURI(from.getEClass())); + LogManager.getLogger(INameFunction.class).warn("No explicit name function for description {} of type {}", from.getEObjectURI(), //$NON-NLS-1$ + EcoreUtil.getURI(from.getEClass())); return from.getName(); } diff --git a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/scoping/NameFunctions.java b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/scoping/NameFunctions.java index ea4aab73fe..643337ff25 100644 --- a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/scoping/NameFunctions.java +++ b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/scoping/NameFunctions.java @@ -10,7 +10,6 @@ *******************************************************************************/ package com.avaloq.tools.ddk.xtext.scoping; -import java.text.MessageFormat; import java.util.Arrays; import org.apache.logging.log4j.LogManager; @@ -35,11 +34,11 @@ public final class NameFunctions { private static final String FEATURE_NAME = "FeatureName:";//$NON-NLS-1$ - private static final String UNKNOWN_FEATURE_0_FROM_1 = "Unknown feature {0} from {1}";//$NON-NLS-1$ + private static final String UNKNOWN_FEATURE_0_FROM_1 = "Unknown feature {} from {}";//$NON-NLS-1$ - private static final String COULD_NOT_READ_FEATURE_0_FROM_1 = "Could not read feature {0} from {1}";//$NON-NLS-1$ + private static final String COULD_NOT_READ_FEATURE_0_FROM_1 = "Could not read feature {} from {}";//$NON-NLS-1$ - private static final String NO_USER_DATA_0_FOUND_FOR_1 = "No user data \'\'{0}\'\' found for {1}."; //$NON-NLS-1$ + private static final String NO_USER_DATA_0_FOUND_FOR_1 = "No user data '{}' found for {}."; //$NON-NLS-1$ /** Class-wide logger. */ private static final Logger LOGGER = LogManager.getLogger(NameFunctions.class); @@ -76,8 +75,8 @@ public static INameFunction fromFeature(final EStructuralFeature feature) { @Override public QualifiedName apply(final IEObjectDescription from) { String res = from.getUserData(feature.getName()); - if (res == null && LOGGER.isDebugEnabled()) { - LOGGER.debug(MessageFormat.format(NO_USER_DATA_0_FOUND_FOR_1, feature.getName(), from.getEObjectOrProxy())); + if (res == null) { + LOGGER.debug(NO_USER_DATA_0_FOUND_FOR_1, feature::getName, from::getEObjectOrProxy); } return QualifiedNames.safeQualifiedName(res); } @@ -89,9 +88,7 @@ public QualifiedName apply(final EObject from) { value = from.eGet(feature); // CHECKSTYLE:OFF } catch (final RuntimeException e) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug(MessageFormat.format(COULD_NOT_READ_FEATURE_0_FROM_1, feature, from), e); - } + LOGGER.debug(COULD_NOT_READ_FEATURE_0_FROM_1, feature, from, e); return null; } // CHECKSTYLE:ON @@ -159,8 +156,8 @@ public static INameFunction fromFeatureName(final String featureName) { @Override public QualifiedName apply(final EObject from) { final EStructuralFeature feature = from.eClass().getEStructuralFeature(featureName); - if (feature == null && LOGGER.isDebugEnabled()) { - LOGGER.debug(MessageFormat.format(UNKNOWN_FEATURE_0_FROM_1, featureName, from)); + if (feature == null) { + LOGGER.debug(UNKNOWN_FEATURE_0_FROM_1, featureName, from); } Object value; try { @@ -168,9 +165,7 @@ public QualifiedName apply(final EObject from) { // CHECKSTYLE:OFF } catch (final RuntimeException e) { // CHECKSTYLE:ON - if (LOGGER.isDebugEnabled()) { - LOGGER.debug(MessageFormat.format(COULD_NOT_READ_FEATURE_0_FROM_1, featureName, from), e); - } + LOGGER.debug(COULD_NOT_READ_FEATURE_0_FROM_1, featureName, from, e); return null; } return value != null ? QualifiedNames.safeQualifiedName(value.toString()) : null; diff --git a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/util/BuilderParticipantSettings.java b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/util/BuilderParticipantSettings.java index aea23f38ad..ea089e1157 100644 --- a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/util/BuilderParticipantSettings.java +++ b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/util/BuilderParticipantSettings.java @@ -51,7 +51,7 @@ public static boolean isBuilderParticipantEnabled(final String languageName) { try { result = BuilderParticipantStatus.valueOf(value); } catch (IllegalArgumentException ex) { - LOGGER.error("Property " + languageName + " has an invalid value: " + value + " (should be one of enabled, disabled)"); + LOGGER.error("Property {} has an invalid value: {} (should be one of enabled, disabled)", languageName, value); result = BuilderParticipantStatus.ENABLED; } return result == BuilderParticipantStatus.ENABLED; diff --git a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/util/EmfResourceUtil.java b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/util/EmfResourceUtil.java index f474445fcd..3f9e079239 100644 --- a/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/util/EmfResourceUtil.java +++ b/com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/util/EmfResourceUtil.java @@ -99,7 +99,7 @@ public static Resource loadURI(final URI uri, final ResourceSet resourceSet) { try { resource.load(resourceSet.getLoadOptions()); } catch (IOException e) { - LOGGER.warn("loadURI: Unable to load resource : " + resource.getURI().toString()); //$NON-NLS-1$ + LOGGER.warn("loadURI: Unable to load resource : {}", resource.getURI()); //$NON-NLS-1$ return null; } }