This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
forked from eclipse-lemminx/lemminx
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from eclipse/master
Use related information for unclosed elements
- Loading branch information
Showing
15 changed files
with
513 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
.../org/eclipse/lemminx/extensions/contentmodel/participants/AggregateRelatedInfoFinder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.lemminx.extensions.contentmodel.participants; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.eclipse.lemminx.dom.DOMDocument; | ||
import org.eclipse.lsp4j.DiagnosticRelatedInformation; | ||
|
||
/** | ||
* Finds related info for any error code | ||
*/ | ||
public class AggregateRelatedInfoFinder implements IRelatedInfoFinder { | ||
|
||
private static IRelatedInfoFinder[] RELATED_INFO_FINDERS = { | ||
new XMLSyntaxRelatedInfoFinder() | ||
}; | ||
|
||
private static AggregateRelatedInfoFinder INSTANCE = null; | ||
|
||
private AggregateRelatedInfoFinder() {} | ||
|
||
public static AggregateRelatedInfoFinder getInstance() { | ||
if (INSTANCE == null) { | ||
INSTANCE = new AggregateRelatedInfoFinder(); | ||
} | ||
return INSTANCE; | ||
} | ||
|
||
@Override | ||
public List<DiagnosticRelatedInformation> findRelatedInformation( | ||
int offset, | ||
String errorKey, | ||
DOMDocument document) { | ||
List<DiagnosticRelatedInformation> relatedInfo = new ArrayList<>(); | ||
for (IRelatedInfoFinder relatedInfoFinder : RELATED_INFO_FINDERS) { | ||
relatedInfo.addAll(relatedInfoFinder.findRelatedInformation( | ||
offset, | ||
errorKey, | ||
document | ||
)); | ||
} | ||
return relatedInfo; | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
...ain/java/org/eclipse/lemminx/extensions/contentmodel/participants/IRelatedInfoFinder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.lemminx.extensions.contentmodel.participants; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.lemminx.dom.DOMDocument; | ||
import org.eclipse.lsp4j.DiagnosticRelatedInformation; | ||
|
||
/** | ||
* Provides an interface to find related info for a given error | ||
*/ | ||
public interface IRelatedInfoFinder { | ||
|
||
/** | ||
* Returns a list of related information | ||
* | ||
* @param offset The LemMinX reported error start offset | ||
* @param errorKey The error key | ||
* @param document The document | ||
* @return a list of related information | ||
*/ | ||
List<DiagnosticRelatedInformation> findRelatedInformation( | ||
int offset, | ||
String errorKey, | ||
DOMDocument document); | ||
|
||
} |
Oops, something went wrong.