-
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
0c09572
commit 0815044
Showing
12 changed files
with
263 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
32 changes: 32 additions & 0 deletions
32
sdkcompat/v193/com/google/idea/sdkcompat/python/FunctionParsingCompat.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,32 @@ | ||
package com.google.idea.sdkcompat.python; | ||
|
||
import com.intellij.lang.PsiBuilder; | ||
import com.intellij.lang.PsiBuilder.Marker; | ||
import com.intellij.psi.tree.IElementType; | ||
import com.jetbrains.python.parsing.FunctionParsing; | ||
import com.jetbrains.python.parsing.ParsingContext; | ||
|
||
/** #api201: Compat class for {@link FunctionParsing}. */ | ||
public class FunctionParsingCompat extends FunctionParsing { | ||
|
||
public FunctionParsingCompat(ParsingContext context) { | ||
super(context); | ||
} | ||
|
||
protected MarkerCompat getMarker() { | ||
return new MarkerCompat(myBuilder.mark()); | ||
} | ||
|
||
/** #api201: Compat class for marker which is represented by a new interface in 2020.2. */ | ||
protected static class MarkerCompat { | ||
private final PsiBuilder.Marker marker; | ||
|
||
private MarkerCompat(Marker marker) { | ||
this.marker = marker; | ||
} | ||
|
||
public void done(IElementType type) { | ||
marker.done(type); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
sdkcompat/v193/com/google/idea/sdkcompat/python/PythonParserDefinitionCompat.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,33 @@ | ||
package com.google.idea.sdkcompat.python; | ||
|
||
import com.intellij.lang.PsiBuilder; | ||
import com.intellij.lang.PsiParser; | ||
import com.intellij.openapi.project.Project; | ||
import com.jetbrains.python.PythonParserDefinition; | ||
import com.jetbrains.python.parsing.ParsingContext; | ||
import com.jetbrains.python.parsing.PyParser; | ||
import com.jetbrains.python.parsing.StatementParsing; | ||
import com.jetbrains.python.psi.LanguageLevel; | ||
|
||
/** Compat class for {@link PythonParserDefinition}. #api201 */ | ||
public abstract class PythonParserDefinitionCompat extends PythonParserDefinition { | ||
|
||
protected abstract ParsingContext createCustomParsingContext( | ||
Project project, | ||
SyntaxTreeBuilderCompat builderCompat, | ||
LanguageLevel languageLevel, | ||
StatementParsing.FUTURE futureFlag); | ||
|
||
@Override | ||
public PsiParser createParser(Project project) { | ||
return new PyParser() { | ||
/** #api201: Super method uses new interface SyntaxTreeBuilder in 2020.2 */ | ||
@Override | ||
protected ParsingContext createParsingContext( | ||
PsiBuilder builder, LanguageLevel languageLevel, StatementParsing.FUTURE futureFlag) { | ||
return createCustomParsingContext( | ||
project, new SyntaxTreeBuilderCompat(builder), languageLevel, futureFlag); | ||
} | ||
}; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
sdkcompat/v193/com/google/idea/sdkcompat/python/SyntaxTreeBuilderCompat.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,20 @@ | ||
package com.google.idea.sdkcompat.python; | ||
|
||
import com.intellij.lang.PsiBuilder; | ||
|
||
/** | ||
* Compat class to support that constructor of ParsingContext uses new interface SyntaxTreeBuilder | ||
* in 2020.2. #api201 | ||
*/ | ||
public class SyntaxTreeBuilderCompat { | ||
|
||
private final PsiBuilder builder; | ||
|
||
public SyntaxTreeBuilderCompat(PsiBuilder builder) { | ||
this.builder = builder; | ||
} | ||
|
||
public PsiBuilder getBuilder() { | ||
return builder; | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
sdkcompat/v201/com/google/idea/sdkcompat/python/FunctionParsingCompat.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,32 @@ | ||
package com.google.idea.sdkcompat.python; | ||
|
||
import com.intellij.lang.PsiBuilder; | ||
import com.intellij.lang.PsiBuilder.Marker; | ||
import com.intellij.psi.tree.IElementType; | ||
import com.jetbrains.python.parsing.FunctionParsing; | ||
import com.jetbrains.python.parsing.ParsingContext; | ||
|
||
/** #api201: Compat class for {@link FunctionParsing}. */ | ||
public class FunctionParsingCompat extends FunctionParsing { | ||
|
||
public FunctionParsingCompat(ParsingContext context) { | ||
super(context); | ||
} | ||
|
||
protected MarkerCompat getMarker() { | ||
return new MarkerCompat(myBuilder.mark()); | ||
} | ||
|
||
/** #api201: Compat class for marker which is represented by a new interface in 2020.2. */ | ||
protected static class MarkerCompat { | ||
private final PsiBuilder.Marker marker; | ||
|
||
private MarkerCompat(Marker marker) { | ||
this.marker = marker; | ||
} | ||
|
||
public void done(IElementType type) { | ||
marker.done(type); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
sdkcompat/v201/com/google/idea/sdkcompat/python/PythonParserDefinitionCompat.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,33 @@ | ||
package com.google.idea.sdkcompat.python; | ||
|
||
import com.intellij.lang.PsiBuilder; | ||
import com.intellij.lang.PsiParser; | ||
import com.intellij.openapi.project.Project; | ||
import com.jetbrains.python.PythonParserDefinition; | ||
import com.jetbrains.python.parsing.ParsingContext; | ||
import com.jetbrains.python.parsing.PyParser; | ||
import com.jetbrains.python.parsing.StatementParsing; | ||
import com.jetbrains.python.psi.LanguageLevel; | ||
|
||
/** Compat class for {@link PythonParserDefinition}. #api201 */ | ||
public abstract class PythonParserDefinitionCompat extends PythonParserDefinition { | ||
|
||
protected abstract ParsingContext createCustomParsingContext( | ||
Project project, | ||
SyntaxTreeBuilderCompat builderCompat, | ||
LanguageLevel languageLevel, | ||
StatementParsing.FUTURE futureFlag); | ||
|
||
@Override | ||
public PsiParser createParser(Project project) { | ||
return new PyParser() { | ||
/** #api201: Super method uses new interface SyntaxTreeBuilder in 2020.2 */ | ||
@Override | ||
protected ParsingContext createParsingContext( | ||
PsiBuilder builder, LanguageLevel languageLevel, StatementParsing.FUTURE futureFlag) { | ||
return createCustomParsingContext( | ||
project, new SyntaxTreeBuilderCompat(builder), languageLevel, futureFlag); | ||
} | ||
}; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
sdkcompat/v201/com/google/idea/sdkcompat/python/SyntaxTreeBuilderCompat.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,20 @@ | ||
package com.google.idea.sdkcompat.python; | ||
|
||
import com.intellij.lang.PsiBuilder; | ||
|
||
/** | ||
* Compat class to support that constructor of ParsingContext uses new interface SyntaxTreeBuilder | ||
* in 2020.2. #api201 | ||
*/ | ||
public class SyntaxTreeBuilderCompat { | ||
|
||
private final PsiBuilder builder; | ||
|
||
public SyntaxTreeBuilderCompat(PsiBuilder builder) { | ||
this.builder = builder; | ||
} | ||
|
||
public PsiBuilder getBuilder() { | ||
return builder; | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
sdkcompat/v202/com/google/idea/sdkcompat/python/FunctionParsingCompat.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,32 @@ | ||
package com.google.idea.sdkcompat.python; | ||
|
||
import com.intellij.lang.SyntaxTreeBuilder; | ||
import com.intellij.lang.SyntaxTreeBuilder.Marker; | ||
import com.intellij.psi.tree.IElementType; | ||
import com.jetbrains.python.parsing.FunctionParsing; | ||
import com.jetbrains.python.parsing.ParsingContext; | ||
|
||
/** #api201: Compat class for {@link FunctionParsing}. */ | ||
public class FunctionParsingCompat extends FunctionParsing { | ||
|
||
public FunctionParsingCompat(ParsingContext context) { | ||
super(context); | ||
} | ||
|
||
protected MarkerCompat getMarker() { | ||
return new MarkerCompat(myBuilder.mark()); | ||
} | ||
|
||
/** #api201: Compat class for marker which is represented by a new interface in 2020.2. */ | ||
protected static class MarkerCompat { | ||
private final SyntaxTreeBuilder.Marker marker; | ||
|
||
private MarkerCompat(Marker marker) { | ||
this.marker = marker; | ||
} | ||
|
||
public void done(IElementType type) { | ||
marker.done(type); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
sdkcompat/v202/com/google/idea/sdkcompat/python/PythonParserDefinitionCompat.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,35 @@ | ||
package com.google.idea.sdkcompat.python; | ||
|
||
import com.intellij.lang.PsiParser; | ||
import com.intellij.lang.SyntaxTreeBuilder; | ||
import com.intellij.openapi.project.Project; | ||
import com.jetbrains.python.PythonParserDefinition; | ||
import com.jetbrains.python.parsing.ParsingContext; | ||
import com.jetbrains.python.parsing.PyParser; | ||
import com.jetbrains.python.parsing.StatementParsing; | ||
import com.jetbrains.python.psi.LanguageLevel; | ||
|
||
/** Compat class for {@link PythonParserDefinition}. #api201 */ | ||
public abstract class PythonParserDefinitionCompat extends PythonParserDefinition { | ||
|
||
protected abstract ParsingContext createCustomParsingContext( | ||
Project project, | ||
SyntaxTreeBuilderCompat builderCompat, | ||
LanguageLevel languageLevel, | ||
StatementParsing.FUTURE futureFlag); | ||
|
||
@Override | ||
public PsiParser createParser(Project project) { | ||
return new PyParser() { | ||
/** #api201: Super method uses new interface SyntaxTreeBuilder in 2020.2 */ | ||
@Override | ||
protected ParsingContext createParsingContext( | ||
SyntaxTreeBuilder builder, | ||
LanguageLevel languageLevel, | ||
StatementParsing.FUTURE futureFlag) { | ||
return createCustomParsingContext( | ||
project, new SyntaxTreeBuilderCompat(builder), languageLevel, futureFlag); | ||
} | ||
}; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
sdkcompat/v202/com/google/idea/sdkcompat/python/SyntaxTreeBuilderCompat.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,20 @@ | ||
package com.google.idea.sdkcompat.python; | ||
|
||
import com.intellij.lang.SyntaxTreeBuilder; | ||
|
||
/** | ||
* Compat class to support that constructor of ParsingContext uses new interface SyntaxTreeBuilder | ||
* in 2020.2. #api201 | ||
*/ | ||
public class SyntaxTreeBuilderCompat { | ||
|
||
private final SyntaxTreeBuilder builder; | ||
|
||
public SyntaxTreeBuilderCompat(SyntaxTreeBuilder builder) { | ||
this.builder = builder; | ||
} | ||
|
||
public SyntaxTreeBuilder getBuilder() { | ||
return builder; | ||
} | ||
} |