-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gloabl constants reference search #1089
base: develop
Are you sure you want to change the base?
Conversation
The model search now has an option to search in the initial values of fb types. Searching global constants in fb instances is not possible as constants are converted to their value literals when instantiated.
import org.eclipse.xtext.ui.editor.findrefs.FindReferencesHandler; | ||
|
||
@SuppressWarnings("restriction") | ||
public class GlobalConstantsFindReferencesHandler extends FindReferencesHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please give a more generic name. we might want to reuse that handler in other places too in the future.
Maybe FordiacFindReferencesHandler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we need to use it also in the other ST languages to handle references to global constants from other ST sources. Please move it to the corresponding structuredtextcore.ui
plugin. By the existing naming convention, it should then also be renamed to STCoreFindReferencesHandler
.
import org.eclipse.xtext.ui.editor.findrefs.FindReferencesHandler; | ||
|
||
@SuppressWarnings("restriction") | ||
public class GlobalConstantsFindReferencesHandler extends FindReferencesHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we need to use it also in the other ST languages to handle references to global constants from other ST sources. Please move it to the corresponding structuredtextcore.ui
plugin. By the existing naming convention, it should then also be renamed to STCoreFindReferencesHandler
.
@@ -206,7 +206,7 @@ | |||
</extension> | |||
<extension point="org.eclipse.ui.handlers"> | |||
<handler | |||
class="org.eclipse.fordiac.ide.globalconstantseditor.ui.GlobalConstantsExecutableExtensionFactory:org.eclipse.xtext.ui.editor.findrefs.FindReferencesHandler" | |||
class="org.eclipse.fordiac.ide.globalconstantseditor.ui.GlobalConstantsExecutableExtensionFactory:org.eclipse.fordiac.ide.globalconstantseditor.ui.handlers.GlobalConstantsFindReferencesHandler" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change the handlers in the other ST languages, as well.
|
||
@Override | ||
protected void findReferences(final EObject target) { | ||
if (target instanceof final STVarDeclaration varDec) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check that it is a global constant and not a local variable with the additional condition:
if (target instanceof final STVarDeclaration varDec) { | |
if (target instanceof final STVarDeclaration varDec && varDec.eContainer() instanceof STVarGlobalDeclarationBlock) { |
@@ -27,7 +27,10 @@ Require-Bundle: org.eclipse.fordiac.ide.globalconstantseditor, | |||
org.eclipse.fordiac.ide.typemanagement, | |||
org.eclipse.fordiac.ide.systemmanagement, | |||
org.eclipse.ui, | |||
org.eclipse.ui.editors | |||
org.eclipse.ui.editors, | |||
org.eclipse.ui.navigator, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you actually need the navigator
dependency?
if (modelElement instanceof final VarDeclaration varDecl) { | ||
final var value = varDecl.getValue(); | ||
return value != null && !value.getValue().isEmpty() | ||
&& value.getValue().contains(modelQuerySpec.searchString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to accurately search for global constants in packages, I would suggest to first strip any leading packages for simple string pre-matching and then use the ST search to determine if it is actually a match.
WOW ! i would like this. also it would be great to have a Function when i see a Constant, to jup to the Definition. |
Replaced the xtext find reference search with the 4diac model search in the global constants editor. It currently does not match on the fully qualified name (e.g. "value2" instead of "GlobalTest::value2") as otherwise it would not match the occurrences in the ST code anymore.