-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python parts: Compatibility fixes for 2020.2
PiperOrigin-RevId: 338496735
- Loading branch information
1 parent
6fd7565
commit bdd0f25
Showing
9 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
sdkcompat/v193/com/google/idea/sdkcompat/python/PyParserAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.google.idea.sdkcompat.python; | ||
|
||
import com.intellij.lang.PsiBuilder; | ||
import com.jetbrains.python.parsing.ParsingContext; | ||
import com.jetbrains.python.parsing.PyParser; | ||
import com.jetbrains.python.parsing.StatementParsing; | ||
import com.jetbrains.python.psi.LanguageLevel; | ||
|
||
/** Compatibility adapter for {@link PyParser}. #api201 */ | ||
public abstract class PyParserAdapter extends PyParser { | ||
|
||
/** #api201: Super method uses new interface SyntaxTreeBuilder in 2020.2 */ | ||
@Override | ||
protected ParsingContext createParsingContext( | ||
PsiBuilder builder, LanguageLevel languageLevel, StatementParsing.FUTURE futureFlag) { | ||
return createParsingContext(SyntaxTreeBuilderWrapper.wrap(builder), languageLevel, futureFlag); | ||
} | ||
|
||
protected abstract ParsingContext createParsingContext( | ||
SyntaxTreeBuilderWrapper builder, | ||
LanguageLevel languageLevel, | ||
StatementParsing.FUTURE futureFlag); | ||
} |
25 changes: 25 additions & 0 deletions
25
sdkcompat/v193/com/google/idea/sdkcompat/python/SyntaxTreeBuilderWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.google.idea.sdkcompat.python; | ||
|
||
import com.intellij.lang.PsiBuilder; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* Compatibility wrapper to support that constructor of ParsingContext uses new interface | ||
* SyntaxTreeBuilder in 2020.2. #api201 | ||
*/ | ||
public interface SyntaxTreeBuilderWrapper extends Supplier<PsiBuilder> { | ||
|
||
static SyntaxTreeBuilderWrapper wrap(PsiBuilder builder) { | ||
return () -> builder; | ||
} | ||
|
||
/** | ||
* #api201: Compatibility wrapper for marker which is represented by a new interface in 2020.2. | ||
*/ | ||
interface MarkerWrapper extends Supplier<PsiBuilder.Marker> { | ||
|
||
static MarkerWrapper wrap(PsiBuilder.Marker marker) { | ||
return () -> marker; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
sdkcompat/v201/com/google/idea/sdkcompat/python/PyParserAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.google.idea.sdkcompat.python; | ||
|
||
import com.intellij.lang.PsiBuilder; | ||
import com.jetbrains.python.parsing.ParsingContext; | ||
import com.jetbrains.python.parsing.PyParser; | ||
import com.jetbrains.python.parsing.StatementParsing; | ||
import com.jetbrains.python.psi.LanguageLevel; | ||
|
||
/** Compatibility adapter for {@link PyParser}. #api201 */ | ||
public abstract class PyParserAdapter extends PyParser { | ||
|
||
/** #api201: Super method uses new interface SyntaxTreeBuilder in 2020.2 */ | ||
@Override | ||
protected ParsingContext createParsingContext( | ||
PsiBuilder builder, LanguageLevel languageLevel, StatementParsing.FUTURE futureFlag) { | ||
return createParsingContext(SyntaxTreeBuilderWrapper.wrap(builder), languageLevel, futureFlag); | ||
} | ||
|
||
protected abstract ParsingContext createParsingContext( | ||
SyntaxTreeBuilderWrapper builder, | ||
LanguageLevel languageLevel, | ||
StatementParsing.FUTURE futureFlag); | ||
} |
25 changes: 25 additions & 0 deletions
25
sdkcompat/v201/com/google/idea/sdkcompat/python/SyntaxTreeBuilderWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.google.idea.sdkcompat.python; | ||
|
||
import com.intellij.lang.PsiBuilder; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* Compatibility wrapper to support that constructor of ParsingContext uses new interface | ||
* SyntaxTreeBuilder in 2020.2. #api201 | ||
*/ | ||
public interface SyntaxTreeBuilderWrapper extends Supplier<PsiBuilder> { | ||
|
||
static SyntaxTreeBuilderWrapper wrap(PsiBuilder builder) { | ||
return () -> builder; | ||
} | ||
|
||
/** | ||
* #api201: Compatibility wrapper for marker which is represented by a new interface in 2020.2. | ||
*/ | ||
interface MarkerWrapper extends Supplier<PsiBuilder.Marker> { | ||
|
||
static MarkerWrapper wrap(PsiBuilder.Marker marker) { | ||
return () -> marker; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
sdkcompat/v202/com/google/idea/sdkcompat/python/PyParserAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.google.idea.sdkcompat.python; | ||
|
||
import com.intellij.lang.SyntaxTreeBuilder; | ||
import com.jetbrains.python.parsing.ParsingContext; | ||
import com.jetbrains.python.parsing.PyParser; | ||
import com.jetbrains.python.parsing.StatementParsing; | ||
import com.jetbrains.python.psi.LanguageLevel; | ||
|
||
/** Compatibility adapter for {@link PyParser}. #api201 */ | ||
public abstract class PyParserAdapter extends PyParser { | ||
|
||
/** #api201: Super method uses new interface SyntaxTreeBuilder in 2020.2 */ | ||
@Override | ||
protected ParsingContext createParsingContext( | ||
SyntaxTreeBuilder builder, LanguageLevel languageLevel, StatementParsing.FUTURE futureFlag) { | ||
return createParsingContext(SyntaxTreeBuilderWrapper.wrap(builder), languageLevel, futureFlag); | ||
} | ||
|
||
protected abstract ParsingContext createParsingContext( | ||
SyntaxTreeBuilderWrapper builder, | ||
LanguageLevel languageLevel, | ||
StatementParsing.FUTURE futureFlag); | ||
} |
25 changes: 25 additions & 0 deletions
25
sdkcompat/v202/com/google/idea/sdkcompat/python/SyntaxTreeBuilderWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.google.idea.sdkcompat.python; | ||
|
||
import com.intellij.lang.SyntaxTreeBuilder; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* Compatibility wrapper to support that constructor of ParsingContext uses new interface | ||
* SyntaxTreeBuilder in 2020.2. #api201 | ||
*/ | ||
public interface SyntaxTreeBuilderWrapper extends Supplier<SyntaxTreeBuilder> { | ||
|
||
static SyntaxTreeBuilderWrapper wrap(SyntaxTreeBuilder builder) { | ||
return () -> builder; | ||
} | ||
|
||
/** | ||
* #api201: Compatibility wrapper for marker which is represented by a new interface in 2020.2. | ||
*/ | ||
interface MarkerWrapper extends Supplier<SyntaxTreeBuilder.Marker> { | ||
|
||
static MarkerWrapper wrap(SyntaxTreeBuilder.Marker marker) { | ||
return () -> marker; | ||
} | ||
} | ||
} |