-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: referencing grammar from 3rd party plugin throws Exception (#654)
- Loading branch information
Showing
5 changed files
with
86 additions
and
10 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
49 changes: 49 additions & 0 deletions
49
org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/utils/ScopeNames.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,49 @@ | ||
/** | ||
* Copyright (c) 2024 Sebastian Thomschke and others. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* - Sebastian Thomschke - initial API and implementation | ||
*/ | ||
package org.eclipse.tm4e.core.internal.utils; | ||
|
||
import org.eclipse.jdt.annotation.Nullable; | ||
|
||
/** | ||
* Utility class to deal with plugin scoped TextMate Scope Names, e.g. "source.batchfile@com.example.myplugin" | ||
*/ | ||
public final class ScopeNames { | ||
|
||
public static final char CONTRIBUTOR_SEPARATOR = '@'; | ||
|
||
public static @Nullable String getContributor(final String scopeName) { | ||
final int separatorAt = scopeName.indexOf(CONTRIBUTOR_SEPARATOR); | ||
if (separatorAt == -1) { | ||
return ""; | ||
} | ||
return scopeName.substring(separatorAt + 1); | ||
} | ||
|
||
/** | ||
* @return true if a scope name is suffixed by the contributing plugin id, e.g. "source.batchfile@com.example.myplugin" | ||
*/ | ||
public static boolean hasContributor(final String scopeName) { | ||
return scopeName.indexOf(CONTRIBUTOR_SEPARATOR) > -1; | ||
} | ||
|
||
public static String withoutContributor(final String scopeName) { | ||
final int separatorAt = scopeName.indexOf(CONTRIBUTOR_SEPARATOR); | ||
if (separatorAt == -1) { | ||
return scopeName; | ||
} | ||
return scopeName.substring(0, separatorAt); | ||
} | ||
|
||
private ScopeNames() { | ||
} | ||
} |
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
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