Search in sources :

Example 46 with Reference

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());
        }
    }
}
Also used : Reference(org.eclipse.titan.designer.AST.Reference) If_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement) If_Clauses(org.eclipse.titan.designer.AST.TTCN3.statements.If_Clauses) If_Clause(org.eclipse.titan.designer.AST.TTCN3.statements.If_Clause) IVisitableNode(org.eclipse.titan.designer.AST.IVisitableNode)

Example 47 with Reference

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;
}
Also used : Reference(org.eclipse.titan.designer.AST.Reference) ArrayList(java.util.ArrayList) If_Clause(org.eclipse.titan.designer.AST.TTCN3.statements.If_Clause)

Example 48 with Reference

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;
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) Reference(org.eclipse.titan.designer.AST.Reference) Module(org.eclipse.titan.designer.AST.Module)

Example 49 with Reference

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;
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) CommonTokenFactory(org.antlr.v4.runtime.CommonTokenFactory) Pr_UnifiedReferenceParserContext(org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3Parser.Pr_UnifiedReferenceParserContext) Reference(org.eclipse.titan.designer.AST.Reference) StringReader(java.io.StringReader) StringReader(java.io.StringReader) Reader(java.io.Reader) UnbufferedCharStream(org.antlr.v4.runtime.UnbufferedCharStream) CharStream(org.antlr.v4.runtime.CharStream) UnbufferedCharStream(org.antlr.v4.runtime.UnbufferedCharStream)

Example 50 with 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;
}
Also used : IVisitableNode(org.eclipse.titan.designer.AST.IVisitableNode) Reference(org.eclipse.titan.designer.AST.Reference) Type(org.eclipse.titan.designer.AST.Type) Scope(org.eclipse.titan.codegenerator.Scope) Def_Template(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Template) TTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template) org.eclipse.titan.codegenerator.myASTVisitor(org.eclipse.titan.codegenerator.myASTVisitor) Identifier(org.eclipse.titan.designer.AST.Identifier) FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) Type(org.eclipse.titan.designer.AST.Type) FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) Identifier(org.eclipse.titan.designer.AST.Identifier) Reference(org.eclipse.titan.designer.AST.Reference) TTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template) Def_Template(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Template) TTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template)

Aggregations

Reference (org.eclipse.titan.designer.AST.Reference)88 Assignment (org.eclipse.titan.designer.AST.Assignment)48 ISubReference (org.eclipse.titan.designer.AST.ISubReference)37 IValue (org.eclipse.titan.designer.AST.IValue)26 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)23 IType (org.eclipse.titan.designer.AST.IType)23 Identifier (org.eclipse.titan.designer.AST.Identifier)22 ArrayList (java.util.ArrayList)19 Module (org.eclipse.titan.designer.AST.Module)16 ParameterisedSubReference (org.eclipse.titan.designer.AST.ParameterisedSubReference)15 Referenced_Value (org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value)13 IFile (org.eclipse.core.resources.IFile)11 Location (org.eclipse.titan.designer.AST.Location)10 ExpressionStruct (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)10 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)9 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)9 ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)9 ArraySubReference (org.eclipse.titan.designer.AST.ArraySubReference)8 Type (org.eclipse.titan.designer.AST.Type)8 BadLocationException (org.eclipse.jface.text.BadLocationException)7