Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for #PyDev-1055: Pydev does not recognize named unicode character…
… escape in f-string (#258)
- Loading branch information
1 parent
b6cdb91
commit c2a03ef
Showing
7 changed files
with
74 additions
and
41 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
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
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
30 changes: 30 additions & 0 deletions
30
...hon.pydev.parser/src/org/python/pydev/parser/grammar_fstrings/FStringsGrammarFactory.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,30 @@ | ||
package org.python.pydev.parser.grammar_fstrings; | ||
|
||
import org.python.pydev.parser.jython.FastCharStream; | ||
|
||
public class FStringsGrammarFactory { | ||
|
||
public static FStringsGrammar createGrammar(String s) { | ||
|
||
char[] c = s.toCharArray(); | ||
for (int i = 0, z = 0; i < c.length; i++) { | ||
if (c[i] == '\\' && i + 2 < c.length && c[i + 1] == 'N' && c[i + 2] == '{') { | ||
c[i + 2] = '_'; | ||
i += 2; | ||
z = i + 1; | ||
for (; z < c.length; z++) { | ||
if (c[z] == '}') { | ||
c[z] = '_'; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
FastCharStream in = new FastCharStream(c); | ||
FStringsGrammar fStringsGrammar = new FStringsGrammar(in); | ||
|
||
return fStringsGrammar; | ||
} | ||
|
||
} |
7 changes: 5 additions & 2 deletions
7
plugins/org.python.pydev.parser/src/org/python/pydev/parser/grammar_fstrings/build.xml
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
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
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