More consistent API in psi
This commit is contained in:
@@ -492,7 +492,7 @@ public class PositioningStrategies {
|
|||||||
if (valueParameterList != null) {
|
if (valueParameterList != null) {
|
||||||
return markElement(valueParameterList);
|
return markElement(valueParameterList);
|
||||||
}
|
}
|
||||||
return markNode(functionLiteral.getOpenBraceNode());
|
return markNode(functionLiteral.getLBrace().getNode());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -53,14 +53,14 @@ public class JetFunctionLiteral extends JetFunctionNotStubbed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ASTNode getOpenBraceNode() {
|
public PsiElement getLBrace() {
|
||||||
return getNode().findChildByType(JetTokens.LBRACE);
|
return findChildByType(JetTokens.LBRACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@IfNotParsed
|
@IfNotParsed
|
||||||
public ASTNode getClosingBraceNode() {
|
public PsiElement getRBrace() {
|
||||||
return getNode().findChildByType(JetTokens.RBRACE);
|
return findChildByType(JetTokens.RBRACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
+4
-4
@@ -54,10 +54,10 @@ class SoftKeywordsHighlightingVisitor extends HighlightingVisitor {
|
|||||||
public void visitFunctionLiteralExpression(@NotNull JetFunctionLiteralExpression expression) {
|
public void visitFunctionLiteralExpression(@NotNull JetFunctionLiteralExpression expression) {
|
||||||
if (ApplicationManager.getApplication().isUnitTestMode()) return;
|
if (ApplicationManager.getApplication().isUnitTestMode()) return;
|
||||||
JetFunctionLiteral functionLiteral = expression.getFunctionLiteral();
|
JetFunctionLiteral functionLiteral = expression.getFunctionLiteral();
|
||||||
holder.createInfoAnnotation(functionLiteral.getOpenBraceNode(), null).setTextAttributes(JetHighlightingColors.FUNCTION_LITERAL_BRACES_AND_ARROW);
|
holder.createInfoAnnotation(functionLiteral.getLBrace(), null).setTextAttributes(JetHighlightingColors.FUNCTION_LITERAL_BRACES_AND_ARROW);
|
||||||
ASTNode closingBraceNode = functionLiteral.getClosingBraceNode();
|
PsiElement closingBrace = functionLiteral.getRBrace();
|
||||||
if (closingBraceNode != null) {
|
if (closingBrace != null) {
|
||||||
holder.createInfoAnnotation(closingBraceNode, null).setTextAttributes(JetHighlightingColors.FUNCTION_LITERAL_BRACES_AND_ARROW);
|
holder.createInfoAnnotation(closingBrace, null).setTextAttributes(JetHighlightingColors.FUNCTION_LITERAL_BRACES_AND_ARROW);
|
||||||
}
|
}
|
||||||
ASTNode arrowNode = functionLiteral.getArrowNode();
|
ASTNode arrowNode = functionLiteral.getArrowNode();
|
||||||
if (arrowNode != null) {
|
if (arrowNode != null) {
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ public class KotlinCompletionContributor : CompletionContributor() {
|
|||||||
}
|
}
|
||||||
if (prev?.getNode()?.getElementType() != JetTokens.LBRACE) return false
|
if (prev?.getNode()?.getElementType() != JetTokens.LBRACE) return false
|
||||||
val functionLiteral = prev!!.getParent() as? JetFunctionLiteral ?: return false
|
val functionLiteral = prev!!.getParent() as? JetFunctionLiteral ?: return false
|
||||||
return functionLiteral.getOpenBraceNode().getPsi() == prev
|
return functionLiteral.getLBrace() == prev
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isAtEndOfLine(offset: Int, document: Document): Boolean {
|
private fun isAtEndOfLine(offset: Int, document: Document): Boolean {
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class MakeTypeExplicitInLambdaIntention : JetSelfTargetingIntention<JetFu
|
|||||||
oldParameterList.replace(newParameterList)
|
oldParameterList.replace(newParameterList)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val openBraceElement = functionLiteral.getOpenBraceNode().getPsi()
|
val openBraceElement = functionLiteral.getLBrace()
|
||||||
val nextSibling = openBraceElement?.getNextSibling()
|
val nextSibling = openBraceElement?.getNextSibling()
|
||||||
val addNewline = nextSibling is PsiWhiteSpace && nextSibling.getText()?.contains("\n") ?: false
|
val addNewline = nextSibling is PsiWhiteSpace && nextSibling.getText()?.contains("\n") ?: false
|
||||||
val (whitespace, arrow) = psiFactory.createWhitespaceAndArrow()
|
val (whitespace, arrow) = psiFactory.createWhitespaceAndArrow()
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class MakeTypeImplicitInLambdaIntention : JetSelfTargetingIntention<JetFu
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hasExplicitReceiverType(element)) {
|
if (hasExplicitReceiverType(element)) {
|
||||||
val childAfterBrace = functionLiteral.getOpenBraceNode().getPsi()?.getNextSibling()
|
val childAfterBrace = functionLiteral.getLBrace()?.getNextSibling()
|
||||||
val childBeforeParamList = oldParameterList?.getPrevSibling()
|
val childBeforeParamList = oldParameterList?.getPrevSibling()
|
||||||
functionLiteral.deleteChildRange(childAfterBrace, childBeforeParamList)
|
functionLiteral.deleteChildRange(childAfterBrace, childBeforeParamList)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@ public class ReplaceItWithExplicitFunctionLiteralParamIntention() : PsiElementBa
|
|||||||
val newExpr = JetPsiFactory(simpleNameExpression).createExpression("{ it -> 42 }") as JetFunctionLiteralExpression
|
val newExpr = JetPsiFactory(simpleNameExpression).createExpression("{ it -> 42 }") as JetFunctionLiteralExpression
|
||||||
funcExpr.addRangeAfter(newExpr.getFunctionLiteral().getValueParameterList(),
|
funcExpr.addRangeAfter(newExpr.getFunctionLiteral().getValueParameterList(),
|
||||||
newExpr.getFunctionLiteral().getArrowNode()!!.getPsi(),
|
newExpr.getFunctionLiteral().getArrowNode()!!.getPsi(),
|
||||||
funcExpr.getOpenBraceNode().getPsi())
|
funcExpr.getLBrace())
|
||||||
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.getDocument())
|
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.getDocument())
|
||||||
|
|
||||||
val paramToRename = funcExpr.getValueParameters().first()
|
val paramToRename = funcExpr.getValueParameters().first()
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ import org.jetbrains.jet.plugin.codeInsight.ShortenReferences;
|
|||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
||||||
import org.jetbrains.jet.plugin.project.ResolveSessionForBodies;
|
import org.jetbrains.jet.plugin.project.ResolveSessionForBodies;
|
||||||
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers;
|
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers;
|
||||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -282,7 +281,7 @@ public class KotlinInlineValHandler extends InlineActionHandler {
|
|||||||
currentParameterList.replace(newParameterList);
|
currentParameterList.replace(newParameterList);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PsiElement openBraceElement = functionLiteral.getOpenBraceNode().getPsi();
|
PsiElement openBraceElement = functionLiteral.getLBrace();
|
||||||
|
|
||||||
PsiElement nextSibling = openBraceElement.getNextSibling();
|
PsiElement nextSibling = openBraceElement.getNextSibling();
|
||||||
PsiElement whitespaceToAdd = nextSibling instanceof PsiWhiteSpace && nextSibling.getText().contains("\n")
|
PsiElement whitespaceToAdd = nextSibling instanceof PsiWhiteSpace && nextSibling.getText().contains("\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user