Commit b9d67b60 authored by Arpad Lovassy's avatar Arpad Lovassy
Browse files

Code completion for execute


Signed-off-by: Arpad Lovassy's avatarzlovarp <arpad.lovassy@semcon.com>
parent 21255669
......@@ -40,10 +40,11 @@ public class CompletionFinder {
private static final String COMPONENT = "(system|mtc|runs[\\s]+on)((\\s+" + IDENTIFIER + "$)|\\s*)";
private static final String PARAMETER = "\\s*\\(([^)]*$)";
private static final String SETVERDICT = "setverdict" + PARAMETER;
private static final String EXECUTE = "execute" + PARAMETER;
private static final String PARAMETERIZED = IDENTIFIER + PARAMETER;
private enum SpecialContext { None, SimpleComment, DocComment, StringLiteral }
private enum ContextType { Assignment, Component, Doccomment, Friend, Import, Setverdict, Parameterized }
private enum ContextType { Assignment, Component, Doccomment, Friend, Import, Setverdict, Execute, Parameterized }
private IEditorPart editor;
private Module module;
......@@ -66,6 +67,7 @@ public class CompletionFinder {
contextMap.put(Pattern.compile(IMPORT), ContextType.Import);
contextMap.put(Pattern.compile(FRIEND), ContextType.Friend);
contextMap.put(Pattern.compile(SETVERDICT), ContextType.Setverdict);
contextMap.put(Pattern.compile(EXECUTE), ContextType.Execute);
contextMap.put(Pattern.compile(PARAMETERIZED), ContextType.Parameterized);
}
......@@ -181,6 +183,8 @@ public class CompletionFinder {
return new ImportContext(info);
case Setverdict:
return new SetverdictContext(info);
case Execute:
return new ExecuteContext(info);
case Parameterized:
return new ParameterizedContext(info);
default:
......
/******************************************************************************
* Copyright (c) 2000-2022 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.contentassist;
import java.util.Map;
import java.util.regex.Matcher;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.titan.designer.AST.IType.Type_type;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Definition;
import org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module;
import org.eclipse.titan.designer.editors.CompletionProposal;
import org.eclipse.titan.designer.editors.ProposalCollector;
import org.eclipse.titan.designer.editors.Stylers;
import org.eclipse.titan.designer.graphics.ImageCache;
import org.eclipse.titan.designer.parsers.CompilationTimeStamp;
/**
* Collects proposals for execute parameter
*
* @author Arpad Lovassy
*
*/
public class ExecuteContext extends ProposalContext {
public ExecuteContext(ProposalContextInfo proposalContextInfo) {
super(proposalContextInfo);
doFallback = false;
}
@Override
public void getProposals(ProposalCollector propCollector) {
final Matcher matcher = proposalContextInfo.matcher;
final String id = matcher.group(1);
final String[] existingPars = matcher.group(1).split(",");
final int actualPar = existingPars.length;
if (proposalContextInfo.module instanceof TTCN3Module) {
TTCN3Module ttcn3module = (TTCN3Module)proposalContextInfo.module;
final CompilationTimeStamp timestamp = proposalContextInfo.module.getLastCompilationTimeStamp();
Map<String, Definition> defs = ttcn3module.getDefinitions().getDefinitionMap();
for (Definition def : defs.values()) {
if (def instanceof Def_Testcase) {
Def_Testcase tc = (Def_Testcase) def;
final String tcname = tc.getGenName();
final String prefix = "";
final int replacementOffset = proposalContextInfo.offset - prefix.length();
final int replacementLength = prefix.length();
final CompletionProposal tcProposal = new CompletionProposal(tcname, replacementOffset, replacementLength,
tcname.length(), ImageCache.getImageByType(Type_type.TYPE_TESTCASE), new StyledString(tcname, new Stylers.ItalicStyler()),
null, null, tcname.toLowerCase().startsWith(prefix.toLowerCase()) ? HIGHEST | PREFIX_MATCHES : TYPE_MATCHES);
propCollector.addProposal(tcProposal);
}
}
}
}
}
......@@ -260,6 +260,7 @@ public abstract class ProposalContext {
case TYPE_OCTETSTRING:
case TYPE_REAL:
case TYPE_UCHARSTRING:
case TYPE_TESTCASE:
addItems(ttype, propCollector, excludeName, replacementLength, replacementLength, prefix);
break;
case TYPE_VERDICT:
......
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