{"id":17210984,"url":"https://github.com/arturbosch/jpal","last_synced_at":"2025-03-25T12:17:21.828Z","repository":{"id":114468513,"uuid":"66165206","full_name":"arturbosch/JPAL","owner":"arturbosch","description":"[Mirror] - Jpal is a library for javaparser which provides additional features like cross referencing, qualified types and other useful classes.","archived":false,"fork":false,"pushed_at":"2021-11-08T15:06:32.000Z","size":373,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-30T11:13:37.398Z","etag":null,"topics":["groovy","javaparser","qualified-types","symbolsolving"],"latest_commit_sha":null,"homepage":"","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arturbosch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-20T19:48:18.000Z","updated_at":"2021-11-08T15:06:35.000Z","dependencies_parsed_at":"2023-06-08T06:30:16.691Z","dependency_job_id":null,"html_url":"https://github.com/arturbosch/JPAL","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arturbosch%2FJPAL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arturbosch%2FJPAL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arturbosch%2FJPAL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arturbosch%2FJPAL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arturbosch","download_url":"https://codeload.github.com/arturbosch/JPAL/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245458710,"owners_count":20618697,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["groovy","javaparser","qualified-types","symbolsolving"],"created_at":"2024-10-15T02:55:56.297Z","updated_at":"2025-03-25T12:17:21.783Z","avatar_url":"https://github.com/arturbosch.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JPAL - Javaparser Aid Library\n\n[![build status](https://gitlab.com/arturbosch/jpal/badges/master/build.svg)](https://gitlab.com/arturbosch/jpal/commits/master)\n[ ![Download](https://api.bintray.com/packages/arturbosch/code-analysis/Jpal/images/download.svg) ](https://bintray.com/arturbosch/code-analysis/Jpal/_latestVersion)\n\nJpal is a library for javaparser which provides additional features\nlike cross referencing, qualified types, symbol solving and other useful classes.\n\nDevelopment on GitLab: https://gitlab.com/arturbosch/JPAL \nMirror on GitHub: https://github.com/arturbosch/JPAL\n\n## Table of contents\n1. [Build](#build)\n2. [Cross Referencing](#cross)\n3. [Symbol solving](#symbols)\n3. [Helpers](#helpers)\n4. [FAQ](#faq)\n4. [Contribute](#contribute)\n4. [Who uses JPAL](#usage)\n\n## \u003ca name=\"build\"\u003eBuild\u003c/a\u003e\n\n#### Bintray\n\nFor Gradle use:\n\n```\nrepositories {\n    maven {\n        url  \"http://dl.bintray.com/arturbosch/generic\" \n    }\n}\n```\n\n`compile 'io.gitlab.arturbosch.jpal:jpal:1.0.RC3'`\n\nFor Maven see `https://bintray.com/arturbosch/generic/JPAL` -\u003e SetUp\n\n```\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.gitlab.arturbosch.jpal\u003c/groupId\u003e\n  \u003cartifactId\u003ejpal\u003c/artifactId\u003e\n  \u003cversion\u003e1.0.RC3\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n#### Raw\n- Make sure gradle is installed\n- Download the jpal git repository\n- Use gradle clean build publishToMavenLocal\n- This will install the library into your local m2 folder\n\n## \u003ca name=\"cross\"\u003eCross Referencing\u003c/a\u003e\n\nIs provided by type resolving and caching of qualified types, paths\nand compilation units via a CompilationStorage.\n\n### CompilationStorage\n\nShould be used before you process the AST as the compilation storage\nanalyzes given project path and caches all compilation units.\nCompilation units are wrapped into CompilationInfo's which stores \nadditional information like used qualified types within this unit.\n\n```CompilationStorage storage = JPAL.new(projectPath)```\n\nObtaining a compilation info can be done through two methods:\n\n```java \ndef maybeInfo = CompilationStorage.getCompilationInfo(path)\ndef maybeInfo = CompilationStorage.getCompilationInfo(qualifiedType)\n```\n\n##### Updating the CompilationStorage\n\n`UpdatableCompilationStorage storage = JPAL.updatable()`\n\nThis creates a new empty updatable storage instance.\n\n`UpdatableCompilationStorage storage = JPAL.initializedUpdatable(projectPath)`\n\nThis creates a precompiled storage with all java sub paths down from project path.\nAll methods of __CompilationStorage__ to retrieve __CompilationInfo__ work also on updatable storages.\n\nUse methods following methods to update the storage:\n```java\nstorage.updateCompilationInfo(List\u003cPath\u003e paths)\nstorage.relocateCompilationInfo(Map\u003cPath, Path\u003e relocates)\nstorage.removeCompilationInfo(List\u003cPath\u003e paths)\n```\n\n### QualifiedType\n\nThe easiest way to obtain a qualified type is to use the Resolver:\n\n```java\nClassOrInterfaceDeclaration clazz = ...;\n`Optional\u003cQualifiedType\u003e maybeType = TypeHelper.getQualifiedType(clazz);\n```\n\nThis has the advantage that only a class or interface declaration\nis needed but costs extra time finding the declared compilation unit.\n\nIf the compilation unit is known or you are sure that the class is \nwithin a specific package, use:\n\n```java\nQualifiedType type = TypeHelper.getQualifiedType(ClassOrInterfaceDeclaration n, CompilationUnit unit)\nQualifiedType type = TypeHelper.getQualifiedTypeFromPackage(TypeDeclaration n, PackageDeclaration packageDeclaration)\n```\n\nThe preferred way is to use a Resolver.\n\n### Resolver\n\nIf you want the qualified type but only have a `Type` or any subclass\nuse the `Resolver` and `CompilationInfo` classes.\n\n```java\nCompilationStorage storage = JPAL.new(projectPath)\nResolver resolver = new Resolver(storage)\nCompilationInfo info = storage.getCompilationInfo(myPath/myType)\nClassOrInterfaceType searchedType = ...\nresolver.resolveType(seachedType, info)\n```\n\nThe resolver checks for following situations:\n\n- Type is a primitive or boxed primitive\n- Type is in the imports and can be easily constructed\n- Type is in within an asterisk import\n- Type is in java.lang\n- Type is within the package\n\n## \u003ca name=\"symbols\"\u003eSymbol Solving\u003c/a\u003e\n\nSimpleName classes of __javaparser__ are treated as symbols. A Resolver can resolve symbols\nand find the type and declaration of a symbol.\n\n```java\nCompilationStorage storage = JPAL.new(projectPath)\nResolver resolver = new Resolver(storage)\nCompilationInfo info = storage.getCompilationInfo(myPath/myType)\nresolver.resolveSymbol(symbol,info)\n```\n\n## \u003ca name=\"helpers\"\u003eHelpers - Useful Classes\u003c/a\u003e\n\n- ClassHelper - signatures, scope check etc\n- LocaleVariableHelper - finds locale variable within a method\n- MethodHelper - getter/setter/anonymous method checks etc\n- NodeHelper - find (declaring) nodes\n- TypeHelper - get qualified types\n- VariableHelper - transforms parameters/fields/locale vars to JpalVariables\n\n## \u003ca name=\"faq\"\u003eFAQ\u003c/a\u003e\n\n#### How to create qualified types for inner classes?\n\nIf you use the CompilationStorage with a CompilationUnit, you can get all\ninner classes with `info.getInnerClasses()`.\n\n#### How to get all inner classes names\n\n```java \nTypeHelper.getQualifiedTypesOfInnerClasses(CompilationUnit unit)\n```\n\n#### How to create a type signature?\n\n```\nClassHelper.createFullSignature(ClassOrInterfaceDeclaration n)\n```\nThis creates a full signature of given class with respect to anonymous or inner class checks.\n\nIf these checks are not needed use:\n```java \nClassHelper.createSignature(ClassOrInterfaceDeclaration n)\n```\n\n#### What information is stored within a CompilationInfo?\n\n```\nfinal QualifiedType qualifiedType\nfinal CompilationUnit unit\nfinal Path path\nfinal TypeDeclaration mainType\nfinal ResolutionData data\nfinal Map\u003cQualifiedType, TypeDeclaration\u003e innerClasses\n```\n\n## \u003ca name=\"contribute\"\u003eHow to contribute?\u003c/a\u003e\n\n- Report Bugs or make feature requests through issues\n- Push merge requests\n\n## \u003ca name=\"usage\"\u003eWho uses JPAL?\u003c/a\u003e\n\n- SmartSmells (https://gitlab.com/arturbosch/SmartSmells/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farturbosch%2Fjpal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farturbosch%2Fjpal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farturbosch%2Fjpal/lists"}