use of org.eclipse.titan.designer.AST.TTCN3.statements.Log_Statement in project titan.EclipsePlug-ins by eclipse.
the class StatementBlockContext method process_internal.
@Override
protected void process_internal() {
localVarIds = new ArrayList<Identifier>();
final Context bottom = getBottom();
final IVisitableNode bottomNode = bottom.getNode();
if (!(bottomNode instanceof Log_Statement)) {
ErrorReporter.logError("StatementBlockContext.process_internal(): Warning! Context chain bottom node is not a Log_Statement! ");
return;
}
final Log_Statement logst = (Log_Statement) bottomNode;
final Location logLoc = logst.getLocation();
//
final StatementBlock sb = getNode();
final StatementBlockVisitor vis = new StatementBlockVisitor(logLoc);
sb.accept(vis);
localVarIds.addAll(vis.getIdsFound());
}
use of org.eclipse.titan.designer.AST.TTCN3.statements.Log_Statement in project titan.EclipsePlug-ins by eclipse.
the class ChangeCreator method createTextEdit.
private TextEdit createTextEdit(final Log_Statement toEdit, final Context toAdd) {
// get insert location
final LogInsertLocationFinder vis = new LogInsertLocationFinder();
toEdit.accept(vis);
int insertOffset = vis.calculateEndOffset();
if (insertOffset < 0) {
ErrorReporter.logError("ChangeCreator.createTextEdit(): Warning! No arguments in log statement! ");
insertOffset = toEdit.getLocation().getEndOffset() - 1;
}
// find variable names that are already present in the log statement
final Set<String> varsAlreadyPresent;
final Context bottomContext = toAdd.getBottom();
if (bottomContext.getNode() instanceof Log_Statement) {
final LoggedVariableFinder vis2 = new LoggedVariableFinder();
final Log_Statement logst = (Log_Statement) bottomContext.getNode();
logst.accept(vis2);
varsAlreadyPresent = vis2.getVarsAlreadyPresent();
} else {
varsAlreadyPresent = new HashSet<String>();
}
// create inserted text
toAdd.process();
final List<String> contextInfos = toAdd.createLogParts(varsAlreadyPresent);
final int len = Math.min(contextInfos.size(), toAdd.getVarCountLimitOption());
if (len == 0) {
return null;
}
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < len; i++) {
sb.append(contextInfos.get(i));
}
// create edit from location and text
return new InsertEdit(insertOffset, sb.toString());
}
use of org.eclipse.titan.designer.AST.TTCN3.statements.Log_Statement in project titan.EclipsePlug-ins by eclipse.
the class ChangeCreator method performOnSelectionOnly.
private void performOnSelectionOnly(final Module module) {
final Location selLoc = new Location(file, textSelection.getStartLine(), textSelection.getOffset(), textSelection.getOffset() + textSelection.getLength());
final SelectionVisitor vis = new SelectionVisitor(selLoc);
module.accept(vis);
final Map<Log_Statement, Context> res = vis.getResult();
final MultiTextEdit rootEdit = new MultiTextEdit();
for (Map.Entry<Log_Statement, Context> e : res.entrySet()) {
final TextEdit edit = createTextEdit(e.getKey(), e.getValue());
if (edit != null) {
rootEdit.addChild(edit);
}
}
if (rootEdit.hasChildren()) {
change = new TextFileChange("Context logging", file);
change.setEdit(rootEdit);
}
}
use of org.eclipse.titan.designer.AST.TTCN3.statements.Log_Statement in project titan.EclipsePlug-ins by eclipse.
the class ChangeCreator method performOnWholeModule.
private void performOnWholeModule(final Module module) {
final ContextFinder vis = new ContextFinder(settings);
module.accept(vis);
final Map<Log_Statement, Context> res = vis.getResult();
final MultiTextEdit rootEdit = new MultiTextEdit();
for (Map.Entry<Log_Statement, Context> e : res.entrySet()) {
final TextEdit edit = createTextEdit(e.getKey(), e.getValue());
if (edit != null) {
rootEdit.addChild(edit);
}
}
if (rootEdit.hasChildren()) {
change = new TextFileChange("Context logging", file);
change.setEdit(rootEdit);
}
}
Aggregations