Commit d29691db authored by Richárd Koch-Gömöri's avatar Richárd Koch-Gömöri
Browse files

Add Find Function Calls function to TTCN3 editor


Signed-off-by: default avatarRichárd Koch-Gömöri <kgomori.richard@gmail.com>
parent 6452528b
......@@ -122,15 +122,20 @@
id="org.eclipse.titan.designer.editors.ttcn3editor.FindReferences"
name="Find References">
</command>
<command
defaultHandler="org.eclipse.titan.designer.editors.ttcn3editor.actions.FindFunctionCalls"
id="org.eclipse.titan.designer.editors.ttcn3editor.FindFunctionCalls"
name="Find Function Calls">
</command>
<command
defaultHandler="org.eclipse.titan.designer.editors.asn1editor.actions.OpenDeclaration"
id="org.eclipse.titan.designer.editors.asn1editor.OpenDeclaration"
name="Open Declaration">
</command>
<command
defaultHandler="org.eclipse.titan.designer.editors.asn1editor.actions.FindReferences"
id="org.eclipse.titan.designer.editors.asn1editor.FindReferences"
name="Find References">
defaultHandler="org.eclipse.titan.designer.editors.asn1editor.actions.FindFunctionCalls"
id="org.eclipse.titan.designer.editors.asn1editor.FindFunctionCalls"
name="Find Function Calls">
</command>
<command
defaultHandler="org.eclipse.titan.designer.editors.asn1editor.actions.RenameRefactoringAction"
......@@ -526,6 +531,12 @@
id="org.eclipse.titan.designer.editors.ttcn3editor.FindReferences"
label="Find References">
</command>
<command
commandId="org.eclipse.titan.designer.editors.ttcn3editor.FindFunctionCalls"
icon="icons/titan.gif"
id="org.eclipse.titan.designer.editors.ttcn3editor.FindFunctionCalls"
label="Find Function Calls">
</command>
<command
commandId="org.eclipse.titan.designer.editors.ttcn3editor.RenameRefactoringAction"
icon="icons/titan.gif"
......@@ -948,6 +959,14 @@
description="Finds references to a declaration/assignment"
id="org.eclipse.titan.designer.editors.ttcn3editor.FindReferences"
name="Find References" />
<command categoryId="org.eclipse.titan.designer.editors.TITANCommands"
description="Finds references to a declaration/assignment"
id="org.eclipse.titan.designer.editors.ttcn3editor.FindFunctionCalls"
name="Find Function Calls" />
<command categoryId="org.eclipse.titan.designer.editors.TITANCommands"
description="Finds function calls"
id="org.eclipse.titan.designer.editors.ttcn3editor.FindFunctionCalls"
name="Find Function Calls" />
<command categoryId="org.eclipse.titan.designer.editors.TITANCommands"
description="Rename refactoring"
id="org.eclipse.titan.designer.editors.ttcn3editor.RenameRefactoring"
......@@ -1045,6 +1064,10 @@
contextId="org.eclipse.titan.designer.editors.TTCN3EditorScope"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="F4" />
<key commandId="org.eclipse.titan.designer.editors.ttcn3editor.FindFunctionCalls"
contextId="org.eclipse.titan.designer.editors.TTCN3EditorScope"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="F5" />
<key
commandId="org.eclipse.titan.designer.editors.ttcn3editor.RenameRefactoringAction"
contextId="org.eclipse.titan.designer.editors.TTCN3EditorScope"
......
......@@ -11,6 +11,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
......@@ -119,7 +120,7 @@ public final class ReferenceFinder {
}
public boolean detectAssignmentDataByOffset(final Module module, final int offset, final IEditorPart targetEditor,
final boolean reportErrors, final boolean reportDebugInformation) {
final boolean reportErrors, final boolean reportDebugInformation, final Set<Assignment_type> filterAssignmentType) {
// detect the scope we are in
scope = module.getSmallestEnclosingScope(offset);
if (scope == null) {
......@@ -161,6 +162,12 @@ public final class ReferenceFinder {
}
}
if (filterAssignmentType != null) {
if (!filterAssignmentType.contains(assignment.getAssignmentType())) {
return false;
}
}
// if it is a type assignment/definition then detect if we are
// in a field
if (assignment.getAssignmentType() == Assignment_type.A_TYPE) {
......
......@@ -381,7 +381,7 @@ public abstract class OccurencesMarker {
// Check if the reference points to a field of a type
// definition
referenceFinder = new ReferenceFinder();
referenceFinder.detectAssignmentDataByOffset(module, offset, editor, false, false);
referenceFinder.detectAssignmentDataByOffset(module, offset, editor, false, false, null);
final Assignment assignment = referenceFinder.assignment;
if (assignment == null) {
......
......@@ -31,7 +31,7 @@ public class FindReferences extends AbstractHandler implements IEditorActionDele
if (targetEditor == null || !(targetEditor instanceof ASN1Editor)) {
return;
}
ReferenceSearch.runAction(targetEditor, selection);
ReferenceSearch.runAction(targetEditor, selection, null);
}
@Override
......@@ -51,7 +51,7 @@ public class FindReferences extends AbstractHandler implements IEditorActionDele
if (targetEditor == null || !(targetEditor instanceof ASN1Editor)) {
return null;
}
ReferenceSearch.runAction(targetEditor, selection);
ReferenceSearch.runAction(targetEditor, selection, null);
return null;
}
}
......@@ -8,6 +8,7 @@
package org.eclipse.titan.designer.editors.referenceSearch;
import java.text.MessageFormat;
import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Platform;
......@@ -16,6 +17,7 @@ import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.search.ui.ISearchQuery;
import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.titan.designer.AST.Assignment.Assignment_type;
import org.eclipse.titan.designer.AST.Module;
import org.eclipse.titan.designer.AST.ReferenceFinder;
import org.eclipse.titan.designer.commonFilters.ResourceExclusionHelper;
......@@ -45,7 +47,7 @@ public final class ReferenceSearch {
* Helper function used by FindReferences classes for TTCN-3, ASN.1 and
* TTCNPP editors
*/
public static void runAction(final IEditorPart targetEditor, final ISelection selection) {
public static void runAction(final IEditorPart targetEditor, final ISelection selection, final Set<Assignment_type> filterAssignmentType) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(null);
final IFile file = (IFile) targetEditor.getEditorInput().getAdapter(IFile.class);
......@@ -90,7 +92,7 @@ public final class ReferenceSearch {
}
final ReferenceFinder rf = new ReferenceFinder();
final boolean isDetected = rf.detectAssignmentDataByOffset(module, offset, targetEditor, true, reportDebugInformation);
final boolean isDetected = rf.detectAssignmentDataByOffset(module, offset, targetEditor, true, reportDebugInformation, filterAssignmentType);
if (!isDetected) {
return;
}
......
/******************************************************************************
* Copyright (c) 2000-2018 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
******************************************************************************/
package org.eclipse.titan.designer.editors.ttcn3editor.actions;
import java.util.HashSet;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.titan.designer.AST.Assignment.Assignment_type;
import org.eclipse.titan.designer.consoles.TITANDebugConsole;
import org.eclipse.titan.designer.editors.referenceSearch.ReferenceSearch;
import org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor;
import org.eclipse.ui.IEditorActionDelegate;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
/**
* @author Richárd Koch-Gömöri
* */
public final class FindFunctionCalls extends AbstractHandler implements IEditorActionDelegate {
private IEditorPart targetEditor = null;
private ISelection selection = TextSelection.emptySelection();
@Override
public void run(final IAction action) {
if (targetEditor == null || !(targetEditor instanceof TTCN3Editor)) {
return;
}
HashSet<Assignment_type> functionAssignmentType = new HashSet<>();
functionAssignmentType.add(Assignment_type.A_FUNCTION);
functionAssignmentType.add(Assignment_type.A_FUNCTION_RVAL);
functionAssignmentType.add(Assignment_type.A_FUNCTION_RTEMP);
functionAssignmentType.add(Assignment_type.A_EXT_FUNCTION);
functionAssignmentType.add(Assignment_type.A_EXT_FUNCTION_RVAL);
functionAssignmentType.add(Assignment_type.A_EXT_FUNCTION_RTEMP);
ReferenceSearch.runAction(targetEditor, selection, functionAssignmentType);
}
@Override
public void selectionChanged(final IAction action, final ISelection selection) {
this.selection = selection;
}
@Override
public void setActiveEditor(final IAction action, final IEditorPart targetEditor) {
this.targetEditor = targetEditor;
}
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
targetEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (targetEditor == null || !(targetEditor instanceof TTCN3Editor)) {
return null;
}
HashSet<Assignment_type> functionAssignmentType = new HashSet<>();
functionAssignmentType.add(Assignment_type.A_FUNCTION);
functionAssignmentType.add(Assignment_type.A_FUNCTION_RVAL);
functionAssignmentType.add(Assignment_type.A_FUNCTION_RTEMP);
functionAssignmentType.add(Assignment_type.A_EXT_FUNCTION);
functionAssignmentType.add(Assignment_type.A_EXT_FUNCTION_RVAL);
functionAssignmentType.add(Assignment_type.A_EXT_FUNCTION_RTEMP);
ReferenceSearch.runAction(targetEditor, selection, functionAssignmentType);
return null;
}
}
......@@ -31,7 +31,7 @@ public final class FindReferences extends AbstractHandler implements IEditorActi
if (targetEditor == null || !(targetEditor instanceof TTCN3Editor)) {
return;
}
ReferenceSearch.runAction(targetEditor, selection);
ReferenceSearch.runAction(targetEditor, selection, null);
}
@Override
......@@ -51,7 +51,7 @@ public final class FindReferences extends AbstractHandler implements IEditorActi
if (targetEditor == null || !(targetEditor instanceof TTCN3Editor)) {
return null;
}
ReferenceSearch.runAction(targetEditor, selection);
ReferenceSearch.runAction(targetEditor, selection, null);
return null;
}
......
......@@ -31,7 +31,7 @@ public final class FindReferences extends AbstractHandler implements IEditorActi
if (targetEditor == null || !(targetEditor instanceof TTCNPPEditor)) {
return;
}
ReferenceSearch.runAction(targetEditor, selection);
ReferenceSearch.runAction(targetEditor, selection, null);
}
@Override
......@@ -51,7 +51,7 @@ public final class FindReferences extends AbstractHandler implements IEditorActi
if (targetEditor == null || !(targetEditor instanceof TTCNPPEditor)) {
return null;
}
ReferenceSearch.runAction(targetEditor, selection);
ReferenceSearch.runAction(targetEditor, selection, null);
return null;
}
......
......@@ -419,7 +419,7 @@ public class RenameRefactoring extends Refactoring {
if (rf == null) {
rf = new ReferenceFinder();
boolean isDetected = rf.detectAssignmentDataByOffset(module, offset, targetEditor, true, reportDebugInformation);
boolean isDetected = rf.detectAssignmentDataByOffset(module, offset, targetEditor, true, reportDebugInformation, null);
if (!isDetected) {
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment