use of org.eclipse.titan.designer.AST.Reference in project titan.EclipsePlug-ins by eclipse.
the class IfContext method process_internal.
protected void process_internal() {
final If_Statement st = getNode();
final If_Clauses ics = st.getIfClauses();
final Context child = getChild();
if (child != null && child.getNode().equals(ics)) {
// the log statement is in one of the conditional clauses
final List<If_Clause> icl = ics.getClauses();
final Context clauseContext = child.getChild();
if (clauseContext != null && icl.contains(clauseContext.getNode())) {
final IVisitableNode ic = clauseContext.getNode();
final ClauseVisitor vis = new ClauseVisitor();
ic.accept(vis);
final List<Reference> refs = vis.getResult();
for (Reference ref : refs) {
varNamesInConditions.add(ref.getDisplayName());
}
}
} else {
// the log statement is in the else block
final List<Reference> refs = extractAllIdsFromClauses(ics);
for (Reference ref : refs) {
varNamesInConditions.add(ref.getDisplayName());
}
}
}
use of org.eclipse.titan.designer.AST.Reference in project titan.EclipsePlug-ins by eclipse.
the class IfContext method extractAllIdsFromClauses.
private static List<Reference> extractAllIdsFromClauses(final If_Clauses ics) {
final List<If_Clause> icl = ics.getClauses();
final List<Reference> ret = new ArrayList<Reference>();
for (If_Clause ic : icl) {
final ClauseVisitor vis = new ClauseVisitor();
ic.accept(vis);
ret.addAll(vis.getResult());
}
return ret;
}
use of org.eclipse.titan.designer.AST.Reference in project titan.EclipsePlug-ins by eclipse.
the class ExternalFeatureEnvyDetector method visit.
@Override
public int visit(final IVisitableNode node) {
if (node instanceof Reference) {
final Reference reference = (Reference) node;
final Assignment assignment = reference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
if (assignment != null) {
final Module module = assignment.getMyScope().getModuleScope();
if (ownModule != module) {
count.inc();
}
}
}
return V_CONTINUE;
}
use of org.eclipse.titan.designer.AST.Reference in project titan.EclipsePlug-ins by eclipse.
the class TTCN3ReferenceAnalyzer method parse.
/**
* @return the parsed reference or null if the text can not form a reference
*/
public Reference parse(final IFile file, final String code, final boolean reportErrors, final int aLine, final int aOffset) {
Reference reference = null;
Reader reader = new StringReader(code);
CharStream charStream = new UnbufferedCharStream(reader);
Ttcn3Lexer lexer = new Ttcn3Lexer(charStream);
lexer.setTokenFactory(new CommonTokenFactory(true));
lexer.initRootInterval(code.length());
lexer.removeErrorListeners();
final CommonTokenStream tokenStream = new CommonTokenStream(lexer);
Ttcn3Parser parser = new Ttcn3Parser(tokenStream);
ParserUtilities.setBuildParseTree(parser);
lexer.setActualFile(file);
parser.setActualFile(file);
parser.setProject(file.getProject());
parser.setLine(aLine);
parser.setOffset(aOffset);
parser.removeErrorListeners();
final Pr_UnifiedReferenceParserContext root = parser.pr_UnifiedReferenceParser();
ParserUtilities.logParseTree(root, parser);
reference = root.reference;
return reference;
}
use of org.eclipse.titan.designer.AST.Reference in project titan.EclipsePlug-ins by eclipse.
the class TemplateParser method process.
@Override
public Scope process(IVisitableNode node) {
if (node instanceof Identifier) {
name = node.toString();
// TODO : find a more sophisticated way of storing symbols (e.g. SymbolTable)
myASTVisitor.nodeNameNodeTypeHashMap.put(name, "template");
}
if (node instanceof Type) {
type = Util.getTypeName((Type) node);
template = new Template(name, type);
return Action.skip(Type.class, this);
}
if (node instanceof FormalParameterList) {
return new FormalParameterParser(this, template);
}
// is a modification
if (node instanceof Reference) {
Reference reference = (Reference) node;
String basename = reference.getId().toString();
Template base = registry.find(basename);
// TODO : templates need a base value as a fallback
// TODO : this base value should be used as a reference, to diff against
// TODO : this was a hotfix for the union types to work
String type = base.getValue().getType();
template.setValue(new Value(type, (code, indent) -> code.append("(", type, ") ").append(basename, "()")));
isModification = true;
return Action.skip(Reference.class, this);
}
if (node instanceof TTCN3Template) {
if (isModification) {
return ModificationParser.getScope(this, template, "", type, node);
}
return TemplateValueParser.getScope(this, template, type, node);
}
return this;
}
Aggregations