Repository navigation
Fixing compilation errors after platform localization. Some refactoring - #54
Conversation
|
@claude review pr with inline comments |
|
Claude finished @unv-unv's task in 1m 46s —— View job PR #54 review
Most of this PR is a reformat plus a switch from Inline comments (each has a one-click
|
| return getRefName("<none>"); | ||
| } | ||
| public LocalizeValue getPresentableText() { | ||
| return LocalizeValue.localizeTODO(getRefName("<none>")); |
There was a problem hiding this comment.
localizeTODO marks text that should be localized later, but this is a reference name (an identifier), so it never needs localization. Every other presentation in this PR uses LocalizeValue.of(...) for identifiers (PyStarImportElementImpl, PyFileImpl, etc.), and using it here too keeps the TODO markers meaningful.
| return LocalizeValue.localizeTODO(getRefName("<none>")); | |
| return LocalizeValue.of(getRefName("<none>")); |
| PsiElement source = PyUtil.turnDirIntoInit(importedFile); | ||
| if (source instanceof PyFile) { | ||
| PyFile sourceFile = (PyFile) source; | ||
| PyModuleType moduleType = new PyModuleType(sourceFile); | ||
| List<? extends RatedResolveResult> results = moduleType.resolveMember( | ||
| name, | ||
| null, | ||
| AccessDirection.READ, | ||
| PyResolveContext.defaultContext() | ||
| ); | ||
| if (results != null && !results.isEmpty() && PyUtil.isStarImportableFrom(name, sourceFile)) { | ||
| if (results.isEmpty()) { | ||
| return Collections.emptyList(); | ||
| } | ||
| List<RatedResolveResult> res = Lists.newArrayList(); | ||
| for (RatedResolveResult result : results) { | ||
| res.add(result); | ||
| } | ||
| return res; | ||
| } |
There was a problem hiding this comment.
Since this method is already being refactored: the inner if (results.isEmpty()) can never be true because the outer condition already checks !results.isEmpty(). The copy loop can also be a plain new ArrayList<>(results). This change would also match the pattern-matching instanceof you used in iterateNames() above. Behaviour stays the same.
| PsiElement source = PyUtil.turnDirIntoInit(importedFile); | |
| if (source instanceof PyFile) { | |
| PyFile sourceFile = (PyFile) source; | |
| PyModuleType moduleType = new PyModuleType(sourceFile); | |
| List<? extends RatedResolveResult> results = moduleType.resolveMember( | |
| name, | |
| null, | |
| AccessDirection.READ, | |
| PyResolveContext.defaultContext() | |
| ); | |
| if (results != null && !results.isEmpty() && PyUtil.isStarImportableFrom(name, sourceFile)) { | |
| if (results.isEmpty()) { | |
| return Collections.emptyList(); | |
| } | |
| List<RatedResolveResult> res = Lists.newArrayList(); | |
| for (RatedResolveResult result : results) { | |
| res.add(result); | |
| } | |
| return res; | |
| } | |
| if (PyUtil.turnDirIntoInit(importedFile) instanceof PyFile sourceFile) { | |
| PyModuleType moduleType = new PyModuleType(sourceFile); | |
| List<? extends RatedResolveResult> results = moduleType.resolveMember( | |
| name, | |
| null, | |
| AccessDirection.READ, | |
| PyResolveContext.defaultContext() | |
| ); | |
| if (results != null && !results.isEmpty() && PyUtil.isStarImportableFrom(name, sourceFile)) { | |
| return new ArrayList<>(results); | |
| } | |
| } |
(You'd need to add import java.util.ArrayList;. The com.google.common.collect.Lists import then becomes unused.)
| if (myVisibility == Visibility.PRIVATE || myVisibility == Visibility.PROTECTED) { | ||
| overlay = PythonIcons.Python.Nodes.Lock; | ||
| } | ||
| else if (myVisibility == Visibility.PREDEFINED) { | ||
| } | ||
| else if (myVisibility == Visibility.PREDEFINED) { | ||
| overlay = PythonIcons.Python.Nodes.Cyan_dot; | ||
| } | ||
| else if (myVisibility == Visibility.INVISIBLE) { | ||
| } | ||
| else if (myVisibility == Visibility.INVISIBLE) { | ||
| overlay = PythonIcons.Python.Nodes.Red_inv_triangle; | ||
| } | ||
| if (overlay != null) { | ||
| iconDescriptor.addLayerIcon(overlay); | ||
| } | ||
| return iconDescriptor.toIcon(); | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| } |
There was a problem hiding this comment.
The reformat skipped these three overlay = ... lines, so they're still at the old indentation.
| if (myVisibility == Visibility.PRIVATE || myVisibility == Visibility.PROTECTED) { | |
| overlay = PythonIcons.Python.Nodes.Lock; | |
| } | |
| else if (myVisibility == Visibility.PREDEFINED) { | |
| } | |
| else if (myVisibility == Visibility.PREDEFINED) { | |
| overlay = PythonIcons.Python.Nodes.Cyan_dot; | |
| } | |
| else if (myVisibility == Visibility.INVISIBLE) { | |
| } | |
| else if (myVisibility == Visibility.INVISIBLE) { | |
| overlay = PythonIcons.Python.Nodes.Red_inv_triangle; | |
| } | |
| if (overlay != null) { | |
| iconDescriptor.addLayerIcon(overlay); | |
| } | |
| return iconDescriptor.toIcon(); | |
| } | |
| } | |
| }; | |
| } | |
| } | |
| if (myVisibility == Visibility.PRIVATE || myVisibility == Visibility.PROTECTED) { | |
| overlay = PythonIcons.Python.Nodes.Lock; | |
| } | |
| else if (myVisibility == Visibility.PREDEFINED) { | |
| overlay = PythonIcons.Python.Nodes.Cyan_dot; | |
| } | |
| else if (myVisibility == Visibility.INVISIBLE) { | |
| overlay = PythonIcons.Python.Nodes.Red_inv_triangle; | |
| } |
| public static final String UNKNOWN_TYPE = "Any"; | ||
|
|
||
| public static final String UNNAMED_ELEMENT = "<unnamed>"; | ||
| public static final LocalizeValue UNNAMED_ELEMENT = LocalizeValue.localizeTODO("<unnamed>"); |
There was a problem hiding this comment.
This changes the type of a public constant in python-psi-api from String to LocalizeValue. That's a source/binary break for any third-party code that uses PyNames.UNNAMED_ELEMENT. Inside this repo, all usages are updated. Two optional follow-ups:
PyElementNode.updateImpl(python-impl/.../projectView/PyElementNode.java:65) still hardcodes"<unnamed>". It could usePyNames.UNNAMED_ELEMENT.get()so the literal lives in one place.- If this is meant to be localized for real, consider adding a proper key to the Python localize YAML instead of
localizeTODO.
| public String getPresentableText() { | ||
| return notNullize(getName(), PyNames.UNNAMED_ELEMENT) + getParameterList().getPresentableText(true); | ||
| public LocalizeValue getPresentableText() { | ||
| return LocalizeValue.join(LocalizeValue.ofNullable(getName()).orIfEmpty(PyNames.UNNAMED_ELEMENT), getParameterList().getPresentableText(true)); |
There was a problem hiding this comment.
Nit: this line is about 150 characters. Wrapping it would match the multi-line argument style used elsewhere in this PR.
| return LocalizeValue.join(LocalizeValue.ofNullable(getName()).orIfEmpty(PyNames.UNNAMED_ELEMENT), getParameterList().getPresentableText(true)); | |
| return LocalizeValue.join( | |
| LocalizeValue.ofNullable(getName()).orIfEmpty(PyNames.UNNAMED_ELEMENT), | |
| getParameterList().getPresentableText(true) | |
| ); |
dc7bf45 to
6749423
Compare
No description provided.