Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,10 @@ public <E> E get(final Object key, final Resource resource, final Provider<E> pr
@SuppressWarnings("unchecked")
ImmutableLinkedItem<E> linkedItem = (ImmutableLinkedItem<E>) 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);
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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$
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion com.avaloq.tools.ddk.xtext/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ private List<ElementLocator> handleParametrizedLocators(final List<ElementLocato
// CHECKSTYLE:OFF if the locator activator fails, simply disable the locator instead of completely failing to format a source
} catch (Exception e) {
// CHECKSTYLE:ON
LOGGER.error(NLS.bind("Failed to calculate the parameter for the paramterized locator for {0}", semanticNodeType), e); //$NON-NLS-1$
LOGGER.error("Failed to calculate the parameter for the parameterized locator for {}", semanticNodeType, e); //$NON-NLS-1$
}
}
}
Expand Down Expand Up @@ -432,7 +432,7 @@ private boolean isActive(final IConditionalLocator locator) {
// CHECKSTYLE:OFF if the locator activator fails, simply disable the locator instead of completely failing to format a source
} catch (Exception e) {
// CHECKSTYLE:ON
LOGGER.error(NLS.bind("Failed to execute the locator activator for {0}", semanticNodeType), e); //$NON-NLS-1$
LOGGER.error("Failed to execute the locator activator for {}", semanticNodeType, e); //$NON-NLS-1$
}
}
return isActive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public boolean exportReference(final EObject context, final EReference reference
return false;
} else if (!target.eIsProxy()) {
if (target.eResource() == null) {
LOGGER.error("Reference from " + EcoreUtil.getURI(context) + " to " + target + " cannot be exported as target is not contained in a resource."); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
LOGGER.error("Reference from {} to {} cannot be exported as target is not contained in a resource.", EcoreUtil.getURI(context), target); //$NON-NLS-1$
return false;
}
return context.eResource() != target.eResource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ public synchronized EObject getEObject(final String uriFragment) {
Triple<EObject, EReference, INode> 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);
}
Expand All @@ -172,8 +172,7 @@ public synchronized EObject getEObject(final String uriFragment) {
Triple<EObject, EReference, INode> 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
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected void inferTargetModel(final EObject eObject, final IAcceptor<EObject>
// 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$
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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$

Expand Down Expand Up @@ -154,9 +156,7 @@ public boolean isAffected(final Collection<Delta> 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;
}

Expand All @@ -165,9 +165,7 @@ public boolean isAffected(final Collection<Delta> 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;
Expand Down Expand Up @@ -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()) {
Expand All @@ -396,15 +392,15 @@ 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;
}
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -322,7 +321,7 @@ protected List<IContainer> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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$
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public interface INameFunction extends Function<EObject, QualifiedName> {
* @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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand All @@ -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
Expand Down Expand Up @@ -159,18 +156,16 @@ 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 {
value = from.eGet(feature);
// 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down