Skip to content

Commit

Permalink
basic reference search for FunctionFBTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
lindhuber committed Jan 17, 2025
1 parent 604456d commit 34839a0
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 8 deletions.
3 changes: 2 additions & 1 deletion plugins/org.eclipse.fordiac.ide.model.search/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
<test forcePluginActivation="false" property="org.eclipse.core.resources.extension" value="sub" />
<test forcePluginActivation="false" property="org.eclipse.core.resources.extension" value="dtd" />
<test forcePluginActivation="false" property="org.eclipse.core.resources.extension" value="dtp" />
</or>
<test forcePluginActivation="false" property="org.eclipse.core.resources.extension" value="fct" />
</or>
</adapt>
</iterate>
</with>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public record ModelQuerySpec(
boolean checkComments,
boolean checkCaseSensitive,
boolean checkExactMatching,
boolean checkSTReferences,
SearchScope scope,
IProject project
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,19 @@ public boolean performAction() {
// string exists
final boolean optionSelected = isCheckedInstanceName || isCheckedPinName || isCheckedType || isCheckedComment;
if (!"".equals(searchString) && optionSelected) { //$NON-NLS-1$

final ModelQuerySpec modelQuerySpec = new ModelQuerySpec(searchString, isCheckedInstanceName,
isCheckedPinName, isCheckedType, isCheckedComment, isCaseSensitive, isExactNameMatching, getScope(),
// @formatter:off
final ModelQuerySpec modelQuerySpec = new ModelQuerySpec(
searchString,
isCheckedInstanceName,
isCheckedPinName,
isCheckedType,
isCheckedComment,
isCaseSensitive,
isExactNameMatching,
false, // TODO
getScope(),
curProject);

// @formatter:on
final ModelSearchQuery searchJob = new ModelSearchQuery(modelQuerySpec);
NewSearchUI.runQueryInBackground(searchJob, NewSearchUI.getSearchResultView());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.eclipse.fordiac.ide.model.libraryElement.FBNetwork;
import org.eclipse.fordiac.ide.model.libraryElement.FBNetworkElement;
import org.eclipse.fordiac.ide.model.libraryElement.FBType;
import org.eclipse.fordiac.ide.model.libraryElement.FunctionFBType;
import org.eclipse.fordiac.ide.model.libraryElement.IInterfaceElement;
import org.eclipse.fordiac.ide.model.libraryElement.INamedElement;
import org.eclipse.fordiac.ide.model.libraryElement.InterfaceList;
Expand Down Expand Up @@ -293,6 +294,9 @@ private boolean matchEObject(final INamedElement modelElement, final IProgressMo
}
}
if (modelQuerySpec.checkType()) {
if (modelElement instanceof FunctionFBType) {
return matchInST(modelElement);
}
if (modelElement instanceof final TypedConfigureableObject config) {
return compareStrings(config.getTypeName())
|| (config.getTypeEntry() != null && compareStrings(config.getTypeEntry().getFullTypeName()));
Expand All @@ -315,7 +319,7 @@ private boolean matchEObject(final INamedElement modelElement, final IProgressMo

private boolean matchInST(final INamedElement modelElement) {
final String text = getImplText(modelElement);
if (text == null || pattern.preScanST(text)) {
if (modelQuerySpec.checkSTReferences() || text == null || pattern.preScanST(text)) {
for (final String fqn : VariableOperations.getAllDependencies(modelElement)) {
if (compareStrings(fqn)) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.eclipse.fordiac.ide.model.search.ModelSearchResult;
import org.eclipse.fordiac.ide.model.typelibrary.DataTypeEntry;
import org.eclipse.fordiac.ide.model.typelibrary.FBTypeEntry;
import org.eclipse.fordiac.ide.model.typelibrary.FunctionFBTypeEntry;
import org.eclipse.fordiac.ide.model.typelibrary.SubAppTypeEntry;
import org.eclipse.fordiac.ide.model.typelibrary.TypeEntry;
import org.eclipse.fordiac.ide.model.typelibrary.TypeLibraryManager;
Expand All @@ -41,8 +42,19 @@ public Object execute(final ExecutionEvent event) throws ExecutionException {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
final TypeEntry typeEntry = getTypeEntryFromSelection(selection);
if (typeEntry != null) {
final ModelQuerySpec searchSpec = new ModelQuerySpec(typeEntry.getFullTypeName(), false, false, true, false,
false, true, SearchScope.PROJECT, typeEntry.getFile().getProject());
// @formatter:off
final ModelQuerySpec searchSpec = new ModelQuerySpec(
typeEntry.getFullTypeName(),
false,
false,
true,
false,
false,
true,
typeEntry instanceof FunctionFBTypeEntry,
SearchScope.PROJECT,
typeEntry.getFile().getProject());
// @formatter:on
final ModelSearchQuery query = createModelSearchQuery(typeEntry, searchSpec);
NewSearchUI.runQueryInBackground(query, NewSearchUI.getSearchResultView());
}
Expand Down

0 comments on commit 34839a0

Please sign in to comment.