Browse Source

Added GrammarRegistry::has

main 0.0.2
Dustin Wilson 2 years ago
parent
commit
1e61057caf
  1. 1
      README.md
  2. 11
      lib/GrammarRegistry.php

1
README.md

@ -215,6 +215,7 @@ $element = MensBeam\Lit\Highlight::toElement($code, $grammar->scopeName);
* Go * Go
* Go modules * Go modules
* Go templates * Go templates
* HTML
* Java * Java
* Java expression language * Java expression language
* Java properties * Java properties

11
lib/GrammarRegistry.php

@ -39,6 +39,17 @@ class GrammarRegistry {
return false; return false;
} }
/**
* Retrieves whether a grammar exists in the registry or not.
*
* @param string $scopeName - The scope name (eg: text.html.php) of the grammar that is being requested
* @return bool
*/
public static function has(string $scopeName): bool {
$result = array_key_exists($scopeName, self::$storage);
return $result ?: file_exists(__DIR__ . "/../data/$scopeName.json");
}
/** /**
* Sets a grammar in the registry. * Sets a grammar in the registry.
* *

Loading…
Cancel
Save