src: moved Java indexer from JavaSymbolSolver to Eclipse JDT

* added some more tests
* changed 3rd party licenses respectively

fortune cookie message = Your present plans are going to succeed.
This commit is contained in:
mlangkabel
2017-09-07 12:40:34 +02:00
parent 6cf0b87f7b
commit 5c614c77e2
51 changed files with 2518 additions and 3480 deletions
@@ -0,0 +1,13 @@
Eclipse Distribution License - v 1.0
Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the Eclipse Foundation, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
@@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
@@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
@@ -1,13 +0,0 @@
Copyright 2014-2016 Javaslang, http://javaslang.io
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
@@ -1,141 +0,0 @@
MOZILLA PUBLIC LICENSE
Version 1.1
1. Definitions.
1.0.1. "Commercial Use" means distribution or otherwise making the Covered Code available to a third party.
1.1. ''Contributor'' means each entity that creates or contributes to the creation of Modifications.
1.2. ''Contributor Version'' means the combination of the Original Code, prior Modifications used by a Contributor, and the Modifications made by that particular Contributor.
1.3. ''Covered Code'' means the Original Code or Modifications or the combination of the Original Code and Modifications, in each case including portions thereof.
1.4. ''Electronic Distribution Mechanism'' means a mechanism generally accepted in the software development community for the electronic transfer of data.
1.5. ''Executable'' means Covered Code in any form other than Source Code.
1.6. ''Initial Developer'' means the individual or entity identified as the Initial Developer in the Source Code notice required by Exhibit A.
1.7. ''Larger Work'' means a work which combines Covered Code or portions thereof with code not governed by the terms of this License.
1.8. ''License'' means this document.
1.8.1. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein.
1.9. ''Modifications'' means any addition to or deletion from the substance or structure of either the Original Code or any previous Modifications. When Covered Code is released as a series of files, a Modification is:
A. Any addition to or deletion from the contents of a file containing Original Code or previous Modifications.
B. Any new file that contains any part of the Original Code or previous Modifications.
1.10. ''Original Code'' means Source Code of computer software code which is described in the Source Code notice required by Exhibit A as Original Code, and which, at the time of its release under this License is not already Covered Code governed by this License.
1.10.1. "Patent Claims" means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor.
1.11. ''Source Code'' means the preferred form of the Covered Code for making modifications to it, including all modules it contains, plus any associated interface definition files, scripts used to control compilation and installation of an Executable, or source code differential comparisons against either the Original Code or another well known, available Covered Code of the Contributor's choice. The Source Code can be in a compressed or archival form, provided the appropriate decompression or de-archiving software is widely available for no charge.
1.12. "You'' (or "Your") means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License or a future version of this License issued under Section 6.1. For legal entities, "You'' includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, "control'' means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
2. Source Code License.
2.1. The Initial Developer Grant.
The Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims:
(a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer to use, reproduce, modify, display, perform, sublicense and distribute the Original Code (or portions thereof) with or without Modifications, and/or as part of a Larger Work; and
(b) under Patents Claims infringed by the making, using or selling of Original Code, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Code (or portions thereof).
(c) the licenses granted in this Section 2.1(a) and (b) are effective on the date Initial Developer first distributes Original Code under the terms of this License.
(d) Notwithstanding Section 2.1(b) above, no patent license is granted: 1) for code that You delete from the Original Code; 2) separate from the Original Code; or 3) for infringements caused by: i) the modification of the Original Code or ii) the combination of the Original Code with other software or devices.
2.2. Contributor Grant.
Subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license
(a) under intellectual property rights (other than patent or trademark) Licensable by Contributor, to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof) either on an unmodified basis, with other Modifications, as Covered Code and/or as part of a Larger Work; and
(b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications made by that Contributor (or portions thereof); and 2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination).
(c) the licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first makes Commercial Use of the Covered Code.
(d) Notwithstanding Section 2.2(b) above, no patent license is granted: 1) for any code that Contributor has deleted from the Contributor Version; 2) separate from the Contributor Version; 3) for infringements caused by: i) third party modifications of Contributor Version or ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or 4) under Patent Claims infringed by Covered Code in the absence of Modifications made by that Contributor.
3. Distribution Obligations.
3.1. Application of License.
The Modifications which You create or to which You contribute are governed by the terms of this License, including without limitation Section 2.2. The Source Code version of Covered Code may be distributed only under the terms of this License or a future version of this License released under Section 6.1, and You must include a copy of this License with every copy of the Source Code You distribute. You may not offer or impose any terms on any Source Code version that alters or restricts the applicable version of this License or the recipients' rights hereunder. However, You may include an additional document offering the additional rights described in Section 3.5.
3.2. Availability of Source Code.
Any Modification which You create or to which You contribute must be made available in Source Code form under the terms of this License either on the same media as an Executable version or via an accepted Electronic Distribution Mechanism to anyone to whom you made an Executable version available; and if made available via Electronic Distribution Mechanism, must remain available for at least twelve (12) months after the date it initially became available, or at least six (6) months after a subsequent version of that particular Modification has been made available to such recipients. You are responsible for ensuring that the Source Code version remains available even if the Electronic Distribution Mechanism is maintained by a third party.
3.3. Description of Modifications.
You must cause all Covered Code to which You contribute to contain a file documenting the changes You made to create that Covered Code and the date of any change. You must include a prominent statement that the Modification is derived, directly or indirectly, from Original Code provided by the Initial Developer and including the name of the Initial Developer in (a) the Source Code, and (b) in any notice in an Executable version or related documentation in which You describe the origin or ownership of the Covered Code.
3.4. Intellectual Property Matters
(a) Third Party Claims.
If Contributor has knowledge that a license under a third party's intellectual property rights is required to exercise the rights granted by such Contributor under Sections 2.1 or 2.2, Contributor must include a text file with the Source Code distribution titled "LEGAL'' which describes the claim and the party making the claim in sufficient detail that a recipient will know whom to contact. If Contributor obtains such knowledge after the Modification is made available as described in Section 3.2, Contributor shall promptly modify the LEGAL file in all copies Contributor makes available thereafter and shall take other steps (such as notifying appropriate mailing lists or newsgroups) reasonably calculated to inform those who received the Covered Code that new knowledge has been obtained.
(b) Contributor APIs.
If Contributor's Modifications include an application programming interface and Contributor has knowledge of patent licenses which are reasonably necessary to implement that API, Contributor must also include this information in the LEGAL file.
(c) Representations.
Contributor represents that, except as disclosed pursuant to Section 3.4(a) above, Contributor believes that Contributor's Modifications are Contributor's original creation(s) and/or Contributor has sufficient rights to grant the rights conveyed by this License.
3.5. Required Notices.
You must duplicate the notice in Exhibit A in each file of the Source Code. If it is not possible to put such notice in a particular Source Code file due to its structure, then You must include such notice in a location (such as a relevant directory) where a user would be likely to look for such a notice. If You created one or more Modification(s) You may add your name as a Contributor to the notice described in Exhibit A. You must also duplicate this License in any documentation for the Source Code where You describe recipients' rights or ownership rights relating to Covered Code. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Code. However, You may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear than any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer.
3.6. Distribution of Executable Versions.
You may distribute Covered Code in Executable form only if the requirements of Section 3.1-3.5 have been met for that Covered Code, and if You include a notice stating that the Source Code version of the Covered Code is available under the terms of this License, including a description of how and where You have fulfilled the obligations of Section 3.2. The notice must be conspicuously included in any notice in an Executable version, related documentation or collateral in which You describe recipients' rights relating to the Covered Code. You may distribute the Executable version of Covered Code or ownership rights under a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable version does not attempt to limit or alter the recipient's rights in the Source Code version from the rights set forth in this License. If You distribute the Executable version under a different license You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or any Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer.
3.7. Larger Works.
You may create a Larger Work by combining Covered Code with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Code.
4. Inability to Comply Due to Statute or Regulation.
If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Code due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be included in the LEGAL file described in Section 3.4 and must be included with all distributions of the Source Code. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it.
5. Application of this License.
This License applies to code to which the Initial Developer has attached the notice in Exhibit A and to related Covered Code.
6. Versions of the License.
6.1. New Versions.
Netscape Communications Corporation (''Netscape'') may publish revised and/or new versions of the License from time to time. Each version will be given a distinguishing version number.
6.2. Effect of New Versions.
Once Covered Code has been published under a particular version of the License, You may always continue to use it under the terms of that version. You may also choose to use such Covered Code under the terms of any subsequent version of the License published by Netscape. No one other than Netscape has the right to modify the terms applicable to Covered Code created under this License.
6.3. Derivative Works.
If You create or use a modified version of this License (which you may only do in order to apply it to code which is not already Covered Code governed by this License), You must (a) rename Your license so that the phrases ''Mozilla'', ''MOZILLAPL'', ''MOZPL'', ''Netscape'', "MPL", ''NPL'' or any confusingly similar phrase do not appear in your license (except to note that your license differs from this License) and (b) otherwise make it clear that Your version of the license contains terms which differ from the Mozilla Public License and Netscape Public License. (Filling in the name of the Initial Developer, Original Code or Contributor in the notice described in Exhibit A shall not of themselves be deemed to be modifications of this License.)
7. DISCLAIMER OF WARRANTY.
COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS'' BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
8. TERMINATION.
8.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. All sublicenses to the Covered Code which are properly granted shall survive any termination of this License. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive.
8.2. If You initiate litigation by asserting a patent infringement claim (excluding declatory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You file such action is referred to as "Participant") alleging that:
(a) such Participant's Contributor Version directly or indirectly infringes any patent, then any and all rights granted by such Participant to You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively, unless if within 60 days after receipt of notice You either: (i) agree in writing to pay Participant a mutually agreeable reasonable royalty for Your past and future use of Modifications made by such Participant, or (ii) withdraw Your litigation claim with respect to the Contributor Version against such Participant. If within 60 days of notice, a reasonable royalty and payment arrangement are not mutually agreed upon in writing by the parties or the litigation claim is not withdrawn, the rights granted by Participant to You under Sections 2.1 and/or 2.2 automatically terminate at the expiration of the 60 day notice period specified above.
(b) any software, hardware, or device, other than such Participant's Contributor Version, directly or indirectly infringes any patent, then any rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are revoked effective as of the date You first made, used, sold, distributed, or had made, Modifications made by that Participant.
8.3. If You assert a patent infringement claim against Participant alleging that such Participant's Contributor Version directly or indirectly infringes any patent where such claim is resolved (such as by license or settlement) prior to the initiation of patent infringement litigation, then the reasonable value of the licenses granted by such Participant under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of any payment or license.
8.4. In the event of termination under Sections 8.1 or 8.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or any distributor hereunder prior to termination shall survive termination.
9. LIMITATION OF LIABILITY.
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
10. U.S. GOVERNMENT END USERS.
The Covered Code is a ''commercial item,'' as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of ''commercial computer software'' and ''commercial computer software documentation,'' as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Code with only those rights set forth herein.
11. MISCELLANEOUS.
This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by California law provisions (except to the extent applicable law, if any, provides otherwise), excluding its conflict-of-law provisions. With respect to disputes in which at least one party is a citizen of, or an entity chartered or registered to do business in the United States of America, any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California, with venue lying in Santa Clara County, California, with the losing party responsible for costs, including without limitation, court costs and reasonable attorneys' fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License.
12. RESPONSIBILITY FOR CLAIMS.
As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability.
13. MULTIPLE-LICENSED CODE.
Initial Developer may designate portions of the Covered Code as "Multiple-Licensed". "Multiple-Licensed" means that the Initial Developer permits you to utilize portions of the Covered Code under Your choice of the MPL or the alternative licenses, if any, specified by the Initial Developer in the file described in Exhibit A.
EXHIBIT A -Mozilla Public License.
The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
ANY KIND, either express or implied. See the License for the specific language governing rights and
limitations under the License.
The Original Code is Javassist.
The Initial Developer of the Original Code is Shigeru Chiba. Portions created by the Initial Developer are
Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
Contributor(s): __Bill Burke, Jason T. Greene______________.
Alternatively, the contents of this software may be used under the terms of the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), or the Apache License Version 2.0 (the "AL"), in which case the provisions of the LGPL or the AL are applicable instead of those above. If you wish to allow use of your version of this software only under the terms of either the LGPL or the AL, and not to allow others to use your version of this software under the terms of the MPL, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the LGPL or the AL. If you do not delete the provisions above, a recipient may use your version of this software under the terms of any one of the MPL, the LGPL or the AL.
+10 -10
View File
@@ -5,7 +5,7 @@ Last date of change: 2017-06-19
BY INSTALLING OR USING THIS SOFTWARE, YOU ARE BECOMING A PARTY TO, AND ARE CONSENTING TO BE BOUND BY, THIS AGREEMENT. IF YOU DO NOT AGREE TO ALL OF THE TERMS OF THIS AGREEMENT, DO NOT INSTALL OR USE THIS SOFTWARE.
DEFINITIONS
1. DEFINITIONS
"SOFTWARE" means:
• A version of the cross-platform source code explorer known as Sourcetrail in executable form. The version is defined by the two leading numbers of the version string (e.g. the version of Sourcetrail 2017.1.x is version 2017.1);
@@ -32,7 +32,7 @@ DEFINITIONS
• an employee or independent contractor who might at any time use the SOFTWARE, of the LICENSEE; for each ACTIVATION KEY an entity has as many AUTHORIZED USER(s) as defined by the amount of seats specified in the ACTIVATION KEY; if no amount of seats is specified in the ACTIVATION KEY the entity has one AUTHORIZED USER for this ACTIVATION KEY.
GRANT
2. GRANT
Subject to the terms of this AGREEMENT, the LICENSOR hereby grants the LICENSEE a worldwide, non-transferable, non-exclusive, non-sub-licensable, limited LICENSE that allows:
• the LICENSEE to distribute (an) ACTIVATION KEY(s) to AUTHORIZED USER(s);
@@ -43,7 +43,7 @@ Subject to the terms of this AGREEMENT, the LICENSOR hereby grants the LICENSEE
• LICENSEE to make a copy of the SOFTWARE for archival purposes provided the copy contains all of the proprietary notices of the SOFTWARE.
RESTRICTIONS AND CONFIDENTIALITY
3. RESTRICTIONS AND CONFIDENTIALITY
The LICENSEE will not, and will have no right to:
• modify, translate, reverse engineer, decompile, disassemble (except to the extent applicable laws specifically prohibit such restriction), create derivative works based on, or otherwise attempt to discover the source code or underlying ideas or algorithms of the SOFTWARE;
@@ -56,37 +56,37 @@ AUTHORIZED USER(s) will not, and will have no right to:
• use a Private/Academic License of the software for any commercial purposes.
Unless a valid non-disclosure agreement exists between the Parties, in which case the terms of that non-disclosure agreement shall apply, the following terms shall: Except as necessary for its performance under the AGREEMENT or required by law, the LICENSOR shall not disclose to anyone any information furnished by the LICENSEE that is marked as confidential or proprietary.
TITLE AND COPYRIGHT
4. TITLE AND COPYRIGHT
Title, ownership rights, intellectual property rights, and copyright to the SOFTWARE, and any copies or portions thereof, shall remain in LICENSOR. The SOFTWARE is protected by European copyright directives, Austrian copyright laws as well as United States copyright laws and international treaty provisions.
DISCLAIMER OF WARRANTY
5. DISCLAIMER OF WARRANTY
THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND. LICENSOR HEREBY DISCLAIMS ALL EXPRESS OR IMPLIED WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS AGREEMENT. SOME U.S. STATES DO NOT ALLOW EXCLUSIONS OF AN IMPLIED WARRANTY, SO THIS DISCLAIMER MAY NOT APPLY TO LICENSEE. LICENSEE MAY HAVE OTHER LEGAL RIGHTS THAT VARY FROM STATE TO STATE OR BY JURISDICTION.
LIMITATION OF LIABILITY
6. LIMITATION OF LIABILITY
LICENSEE ASSUMES THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE. LICENSOR ASSUMES NO LIABILITY FOR THE COST OF ANY SERVICE OR REPAIR IF THE SOFTWARE IS DEFECTIVE. UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT, STRICT LIABILITY, OR OTHERWISE, SHALL LICENSOR, OR ITS LICENSORS, SUPPLIERS OR RESELLERS, BE LIABLE TO LICENSEE OR ANY OTHER PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES. IN NO EVENT WILL LICENSOR BE LIABLE FOR ANY DAMAGES IN EXCESS OF THE MONEY PAID FOR THE SOFTWARE, EVEN IF LICENSOR SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. FURTHERMORE, SOME U.S. STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS LIMITATION AND EXCLUSION MAY NOT APPLY TO LICENSEE.
TERMINATION
7. TERMINATION
The license granted herein shall be perpetual. If LICENSEE fails to comply with any of the terms of this AGREEMENT, this AGREEMENT and the rights granted herein will terminate immediately. LICENSOR may, at its sole discretion and at any time, terminate this AGREEMENT. On termination, LICENSEE must cease using and destroy all copies of the SOFTWARE.
EXPORT CONTROLS
8. EXPORT CONTROLS
LICENSEE shall comply with all export laws, restrictions and regulations of the United States, the Directive 2009/428/EC of the European Parliament and of the Council and the Austrian Außenwirtschaftsgesetz 2011, BGBl I No. 26/2011. LICENSEE shall not export, re-export or otherwise transfer the SOFTWARE to any country for which the United States or the European Union or Austria maintains an embargo, or to any person or entity on the U.S. Department of Treasury List of Specially Designated Nationals or the U.S. Department of Commerce Denied Persons List or Entity List. LICENSEE represents and warrants that licensee is not located in, under the control of, or a national or resident of any restricted country or on any such list.
THIRD PARTY CREDITS
9. THIRD PARTY CREDITS
Portions of the SOFTWARE utilize or include third party software and other copyrighted materials. Credits, licensing terms, and disclaimers for such materials are contained in the installation directory for the SOFTWARE, and are accessible via the “3rd Party Licenses” dialog for the SOFTWARE. LICENSEE agrees that use of such copyrighted materials is governed by their respective terms.
ENTIRE AGREEMENT
10. ENTIRE AGREEMENT
This AGREEMENT represents the complete agreement concerning this SOFTWARE between the PARTIES and supersedes all prior agreements and representations between them. It may be amended only in writing executed by both PARTIES. Coati Software OG reserves the exclusive right to periodically update this AGREEMENT at its discretion at any time, with reasonable notice to LICENSEE by posting the new AGREEMENT at the following URL: <https://www.sourcetrail.com/terms-of-use>. Any action arising out of or relating to this AGREEMENT may be brought exclusively in Salzburg, Austria, and the PARTIES irrevocably consent to the jurisdiction of such courts and venue in Salzburg, Austria.
+14
View File
@@ -87,3 +87,17 @@ TextAccess.cpp WARNING: Line numbers start with one, is 0
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
+1 -5
View File
@@ -25,11 +25,7 @@ AddLicense("Boost" "http://www.boost.org" "${LICENSEFOLDER}/license_boost.txt")
AddLicense("Botan" "http://botan.randombit.net/" "${LICENSEFOLDER}/license_botan.txt")
AddLicense("Clang" "http://clang.llvm.org/" "${LICENSEFOLDER}/license_clang.txt")
AddLicense("CppSQLite" "http://www.codeproject.com/Articles/6343/CppSQLite-C-Wrapper-for-SQLite" "${LICENSEFOLDER}/license_cpp_sqlite.txt")
AddLicense("Guava" "https://github.com/google/guava" "${LICENSEFOLDER}/license_guava.txt")
AddLicense("JavaSymbolSolver" "https://github.com/ftomassetti/java-symbol-solver" "${LICENSEFOLDER}/license_java_symbol_solver.txt")
AddLicense("Javaparser" "http://javaparser.org/" "${LICENSEFOLDER}/license_javaparser.txt")
AddLicense("Javaslang" "http://www.javaslang.io/" "${LICENSEFOLDER}/license_javaslang.txt")
AddLicense("Javassist" "http://www.javassist.org/" "${LICENSEFOLDER}/license_javassist.txt")
AddLicense("Eclipse" "https://github.com/eclipse/eclipse.jdt.core" "${LICENSEFOLDER}/license_eclipse.txt")
AddLicense("OpenSSL" "https://www.openssl.org/" "${LICENSEFOLDER}/license_openssl.txt")
AddLicense("Qt" "http://qt.io" "${LICENSEFOLDER}/license_qt.txt")
AddLicense("TinyXML" "http://www.grinninglizard.com/tinyxml2/" "${LICENSEFOLDER}/license_tinyxml.txt")
+2 -14
View File
@@ -268,20 +268,8 @@
<Component Id='LicenseCppSqliteTxt' Guid='*' Win64="$(var.Win64)">
<File Id='LicenseCppSqlite' Name='license_cpp_sqlite.txt' DiskId='1' Source='./../../../bin/app/data/3rd_party_licenses/license_cpp_sqlite.txt' KeyPath='yes' />
</Component>
<Component Id='LicenseGuavaTxt' Guid='*' Win64="$(var.Win64)">
<File Id='LicenseGuava' Name='license_guava.txt' DiskId='1' Source='./../../../bin/app/data/3rd_party_licenses/license_guava.txt' KeyPath='yes' />
</Component>
<Component Id='LicenseJavaSymbolSolverTxt' Guid='*' Win64="$(var.Win64)">
<File Id='LicenseJavaSymbolSolver' Name='license_java_symbol_solver.txt' DiskId='1' Source='./../../../bin/app/data/3rd_party_licenses/license_java_symbol_solver.txt' KeyPath='yes' />
</Component>
<Component Id='LicenseJavaparserTxt' Guid='*' Win64="$(var.Win64)">
<File Id='LicenseJavaparser' Name='license_javaparser.txt' DiskId='1' Source='./../../../bin/app/data/3rd_party_licenses/license_javaparser.txt' KeyPath='yes' />
</Component>
<Component Id='LicenseJavaslangTxt' Guid='*' Win64="$(var.Win64)">
<File Id='LicenseJavaslang' Name='license_javaslang.txt' DiskId='1' Source='./../../../bin/app/data/3rd_party_licenses/license_javaslang.txt' KeyPath='yes' />
</Component>
<Component Id='LicenseJavassistTxt' Guid='*' Win64="$(var.Win64)">
<File Id='LicenseJavassist' Name='license_javassist.txt' DiskId='1' Source='./../../../bin/app/data/3rd_party_licenses/license_javassist.txt' KeyPath='yes' />
<Component Id='LicenseEclipseTxt' Guid='*' Win64="$(var.Win64)">
<File Id='LicenseEclipse' Name='license_eclipse.txt' DiskId='1' Source='./../../../bin/app/data/3rd_party_licenses/license_eclipse.txt' KeyPath='yes' />
</Component>
<Component Id='LicenseQtTxt' Guid='*' Win64="$(var.Win64)">
<File Id='LicenseQt' Name='license_qt.txt' DiskId='1' Source='./../../../bin/app/data/3rd_party_licenses/license_qt.txt' KeyPath='yes' />
+1 -5
View File
@@ -236,11 +236,7 @@
<ComponentRef Id='LicenseBotanTxt'/>
<ComponentRef Id='LicenseClangTxt'/>
<ComponentRef Id='LicenseCppSqliteTxt'/>
<ComponentRef Id='LicenseGuavaTxt'/>
<ComponentRef Id='LicenseJavaSymbolSolverTxt'/>
<ComponentRef Id='LicenseJavaparserTxt'/>
<ComponentRef Id='LicenseJavaslangTxt'/>
<ComponentRef Id='LicenseJavassistTxt'/>
<ComponentRef Id='LicenseEclipseTxt'/>
<ComponentRef Id='LicenseQtTxt'/>
<ComponentRef Id='LicenseTinyxmlTxt'/>
Binary file not shown.
Binary file not shown.
Binary file not shown.
+3 -44
View File
@@ -8,7 +8,6 @@
<url>http://maven.apache.org</url>
<properties>
<java.version>1.8</java.version>
<javasymbolsolver.version>x.x.x</javasymbolsolver.version>
</properties>
<build>
@@ -27,49 +26,9 @@
<dependencies>
<dependency>
<groupId>org.dummy</groupId>
<artifactId>java-symbol-solver-core</artifactId>
<version>${javasymbolsolver.version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/java-symbol-solver-core.jar</systemPath>
</dependency>
<dependency>
<groupId>org.dummy</groupId>
<artifactId>java-symbol-solver-logic</artifactId>
<version>${javasymbolsolver.version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/java-symbol-solver-logic.jar</systemPath>
</dependency>
<dependency>
<groupId>org.dummy</groupId>
<artifactId>java-symbol-solver-model</artifactId>
<version>${javasymbolsolver.version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/java-symbol-solver-model.jar</systemPath>
</dependency>
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-core</artifactId>
<version>3.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.19.0-GA</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>21.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.javaslang</groupId>
<artifactId>javaslang</artifactId>
<version>2.0.3</version>
<scope>compile</scope>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.12.3</version>
</dependency>
</dependencies>
</project>
@@ -1,6 +1,6 @@
package com.sourcetrail;
import com.github.javaparser.ast.AccessSpecifier;
import org.eclipse.jdt.core.dom.Modifier;
public enum AccessKind
{ // these values need to be the same as AccesKind in C++ code
@@ -14,31 +14,23 @@ public enum AccessKind
private final int m_value;
private AccessKind(int value)
{
this.m_value = value;
}
public int getValue()
{
return m_value;
}
public static AccessKind fromAccessSpecifier(AccessSpecifier specifier)
{
switch (specifier)
{
case PUBLIC:
return AccessKind.PUBLIC;
case PROTECTED:
return AccessKind.PROTECTED;
case PRIVATE:
return AccessKind.PRIVATE;
case DEFAULT:
return AccessKind.DEFAULT;
default:
return AccessKind.NONE;
}
}
private AccessKind(int value)
{
this.m_value = value;
}
public int getValue()
{
return m_value;
}
public static AccessKind fromModifiers(int modifiers)
{
if ((modifiers & Modifier.PUBLIC) != 0) { return AccessKind.PUBLIC; }
if ((modifiers & Modifier.PROTECTED) != 0) { return AccessKind.PROTECTED; }
if ((modifiers & Modifier.PRIVATE) != 0) { return AccessKind.PRIVATE; }
if ((modifiers & Modifier.DEFAULT) != 0) { return AccessKind.DEFAULT; }
return AccessKind.DEFAULT;
}
}
File diff suppressed because it is too large Load Diff
@@ -1,269 +0,0 @@
package com.sourcetrail;
import com.github.javaparser.ast.visitor.GenericVisitorAdapter;
import com.github.javaparser.ast.*;
import com.github.javaparser.ast.body.*;
import com.github.javaparser.ast.expr.*;
import com.github.javaparser.ast.stmt.*;
import com.github.javaparser.ast.type.*;
import java.util.Stack;
public abstract class AstVisitorAdapter extends GenericVisitorAdapter<Boolean, Void>
{
private Stack<ReferenceKind> m_typeRefKind = new Stack<ReferenceKind>();
protected ReferenceKind getTypeReferenceKind()
{
if (!m_typeRefKind.isEmpty())
{
return m_typeRefKind.peek();
}
return ReferenceKind.TYPE_USAGE;
}
//- Compilation Unit ----------------------------------
@Override public Boolean visit(final CompilationUnit n, Void arg)
{
m_typeRefKind.push(ReferenceKind.TYPE_USAGE);
Boolean result = super.visit(n, arg);
m_typeRefKind.pop();
return result;
}
//- Body ----------------------------------------------
@Override public Boolean visit(ClassOrInterfaceDeclaration n, Void arg)
{
Boolean result;
{
result = n.getTypeParameters().accept(this, arg);
if (result != null)
return result;
}
{
result = n.getMembers().accept(this, arg);
if (result != null)
return result;
}
{
result = n.getName().accept(this, arg);
if (result != null)
return result;
}
{
result = n.getAnnotations().accept(this, arg);
if (result != null)
return result;
}
if (n.getComment().isPresent()) {
result = n.getComment().get().accept(this, arg);
if (result != null)
return result;
}
m_typeRefKind.push(ReferenceKind.INHERITANCE);
{
result = n.getExtendedTypes().accept(this, arg);
if (result != null)
return result;
}
{
result = n.getImplementedTypes().accept(this, arg);
if (result != null)
return result;
}
m_typeRefKind.pop();
return null;
}
@Override public Boolean visit(EnumDeclaration n, Void arg)
{
Boolean result;
{
result = n.getEntries().accept(this, arg);
if (result != null)
return result;
}
{
result = n.getMembers().accept(this, arg);
if (result != null)
return result;
}
{
result = n.getName().accept(this, arg);
if (result != null)
return result;
}
{
result = n.getAnnotations().accept(this, arg);
if (result != null)
return result;
}
if (n.getComment().isPresent()) {
result = n.getComment().get().accept(this, arg);
if (result != null)
return result;
}
m_typeRefKind.push(ReferenceKind.INHERITANCE);
{
result = n.getImplementedTypes().accept(this, arg);
if (result != null)
return result;
}
m_typeRefKind.pop();
return null;
}
//- Type ----------------------------------------------
@Override public Boolean visit(ClassOrInterfaceType n, Void arg)
{
Boolean result;
{
result = n.getName().accept(this, arg);
if (result != null)
return result;
}
// don't visit the qualifier here.
// if (n.getScope().isPresent()) {
// result = n.getScope().get().accept(this, arg);
// if (result != null)
// return result;
// }
{
result = n.getAnnotations().accept(this, arg);
if (result != null)
return result;
}
if (n.getComment().isPresent()) {
result = n.getComment().get().accept(this, arg);
if (result != null)
return result;
}
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
if (n.getTypeArguments().isPresent()) {
result = n.getTypeArguments().get().accept(this, arg);
if (result != null)
return result;
}
m_typeRefKind.pop();
return null;
}
//- Expression ----------------------------------------
@Override public Boolean visit(MethodCallExpr n, Void arg)
{
Boolean result;
{
result = n.getArguments().accept(this, arg);
if (result != null)
return result;
}
{
result = n.getName().accept(this, arg);
if (result != null)
return result;
}
if (n.getScope().isPresent()) {
result = n.getScope().get().accept(this, arg);
if (result != null)
return result;
}
if (n.getComment().isPresent()) {
result = n.getComment().get().accept(this, arg);
if (result != null)
return result;
}
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
if (n.getTypeArguments().isPresent()) {
result = n.getTypeArguments().get().accept(this, arg);
if (result != null)
return result;
}
m_typeRefKind.pop();
return null;
}
@Override public Boolean visit(ObjectCreationExpr n, Void arg)
{
Boolean result;
if (n.getAnonymousClassBody().isPresent()) {
result = n.getAnonymousClassBody().get().accept(this, arg);
if (result != null)
return result;
}
{
result = n.getArguments().accept(this, arg);
if (result != null)
return result;
}
if (n.getScope().isPresent()) {
result = n.getScope().get().accept(this, arg);
if (result != null)
return result;
}
// {
// result = n.getType().accept(this, arg);
// if (result != null)
// return result;
// }
if (n.getComment().isPresent()) {
result = n.getComment().get().accept(this, arg);
if (result != null)
return result;
}
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
if (n.getTypeArguments().isPresent()) {
result = n.getTypeArguments().get().accept(this, arg);
if (result != null)
return result;
}
m_typeRefKind.pop();
return null;
}
//- Statements ----------------------------------------
@Override public Boolean visit(ExplicitConstructorInvocationStmt n, Void arg)
{
Boolean result;
{
result = n.getArguments().accept(this, arg);
if (result != null)
return result;
}
if (n.getExpression().isPresent()) {
result = n.getExpression().get().accept(this, arg);
if (result != null)
return result;
}
if (n.getComment().isPresent()) {
result = n.getComment().get().accept(this, arg);
if (result != null)
return result;
}
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
if (n.getTypeArguments().isPresent()) {
result = n.getTypeArguments().get().accept(this, arg);
if (result != null)
return result;
}
m_typeRefKind.pop();
return null;
}
}
@@ -2,73 +2,63 @@ package com.sourcetrail;
import java.util.Optional;
import com.github.javaparser.Range;
import com.sourcetrail.name.NameHierarchy;
public abstract class AstVisitorClient
{
public void recordSymbolWithLocation(
String symbolName, SymbolKind symbolType,
Optional<Range> range,
AccessKind access, DefinitionKind definitionKind
)
NameHierarchy symbolName, SymbolKind symbolKind,
Optional<Range> range,
AccessKind access, DefinitionKind definitionKind)
{
recordSymbolWithLocation(
symbolName, symbolType,
range.orElse(Range.range(0, 0, 0, 0)),
access, definitionKind
);
symbolName, symbolKind,
range.orElse(new Range(0, 0, 0, 0)),
access, definitionKind);
}
public void recordSymbolWithLocationAndScope(
String symbolName, SymbolKind symbolType,
Optional<Range> range,
Optional<Range> scopeRange,
AccessKind access, DefinitionKind definitionKind
)
NameHierarchy symbolName, SymbolKind symbolKind,
Optional<Range> range,
Optional<Range> scopeRange,
AccessKind access, DefinitionKind definitionKind)
{
recordSymbolWithLocationAndScope(
symbolName, symbolType,
range.orElse(Range.range(0, 0, 0, 0)),
scopeRange.orElse(Range.range(0, 0, 0, 0)),
access, definitionKind
);
symbolName, symbolKind,
range.orElse(new Range(0, 0, 0, 0)),
scopeRange.orElse(new Range(0, 0, 0, 0)),
access, definitionKind);
}
public void recordReference(
ReferenceKind referenceKind, String referencedName, String contextName,
Optional<Range> range
)
ReferenceKind referenceKind, NameHierarchy referencedName, NameHierarchy contextName,
Optional<Range> range)
{
recordReference(
referenceKind, referencedName, contextName,
range.orElse(Range.range(0, 0, 0, 0))
);
referenceKind, referencedName, contextName,
range.orElse(new Range(0, 0, 0, 0)));
}
public void recordLocalSymbol(
String symbolName,
Optional<Range> range
)
NameHierarchy symbolName,
Optional<Range> range)
{
recordLocalSymbol(symbolName, range.orElse(Range.range(0, 0, 0, 0)));
recordLocalSymbol(symbolName, range.orElse(new Range(0, 0, 0, 0)));
}
public void recordComment(
Optional<Range> range
)
Optional<Range> range)
{
recordComment(range.orElse(Range.range(0, 0, 0, 0)));
recordComment(range.orElse(new Range(0, 0, 0, 0)));
}
public void recordError(
String message, boolean fatal, boolean indexed,
Optional<Range> range
)
Optional<Range> range)
{
recordError(
message, fatal, indexed,
range.orElse(Range.range(0, 0, 0, 0))
);
message, fatal, indexed,
range.orElse(new Range(0, 0, 0, 0)));
}
public abstract boolean getInterrupted();
@@ -80,40 +70,33 @@ public abstract class AstVisitorClient
public abstract void logError(String error);
public abstract void recordSymbol(
String symbolName, SymbolKind symbolType,
AccessKind access, DefinitionKind definitionKind
);
NameHierarchy symbolName, SymbolKind symbolKind,
AccessKind access, DefinitionKind definitionKind);
public abstract void recordSymbolWithLocation(
String symbolName, SymbolKind symbolType,
Range range,
AccessKind access, DefinitionKind definitionKind
);
NameHierarchy symbolName, SymbolKind symbolKind,
Range range,
AccessKind access, DefinitionKind definitionKind);
public abstract void recordSymbolWithLocationAndScope(
String symbolName, SymbolKind symbolType,
Range range,
Range scopeRange,
AccessKind access, DefinitionKind definitionKind
);
NameHierarchy symbolName, SymbolKind symbolKind,
Range range,
Range scopeRange,
AccessKind access, DefinitionKind definitionKind);
public abstract void recordReference(
ReferenceKind referenceKind, String referencedName, String contextName,
Range range
);
ReferenceKind referenceKind, NameHierarchy referencedName, NameHierarchy contextName,
Range range);
public abstract void recordLocalSymbol(
String symbolName,
Range range
);
NameHierarchy symbolName,
Range range);
public abstract void recordComment(
Range range
);
Range range);
public abstract void recordError(
String message, boolean fatal, boolean indexed,
Range range
);
String message, boolean fatal, boolean indexed,
Range range);
}
@@ -1,54 +0,0 @@
package com.sourcetrail;
import com.github.javaparser.ast.type.TypeParameter;
import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.body.BodyDeclaration;
import com.github.javaparser.ast.body.ConstructorDeclaration;
import com.github.javaparser.ast.body.Parameter;
import com.github.javaparser.ast.type.Type;
import com.github.javaparser.ast.type.UnknownType;
public class CallableConstructorDecl implements CallableDecl
{
private ConstructorDeclaration m_decl;
public CallableConstructorDecl(ConstructorDeclaration decl)
{
m_decl = decl;
}
public BodyDeclaration getWrappedNode()
{
return m_decl;
}
public boolean isMethod()
{
return false;
}
public String getName()
{
return m_decl.getNameAsString();
}
public NodeList<TypeParameter> getTypeParameters()
{
return m_decl.getTypeParameters();
}
public NodeList<Parameter> getParameters()
{
return m_decl.getParameters();
}
public Type getType()
{
return new UnknownType();
}
public boolean isStatic()
{
return m_decl.isStatic();
}
}
@@ -1,18 +0,0 @@
package com.sourcetrail;
import com.github.javaparser.ast.type.TypeParameter;
import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.body.BodyDeclaration;
import com.github.javaparser.ast.body.Parameter;
import com.github.javaparser.ast.type.Type;
public interface CallableDecl
{
public BodyDeclaration getWrappedNode();
public boolean isMethod();
public String getName();
public NodeList<TypeParameter> getTypeParameters();
public NodeList<Parameter> getParameters();
public Type getType();
public boolean isStatic();
}
@@ -1,53 +0,0 @@
package com.sourcetrail;
import com.github.javaparser.ast.type.TypeParameter;
import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.body.BodyDeclaration;
import com.github.javaparser.ast.body.MethodDeclaration;
import com.github.javaparser.ast.body.Parameter;
import com.github.javaparser.ast.type.Type;
public class CallableMethodDecl implements CallableDecl
{
private MethodDeclaration m_decl;
public CallableMethodDecl(MethodDeclaration decl)
{
m_decl = decl;
}
public BodyDeclaration getWrappedNode()
{
return m_decl;
}
public boolean isMethod()
{
return true;
}
public String getName()
{
return m_decl.getNameAsString();
}
public NodeList<TypeParameter> getTypeParameters()
{
return m_decl.getTypeParameters();
}
public NodeList<Parameter> getParameters()
{
return m_decl.getParameters();
}
public Type getType()
{
return m_decl.getType();
}
public boolean isStatic()
{
return m_decl.isStatic();
}
}
@@ -0,0 +1,387 @@
package com.sourcetrail;
import java.io.File;
import java.util.List;
import java.util.Stack;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ClassInstanceCreation;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.ConstructorInvocation;
import org.eclipse.jdt.core.dom.CreationReference;
import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
import org.eclipse.jdt.core.dom.EnumDeclaration;
import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.ImportDeclaration;
import org.eclipse.jdt.core.dom.Javadoc;
import org.eclipse.jdt.core.dom.MethodInvocation;
import org.eclipse.jdt.core.dom.NameQualifiedType;
import org.eclipse.jdt.core.dom.ParameterizedType;
import org.eclipse.jdt.core.dom.QualifiedType;
import org.eclipse.jdt.core.dom.SuperConstructorInvocation;
import org.eclipse.jdt.core.dom.SuperMethodInvocation;
import org.eclipse.jdt.core.dom.SuperMethodReference;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.TypeMethodReference;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
public class ContextAwareAstVisitor extends AstVisitor
{
private Stack<ReferenceKind> m_typeRefKind = new Stack<>();
public ContextAwareAstVisitor(AstVisitorClient client, File filePath, String fileContent, CompilationUnit compilationUnit)
{
super(client, filePath, fileContent, compilationUnit);
}
@Override
public boolean visit(TypeDeclaration node)
{
boolean visitChildren = super.visit(node);
if (visitChildren)
{
acceptChild(node.getJavadoc());
acceptChildren(node.modifiers());
acceptChild(node.getName());
acceptChildren(node.typeParameters());
{
m_typeRefKind.push(ReferenceKind.INHERITANCE);
acceptChild(node.getSuperclassType());
acceptChildren(node.superInterfaceTypes());
m_typeRefKind.pop();
}
acceptChildren(node.bodyDeclarations());
}
return false;
}
@Override
public boolean visit(EnumDeclaration node)
{
boolean visitChildren = super.visit(node);
if (visitChildren)
{
acceptChild(node.getJavadoc());
acceptChildren(node.modifiers());
acceptChild(node.getName());
{
m_typeRefKind.push(ReferenceKind.INHERITANCE);
acceptChildren(node.superInterfaceTypes());
m_typeRefKind.pop();
}
acceptChildren(node.enumConstants());
acceptChildren(node.bodyDeclarations());
}
return false;
}
@Override
public boolean visit(EnumConstantDeclaration node)
{
boolean visitChildren = super.visit(node);
if (visitChildren)
{
// we don't visit and record the name of enum constant declarations because
// this would create an unwanted self-reference.
acceptChild(node.getJavadoc());
acceptChildren(node.modifiers());
acceptChildren(node.arguments());
acceptChild(node.getAnonymousClassDeclaration());
}
return false;
}
@Override
public boolean visit(VariableDeclarationFragment node)
{
boolean visitChildren = super.visit(node);
if (visitChildren)
{
// we don't visit and record the name of field declarations because
// this would create an unwanted self-reference.
if (!(node.getParent() instanceof FieldDeclaration))
{
acceptChild(node.getName());
}
acceptChildren(node.extraDimensions());
acceptChild(node.getInitializer());
}
return false;
}
@Override
public boolean visit(ClassInstanceCreation node)
{
boolean visitChildren = super.visit(node);
if (visitChildren)
{
acceptChild(node.getExpression());
{
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
acceptChildren(node.typeArguments());
m_typeRefKind.pop();
}
if (node.getAnonymousClassDeclaration() != null)
{
m_typeRefKind.push(ReferenceKind.INHERITANCE);
acceptChild(node.getType());
m_typeRefKind.pop();
}
else
{
acceptChild(node.getType());
}
acceptChildren(node.arguments());
acceptChild(node.getAnonymousClassDeclaration());
}
return false;
}
@Override
public boolean visit(ParameterizedType node)
{
boolean visitChildren = super.visit(node);
if (visitChildren)
{
acceptChild(node.getType());
{
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
acceptChildren(node.typeArguments());
m_typeRefKind.pop();
}
}
return false;
}
@Override
public boolean visit(QualifiedType node)
{
// We don't want to visit the qualifier right now.
boolean visitChildren = super.visit(node);
if (visitChildren)
{
acceptChildren(node.annotations());
acceptChild(node.getName());
}
return false;
}
@Override
public boolean visit(NameQualifiedType node)
{
// We don't want to visit the qualifier right now.
boolean visitChildren = super.visit(node);
if (visitChildren)
{
acceptChildren(node.annotations());
acceptChild(node.getName());
}
return false;
}
@Override
public boolean visit(final ImportDeclaration node)
{
// We don't want to visit the name of the ImportDeclaration because this could cause a self reference.
super.visit(node);
return false;
}
@Override
public boolean visit(MethodInvocation node)
{
boolean visitChildren = super.visit(node);
if (visitChildren)
{
acceptChild(node.getExpression());
{
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
acceptChildren(node.typeArguments());
m_typeRefKind.pop();
}
acceptChild(node.getName());
acceptChildren(node.arguments());
}
return false;
}
@Override
public boolean visit(SuperMethodInvocation node)
{
// We don't want to visit the qualifier right now.
boolean visitChildren = super.visit(node);
if (visitChildren)
{
{
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
acceptChildren(node.typeArguments());
m_typeRefKind.pop();
}
acceptChild(node.getName());
acceptChildren(node.arguments());
}
return false;
}
@Override
public boolean visit(ConstructorInvocation node)
{
boolean visitChildren = super.visit(node);
if (visitChildren)
{
{
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
acceptChildren(node.typeArguments());
m_typeRefKind.pop();
}
acceptChildren(node.arguments());
}
return false;
}
@Override
public boolean visit(SuperConstructorInvocation node)
{
boolean visitChildren = super.visit(node);
if (visitChildren)
{
acceptChild(node.getExpression());
{
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
acceptChildren(node.typeArguments());
m_typeRefKind.pop();
}
acceptChildren(node.arguments());
}
return false;
}
@Override
public boolean visit(CreationReference node)
{
// We don't want to visit the qualifying type right now.
boolean visitChildren = super.visit(node);
if (visitChildren)
{
{
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
acceptChildren(node.typeArguments());
m_typeRefKind.pop();
}
}
return false;
}
@Override
public boolean visit(SuperMethodReference node)
{
// We don't want to visit qualifiers right now.
boolean visitChildren = super.visit(node);
if (visitChildren)
{
{
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
acceptChildren(node.typeArguments());
m_typeRefKind.pop();
}
acceptChild(node.getName());
}
return false;
}
@Override
public boolean visit(TypeMethodReference node)
{
// We don't want to visit the qualifying type right now.
boolean visitChildren = super.visit(node);
if (visitChildren)
{
{
m_typeRefKind.push(ReferenceKind.TYPE_ARGUMENT);
acceptChildren(node.typeArguments());
m_typeRefKind.pop();
}
acceptChild(node.getName());
}
return false;
}
@Override
public boolean visit(Javadoc node)
{
// We don't want to visit symbol references inside Javadoc right now.
super.visit( node);
return false;
}
@Override
protected ReferenceKind getTypeReferenceKind()
{
if (!m_typeRefKind.isEmpty())
{
return m_typeRefKind.peek();
}
return ReferenceKind.TYPE_USAGE;
}
private void acceptChild(ASTNode node)
{
if (node != null)
{
node.accept(this);
}
}
private void acceptChildren(List<?> nodes)
{
if (nodes != null)
{
for (Object node: nodes)
{
if (node instanceof ASTNode)
{
acceptChild((ASTNode) node);
}
}
}
}
}
@@ -1,57 +1,33 @@
package com.sourcetrail;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.util.Set;
import com.github.javaparser.ast.body.BodyDeclaration;
import com.github.javaparser.symbolsolver.model.declarations.TypeParametrizable;
import org.eclipse.jdt.core.dom.IBinding;
public class ContextList
{
private List<BodyDeclaration> m_bodyDeclarations = new ArrayList<>();
private List<TypeParametrizable> m_typeParameterizables = new ArrayList<>();
private Set<String> m_bindingKeys = new HashSet<>();
public ContextList copy()
{
ContextList contextList = new ContextList();
contextList.m_bodyDeclarations = new ArrayList<>(m_bodyDeclarations);
contextList.m_typeParameterizables = new ArrayList<>(m_typeParameterizables);
contextList.m_bindingKeys = new HashSet<>(m_bindingKeys);
return contextList;
}
public void add(BodyDeclaration v)
public void add(IBinding v)
{
m_bodyDeclarations.add(v);
}
public boolean contains(BodyDeclaration v)
{
for (BodyDeclaration bodyDeclaration: m_bodyDeclarations)
if (v != null)
{
if (bodyDeclaration.equals(v))
{
return true;
}
m_bindingKeys.add(v.getKey());
}
return false;
}
public void add(TypeParametrizable v)
public boolean contains(IBinding v)
{
m_typeParameterizables.add(v);
}
public boolean contains(TypeParametrizable v)
{
for (TypeParametrizable typeParameterizable: m_typeParameterizables)
{
if (typeParameterizable.toString().equals(v.toString()))
{
return true;
}
}
return false;
return v != null && m_bindingKeys.contains(v.getKey());
}
}
@@ -1,16 +0,0 @@
package com.sourcetrail;
public class DeclContext
{
private String m_name = null;
public DeclContext(String name)
{
m_name = name;
}
public String getName()
{
return m_name;
}
}
@@ -2,24 +2,9 @@ package com.sourcetrail;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import com.github.javaparser.Position;
public class FileContent
{
public class Location
{
public int line;
public int column;
Location(int line, int column)
{
this.line = line;
this.column = column;
}
}
private List<String> m_lines;
public FileContent(String text)
@@ -27,17 +12,12 @@ public class FileContent
m_lines = Arrays.asList(text.split("\\r?\\n"));
}
public Location find(String s)
public Position findStartPosition(String s)
{
return find(s, Position.pos(1, 1));
return findStartPosition(s, new Position(1, 1));
}
public Location find(String s, Optional<Position> from)
{
return find(s, from.orElse(Position.pos(1, 1)));
}
public Location find(String s, Position from)
public Position findStartPosition(String s, Position from)
{
int lineIndex = from.line - 1;
int startColumn = from.column - 1;
@@ -47,11 +27,25 @@ public class FileContent
column = m_lines.get(lineIndex).indexOf(s, startColumn);
if (column != -1)
{
return new Location(lineIndex + 1, column + 1);
return new Position(lineIndex + 1, column + 1);
}
startColumn = 0;
lineIndex++;
}
return new Location(0, 0);
return new Position(0, 0);
}
public Range findRange(String s)
{
return findRange(s, new Position(1, 1));
}
public Range findRange(String s, Position from)
{
Position startPosition = findStartPosition(s, from);
return new Range(
startPosition,
new Position(startPosition.line, startPosition.column + s.length() - 1));
}
}
@@ -1,147 +1,128 @@
package com.sourcetrail;
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Hashtable;
import com.github.javaparser.JavaParser;
import com.github.javaparser.ParseProblemException;
import com.github.javaparser.Position;
import com.github.javaparser.Problem;
import com.github.javaparser.Range;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.PackageDeclaration;
import com.github.javaparser.symbolsolver.javaparser.Navigator;
import com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade;
import com.github.javaparser.symbolsolver.model.resolution.TypeSolver;
import com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver;
import com.github.javaparser.symbolsolver.resolution.typesolvers.JarTypeSolver;
import com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver;
import com.sourcetrail.typesolver.SynchronizedJavaParserTypeSolver;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.BlockComment;
import org.eclipse.jdt.core.dom.Comment;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.LineComment;
import org.eclipse.jdt.core.dom.PackageDeclaration;
public class JavaIndexer
{
private static Map<String, TypeSolver> typeSolvers = new HashMap<>();
{
public static void processFile(int address, String filePath, String fileContent, String classPath, int verbose)
{
AstVisitorClient astVisitorClient = new JavaIndexerAstVisitorClient(address);
processFile(new JavaIndexerAstVisitorClient(address), filePath, fileContent, classPath, verbose);
}
public static void processFile(AstVisitorClient astVisitorClient, String filePath, String fileContent, String classPath, int verbose)
{
astVisitorClient.logInfo("indexing source file: " + filePath);
try
{
CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver();
Path path = Paths.get(filePath);
ASTParser parser = ASTParser.newParser(AST.JLS8);
parser.setResolveBindings(true); // solve "bindings" like the declatarion of the type used in a var decl
parser.setKind(ASTParser.K_COMPILATION_UNIT); // specify to parse the entire compilation unit
parser.setBindingsRecovery(true); // also return bindings that are not resolved completely
parser.setStatementsRecovery(true);
Hashtable<String, String> options = JavaCore.getOptions();
JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options);
parser.setCompilerOptions(options);
parser.setUnitName(path.getFileName().toString());
combinedTypeSolver.add(new ReflectionTypeSolver());
synchronized (typeSolvers)
String sources = "";
String classpath = "";
for (String classPathEntry: classPath.split("\\;"))
{
if (classPathEntry.endsWith(".jar"))
{
for (String path: classPath.split("\\;"))
if (!classpath.isEmpty())
{
if (typeSolvers.containsKey(path))
{
combinedTypeSolver.add(typeSolvers.get(path));
}
else
{
try
{
TypeSolver typeSolver = null;
if (path.endsWith(".jar"))
{
try
{
typeSolver = new JarTypeSolver(path);
}
catch (IOException e)
{
System.out.println("unable to add jar file: " + path);
}
}
else if (!path.isEmpty())
{
typeSolver = new SynchronizedJavaParserTypeSolver(new File(path));
}
if (typeSolver != null)
{
typeSolvers.put(path, typeSolver);
combinedTypeSolver.add(typeSolver);
}
}
catch (Exception e)
{
astVisitorClient.logWarning("unable to add dependency: " + path);
}
}
classpath += ";";
}
classpath += classPathEntry;
}
CompilationUnit cu = JavaParser.parse(new StringReader(fileContent));
AstVisitor astVisitor = (
verbose == 1 ?
new VerboseAstVisitor(astVisitorClient, filePath, new FileContent(fileContent), combinedTypeSolver) :
new AstVisitor(astVisitorClient, filePath, new FileContent(fileContent), combinedTypeSolver)
);
cu.accept(astVisitor, null);
}
catch (ParseProblemException e)
{
for (Problem problem: e.getProblems())
else if (!classPathEntry.isEmpty())
{
// "Parse error. Found \"package\", expected one of \";\" \"@\" \"\\u001a\" \"abstract\" \"class\" \"default\" \"enum\" \"final\" \"import\" \"interface\" \"module\" \"native\" \"open\" \"private\" \"protected\" \"public\" \"static\" \"stric...
String message = problem.toString();
if (message.startsWith("Parse error. Found "))
if (!sources.isEmpty())
{
message = "Encountered unexpected token.";
}
Range range = new Range(new Position(0, 0), new Position(0, 0));
if (problem.getLocation().isPresent())
{
range = problem.getLocation().get().toRange();
sources += ";";
}
astVisitorClient.recordError(message, true, true, range);
sources += classPathEntry;
}
}
parser.setEnvironment(new String[] {classpath} , new String[] {sources}, new String[] {"UTF-8"}, true);
parser.setSource(fileContent.toCharArray());
CompilationUnit cu = (CompilationUnit) parser.createAST(null);
ASTVisitor visitor;
if (verbose != 0)
{
visitor = new VerboseContextAwareAstVisitor(astVisitorClient, path.toFile(), fileContent, cu);
}
else
{
visitor = new ContextAwareAstVisitor(astVisitorClient, path.toFile(), fileContent, cu);
}
cu.accept(visitor);
for (IProblem problem: cu.getProblems())
{
if (problem.isError())
{
Range range = new Range(
cu.getLineNumber(problem.getSourceStart()),
cu.getColumnNumber(problem.getSourceStart() + 1),
cu.getLineNumber(problem.getSourceEnd()),
cu.getColumnNumber(problem.getSourceEnd()) + 1);
astVisitorClient.recordError(problem.getMessage(), false, true, range);
}
}
for (Object commentObject: cu.getCommentList())
{
if ((commentObject instanceof LineComment) || (commentObject instanceof BlockComment))
{
((Comment) commentObject).accept(visitor);
}
}
}
public static String getPackageName(String fileContent)
{
String packageName = "";
try
{
CompilationUnit cu = JavaParser.parse(new StringReader(fileContent));
PackageDeclaration pd = Navigator.findNodeOfGivenClass(cu, PackageDeclaration.class);
if (pd != null)
{
packageName = JavaparserDeclNameResolver.getQualifiedName(pd.getName()).toString();
}
}
catch (ParseProblemException e)
{
// do nothing
}
catch (IllegalArgumentException e)
{
// do nothing
}
ASTParser parser = ASTParser.newParser(AST.JLS8);
parser.setKind(ASTParser.K_COMPILATION_UNIT); // specify to parse the entire compilation unit
parser.setSource(fileContent.toCharArray());
CompilationUnit cu = (CompilationUnit) parser.createAST(null);
PackageDeclaration packageDeclaration = cu.getPackage();
if (packageDeclaration != null)
{
packageName = packageDeclaration.getName().getFullyQualifiedName();
}
return packageName;
}
public static void clearCaches()
{
typeSolvers.clear();
JavaParserFacade.clearInstances();
Runtime.getRuntime().gc();
}
@@ -158,36 +139,30 @@ public class JavaIndexer
static public native void logError(int address, String error);
static public native void recordSymbol(
int address, String symbolName, int symbolType,
int access, int definitionKind
);
int address, String symbolName, int symbolType,
int access, int definitionKind);
static public native void recordSymbolWithLocation(
int address, String symbolName, int symbolType,
int beginLine, int beginColumn, int endLine, int endColumn,
int access, int definitionKind
);
int address, String symbolName, int symbolType,
int beginLine, int beginColumn, int endLine, int endColumn,
int access, int definitionKind);
static public native void recordSymbolWithLocationAndScope(
int address, String symbolName, int symbolType,
int beginLine, int beginColumn, int endLine, int endColumn,
int scopeBeginLine, int scopeBeginColumn, int scopeEndLine, int scopeEndColumn,
int access, int definitionKind
int address, String symbolName, int symbolType,
int beginLine, int beginColumn, int endLine, int endColumn,
int scopeBeginLine, int scopeBeginColumn, int scopeEndLine, int scopeEndColumn,
int access, int definitionKind
);
static public native void recordReference(
int address, int referenceKind, String referencedName, String contextName, int beginLine, int beginColumn, int endLine, int endColumn
);
int address, int referenceKind, String referencedName, String contextName, int beginLine, int beginColumn, int endLine, int endColumn);
static public native void recordLocalSymbol(
int address, String symbolName, int beginLine, int beginColumn, int endLine, int endColumn
);
int address, String symbolName, int beginLine, int beginColumn, int endLine, int endColumn);
static public native void recordComment(
int address, int beginLine, int beginColumn, int endLine, int endColumn
);
int address, int beginLine, int beginColumn, int endLine, int endColumn);
static public native void recordError(
int address, String message, int fatal, int indexed, int beginLine, int beginColumn, int endLine, int endColumn
);
int address, String message, int fatal, int indexed, int beginLine, int beginColumn, int endLine, int endColumn);
}
@@ -1,6 +1,6 @@
package com.sourcetrail;
import com.github.javaparser.Range;
import com.sourcetrail.name.NameHierarchy;
public class JavaIndexerAstVisitorClient extends AstVisitorClient
{
@@ -37,76 +37,68 @@ public class JavaIndexerAstVisitorClient extends AstVisitorClient
@Override
public void recordSymbol(
String symbolName, SymbolKind symbolType,
AccessKind access, DefinitionKind definitionKind)
NameHierarchy symbolName, SymbolKind symbolKind,
AccessKind access, DefinitionKind definitionKind)
{
JavaIndexer.recordSymbol(
m_address, symbolName, symbolType.getValue(),
access.getValue(), definitionKind.getValue()
);
m_address, symbolName.serialize(), symbolKind.getValue(),
access.getValue(), definitionKind.getValue());
}
@Override
public void recordSymbolWithLocation(
String symbolName, SymbolKind symbolType, Range range,
AccessKind access, DefinitionKind definitionKind)
NameHierarchy symbolName, SymbolKind symbolKind, Range range,
AccessKind access, DefinitionKind definitionKind)
{
JavaIndexer.recordSymbolWithLocation(
m_address, symbolName, symbolType.getValue(),
range.begin.line, range.begin.column, range.end.line, range.end.column,
access.getValue(), definitionKind.getValue()
);
m_address, symbolName.serialize(), symbolKind.getValue(),
range.begin.line, range.begin.column, range.end.line, range.end.column,
access.getValue(), definitionKind.getValue());
}
@Override
public void recordSymbolWithLocationAndScope(
String symbolName, SymbolKind symbolType, Range range,
Range scopeRange, AccessKind access, DefinitionKind definitionKind)
NameHierarchy symbolName, SymbolKind symbolKind, Range range,
Range scopeRange, AccessKind access, DefinitionKind definitionKind)
{
JavaIndexer.recordSymbolWithLocationAndScope(
m_address, symbolName, symbolType.getValue(),
range.begin.line, range.begin.column, range.end.line, range.end.column,
scopeRange.begin.line, scopeRange.begin.column, scopeRange.end.line, scopeRange.end.column,
access.getValue(), definitionKind.getValue()
);
m_address, symbolName.serialize(), symbolKind.getValue(),
range.begin.line, range.begin.column, range.end.line, range.end.column,
scopeRange.begin.line, scopeRange.begin.column, scopeRange.end.line, scopeRange.end.column,
access.getValue(), definitionKind.getValue());
}
@Override
public void recordReference(
ReferenceKind referenceKind, String referencedName,
String contextName, Range range)
ReferenceKind referenceKind, NameHierarchy referencedName,
NameHierarchy contextName, Range range)
{
JavaIndexer.recordReference(
m_address, referenceKind.getValue(), referencedName, contextName,
range.begin.line, range.begin.column, range.end.line, range.end.column
);
m_address, referenceKind.getValue(), referencedName.serialize(), contextName.serialize(),
range.begin.line, range.begin.column, range.end.line, range.end.column);
}
@Override
public void recordLocalSymbol(String symbolName, Range range)
public void recordLocalSymbol(NameHierarchy symbolName, Range range)
{
JavaIndexer.recordLocalSymbol(
m_address, symbolName,
range.begin.line, range.begin.column, range.end.line, range.end.column
);
m_address, symbolName.serialize(),
range.begin.line, range.begin.column, range.end.line, range.end.column);
}
@Override
public void recordComment(Range range)
{
JavaIndexer.recordComment(
m_address,
range.begin.line, range.begin.column, range.end.line, range.end.column
);
m_address,
range.begin.line, range.begin.column, range.end.line, range.end.column);
}
@Override
public void recordError(String message, boolean fatal, boolean indexed, Range range)
{
JavaIndexer.recordError(
m_address, message, (fatal ? 1 : 0), (indexed ? 1 : 0),
range.begin.line, range.begin.column, range.end.line, range.end.column
);
m_address, message, (fatal ? 1 : 0), (indexed ? 1 : 0),
range.begin.line, range.begin.column, range.end.line, range.end.column);
}
}
@@ -1,26 +0,0 @@
package com.sourcetrail;
import java.io.File;
import com.github.javaparser.symbolsolver.model.resolution.TypeSolver;
public abstract class JavaNameResolver
{
File m_currentFile = null;
TypeSolver m_typeSolver = null;
ContextList m_ignoredContexts = null;
public JavaNameResolver(File currentFile, TypeSolver typeSolver, ContextList ignoredContexts)
{
m_currentFile = currentFile;
m_typeSolver = typeSolver;
if (ignoredContexts != null)
{
m_ignoredContexts = ignoredContexts;
}
else
{
m_ignoredContexts = new ContextList();
}
}
}
@@ -1,239 +0,0 @@
package com.sourcetrail;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserAnnotationDeclaration;
import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserAnonymousClassDeclaration;
import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration;
import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserConstructorDeclaration;
import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserEnumConstantDeclaration;
import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserEnumDeclaration;
import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserFieldDeclaration;
import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserInterfaceDeclaration;
import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserMethodDeclaration;
import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserParameterDeclaration;
import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserSymbolDeclaration;
import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserTypeParameter;
import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserTypeVariableDeclaration;
import com.github.javaparser.symbolsolver.model.declarations.Declaration;
import com.github.javaparser.symbolsolver.model.declarations.MethodDeclaration;
import com.github.javaparser.symbolsolver.model.declarations.MethodLikeDeclaration;
import com.github.javaparser.symbolsolver.model.declarations.ReferenceTypeDeclaration;
import com.github.javaparser.symbolsolver.model.declarations.TypeParameterDeclaration;
import com.github.javaparser.symbolsolver.model.declarations.TypeParametrizable;
import com.github.javaparser.symbolsolver.model.resolution.TypeSolver;
import com.sourcetrail.name.JavaDeclName;
import com.sourcetrail.name.JavaFunctionDeclName;
import com.sourcetrail.name.JavaTypeName;
import com.sourcetrail.name.JavaVariableDeclName;
public class JavaSymbolSolverDeclNameResolver extends JavaNameResolver
{
public JavaSymbolSolverDeclNameResolver(File currentFile, TypeSolver typeSolver, ContextList ignoredContexts)
{
super(currentFile, typeSolver, ignoredContexts);
}
public static JavaDeclName getQualifiedDeclName(Declaration decl, File currentFile, TypeSolver typeSolver)
{
return getQualifiedDeclName(decl, currentFile, typeSolver, null);
}
public static JavaDeclName getQualifiedDeclName(Declaration decl, File currentFile, TypeSolver typeSolver, ContextList ignoredContexts)
{
JavaSymbolSolverDeclNameResolver resolver = new JavaSymbolSolverDeclNameResolver(currentFile, typeSolver, ignoredContexts);
return resolver.getQualifiedDeclName(decl);
}
public JavaDeclName getQualifiedDeclName(Declaration decl)
{
JavaDeclName declName = null;
if (decl instanceof JavaParserAnnotationDeclaration)
{
// TODO: implement
System.out.println("solving name of JavaParserAnnotationDeclaration not implemented");
declName = JavaDeclName.unsolved();
}
if (decl instanceof JavaParserAnonymousClassDeclaration)
{
// TODO: implement maybe the case is new XXX { methods and stuff }.doSomething();
System.out.println("solving name of JavaParserAnonymousClassDeclaration not implemented");
declName = JavaDeclName.unsolved();
}
else if (decl instanceof JavaParserClassDeclaration)
{
declName = JavaparserDeclNameResolver.getQualifiedDeclName(
((JavaParserClassDeclaration)decl).getWrappedNode(), m_currentFile, m_typeSolver, m_ignoredContexts);
}
else if (decl instanceof JavaParserConstructorDeclaration)
{
declName = JavaparserDeclNameResolver.getQualifiedDeclName(
((JavaParserConstructorDeclaration)decl).getWrappedNode(), m_currentFile, m_typeSolver, m_ignoredContexts);
}
else if (decl instanceof JavaParserEnumDeclaration)
{
declName = JavaparserDeclNameResolver.getQualifiedDeclName(
((JavaParserEnumDeclaration)decl).getWrappedNode(), m_currentFile, m_typeSolver, m_ignoredContexts);
}
else if (decl instanceof JavaParserEnumConstantDeclaration)
{
declName = JavaparserDeclNameResolver.getQualifiedDeclName(
((JavaParserEnumConstantDeclaration)decl).getWrappedNode(), m_currentFile, m_typeSolver, m_ignoredContexts);
}
else if (decl instanceof JavaParserFieldDeclaration)
{
declName = JavaparserDeclNameResolver.getQualifiedDeclName(
((JavaParserFieldDeclaration)decl).getWrappedNode(), m_currentFile, m_typeSolver, m_ignoredContexts);
}
else if (decl instanceof JavaParserInterfaceDeclaration)
{
declName = JavaparserDeclNameResolver.getQualifiedDeclName(
((JavaParserInterfaceDeclaration)decl).getWrappedNode(), m_currentFile, m_typeSolver, m_ignoredContexts);
}
else if (decl instanceof JavaParserMethodDeclaration)
{
declName = JavaparserDeclNameResolver.getQualifiedDeclName(
((JavaParserMethodDeclaration)decl).getWrappedNode(), m_currentFile, m_typeSolver, m_ignoredContexts);
}
else if (decl instanceof JavaParserParameterDeclaration)
{
System.out.println("solving name of JavaParserParameterDeclaration not implemented");
declName = JavaDeclName.unsolved();
}
else if (decl instanceof JavaParserSymbolDeclaration)
{
System.out.println("solving name of JavaParserSymbolDeclaration not implemented");
declName = JavaDeclName.unsolved();
}
else if (decl instanceof JavaParserTypeParameter)
{
declName = JavaparserDeclNameResolver.getQualifiedDeclName(
((JavaParserTypeParameter)decl).getWrappedNode(), m_currentFile, m_typeSolver, m_ignoredContexts);
}
else if (decl instanceof JavaParserTypeVariableDeclaration)
{
declName = JavaparserDeclNameResolver.getQualifiedDeclName(
((JavaParserTypeVariableDeclaration)decl).getWrappedNode(), m_currentFile, m_typeSolver, m_ignoredContexts);
}
else
{
String name = decl.getName();
List<String> typeParameters = new ArrayList<>();
if (decl instanceof TypeParametrizable)
{
typeParameters = getTypeParameterNames((TypeParametrizable) decl);
}
if (decl instanceof ReferenceTypeDeclaration)
{
declName = new JavaDeclName(name, typeParameters);
Optional<ReferenceTypeDeclaration> containerType = ((ReferenceTypeDeclaration) decl).containerType();
if (containerType.isPresent())
{
declName.setParent(getQualifiedDeclName(containerType.get(), m_currentFile, m_typeSolver, m_ignoredContexts));
}
else
{
declName.setParent(JavaDeclName.fromDotSeparatedString(((ReferenceTypeDeclaration) decl).getPackageName()));
}
}
else if (decl instanceof TypeParameterDeclaration)
{
declName = new JavaDeclName(name);
TypeParametrizable container = ((TypeParameterDeclaration) decl).getContainer();
if (!m_ignoredContexts.contains(container))
{
if (container instanceof ReferenceTypeDeclaration)
{
declName.setParent(getQualifiedDeclName((ReferenceTypeDeclaration) container, m_currentFile, m_typeSolver, m_ignoredContexts));
}
if (container instanceof MethodLikeDeclaration)
{
declName.setParent(getQualifiedDeclName((MethodLikeDeclaration) container, m_currentFile, m_typeSolver, m_ignoredContexts));
}
}
}
else if (decl instanceof MethodLikeDeclaration)
{
ContextList ignoredContextsForTypes = m_ignoredContexts.copy();
ignoredContextsForTypes.add((MethodLikeDeclaration) decl); // adding own decl
JavaTypeName returnTypeName = new JavaTypeName("", null);
boolean isStatic = false;
if (decl instanceof MethodDeclaration)
{
returnTypeName = JavaSymbolSolverTypeNameResolver.getQualifiedTypeName(((MethodDeclaration)decl).getReturnType(), m_currentFile, m_typeSolver, ignoredContextsForTypes);
isStatic = ((MethodDeclaration)decl).isStatic();
}
declName = new JavaFunctionDeclName(
name, typeParameters,
returnTypeName,
getParameterTypeNames((MethodLikeDeclaration) decl, m_currentFile, m_typeSolver, ignoredContextsForTypes),
isStatic);
declName.setParent(
getQualifiedDeclName(((MethodLikeDeclaration) decl).declaringType(), m_currentFile, m_typeSolver, m_ignoredContexts));
}
else if (decl instanceof com.github.javaparser.symbolsolver.model.declarations.FieldDeclaration)
{
com.github.javaparser.symbolsolver.model.declarations.FieldDeclaration fieldDecl = ((com.github.javaparser.symbolsolver.model.declarations.FieldDeclaration) decl);
declName = new JavaVariableDeclName(
name,
JavaSymbolSolverTypeNameResolver.getQualifiedTypeName(fieldDecl.getType(), m_currentFile, m_typeSolver, m_ignoredContexts),
fieldDecl.isStatic());
declName.setParent(
getQualifiedDeclName(
fieldDecl.declaringType(),
m_currentFile,
m_typeSolver,
m_ignoredContexts));
}
}
if (declName == null)
{
System.out.println("Unable to resolve qualified declaration name of " + decl.getClass().toString() + ": " + decl.toString());
declName = JavaDeclName.unsolved();
}
return declName;
}
private static List<String> getTypeParameterNames(TypeParametrizable decl)
{
List<String> typeParameterNames = new ArrayList<>();
List<TypeParameterDeclaration> typeParameters = decl.getTypeParameters();
if (typeParameters != null && typeParameters.size() > 0)
{
for (int i = 0; i < typeParameters.size(); i++)
{
typeParameterNames.add(typeParameters.get(i).getName());
}
}
return typeParameterNames;
}
private static List<JavaTypeName> getParameterTypeNames(MethodLikeDeclaration decl, File currentFile, TypeSolver typeSolver, ContextList ignoredContexts)
{
List<JavaTypeName> typeTypeParameterNames = new ArrayList<>();
for (int i = 0; i < decl.getNumberOfParams(); i++)
{
typeTypeParameterNames.add(JavaSymbolSolverTypeNameResolver.getQualifiedTypeName(
decl.getParam(i).getType(), currentFile, typeSolver, ignoredContexts
));
}
return typeTypeParameterNames;
}
}
@@ -1,99 +0,0 @@
package com.sourcetrail;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import com.github.javaparser.ast.body.BodyDeclaration;
import com.github.javaparser.symbolsolver.javaparsermodel.LambdaArgumentTypePlaceholder;
import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserTypeParameter;
import com.github.javaparser.symbolsolver.logic.InferenceVariableType;
import com.github.javaparser.symbolsolver.model.declarations.TypeParameterDeclaration;
import com.github.javaparser.symbolsolver.model.resolution.TypeSolver;
import com.github.javaparser.symbolsolver.model.typesystem.ArrayType;
import com.github.javaparser.symbolsolver.model.typesystem.NullType;
import com.github.javaparser.symbolsolver.model.typesystem.PrimitiveType;
import com.github.javaparser.symbolsolver.model.typesystem.ReferenceType;
import com.github.javaparser.symbolsolver.model.typesystem.Type;
import com.github.javaparser.symbolsolver.model.typesystem.TypeVariable;
import com.github.javaparser.symbolsolver.model.typesystem.VoidType;
import com.github.javaparser.symbolsolver.model.typesystem.Wildcard;
import com.sourcetrail.name.JavaDeclName;
import com.sourcetrail.name.JavaTypeName;
public class JavaSymbolSolverTypeNameResolver extends JavaNameResolver
{
public JavaSymbolSolverTypeNameResolver(File currentFile, TypeSolver typeSolver, ContextList ignoredContexts)
{
super(currentFile, typeSolver, ignoredContexts);
}
public static JavaTypeName getQualifiedTypeName(Type type, File currentFile, TypeSolver typeSolver)
{
return getQualifiedTypeName(type, currentFile, typeSolver, null);
}
public static JavaTypeName getQualifiedTypeName(Type type, File currentFile, TypeSolver typeSolver, ContextList ignoredContexts)
{
JavaSymbolSolverTypeNameResolver resolver = new JavaSymbolSolverTypeNameResolver(currentFile, typeSolver, ignoredContexts);
return resolver.getQualifiedTypeName(type);
}
public JavaTypeName getQualifiedTypeName(Type type)
{
if (type instanceof ArrayType)
{
return getQualifiedTypeName(((ArrayType)type).getComponentType());
}
else if (type instanceof LambdaArgumentTypePlaceholder)
{
}
else if (type instanceof InferenceVariableType)
{
}
else if (type instanceof NullType)
{
return JavaTypeName.fromDotSeparatedString(type.describe());
}
else if (type instanceof PrimitiveType)
{
return JavaTypeName.fromDotSeparatedString(type.describe());
}
else if (type instanceof ReferenceType)
{
ReferenceType refTypeUsage = (ReferenceType)type;
JavaDeclName declName = JavaSymbolSolverDeclNameResolver.getQualifiedDeclName(
refTypeUsage.getTypeDeclaration(),
m_currentFile,
m_typeSolver,
m_ignoredContexts);
return new JavaTypeName(declName.getName() + declName.getTypeParameterString(), new ArrayList<JavaTypeName>(), declName.getParent());
}
else if (type instanceof TypeVariable)
{
JavaDeclName declName = JavaSymbolSolverDeclNameResolver.getQualifiedDeclName(
((TypeVariable)type).asTypeParameter(),
m_currentFile,
m_typeSolver,
m_ignoredContexts);
return new JavaTypeName(declName.getName(), new ArrayList<JavaTypeName>(), declName.getParent());
}
else if (type instanceof VoidType)
{
return JavaTypeName.fromDotSeparatedString(type.describe());
}
else if (type instanceof Wildcard)
{
return new JavaTypeName("?", null);
}
System.out.println("Unable to resolve qualified name of " + type.getClass().toString() + ": " + type.toString());
return JavaTypeName.unsolved();
}
}
@@ -1,309 +0,0 @@
package com.sourcetrail;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import com.github.javaparser.Position;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.PackageDeclaration;
import com.github.javaparser.ast.body.AnnotationMemberDeclaration;
import com.github.javaparser.ast.body.BodyDeclaration;
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
import com.github.javaparser.ast.body.ConstructorDeclaration;
import com.github.javaparser.ast.body.EnumConstantDeclaration;
import com.github.javaparser.ast.body.FieldDeclaration;
import com.github.javaparser.ast.body.InitializerDeclaration;
import com.github.javaparser.ast.body.MethodDeclaration;
import com.github.javaparser.ast.body.Parameter;
import com.github.javaparser.ast.body.TypeDeclaration;
import com.github.javaparser.ast.body.VariableDeclarator;
import com.github.javaparser.ast.expr.Name;
import com.github.javaparser.ast.expr.ObjectCreationExpr;
import com.github.javaparser.ast.type.TypeParameter;
import com.github.javaparser.symbolsolver.model.resolution.TypeSolver;
import com.sourcetrail.name.JavaDeclName;
import com.sourcetrail.name.JavaFunctionDeclName;
import com.sourcetrail.name.JavaTypeName;
import com.sourcetrail.name.JavaVariableDeclName;
public class JavaparserDeclNameResolver extends JavaNameResolver
{
public JavaparserDeclNameResolver(File currentFile, TypeSolver typeSolver, ContextList ignoredContexts)
{
super(currentFile, typeSolver, ignoredContexts);
}
public static JavaDeclName getQualifiedDeclName(VariableDeclarator decl, File currentFile, TypeSolver typeSolver)
{
return getQualifiedDeclName(decl, currentFile, typeSolver, null);
}
public static JavaDeclName getQualifiedDeclName(VariableDeclarator decl, File currentFile, TypeSolver typeSolver, ContextList ignoredContexts)
{
JavaparserDeclNameResolver resolver = new JavaparserDeclNameResolver(currentFile, typeSolver, ignoredContexts);
return resolver.getQualifiedDeclName(decl);
}
public JavaDeclName getQualifiedDeclName(VariableDeclarator decl)
{
JavaDeclName declName = JavaDeclName.unsolved();
if (decl != null)
{
declName = getDeclName(decl);
if (!declName.getIsUnsolved())
{
declName.setParent(getQualifiedContextName(decl));
}
}
return declName;
}
public JavaDeclName getDeclName(VariableDeclarator decl)
{
JavaTypeName typeName = JavaparserTypeNameResolver.getQualifiedTypeName(decl.getType(), m_currentFile, m_typeSolver, m_ignoredContexts.copy());
boolean isStatic = false;
Optional<FieldDeclaration> fieldDeclaration = decl.getAncestorOfType(FieldDeclaration.class);
if (fieldDeclaration.isPresent())
{
isStatic = fieldDeclaration.get().isStatic();
}
return new JavaVariableDeclName(decl.getNameAsString(), typeName, isStatic);
}
public static JavaDeclName getQualifiedDeclName(BodyDeclaration decl, File currentFile, TypeSolver typeSolver)
{
return getQualifiedDeclName(decl, currentFile, typeSolver, null);
}
public static JavaDeclName getQualifiedDeclName(BodyDeclaration decl, File currentFile, TypeSolver typeSolver, ContextList ignoredContexts)
{
JavaparserDeclNameResolver resolver = new JavaparserDeclNameResolver(currentFile, typeSolver, ignoredContexts);
return resolver.getQualifiedDeclName(decl);
}
public JavaDeclName getQualifiedDeclName(BodyDeclaration<?> decl)
{
JavaDeclName declName = JavaDeclName.unsolved();
if (decl != null)
{
declName = getDeclName(decl);
if (!declName.getIsUnsolved())
{
declName.setParent(getQualifiedContextName(decl));
}
}
return declName;
}
public JavaDeclName getDeclName(BodyDeclaration decl)
{
JavaDeclName declName = JavaDeclName.unsolved();
if (decl != null)
{
if (decl instanceof AnnotationMemberDeclaration)
{
declName = new JavaDeclName("AnnotationMemberDeclaration");
}
else if (decl instanceof ConstructorDeclaration)
{
CallableConstructorDecl callableDecl = new CallableConstructorDecl((ConstructorDeclaration)decl);
declName = getDeclNameOfCallable(callableDecl);
}
else if (decl instanceof EnumConstantDeclaration)
{
declName = new JavaDeclName(((EnumConstantDeclaration)decl).getNameAsString());
}
else if (decl instanceof FieldDeclaration)
{
throw new UnsupportedOperationException();
}
else if (decl instanceof InitializerDeclaration)
{
declName = new JavaDeclName("InitializerDeclaration");
}
else if (decl instanceof MethodDeclaration)
{
CallableMethodDecl callableDecl = new CallableMethodDecl((MethodDeclaration)decl);
declName = getDeclNameOfCallable(callableDecl);
}
else if (decl instanceof TypeDeclaration)
{
declName = new JavaDeclName(((TypeDeclaration)decl).getNameAsString(), getTypeParameterNames((TypeDeclaration)decl));
}
}
return declName;
}
public static JavaDeclName getQualifiedDeclName(TypeParameter decl, File currentFile, TypeSolver typeSolver)
{
return getQualifiedDeclName(decl, currentFile, typeSolver, null);
}
public static JavaDeclName getQualifiedDeclName(TypeParameter decl, File currentFile, TypeSolver typeSolver, ContextList ignoredContexts)
{
JavaparserDeclNameResolver resolver = new JavaparserDeclNameResolver(currentFile, typeSolver, ignoredContexts);
return resolver.getQualifiedDeclName(decl);
}
public JavaDeclName getQualifiedDeclName(TypeParameter decl)
{
JavaDeclName declName = JavaDeclName.unsolved();
if (decl != null)
{
declName = getDeclName(decl);
if (!declName.getIsUnsolved())
{
declName.setParent(getQualifiedContextName(decl));
}
}
return declName;
}
public JavaDeclName getDeclName(TypeParameter decl)
{
return new JavaDeclName(decl.getName().asString());
}
public static JavaDeclName getQualifiedDeclName(ObjectCreationExpr anonymousClassDecl, File currentFile, TypeSolver typeSolver)
{
return getQualifiedDeclName(anonymousClassDecl, currentFile, typeSolver, null);
}
public static JavaDeclName getQualifiedDeclName(ObjectCreationExpr anonymousClassDecl, File currentFile, TypeSolver typeSolver, ContextList ignoredContexts)
{
JavaparserDeclNameResolver resolver = new JavaparserDeclNameResolver(currentFile, typeSolver, ignoredContexts);
return resolver.getQualifiedDeclName(anonymousClassDecl);
}
public JavaDeclName getQualifiedDeclName(ObjectCreationExpr anonymousClassDecl)
{
JavaDeclName declName = JavaDeclName.unsolved();
if (anonymousClassDecl != null)
{
declName = getDeclName(anonymousClassDecl);
if (!declName.getIsUnsolved())
{
declName.setParent(getQualifiedContextName(anonymousClassDecl));
}
}
return declName;
}
public JavaDeclName getDeclName(ObjectCreationExpr anonymousClassDecl)
{
if (anonymousClassDecl.getAnonymousClassBody().isPresent())
{
Position position = anonymousClassDecl.getBegin().orElse(new Position(0, 0));
return JavaDeclName.anonymousClass(m_currentFile.getName(), position.line, position.column);
}
return JavaDeclName.unsolved();
}
private static List<String> getTypeParameterNames(TypeDeclaration decl)
{
NodeList<TypeParameter> typeParameters = null;
if (decl instanceof ClassOrInterfaceDeclaration)
{
typeParameters = (NodeList<TypeParameter>) ((ClassOrInterfaceDeclaration)decl).getTypeParameters();
}
return getTypeParameterNames(typeParameters);
}
private static List<String> getTypeParameterNames(NodeList<TypeParameter> typeParameters)
{
List<String> typeParameterNames = new ArrayList<>();
if (typeParameters != null && typeParameters.size() > 0)
{
for (int i = 0; i < typeParameters.size(); i++)
{
typeParameterNames.add(typeParameters.get(i).getNameAsString());
}
}
return typeParameterNames;
}
public static JavaDeclName getQualifiedName(Name name)
{
JavaDeclName declName = new JavaDeclName(name.getId());
if (name.getQualifier().isPresent())
{
declName.setParent(getQualifiedName(name.getQualifier().get()));
}
return declName;
}
private JavaDeclName getQualifiedContextName(Node decl)
{
Node parentNode = decl.getParentNode().orElse(null);
if (parentNode == null)
{
return null;
}
if (parentNode instanceof BodyDeclaration && !(parentNode instanceof FieldDeclaration))
{
if (m_ignoredContexts.contains((BodyDeclaration) parentNode))
{
return null;
}
return getQualifiedDeclName((BodyDeclaration) parentNode);
}
else if (parentNode instanceof CompilationUnit)
{
Optional<PackageDeclaration> packageDecl = ((CompilationUnit) parentNode).getPackageDeclaration();
if (packageDecl.isPresent())
{
return getQualifiedName(packageDecl.get().getName());
}
return null;
}
else if (parentNode instanceof ObjectCreationExpr && ((ObjectCreationExpr) parentNode).getAnonymousClassBody().isPresent())
{
return getQualifiedDeclName((ObjectCreationExpr) parentNode);
}
return getQualifiedContextName(parentNode);
}
private <T extends CallableDecl> JavaDeclName getDeclNameOfCallable(T decl)
{
ContextList ignoredContextsForTypes = m_ignoredContexts.copy();
ignoredContextsForTypes.add(decl.getWrappedNode()); // adding own decl
List<JavaTypeName> parameterNames = new ArrayList<>();
for (Parameter parameter: decl.getParameters())
{
parameterNames.add(JavaparserTypeNameResolver.getQualifiedTypeName(parameter.getType(), m_currentFile, m_typeSolver, ignoredContextsForTypes));
}
JavaTypeName returnType = new JavaTypeName("", null);
if (decl.isMethod())
{
returnType = JavaparserTypeNameResolver.getQualifiedTypeName(decl.getType(), m_currentFile, m_typeSolver, ignoredContextsForTypes);
}
return new JavaFunctionDeclName(
decl.getName(),
getTypeParameterNames(decl.getTypeParameters()),
returnType,
parameterNames,
decl.isStatic()
);
}
}
@@ -1,101 +0,0 @@
package com.sourcetrail;
import java.io.File;
import com.github.javaparser.ast.type.*;
import com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade;
import com.github.javaparser.symbolsolver.model.resolution.TypeSolver;
import com.sourcetrail.name.JavaTypeName;
public class JavaparserTypeNameResolver extends JavaNameResolver
{
public JavaparserTypeNameResolver(File currentFile, TypeSolver typeSolver, ContextList ignoredContexts)
{
super(currentFile, typeSolver, ignoredContexts);
}
public static JavaTypeName getQualifiedTypeName(Type type, File currentFile, TypeSolver typeSolver)
{
return getQualifiedTypeName(type, currentFile, typeSolver, null);
}
public static JavaTypeName getQualifiedTypeName(Type type, File currentFile, TypeSolver typeSolver, ContextList ignoredContexts)
{
JavaparserTypeNameResolver resolver = new JavaparserTypeNameResolver(currentFile, typeSolver, ignoredContexts);
return resolver.getQualifiedTypeName(type);
}
public JavaTypeName getQualifiedTypeName(Type type)
{
String fallbackTypeName = type.toString();
if (type instanceof ClassOrInterfaceType)
{
try
{
return JavaSymbolSolverTypeNameResolver.getQualifiedTypeName(
JavaParserFacade.get(m_typeSolver).convert(type, type),
m_currentFile,
m_typeSolver,
m_ignoredContexts
);
}
catch (Exception e)
{
// log...
}
}
else if (type instanceof ArrayType)
{
ArrayType arrayType = (ArrayType)type;
// TODO: regard array info!
return getQualifiedTypeName(arrayType.getComponentType());
}
else if (type instanceof TypeParameter)
{
return JavaSymbolSolverTypeNameResolver.getQualifiedTypeName(
JavaParserFacade.get(m_typeSolver).convert(type, type),
m_currentFile,
m_typeSolver,
m_ignoredContexts
);
}
else if (type instanceof IntersectionType)
{
// System.out.println(" IntersectionType: " + fallbackTypeName);
return JavaTypeName.fromDotSeparatedString(type.toString());
}
else if (type instanceof PrimitiveType)
{
return JavaTypeName.fromDotSeparatedString(type.toString());
}
else if (type instanceof UnionType)
{
// System.out.println(" UnionType: " + fallbackTypeName);
return JavaTypeName.fromDotSeparatedString(type.toString());
}
else if (type instanceof UnknownType)
{
// System.out.println(" UnknownType: " + fallbackTypeName);
return JavaTypeName.fromDotSeparatedString(type.toString());
}
else if (type instanceof VoidType)
{
return JavaTypeName.fromDotSeparatedString(type.toString());
}
else if (type instanceof WildcardType)
{
// System.out.println(" WildcardType: " + fallbackTypeName);
return JavaTypeName.fromDotSeparatedString(type.toString());
}
System.out.println("Unable to resolve qualified name of " + type.getClass().toString() + ": " + fallbackTypeName);
return JavaTypeName.unsolved();
}
}
@@ -0,0 +1,17 @@
package com.sourcetrail;
public class Position
{
public int line = 0;
public int column = 0;
public Position()
{
}
public Position(int line, int column)
{
this.line = line;
this.column = column;
}
}
@@ -0,0 +1,27 @@
package com.sourcetrail;
public class Range
{
public Position begin = new Position();
public Position end = new Position();
public Range()
{
}
public Range(int beginLine, int beginColumn, int endLine, int endColumn)
{
this.begin.line = beginLine;
this.begin.column = beginColumn;
this.end.line = endLine;
this.end.column = endColumn;
}
public Range(Position begin, Position end)
{
this.begin.line = begin.line;
this.begin.column = begin.column;
this.end.line = end.line;
this.end.column = end.column;
}
}
@@ -0,0 +1,27 @@
package com.sourcetrail;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.BodyDeclaration;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.Javadoc;
public class Utility
{
public static Range getRange(ASTNode node, CompilationUnit compilationUnit)
{
int startPosition = node.getStartPosition() + 1;
int endPosition = node.getStartPosition() + node.getLength() - 1;
if (node instanceof BodyDeclaration && ((BodyDeclaration) node).getJavadoc() != null)
{
Javadoc javadoc = ((BodyDeclaration) node).getJavadoc();
startPosition = javadoc.getStartPosition() + javadoc.getLength() + 2;
}
return new Range(
compilationUnit.getLineNumber(startPosition),
compilationUnit.getColumnNumber(startPosition),
compilationUnit.getLineNumber(endPosition),
compilationUnit.getColumnNumber(endPosition) + 1);
}
}
@@ -1,226 +0,0 @@
package com.sourcetrail;
import com.github.javaparser.ast.*;
import com.github.javaparser.ast.body.*;
import com.github.javaparser.ast.comments.*;
import com.github.javaparser.ast.expr.*;
import com.github.javaparser.ast.nodeTypes.NodeWithName;
import com.github.javaparser.ast.stmt.*;
import com.github.javaparser.ast.type.*;
import com.github.javaparser.symbolsolver.model.resolution.TypeSolver;
public class VerboseAstVisitor extends AstVisitor{
public VerboseAstVisitor(AstVisitorClient client, String filePath, FileContent fileContent, TypeSolver typeSolver) {
super(client, filePath, fileContent, typeSolver);
}
int indent = 0;
String indentSymbol = "| ";
private String obfuscate(final String s)
{
if (s.isEmpty())
{
return "";
}
else if (s.length() <= 2)
{
return s;
}
return s.substring(0, 1) + ".." + s.substring(s.length() - 1, s.length());
}
private void dump(Node n)
{
String line = "";
for (int i = 0; i < this.indent; i++)
{
line += this.indentSymbol;
}
line += n.getClass().getName();
if (n instanceof NodeWithName<?>)
{
line += " [" + obfuscate(((NodeWithName<?>)n).getNameAsString()) + "]";
}
if (n.getBegin().isPresent())
{
line += " line: " + n.getBegin().get().line;
}
m_client.logInfo(line);
}
//- Compilation Unit ----------------------------------
public Boolean visit(CompilationUnit n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(PackageDeclaration n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(ImportDeclaration n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(TypeParameter n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(LineComment n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(BlockComment n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
//- Body ----------------------------------------------
public Boolean visit(ClassOrInterfaceDeclaration n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(EnumDeclaration n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(EnumConstantDeclaration n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(AnnotationDeclaration n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(AnnotationMemberDeclaration n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(FieldDeclaration n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(VariableDeclarator n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(ConstructorDeclaration n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(MethodDeclaration n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(Parameter n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(InitializerDeclaration n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(JavadocComment n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
//- Type ----------------------------------------------
public Boolean visit(ClassOrInterfaceType n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(PrimitiveType n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(ArrayType n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(ArrayCreationLevel n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(IntersectionType n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(UnionType n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(VoidType n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(WildcardType n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(UnknownType n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
//- Expression ----------------------------------------
public Boolean visit(ArrayAccessExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(ArrayCreationExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(ArrayInitializerExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(AssignExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(BinaryExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(CastExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(ClassExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(ConditionalExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(EnclosedExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(FieldAccessExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(InstanceOfExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(StringLiteralExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(IntegerLiteralExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(LongLiteralExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(CharLiteralExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(DoubleLiteralExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(BooleanLiteralExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(NullLiteralExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(MethodCallExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(NameExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(ObjectCreationExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(ThisExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(SuperExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(UnaryExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(VariableDeclarationExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(MarkerAnnotationExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(SingleMemberAnnotationExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(NormalAnnotationExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(MemberValuePair n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
//- Statements ----------------------------------------
public Boolean visit(ExplicitConstructorInvocationStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(AssertStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(BlockStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(LabeledStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(EmptyStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(ExpressionStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(SwitchStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(SwitchEntryStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(BreakStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(ReturnStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(IfStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(WhileStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(ContinueStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(DoStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(ForeachStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(ForStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(ThrowStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(SynchronizedStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(TryStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(CatchClause n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(LambdaExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(MethodReferenceExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(TypeExpr n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
public Boolean visit(UnparsableStmt n, Void v) { dump(n); indent++; Boolean result = super.visit(n, v); indent--; return result; }
}
@@ -0,0 +1,28 @@
package com.sourcetrail;
import java.io.File;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.CompilationUnit;
public class VerboseContextAwareAstVisitor extends ContextAwareAstVisitor
{
private String indentation = "";
public VerboseContextAwareAstVisitor(AstVisitorClient client, File filePath, String fileContent, CompilationUnit compilationUnit)
{
super(client, filePath, fileContent, compilationUnit);
}
public void preVisit(ASTNode node)
{
Range range = getRange(node);
m_client.logInfo(indentation + node.getClass().toString() + "[" + range.begin.line + ":" + range.begin.column + "|" + range.end.line + ":" + range.end.column + "]");
indentation += "| ";
}
public void postVisit(ASTNode node)
{
indentation = indentation.substring(0, indentation.length() - 2);
}
}
@@ -1,14 +1,19 @@
package com.sourcetrail.name;
import java.io.File;
import java.util.List;
public class JavaDeclName
import com.sourcetrail.Position;
public class JavaDeclName implements JavaSymbolName
{
private JavaDeclName m_parent = null;
private String m_name = "";
private List<String> m_typeParameterNames = null;
private boolean m_isUnsolved = false;
private boolean m_isAnonymous = false;
private boolean m_isLocal = false;
private boolean m_isGlobal = false;
public static JavaDeclName unsolved()
{
@@ -17,13 +22,33 @@ public class JavaDeclName
return declName;
}
public static JavaDeclName anonymousClass(String fileName, int line, int col)
public static JavaDeclName anonymousClass(File filePath, int line, int col)
{
JavaDeclName declName = new JavaDeclName("anonymous class (" + fileName + "<" + line + ":" + col + ">)");
JavaDeclName declName = new JavaDeclName("anonymous class (" + filePath.getName() + "<" + line + ":" + col + ">)");
declName.m_isAnonymous = true;
return declName;
}
public static JavaDeclName localSymbol(JavaDeclName methodContextName, int id)
{
JavaDeclName declName = new JavaDeclName(methodContextName + "<" + id + ">");
declName.m_isLocal = true;
return declName;
}
public static JavaDeclName globalSymbol(File fileContext, int id)
{
JavaDeclName declName = new JavaDeclName(fileContext.getName() + "<" + id + ">");
declName.m_isGlobal = true;
return declName;
}
public static JavaDeclName scope(File fileContext, Position begin)
{
JavaDeclName declName = new JavaDeclName(fileContext.getName() + "<" + begin.line + ":" + begin.column + ">");
return declName;
}
public static JavaDeclName fromDotSeparatedString(String s)
{
JavaDeclName declName = null;
@@ -78,6 +103,16 @@ public class JavaDeclName
return m_isAnonymous;
}
public boolean getIsLocal()
{
return m_isLocal;
}
public boolean getIsGlobal()
{
return m_isGlobal;
}
public NameHierarchy toNameHierarchy()
{
NameHierarchy nameHierarchy;
@@ -129,4 +164,8 @@ public class JavaDeclName
}
return string;
}
public List<String> getTypeParameterNames() {
return m_typeParameterNames;
}
}
@@ -0,0 +1,29 @@
package com.sourcetrail.name;
import java.io.File;
public class JavaFileName implements JavaSymbolName
{
private File m_filePath = null;
public JavaFileName(File filePath)
{
m_filePath = filePath;
}
@Override
public NameHierarchy toNameHierarchy()
{
NameHierarchy nameHierarchy;
if (m_filePath != null)
{
nameHierarchy = new NameHierarchy(m_filePath.toString().replaceAll("\\\\", "/"));
}
else
{
nameHierarchy = new NameHierarchy("unsolved-file");
}
nameHierarchy.setSeparator('/');
return nameHierarchy;
}
}
@@ -7,24 +7,24 @@ import java.util.Optional;
public class JavaFunctionDeclName extends JavaDeclName
{
private JavaTypeName m_returnTypeName = null;
private List<JavaTypeName> m_parameterNames = new ArrayList<>();
private List<JavaTypeName> m_parameterTypeNames = new ArrayList<>();
private boolean m_isStatic = false;
public JavaFunctionDeclName(String name, JavaTypeName returnTypeName, List<JavaTypeName> parameterNames, boolean isStatic)
public JavaFunctionDeclName(String name, JavaTypeName returnTypeName, List<JavaTypeName> parameterTypeNames, boolean isStatic)
{
super(name);
m_returnTypeName = returnTypeName;
if (m_parameterNames != null) m_parameterNames = parameterNames;
if (parameterTypeNames != null) m_parameterTypeNames = parameterTypeNames;
m_isStatic = isStatic;
}
public JavaFunctionDeclName(String name, List<String> typeParameterNames, JavaTypeName returnTypeName, List<JavaTypeName> parameterNames, boolean isStatic)
public JavaFunctionDeclName(String name, List<String> typeParameterNames, JavaTypeName returnTypeName, List<JavaTypeName> parameterTypeNames, boolean isStatic)
{
super(name, typeParameterNames);
m_returnTypeName = returnTypeName;
m_parameterNames = parameterNames;
if (parameterTypeNames != null) m_parameterTypeNames = parameterTypeNames;
m_isStatic = isStatic;
}
@@ -60,15 +60,15 @@ public class JavaFunctionDeclName extends JavaDeclName
private String getParameterString()
{
String string = "(";
if (m_parameterNames != null)
if (m_parameterTypeNames != null)
{
for (int i = 0; i < m_parameterNames.size(); i++)
for (int i = 0; i < m_parameterTypeNames.size(); i++)
{
if (i != 0)
{
string += ", ";
}
string += m_parameterNames.get(i).toString();
string += m_parameterTypeNames.get(i).toString();
}
}
string += ")";
@@ -0,0 +1,6 @@
package com.sourcetrail.name;
public interface JavaSymbolName
{
public NameHierarchy toNameHierarchy();
}
@@ -2,15 +2,19 @@ package com.sourcetrail.name;
import java.util.List;
public class JavaTypeName
public class JavaTypeName implements JavaSymbolName
{
private JavaDeclName m_parent = null;
private String m_name = "";
private List<JavaTypeName> m_typeArgumentNames = null;
private List<String> m_typeParameterNames = null;
private List<JavaTypeName> m_typeArguments = null;
private boolean m_isUnsolved = false;
public static JavaTypeName unsolved()
{
return new JavaTypeName("unsolved-type", null);
JavaTypeName typeName = new JavaTypeName("unsolved-type", null);
typeName.m_isUnsolved = true;
return typeName;
}
public static JavaTypeName fromDotSeparatedString(String s)
@@ -36,11 +40,12 @@ public class JavaTypeName
m_name = name;
}
public JavaTypeName(String name, List<JavaTypeName> typeArgumentNames, JavaDeclName parent)
public JavaTypeName(String name, List<String> typeParameterNames, List<JavaTypeName> typeArguments, JavaDeclName parent)
{
m_parent = parent;
m_name = name;
m_typeArgumentNames = typeArgumentNames;
m_typeParameterNames = typeParameterNames;
m_typeArguments = typeArguments;
}
public JavaDeclName getParent()
@@ -53,6 +58,13 @@ public class JavaTypeName
return m_name;
}
public JavaDeclName toDeclName()
{
JavaDeclName declName = new JavaDeclName(m_name, m_typeParameterNames);
declName.setParent(m_parent);
return declName;
}
public NameHierarchy toNameHierarchy()
{
NameHierarchy nameHierarchy;
@@ -89,16 +101,16 @@ public class JavaTypeName
private String getTypeArgumentString()
{
String string = "";
if (m_typeArgumentNames != null && !m_typeArgumentNames.isEmpty())
if (m_typeArguments != null && !m_typeArguments.isEmpty())
{
string += "<";
for (int i = 0; i < m_typeArgumentNames.size(); i++)
for (int i = 0; i < m_typeArguments.size(); i++)
{
if (i != 0)
{
string += ", ";
}
string += m_typeArgumentNames.get(i).toString();
string += m_typeArguments.get(i).toString();
}
string += ">";
}
@@ -7,6 +7,7 @@ import java.util.Optional;
public class NameHierarchy
{
private List<NameElement> m_elements = new ArrayList<>();
private char m_separatpr = '.';
public NameHierarchy()
{
@@ -27,6 +28,11 @@ public class NameHierarchy
m_elements.addAll(names);
}
public void setSeparator(char separator)
{
m_separatpr = separator;
}
public void push(NameElement element)
{
m_elements.add(element);
@@ -51,7 +57,7 @@ public class NameHierarchy
public String serialize()
{
String serialized = ".\tm";
String serialized = m_separatpr + "\tm";
for (int i = 0; i < m_elements.size(); i++)
{
@@ -0,0 +1,341 @@
package com.sourcetrail.name.resolver;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.IPackageBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.IVariableBinding;
import org.eclipse.jdt.core.dom.Modifier;
import com.sourcetrail.ContextList;
import com.sourcetrail.name.JavaDeclName;
import com.sourcetrail.name.JavaFunctionDeclName;
import com.sourcetrail.name.JavaTypeName;
import com.sourcetrail.name.JavaVariableDeclName;
public class BindingNameResolver extends NameResolver
{
public static IBinding getParentBinding(IBinding binding)
{
if (binding instanceof ITypeBinding)
{
return getParentBinding((ITypeBinding) binding);
}
else if (binding instanceof IMethodBinding)
{
return ((IMethodBinding) binding).getDeclaringClass();
}
else if (binding instanceof IVariableBinding)
{
return ((IVariableBinding) binding).getDeclaringClass();
}
return null;
}
public static IBinding getParentBinding(ITypeBinding binding)
{
if (binding.isLocal() || binding.isAnonymous())
{
if (binding.getDeclaringMember() instanceof IVariableBinding)
{
IVariableBinding variableBinding = (IVariableBinding) binding.getDeclaringMember();
if (variableBinding.getDeclaringClass() != null)
{
return variableBinding.getDeclaringClass();
}
else
{
return variableBinding.getDeclaringMethod();
}
}
else
{
return binding.getDeclaringMethod();
}
}
else if (binding.isMember())
{
return binding.getDeclaringClass();
}
else if (binding.isTypeVariable())
{
if (binding.getDeclaringClass() != null)
{
return binding.getDeclaringClass();
}
else
{
return binding.getDeclaringMethod();
}
}
else if (binding.isTopLevel())
{
return binding.getPackage();
}
return null; // we don't have a parent (like void doesn't have a parent)
}
public BindingNameResolver(File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
{
super(currentFile, compilationUnit, ignoredContexts);
}
public static Optional<JavaTypeName> getQualifiedName(ITypeBinding binding, File currentFile, CompilationUnit compilationUnit)
{
return getQualifiedName(binding, currentFile, compilationUnit, null);
}
public static Optional<JavaTypeName> getQualifiedName(ITypeBinding binding, File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
{
BindingNameResolver resolver = new BindingNameResolver(currentFile, compilationUnit, ignoredContexts);
return resolver.getQualifiedName(binding);
}
public Optional<JavaTypeName> getQualifiedName(ITypeBinding binding)
{
if (binding == null)
{
return Optional.empty();
}
if (binding.isArray())
{
return getQualifiedName(binding.getElementType());
}
else if (binding.isAnonymous())
{
ASTNode node = m_compilationUnit.findDeclaringNode(binding);
if (node instanceof AnonymousClassDeclaration)
{
JavaDeclName decl = DeclNameResolver.getQualifiedDeclName((AnonymousClassDeclaration) node, m_currentFile, m_compilationUnit, m_ignoredContexts);
return Optional.of(new JavaTypeName(decl.getName(), decl.getTypeParameterNames(), null, decl.getParent()));
}
else
{
return Optional.empty();
}
}
if (binding.isParameterizedType())
{
List<JavaTypeName> typeArguments = new ArrayList<>();
for (ITypeBinding typeArgumentBinding: binding.getTypeArguments())
{
Optional<JavaTypeName> typeArgument = getQualifiedName(typeArgumentBinding);
if (typeArgument.isPresent())
{
typeArguments.add(typeArgument.get());
}
}
Optional<JavaTypeName> typeName = getQualifiedName(binding.getTypeDeclaration());
if (typeName.isPresent())
{
JavaDeclName declName = typeName.get().toDeclName();
return Optional.of(new JavaTypeName(declName.getName(), declName.getTypeParameterNames(), typeArguments, declName.getParent()));
}
else
{
return Optional.empty();
}
}
String name = binding.getName();
List<String> typeParameterNames = null;
if (binding.isGenericType())
{
typeParameterNames = new ArrayList<>();
for (ITypeBinding typeParameter: binding.getTypeParameters())
{
typeParameterNames.add(typeParameter.getName());
}
}
JavaDeclName parentDeclName = getQualifiedContextName(binding);
if (parentDeclName != null && parentDeclName.getIsUnsolved())
{
return Optional.empty();
}
// type arguments will be set in caller (which is this same method)
return Optional.of(new JavaTypeName(name, typeParameterNames, null, parentDeclName));
}
public static Optional<JavaDeclName> getQualifiedName(IMethodBinding binding, File currentFile, CompilationUnit compilationUnit)
{
return getQualifiedName(binding, currentFile, compilationUnit, null);
}
public static Optional<JavaDeclName> getQualifiedName(IMethodBinding binding, File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
{
BindingNameResolver resolver = new BindingNameResolver(currentFile, compilationUnit, ignoredContexts);
return resolver.getQualifiedName(binding);
}
public Optional<JavaDeclName> getQualifiedName(IMethodBinding binding)
{
if (binding == null)
{
return Optional.empty();
}
String name = binding.getName();
List<String> typeParameterNames = null;
if (binding.isGenericMethod())
{
typeParameterNames = new ArrayList<>();
for (ITypeBinding typeParameter: binding.getTypeParameters())
{
typeParameterNames.add(typeParameter.getName());
}
}
ContextList ignoredContexts = m_ignoredContexts.copy();
ignoredContexts.add(binding);
JavaTypeName returnTypeName = binding.isConstructor() ? null : getQualifiedName(binding.getReturnType(), m_currentFile, m_compilationUnit, ignoredContexts).orElse(JavaTypeName.unsolved());
List<JavaTypeName> parameterTypeNames = new ArrayList<>();
for (ITypeBinding parameterType: binding.getParameterTypes())
{
parameterTypeNames.add(getQualifiedName(parameterType, m_currentFile, m_compilationUnit, ignoredContexts).orElse(JavaTypeName.unsolved()));
}
boolean isStatic = Modifier.isStatic(binding.getModifiers());
JavaFunctionDeclName declName = new JavaFunctionDeclName(name, typeParameterNames, returnTypeName, parameterTypeNames, isStatic);
JavaDeclName parentDeclName = getQualifiedContextName(binding);
if (parentDeclName != null)
{
if (!parentDeclName.getIsUnsolved())
{
declName.setParent(parentDeclName);
}
else
{
return Optional.empty();
}
}
return Optional.of(declName);
}
public static Optional<JavaDeclName> getQualifiedName(IPackageBinding binding, File currentFile, CompilationUnit compilationUnit)
{
return getQualifiedName(binding, currentFile, compilationUnit, null);
}
public static Optional<JavaDeclName> getQualifiedName(IPackageBinding binding, File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
{
BindingNameResolver resolver = new BindingNameResolver(currentFile, compilationUnit, ignoredContexts);
return resolver.getQualifiedName(binding);
}
public Optional<JavaDeclName> getQualifiedName(IPackageBinding binding)
{
if (!binding.isUnnamed())
{
return Optional.of(JavaDeclName.fromDotSeparatedString(binding.getName()));
}
return Optional.empty();
}
public static JavaDeclName getQualifiedName(IVariableBinding binding, File currentFile, CompilationUnit compilationUnit)
{
return getQualifiedName(binding, currentFile, compilationUnit, null);
}
public static JavaDeclName getQualifiedName(IVariableBinding binding, File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
{
BindingNameResolver resolver = new BindingNameResolver(currentFile, compilationUnit, ignoredContexts);
return resolver.getQualifiedName(binding);
}
public JavaDeclName getQualifiedName(IVariableBinding binding)
{
if (binding == null)
{
return JavaDeclName.unsolved();
}
if (binding.isField() || binding.isEnumConstant())
{
JavaDeclName declName;
if (binding.isEnumConstant())
{
declName = new JavaDeclName(binding.getName());
}
else
{
JavaTypeName typeName = getQualifiedName(binding.getType()).orElse(JavaTypeName.unsolved());
declName = new JavaVariableDeclName(binding.getName(), typeName, Modifier.isStatic(binding.getModifiers()));
}
JavaDeclName parentDeclName = getQualifiedContextName(binding);
if (parentDeclName != null)
{
if (!parentDeclName.getIsUnsolved())
{
declName.setParent(parentDeclName);
}
else
{
declName = JavaDeclName.unsolved();
}
}
return declName;
}
else
{
if (binding.getDeclaringMethod() != null)
{
return JavaDeclName.localSymbol(getQualifiedName(binding.getDeclaringMethod()).orElse(JavaDeclName.unsolved()), binding.getVariableId());
}
else
{
return JavaDeclName.globalSymbol(m_currentFile, binding.getVariableId());
}
}
}
private JavaDeclName getQualifiedContextName(IBinding binding)
{
IBinding parentBinding = getParentBinding(binding);
if (parentBinding == null || m_ignoredContexts.contains(parentBinding))
{
return null;
}
if (parentBinding instanceof ITypeBinding)
{
return getQualifiedName((ITypeBinding) parentBinding).map(tn ->tn.toDeclName()).orElse(JavaDeclName.unsolved());
}
else if (parentBinding instanceof IMethodBinding)
{
return getQualifiedName((IMethodBinding) parentBinding).orElse(JavaDeclName.unsolved());
}
else if (parentBinding instanceof IVariableBinding)
{
return getQualifiedName((IVariableBinding) parentBinding);
}
else if (parentBinding instanceof IPackageBinding)
{
return getQualifiedName((IPackageBinding) parentBinding).orElse(null);
}
return null;
}
}
@@ -0,0 +1,318 @@
package com.sourcetrail.name.resolver;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.AnnotationTypeDeclaration;
import org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration;
import org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
import org.eclipse.jdt.core.dom.BodyDeclaration;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
import org.eclipse.jdt.core.dom.EnumDeclaration;
import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.IVariableBinding;
import org.eclipse.jdt.core.dom.Initializer;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jdt.core.dom.Name;
import org.eclipse.jdt.core.dom.PackageDeclaration;
import org.eclipse.jdt.core.dom.QualifiedName;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.TypeParameter;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import com.sourcetrail.ContextList;
import com.sourcetrail.Position;
import com.sourcetrail.Utility;
import com.sourcetrail.name.JavaDeclName;
import com.sourcetrail.name.JavaFunctionDeclName;
import com.sourcetrail.name.JavaTypeName;
import com.sourcetrail.name.JavaVariableDeclName;
public class DeclNameResolver extends NameResolver
{
public DeclNameResolver(File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
{
super(currentFile, compilationUnit, ignoredContexts);
}
public static JavaDeclName getQualifiedDeclName(VariableDeclarationFragment decl, File currentFile, CompilationUnit compilationUnit)
{
return getQualifiedDeclName(decl, currentFile, compilationUnit, null);
}
public static JavaDeclName getQualifiedDeclName(VariableDeclarationFragment decl, File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
{
DeclNameResolver resolver = new DeclNameResolver(currentFile, compilationUnit, ignoredContexts);
return resolver.getQualifiedDeclName(decl);
}
public JavaDeclName getQualifiedDeclName(VariableDeclarationFragment decl)
{
JavaDeclName declName = JavaDeclName.unsolved();
if (decl != null)
{
declName = getDeclName(decl);
if (!declName.getIsUnsolved())
{
JavaDeclName parentDeclName = getQualifiedContextName(decl);
if (parentDeclName != null)
{
if (!parentDeclName.getIsUnsolved())
{
declName.setParent(parentDeclName);
}
else
{
declName = JavaDeclName.unsolved();
}
}
}
}
return declName;
}
public JavaDeclName getDeclName(VariableDeclarationFragment decl)
{
JavaTypeName typeName = JavaTypeName.unsolved();
boolean isStatic = false;
Optional<FieldDeclaration> fieldDeclaration = getAncestorOfType(decl, FieldDeclaration.class);
if (fieldDeclaration.isPresent())
{
if (decl.resolveBinding() instanceof IVariableBinding)
{
isStatic = Modifier.isStatic(decl.resolveBinding().getModifiers());
}
else
{
isStatic = Modifier.isStatic(fieldDeclaration.get().getModifiers());
}
typeName = BindingNameResolver.getQualifiedName(
fieldDeclaration.get().getType().resolveBinding(),
m_currentFile,
m_compilationUnit,
m_ignoredContexts.copy()).orElse(JavaTypeName.unsolved());
}
return new JavaVariableDeclName(decl.getName().getIdentifier(), typeName, isStatic);
}
public static JavaDeclName getQualifiedDeclName(BodyDeclaration decl, File currentFile, CompilationUnit compilationUnit)
{
return getQualifiedDeclName(decl, currentFile, compilationUnit, null);
}
public static JavaDeclName getQualifiedDeclName(BodyDeclaration decl, File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
{
DeclNameResolver resolver = new DeclNameResolver(currentFile, compilationUnit, ignoredContexts);
return resolver.getQualifiedDeclName(decl);
}
public JavaDeclName getQualifiedDeclName(BodyDeclaration decl)
{
JavaDeclName declName = JavaDeclName.unsolved();
if (decl != null)
{
declName = getDeclName(decl);
if (!declName.getIsUnsolved())
{
JavaDeclName parentDeclName = getQualifiedContextName(decl);
if (parentDeclName != null)
{
if (!parentDeclName.getIsUnsolved())
{
declName.setParent(parentDeclName);
}
else
{
declName = JavaDeclName.unsolved();
}
}
}
}
return declName;
}
public JavaDeclName getDeclName(BodyDeclaration decl)
{
JavaDeclName declName = JavaDeclName.unsolved();
if (decl != null)
{
if (decl instanceof AnnotationTypeDeclaration)
{
declName = new JavaDeclName("AnnotationTypeDeclaration");
}
else if (decl instanceof EnumDeclaration)
{
declName = new JavaDeclName(((EnumDeclaration) decl).getName().getIdentifier());
}
else if (decl instanceof TypeDeclaration)
{
TypeDeclaration typeDeclaration = (TypeDeclaration) decl;
List<String> typeParameterNames = new ArrayList<>();
for (Object typeParameter: typeDeclaration.typeParameters())
{
if (typeParameter instanceof TypeParameter)
{
typeParameterNames.add(((TypeParameter) typeParameter).getName().getIdentifier());
}
}
declName = new JavaDeclName(typeDeclaration.getName().getIdentifier(), typeParameterNames);
}
else if (decl instanceof AnnotationTypeMemberDeclaration)
{
declName = new JavaDeclName("AnnotationTypeMemberDeclaration");
}
else if (decl instanceof EnumConstantDeclaration)
{
declName = new JavaDeclName(((EnumConstantDeclaration) decl).getName().getIdentifier());
}
else if (decl instanceof FieldDeclaration)
{
declName = new JavaDeclName("FieldDeclaration");
}
else if (decl instanceof Initializer)
{
declName = new JavaDeclName("Initializer");
}
else if (decl instanceof MethodDeclaration)
{
MethodDeclaration methodDeclaration = (MethodDeclaration) decl;
List<String> typeParameterNames = new ArrayList<>();
for (Object typeParameter: methodDeclaration.typeParameters())
{
if (typeParameter instanceof TypeParameter)
{
typeParameterNames.add(((TypeParameter) typeParameter).getName().getIdentifier());
}
}
ContextList ignoredContexts = m_ignoredContexts.copy();
ignoredContexts.add(((MethodDeclaration) decl).resolveBinding());
JavaTypeName returnTypeName = methodDeclaration.isConstructor() ? null : BindingNameResolver.getQualifiedName(
methodDeclaration.getReturnType2().resolveBinding(), m_currentFile, m_compilationUnit, ignoredContexts).orElse(JavaTypeName.unsolved());
List<JavaTypeName> parameterTypeNames = new ArrayList<>();
for (Object parameter: methodDeclaration.parameters())
{
if (parameter instanceof SingleVariableDeclaration)
{
parameterTypeNames.add(BindingNameResolver.getQualifiedName(
((SingleVariableDeclaration) parameter).getType().resolveBinding(), m_currentFile, m_compilationUnit, ignoredContexts).orElse(JavaTypeName.unsolved()));
}
}
declName = new JavaFunctionDeclName(
methodDeclaration.getName().getIdentifier(),
typeParameterNames,
returnTypeName,
parameterTypeNames,
Modifier.isStatic(methodDeclaration.getModifiers()));
}
}
return declName;
}
public static JavaDeclName getQualifiedDeclName(AnonymousClassDeclaration decl, File currentFile, CompilationUnit compilationUnit)
{
return getQualifiedDeclName(decl, currentFile, compilationUnit, null);
}
public static JavaDeclName getQualifiedDeclName(AnonymousClassDeclaration decl, File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
{
DeclNameResolver resolver = new DeclNameResolver(currentFile, compilationUnit, ignoredContexts);
return resolver.getQualifiedDeclName(decl);
}
public JavaDeclName getQualifiedDeclName(AnonymousClassDeclaration decl)
{
JavaDeclName declName = JavaDeclName.unsolved();
if (decl != null)
{
declName = getDeclName(decl);
if (!declName.getIsUnsolved())
{
JavaDeclName parentDeclName = getQualifiedContextName(decl);
if (parentDeclName != null)
{
if (!parentDeclName.getIsUnsolved())
{
declName.setParent(parentDeclName);
}
else
{
declName = JavaDeclName.unsolved();
}
}
}
}
return declName;
}
public JavaDeclName getDeclName(AnonymousClassDeclaration decl)
{
Position pos = Utility.getRange(decl, m_compilationUnit).begin;
return JavaDeclName.anonymousClass(m_currentFile, pos.line, pos.column);
}
public static JavaDeclName getQualifiedName(Name name)
{
if (name.isSimpleName())
{
return new JavaDeclName(((SimpleName) name).getIdentifier());
}
else
{
JavaDeclName declName = new JavaDeclName(((QualifiedName) name).getName().getIdentifier());
declName.setParent(getQualifiedName(((QualifiedName) name).getQualifier()));
return declName;
}
}
private JavaDeclName getQualifiedContextName(ASTNode decl)
{
ASTNode parentNode = decl.getParent();
if (parentNode == null)
{
return null;
}
if (parentNode instanceof BodyDeclaration && !(parentNode instanceof FieldDeclaration))
{
return getQualifiedDeclName((BodyDeclaration) parentNode);
}
else if (parentNode instanceof AnonymousClassDeclaration)
{
return getQualifiedDeclName((AnonymousClassDeclaration) parentNode);
}
else if (parentNode instanceof CompilationUnit)
{
PackageDeclaration packageDecl = ((CompilationUnit) parentNode).getPackage();
if (packageDecl != null)
{
return getQualifiedName(packageDecl.getName());
}
return null;
}
return getQualifiedContextName(parentNode);
}
}
@@ -0,0 +1,45 @@
package com.sourcetrail.name.resolver;
import java.io.File;
import java.util.Optional;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.CompilationUnit;
import com.sourcetrail.ContextList;
public abstract class NameResolver
{
protected File m_currentFile = null;
protected ContextList m_ignoredContexts = null;
protected CompilationUnit m_compilationUnit = null;
static protected <N> Optional<N> getAncestorOfType(ASTNode node, Class<N> classType)
{
ASTNode parent = node.getParent();
while (parent != null)
{
if (classType.isAssignableFrom(parent.getClass()))
{
return Optional.of(classType.cast(parent));
}
parent = parent.getParent();
}
return Optional.empty();
}
public NameResolver(File currentFile, CompilationUnit compilationUnit, ContextList ignoredContexts)
{
m_currentFile = currentFile;
m_compilationUnit = compilationUnit;
if (ignoredContexts != null)
{
m_ignoredContexts = ignoredContexts;
}
else
{
m_ignoredContexts = new ContextList();
}
}
}
@@ -1,53 +0,0 @@
package com.sourcetrail.typesolver;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import com.github.javaparser.symbolsolver.model.declarations.ReferenceTypeDeclaration;
import com.github.javaparser.symbolsolver.model.resolution.SymbolReference;
import com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver;
public class SynchronizedJavaParserTypeSolver extends JavaParserTypeSolver
{
private ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
private Map<String, SymbolReference<ReferenceTypeDeclaration>> solvedTypes = new HashMap<>();
public SynchronizedJavaParserTypeSolver(File srcDir)
{
super(srcDir);
}
@Override
public SymbolReference<ReferenceTypeDeclaration> tryToSolveType(String name)
{
SymbolReference<ReferenceTypeDeclaration> solvedType = SymbolReference.unsolved(ReferenceTypeDeclaration.class);
{
lock.readLock().lock();
if (solvedTypes.containsKey(name))
{
solvedType = solvedTypes.get(name);
}
lock.readLock().unlock();
}
if (!solvedType.isSolved())
{
solvedType = super.tryToSolveType(name);
if (solvedType.isSolved())
{
lock.writeLock().lock();
if (!solvedTypes.containsKey(name))
{
solvedTypes.put(name, solvedType);
}
lock.writeLock().unlock();
}
}
return solvedType;
}
}
+1 -7
View File
@@ -38,10 +38,4 @@ echo -e $INFO "copy jars"
mkdir -p bin/app/data/java
rm -rf bin/app/data/java/*
cp -r java_indexer/target/java-indexer-1.0.jar bin/app/data/java/java-indexer.jar
cp -r java_indexer/target/dependency/guava*.jar bin/app/data/java
cp -r java_indexer/target/dependency/javaparser-core*.jar bin/app/data/java/javaparser-core.jar
cp -r java_indexer/target/dependency/javaslang*.jar bin/app/data/java
cp -r java_indexer/target/dependency/javassist*.jar bin/app/data/java
cp -r java_indexer/target/dependency/java-symbol-solver-core-x.x.x.jar bin/app/data/java/java-symbol-solver-core.jar
cp -r java_indexer/target/dependency/java-symbol-solver-logic-x.x.x.jar bin/app/data/java/java-symbol-solver-logic.jar
cp -r java_indexer/target/dependency/java-symbol-solver-model-x.x.x.jar bin/app/data/java/java-symbol-solver-model.jar
cp -r java_indexer/target/dependency/*.jar bin/app/data/java
+16 -8
View File
@@ -16,14 +16,22 @@
std::vector<std::string> JavaParser::getRequiredJarNames()
{
std::vector<std::string> jarNames = {
"guava-21.0.jar",
"java-indexer.jar",
"javaparser-core.jar",
"javaslang-2.0.3.jar",
"javassist-3.19.0-GA.jar",
"java-symbol-solver-core.jar",
"java-symbol-solver-logic.jar",
"java-symbol-solver-model.jar"
"org.eclipse.core.commands-3.8.1.jar",
"org.eclipse.core.contenttype-3.5.100.jar",
"org.eclipse.core.expressions-3.5.100.jar",
"org.eclipse.core.filesystem-1.6.1.jar",
"org.eclipse.core.jobs-3.8.0.jar",
"org.eclipse.core.resources-3.11.1.jar",
"org.eclipse.core.runtime-3.12.0.jar",
"org.eclipse.equinox.app-1.3.400.jar",
"org.eclipse.equinox.common-3.8.0.jar",
"org.eclipse.equinox.preferences-3.6.1.jar",
"org.eclipse.equinox.registry-3.6.100.jar",
"org.eclipse.jdt.core-3.12.3.jar",
"org.eclipse.osgi-3.11.3.jar",
"org.eclipse.text-3.6.0.jar"
};
return jarNames;
}
@@ -273,7 +281,7 @@ void JavaParser::doRecordReference(
void JavaParser::doRecordLocalSymbol(jstring jSymbolName, jint beginLine, jint beginColumn, jint endLine, jint endColumn)
{
m_client->onLocalSymbolParsed(
m_javaEnvironment->toStdString(jSymbolName),
NameHierarchy::deserialize(m_javaEnvironment->toStdString(jSymbolName)).getQualifiedName(),
ParseLocation(m_currentFilePath, beginLine, beginColumn, endLine, endColumn)
);
}
+322 -37
View File
@@ -37,7 +37,7 @@ public:
);
TS_ASSERT(utility::containsElement<std::string>(
client->packages, "foo <1:1 <1:9 1:11> 1:12>"
client->packages, "foo <1:9 1:11>"
));
}
@@ -120,7 +120,7 @@ public:
);
TS_ASSERT(utility::containsElement<std::string>(
client->enumConstants, "foo.A.A_TEST <4:2 4:10>"
client->enumConstants, "foo.A.A_TEST <4:2 4:7>"
));
}
@@ -173,7 +173,7 @@ public:
);
TS_ASSERT(utility::containsElement<std::string>(
client->classes, "foo.A.bar.anonymous class (input.cc<7:9>) <7:9 <7:13 7:13> 7:19>"
client->classes, "foo.A.bar.anonymous class (input.cc<7:17>) <7:17 <7:17 7:17> 7:19>"
));
}
@@ -197,7 +197,7 @@ public:
);
TS_ASSERT(utility::containsElement<std::string>(
client->methods, "public void foo.A.bar.anonymous class (input.cc<9:9>).foo() <11:4 <11:16 11:18> 11:23>"
client->methods, "public void foo.A.bar.anonymous class (input.cc<10:3>).foo() <11:4 <11:16 11:18> 11:23>"
));
}
@@ -306,7 +306,7 @@ public:
);
TS_ASSERT(utility::containsElement<std::string>(
client->localSymbols, "input.cc<4:15> <4:15 4:15>"
client->localSymbols, "foo.A.bar<0> <4:15 4:15>"
));
}
@@ -324,7 +324,7 @@ public:
);
TS_ASSERT(utility::containsElement<std::string>(
client->localSymbols, "input.cc<6:7> <6:7 6:7>"
client->localSymbols, "foo.A.bar<0> <6:7 6:7>"
));
}
@@ -357,6 +357,20 @@ public:
));
}
void test_java_parser_finds_field_of_interface_to_be_implicitly_static()
{
std::shared_ptr<TestParserClient> client = parseCode(
"public interface A\n"
"{\n"
" int b = 5;\n"
"}\n"
);
TS_ASSERT(utility::containsElement<std::string>(
client->fields, "default static int A.b <3:6 3:6>"
));
}
void test_java_parser_finds_line_comment()
{
std::shared_ptr<TestParserClient> client = parseCode(
@@ -365,7 +379,7 @@ public:
);
TS_ASSERT(utility::containsElement<std::string>(
client->comments, "comment <1:1 1:26>"
client->comments, "comment <1:1 1:25>"
));
}
@@ -388,19 +402,20 @@ public:
);
TS_ASSERT(utility::containsElement<std::string>(
client->errors, "Encountered unexpected token. <0:0 0:0>"
client->errors, "Syntax error on token \"foo\", ; expected after this token <1:9 1:11>"
));
}
//void _test_java_parser_finds_missing_import_as_error()
//{
// std::shared_ptr<TestParserClient> client = parseCode(
// "import foo;\n"
// );
void test_java_parser_finds_missing_import_as_error()
{
std::shared_ptr<TestParserClient> client = parseCode(
"import foo;\n"
);
// TS_ASSERT_EQUALS(client->errors.size(), 1);
// TS_ASSERT_EQUALS(client->errors[0], "Import not found. <1:8 1:10>");
//}
TS_ASSERT(utility::containsElement<std::string>(
client->errors, "The import foo cannot be resolved <1:8 1:10>"
));
}
@@ -449,17 +464,6 @@ public:
///////////////////////////////////////////////////////////////////////////////
// test finding usages of symbols
void test_java_parser_finds_name_of_package_imported_with_asterisk()
{
std::shared_ptr<TestParserClient> client = parseCode(
"import foo.bar.*;\n"
);
TS_ASSERT(utility::containsElement<std::string>(
client->imports, "input.cc -> foo.bar <1:8 1:14>"
));
}
void test_java_parser_finds_inheritance_using_extends_keyword()
{
std::shared_ptr<TestParserClient> client = parseCode(
@@ -496,6 +500,29 @@ public:
));
}
void test_java_parser_finds_inheritance_of_anonymous_class_declaration()
{
std::shared_ptr<TestParserClient> client = parseCode(
"public class A\n"
"{\n"
" public interface Base\n"
" {\n"
" }\n"
"\n"
" void foo()\n"
" {\n"
" Base b = new Base()\n"
" {\n"
" }\n"
" };\n"
"}\n"
);
TS_ASSERT(utility::containsElement<std::string>(
client->inheritances, "A.foo.anonymous class (input.cc<10:3>) -> A.Base <9:16 9:19>"
));
}
void test_java_parser_finds_type_parameter_in_signature_of_method()
{
std::shared_ptr<TestParserClient> client = parseCode(
@@ -508,10 +535,10 @@ public:
);
TS_ASSERT(utility::containsElement<std::string>(
client->typeUses, "A<T> A<T>.foo(A<T>) -> A<T> <3:9 3:9>"
client->typeUses, "A<java.lang.Void> A<T>.foo(A<java.lang.Void>) -> A<T> <3:9 3:9>"
));
TS_ASSERT(utility::containsElement<std::string>(
client->typeUses, "A<T> A<T>.foo(A<T>) -> A<T> <3:21 3:21>"
client->typeUses, "A<java.lang.Void> A<T>.foo(A<java.lang.Void>) -> A<T> <3:21 3:21>"
));
}
@@ -554,7 +581,7 @@ public:
));
}
void test_java_parser_finds_method_call_to_super()
void test_java_parser_finds_super_method_invocation()
{
std::shared_ptr<TestParserClient> client = parseCode(
"package foo;\n"
@@ -582,6 +609,237 @@ public:
));
}
void test_java_parser_finds_constructor_invocation()
{
std::shared_ptr<TestParserClient> client = parseCode(
"package foo;\n"
"public class Bar\n"
"{\n"
" public Bar()\n"
" {\n"
" }\n"
" \n"
" public Bar(int i)\n"
" {\n"
" this();\n"
" }\n"
"}\n"
);
TS_ASSERT(utility::containsElement<std::string>(
client->calls, "foo.Bar.Bar(int) -> foo.Bar.Bar() <10:3 10:6>"
));
}
void test_java_parser_finds_super_constructor_invocation()
{
std::shared_ptr<TestParserClient> client = parseCode(
"public class A\n"
"{\n"
" public class Base\n"
" {\n"
" }\n"
"\n"
" public class Derived extends Base\n"
" {\n"
" public Derived()\n"
" {\n"
" super();\n"
" }\n"
" }\n"
"}\n"
);
TS_ASSERT(utility::containsElement<std::string>(
client->calls, "A.Derived.Derived() -> A.Base.Base() <11:4 11:8>"
));
}
void test_java_parser_finds_invocation_of_method_of_anonymous_class()
{
std::shared_ptr<TestParserClient> client = parseCode(
"class Main {\n"
" public interface Interfaze {\n"
" public void foo();\n"
" }\n"
"\n"
" private Interfaze i = new Interfaze() {\n"
" public void foo() {\n"
" bar();\n"
" }\n"
"\n"
" private void bar() {\n"
" }\n"
" };\n"
"}\n"
);
TS_ASSERT(utility::containsElement<std::string>(
client->calls, "void Main.anonymous class (input.cc<6:40>).foo() -> void Main.anonymous class (input.cc<6:40>).bar() <8:4 8:6>"
));
}
void test_java_parser_finds_overridden_method_with_same_signature()
{
std::shared_ptr<TestParserClient> client = parseCode(
"class Main {\n"
" public interface Interfaze {\n"
" public void foo(int t);\n"
" }\n"
"\n"
" public class C implements Interfaze {\n"
" public void foo(int t) {\n"
" }\n"
" }\n"
"}\n"
);
TS_ASSERT(utility::containsElement<std::string>(
client->overrides, "void Main.C.foo(int) -> void Main.Interfaze.foo(int) <7:15 7:17>"
));
}
void test_java_parser_finds_overridden_method_with_generic_signature()
{
std::shared_ptr<TestParserClient> client = parseCode(
"class Main <X> {\n"
" public interface Interfaze <T> {\n"
" public void foo(T t);\n"
" }\n"
"\n"
" public class C implements Interfaze <X> {\n"
" public void foo(X t) {\n"
" }\n"
" }\n"
"}\n"
);
TS_ASSERT(utility::containsElement<std::string>(
client->overrides, "void Main<X>.C.foo(Main<X>.X) -> void Main<X>.Interfaze<T>.foo(Main<X>.Interfaze<T>.T) <7:15 7:17>"
));
}
void test_java_parser_finds_method_usage_for_creation_reference()
{
std::shared_ptr<TestParserClient> client = parseCode(
"public class A\n"
"{\n"
" public interface Functor\n"
" {\n"
" public void doSomething();\n"
" }\n"
"\n"
" public class B\n"
" {\n"
" }\n"
"\n"
" void foo()\n"
" {\n"
" Functor method = B::new;\n"
" }\n"
"}\n"
);
TS_ASSERT(utility::containsElement<std::string>(
client->usages, "void A.foo() -> A.B.B() <14:23 14:25>"
));
}
void test_java_parser_finds_method_usage_for_expression_method_reference()
{
std::shared_ptr<TestParserClient> client = parseCode(
"public class A\n"
"{\n"
" public interface Functor\n"
" {\n"
" public void doSomething();\n"
" }\n"
"\n"
" public class B\n"
" {\n"
" void bar()\n"
" {\n"
" }\n"
" }\n"
"\n"
" void foo()\n"
" {\n"
" Functor method = B::bar;\n"
" }\n"
"}\n"
);
TS_ASSERT(utility::containsElement<std::string>(
client->usages, "void A.foo() -> void A.B.bar() <17:23 17:25>"
));
}
void test_java_parser_finds_method_usage_for_super_method_reference()
{
std::shared_ptr<TestParserClient> client = parseCode(
"public class A {\n"
" public interface Functor {\n"
" public void doSomething();\n"
" }\n"
"\n"
" public class B {\n"
" void bar() {\n"
" }\n"
" }\n"
"\n"
" public class C extends B {\n"
" void foo() {\n"
" Functor method = super::bar;\n"
" }\n"
" }\n"
"}\n"
);
TS_ASSERT(utility::containsElement<std::string>(
client->usages, "void A.C.foo() -> void A.B.bar() <13:28 13:30>"
));
}
void test_java_parser_finds_no_method_usage_for_type_method_reference()
{
std::shared_ptr<TestParserClient> client = parseCode(
"public class A {\n"
" void foo() {\n"
" Functor method = int []::clone;\n"
" }\n"
"}\n"
);
// finding method usage here may be implemented in the future.
TS_ASSERT_EQUALS(client->usages.size(), 0);
}
void test_java_parser_finds_no_usage_of_field_within_that_fields_declaration()
{
std::shared_ptr<TestParserClient> client = parseCode(
"package foo;\n"
"public class X\n"
"{\n"
" private int t;\n"
"}\n"
);
TS_ASSERT_EQUALS(client->usages.size(), 0);
}
void test_java_parser_finds_no_usage_of_enum_constant_within_that_enum_constants_declaration()
{
std::shared_ptr<TestParserClient> client = parseCode(
"package foo;\n"
"public enum X\n"
"{\n"
" OPTION_0;\n"
"}\n"
);
TS_ASSERT_EQUALS(client->usages.size(), 0);
}
void test_java_parser_finds_usage_of_field_with_same_name_as_method_parameter()
{
std::shared_ptr<TestParserClient> client = parseCode(
@@ -608,7 +866,7 @@ public:
"public class X\n"
"{\n"
" private int foo;\n"
" public foo()\n"
" public void foo()\n"
" {\n"
" this.foo = 5;\n"
" }\n"
@@ -616,11 +874,11 @@ public:
);
TS_ASSERT(utility::containsElement<std::string>(
client->usages, "foo.X.foo() -> int foo.X.foo <7:8 7:10>"
client->usages, "void foo.X.foo() -> int foo.X.foo <7:8 7:10>"
));
}
void test_java_parser_finds_assignment_of_method_argument()
void test_java_parser_finds_assignment_of_method_parameter()
{
std::shared_ptr<TestParserClient> client = parseCode(
"package foo;\n"
@@ -634,7 +892,7 @@ public:
);
TS_ASSERT(utility::containsElement<std::string>(
client->localSymbols, "input.cc<4:15> <6:3 6:3>"
client->localSymbols, "foo.A.bar<0> <6:3 6:3>"
));
}
@@ -653,7 +911,7 @@ public:
);
TS_ASSERT(utility::containsElement<std::string>(
client->localSymbols, "input.cc<6:7> <7:3 7:3>"
client->localSymbols, "foo.A.bar<0> <7:3 7:3>"
));
}
@@ -789,6 +1047,32 @@ public:
));
}
void test_java_parser_finds_scope_of_anonymous_class_declaration()
{
std::shared_ptr<TestParserClient> client = parseCode(
"public class A\n"
"{\n"
" public interface Base\n"
" {\n"
" }\n"
"\n"
" void foo()\n"
" {\n"
" Base b = new Base()\n"
" {\n"
" }\n"
" };\n"
"}\n"
);
TS_ASSERT(utility::containsElement<std::string>(
client->localSymbols, "input.cc<10:3> <10:3 10:3>"
));
TS_ASSERT(utility::containsElement<std::string>(
client->localSymbols, "input.cc<10:3> <11:3 11:3>"
));
}
void test_java_parser_finds_usage_of_type_parameter_of_class()
{
std::shared_ptr<TestParserClient> client = parseCode(
@@ -827,7 +1111,7 @@ public:
);
TS_ASSERT(utility::containsElement<std::string>(
client->typeUses, "A<T> A<T>.t -> A<T> <3:2 3:2>"
client->typeUses, "A<java.lang.Void> A<T>.t -> A<T> <3:2 3:2>"
));
}
@@ -841,7 +1125,8 @@ public:
TS_ASSERT(utility::containsElement<std::string>(
client->typeUses, "A<T>.T -> java.lang.Void <1:27 1:30>"
))
));
system("PAUSE");
}