generated from ThalesGroup/template-project
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
44 additions
and
1 deletion.
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
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
35 changes: 35 additions & 0 deletions
35
org.eclipse.xsmp.ide/src/org/eclipse/xsmp/ide/symbol/XsmpDocumentSymbolRangeProvider.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) 2024 THALES ALENIA SPACE FRANCE. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
******************************************************************************/ | ||
package org.eclipse.xsmp.ide.symbol; | ||
|
||
import org.eclipse.emf.ecore.EObject; | ||
import org.eclipse.lsp4j.Range; | ||
import org.eclipse.lsp4j.util.Ranges; | ||
import org.eclipse.xtext.ide.server.symbol.DocumentSymbolMapper.DocumentSymbolRangeProvider; | ||
|
||
public class XsmpDocumentSymbolRangeProvider extends DocumentSymbolRangeProvider | ||
{ | ||
|
||
@Override | ||
public Range getSelectionRange(EObject object) | ||
{ | ||
final var range = getRange(object); | ||
if (range == null) | ||
{ | ||
return null; | ||
} | ||
final var selectionRange = super.getSelectionRange(object); | ||
// sometimes during edition the selection range is invalid and is outside the range. | ||
// in this case return null to avoid error in vs code | ||
return selectionRange != null && Ranges.containsRange(range, selectionRange) ? selectionRange | ||
: null; | ||
} | ||
} |