From f54070028ad16ec6ea2f5fbc46ceab4ccbf915b6 Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Tue, 20 Dec 2016 18:05:31 +0300 Subject: [PATCH] Add isAsync method to PyWithStatement --- .../src/com/jetbrains/python/psi/PyWithStatement.java | 4 +++- .../jetbrains/python/psi/impl/PyWithStatementImpl.java | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/python/psi-api/src/com/jetbrains/python/psi/PyWithStatement.java b/python/psi-api/src/com/jetbrains/python/psi/PyWithStatement.java index 568c1199c1ac..4e6367ace82c 100644 --- a/python/psi-api/src/com/jetbrains/python/psi/PyWithStatement.java +++ b/python/psi-api/src/com/jetbrains/python/psi/PyWithStatement.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,4 +20,6 @@ package com.jetbrains.python.psi; */ public interface PyWithStatement extends PyStatement, PyNamedElementContainer, PyStatementListContainer { PyWithItem[] getWithItems(); + + boolean isAsync(); } diff --git a/python/src/com/jetbrains/python/psi/impl/PyWithStatementImpl.java b/python/src/com/jetbrains/python/psi/impl/PyWithStatementImpl.java index 9f12433d2a38..3e406291571b 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyWithStatementImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyWithStatementImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import com.intellij.psi.PsiNamedElement; import com.intellij.psi.tree.TokenSet; import com.intellij.psi.util.PsiTreeUtil; import com.jetbrains.python.PyElementTypes; +import com.jetbrains.python.PyTokenTypes; import com.jetbrains.python.psi.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -75,4 +76,9 @@ public class PyWithStatementImpl extends PyElementImpl implements PyWithStatemen assert statementList != null : "Statement list missing for with statement " + getText(); return statementList; } + + @Override + public boolean isAsync() { + return getNode().findChildByType(PyTokenTypes.ASYNC_KEYWORD) != null; + } }