Skip to content

Commit

Permalink
Some more minor parser fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Oct 5, 2023
1 parent b4887f7 commit fdb38c7
Showing 1 changed file with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@
import org.jetbrains.kotlin.fir.ClassMembersKt;
import org.jetbrains.kotlin.fir.FirElement;
import org.jetbrains.kotlin.fir.FirSession;
import org.jetbrains.kotlin.fir.declarations.*;
import org.jetbrains.kotlin.fir.declarations.FirFile;
import org.jetbrains.kotlin.fir.declarations.FirFunction;
import org.jetbrains.kotlin.fir.declarations.FirResolvedImport;
import org.jetbrains.kotlin.fir.declarations.FirVariable;
import org.jetbrains.kotlin.fir.expressions.FirConstExpression;
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall;
import org.jetbrains.kotlin.fir.resolve.LookupTagUtilsKt;
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag;
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol;
import org.jetbrains.kotlin.fir.symbols.impl.*;
import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousObjectSymbol;
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol;
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol;
import org.jetbrains.kotlin.fir.types.ConeClassLikeType;
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef;
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken;
Expand All @@ -56,7 +61,10 @@

import java.nio.charset.Charset;
import java.nio.file.Path;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
Expand Down Expand Up @@ -429,13 +437,13 @@ public J visitPropertyAccessor(KtPropertyAccessor accessor, ExecutionContext dat
new J.MethodDeclaration.IdentifierWithAnnotations(
name,
lastAnnotations
),
),
params,
null,
body,
null,
methodDeclarationType(accessor)
);
);
}

@Override
Expand All @@ -455,7 +463,10 @@ public J visitReturnExpression(KtReturnExpression expression, ExecutionContext d
throw new UnsupportedOperationException("TODO");
}

Expression returnExpr = convertToExpression(expression.getReturnedExpression().accept(this, data).withPrefix(prefix(expression.getReturnedExpression())));
KtExpression returnedExpression = expression.getReturnedExpression();
Expression returnExpr = returnedExpression != null ?
convertToExpression(returnedExpression.accept(this, data).withPrefix(prefix(returnedExpression))) :
null;
return new K.KReturn(
randomId(),
new J.Return(
Expand Down Expand Up @@ -845,7 +856,7 @@ public J visitCallExpression(KtCallExpression expression, ExecutionContext data)
}

if (expressions.isEmpty()) {
expressions.add(padRight(new J.Empty(randomId(), prefix(expression.getValueArgumentList().getRightParenthesis()), Markers.EMPTY), Space.EMPTY));
expressions.add(padRight(new J.Empty(randomId(), prefix(expression.getValueArgumentList().getRightParenthesis()), Markers.EMPTY), Space.EMPTY));
}

JContainer<Expression> args = JContainer.build(prefix(expression.getValueArgumentList()), expressions, markers);
Expand Down Expand Up @@ -1263,7 +1274,6 @@ public J visitNamedFunction(KtNamedFunction function, ExecutionContext data) {
);



if (function.getNameIdentifier() == null) {
throw new UnsupportedOperationException("TODO");
}
Expand Down Expand Up @@ -1663,6 +1673,8 @@ else if (elementType == KtTokens.MUL)
return J.Binary.Type.Multiplication;
else if (elementType == KtTokens.DIV)
return J.Binary.Type.Division;
else if (elementType == KtTokens.EQEQ)
return J.Binary.Type.Equal; // TODO should this not be mapped to `Object#equals(Object)`?
else
return null;
}
Expand Down

0 comments on commit fdb38c7

Please sign in to comment.