Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution approach for four known shortcomings on Java source file import #1136

Closed
4 tasks done
codemanyak opened this issue Mar 12, 2024 · 0 comments
Closed
4 tasks done
Assignees
Labels
Fixed Implemented (though possibly still not delivered) inconvenient
Milestone

Comments

@codemanyak
Copy link
Collaborator

codemanyak commented Mar 12, 2024

There are four known shortcomings of the Java source import, related to type arguments:

  • Type casting to a parameterized type causes parser failure, e.g.:
    Vector<String> lines = (Vector<String>) getLinesFromFile("test.txt");;
  • Array declarations over parameterized types cause parser failure, e.g.:
    JComboBox<String>[] comboBoxes = null;;
  • Nested parameterized types cause parser trouble if their closing angular brackets cling together (the lexer reads them as shift operator in this case, which can be prevented by inserting space, however), e.g.
    HashMap<String, ArrayList<String>> myMap;;
  • Type parameter ? (as e.g in Class<?>) causes parser failure.

All of these shortcomings can of course be overcome by deriving a manually modificied copy of the source file before importing it, where disturbing type parameters are effaced or enclosed by comments, but it is tedious and cumbersome.

Therefore Structorizer might mitigate at least the first and the third of them via automatic file preprocessing. The second one, however, is more tricky, but it should be possible to separate closing angular brackets in a heuristic approach with sufficient likelihood of appropriateness. It seems safer, though, to offer it only optionally (i.e., leaving it to a new Java-specific import option), because it may be easier to manually fill in the blanks where actually needed (before the import) than to find a way to prevent or circumvent a mistaken automatic splitting of mis-conceived real shift operators (if the file preprocessing mechanism overdoes).

@codemanyak codemanyak added this to the Release 3.33 milestone Mar 12, 2024
@codemanyak codemanyak self-assigned this Mar 12, 2024
@codemanyak codemanyak added the Fixed Implemented (though possibly still not delivered) label Mar 12, 2024
@codemanyak codemanyak changed the title Solution approach for three known shortcomings on Java source file import Solution approach for four known shortcomings on Java source file import Mar 17, 2024
@fesch fesch closed this as completed in 185a4dd Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed Implemented (though possibly still not delivered) inconvenient
Projects
None yet
Development

No branches or pull requests

1 participant