Example usage for org.eclipse.jdt.internal.compiler.parser Parser problemReporter

List of usage examples for org.eclipse.jdt.internal.compiler.parser Parser problemReporter

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.parser Parser problemReporter.

Prototype

ProblemReporter problemReporter

To view the source code for org.eclipse.jdt.internal.compiler.parser Parser problemReporter.

Click Source Link

Usage

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.AbstractMethodMappingDeclaration.java

License:Open Source License

/**
 * After parameter mappings are parsed perform AST-based analysis in order to
 * create the two arrays positions and mappingExpressions.
 *//*  w  ww .  ja  v  a2 s  .  co  m*/
@SuppressWarnings("unchecked") // array of generic (Pair<Expression,Integer>[]) cannot be specified :(
public void analyzeParameterMappings(Parser parser) {
    if (this.mappings != null) {
        for (ParameterMapping mapping : this.mappings)
            if (mapping.direction == TerminalTokens.TokenNameBINDIN) // ident <- expr
                mapping.expression.traverse(new BaseScopeMarker(), this.scope);

        // check 4.4(c) - sentence 2:
        if (isCallin() && !isReplaceCallin())
            for (ParameterMapping mapping : this.mappings)
                if (mapping.direction == TerminalTokens.TokenNameBINDOUT) // expr -> ident
                    parser.problemReporter().illegalBindingDirectionNonReplaceCallin(mapping);

        { // prepare positions:
            MethodSpec targetSpec = isCallin() ? this.roleMethodSpec
                    : ((CalloutMappingDeclaration) this).baseMethodSpec;
            Argument[] targetArguments = targetSpec.arguments;
            this.positions = targetArguments != null ? new int[targetArguments.length] : new int[0];
            Arrays.fill(this.positions, -1); // mark as invalid
        }

        { // compute mappingExpressions:
            MethodSpec implementationMethodSpec = getImplementationMethodSpec();
            int implParamsLength = 0;
            if (implementationMethodSpec.arguments != null)
                implParamsLength = implementationMethodSpec.arguments.length;
            this.mappingExpressions = new Pair[implParamsLength];

            MethodSpec sourceSpec = isCallin() ? getBaseMethodSpecs()[0] : this.roleMethodSpec;
            for (int idx = 0; idx < implParamsLength; idx++) {
                char[] targetArgName = implementationMethodSpec.arguments[idx].name;
                Pair<Expression, Integer> mapper = getMappedArgument(sourceSpec, idx, targetArgName);
                this.mappingExpressions[idx] = mapper;
            }
        }
        if (isCallin()) {
            MethodSpec[] allSpecs = getBaseMethodSpecs();
            if (allSpecs.length > 1) {
                // FIXME(SH): check equal arguments
            }
        }
    }
}