Skip to content

2 matches found for XPath: not telling which file #1349

@hohwille

Description

@hohwille

Actual behavior

In the logs I get this warning:

2 matches found for XPath configuration[@default='true' and @type='JUnit'] in workspace XML at /project[@version='4']/component[@name='RunManager' @selected='JUnit.StepTest']

It is missing the path to the files in the workspace and the template leading to this error so the user can easily analyse and fix the problem.

Reproduce

  1. edit your workspace.xml in your IJ workspace and duplicate the JUnit default RunManager.
  2. run ide intellij

Expected behavior

I would rather expect a warning like this:

2 matches found for XPath configuration[@default='true' and @type='JUnit'] in workspace XML file `~/projects/example/workspaces/main/.idea/workspace.xml at /project[@version='4']/component[@name='RunManager' @selected='JUnit.StepTest'] for template file `~/projects/example/settings/intellij/workspace/update/.idea/workspace.xml

IDEasy status

$ ide status
IDE_ROOT is set to D:\projects
IDE_HOME is set to D:\projects\IDEasy
You are online.
Your settings are up-to-date.
Your version of IDEasy is 2025.05.002-05_29_02-SNAPSHOT but version 2025.05.002-20250529.024405-8 is available. Please run the following command to upgrade to the latest version:
ide upgrade
Your operating system is windows(10.0)@x64 [Windows 11@amd64]
Successfully completed ide (status)

Related/Dependent issues

#1138

Comments/Hints

Problem is here in the warning logging:

String message = length + " matches found for XPath " + xpathExpr + " in workspace XML at " + XmlMergeSupport.getXPath(workspaceElement, true);
if ("true".equals(this.context.getVariables().get(FAIL_ON_AMBIGOUS_MERGE))) {
throw new IllegalStateException(message);
} else {
this.context.warning(message);
}

Problem is that the Element only allows getOwnerDocument() but from there we cannot get the source from where the XML was loaded. Therefore, this method needs to be refactored to additionally get the two Path args for the XMLs so this can also be logged here.

Log-messages should be helpful and give contextual information.

See https://github.com/devonfw/IDEasy/blob/main/documentation/coding-conventions.adoc#log-messages

Metadata

Metadata

Assignees

Labels

Type

Projects

Status

🏗 In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions