use of org.gradle.language.nativeplatform.internal.incremental.sourceparser.SimpleExpression in project gradle by gradle.
the class DefaultSourceIncludesResolver method resolveMacro.
private void resolveMacro(MacroLookup visibleMacros, Expression expression, ExpressionVisitor visitor, TokenLookup tokenLookup) {
boolean found = false;
for (IncludeDirectives includeDirectives : visibleMacros) {
Iterable<Macro> macros = includeDirectives.getMacros(expression.getValue());
for (Macro macro : macros) {
found = true;
resolveExpression(visibleMacros, macro, visitor, tokenLookup);
}
}
if (!found) {
visitor.visitIdentifier(new SimpleExpression(expression.getValue(), IncludeType.IDENTIFIER));
}
}
use of org.gradle.language.nativeplatform.internal.incremental.sourceparser.SimpleExpression in project gradle by gradle.
the class DefaultSourceIncludesResolver method resolveTokenConcatenationToTokens.
private Collection<Expression> resolveTokenConcatenationToTokens(MacroLookup visibleMacros, Expression expression, ExpressionVisitor visitor, TokenLookup tokenLookup) {
Expression left = expression.getArguments().get(0);
Expression right = expression.getArguments().get(1);
Collection<Expression> leftValues = resolveExpressionToTokens(visibleMacros, left, visitor, tokenLookup);
Collection<Expression> rightValues = resolveExpressionToTokens(visibleMacros, right, visitor, tokenLookup);
if (leftValues.isEmpty() || rightValues.isEmpty()) {
return Collections.emptyList();
}
List<Expression> expressions = new ArrayList<Expression>(leftValues.size() * rightValues.size());
for (Expression leftValue : leftValues) {
if (leftValue.getType() != IncludeType.IDENTIFIER) {
if (rightValues.size() == 1) {
Expression rightValue = rightValues.iterator().next();
if (rightValue.getType() == IncludeType.EXPRESSIONS && rightValue.getArguments().isEmpty()) {
// Empty RHS
expressions.add(leftValue);
continue;
}
}
// Not supported for now
visitor.visitUnresolved();
continue;
}
String leftString = leftValue.getValue();
for (Expression rightValue : rightValues) {
// Handle just empty string, single identifier or '(' params? ')', should handle more by parsing the tokens into an expression
if (rightValue.getType() == IncludeType.IDENTIFIER) {
expressions.add(new SimpleExpression(leftString + rightValue.getValue(), IncludeType.IDENTIFIER));
continue;
}
if (rightValue.getType() == IncludeType.ARGS_LIST) {
expressions.add(new ComplexExpression(IncludeType.MACRO_FUNCTION, leftString, rightValue.getArguments()));
continue;
}
if (rightValue.getType() == IncludeType.EXPRESSIONS && rightValue.getArguments().isEmpty()) {
expressions.add(new SimpleExpression(leftString, IncludeType.IDENTIFIER));
continue;
}
visitor.visitUnresolved();
}
}
return expressions;
}
Aggregations