Giter VIP home page Giter VIP logo

autoimport's Introduction

Autoimport

Given source code, class names can be found in available .jar files, and import statements can be generated, for Java and for Kotlin.

This currently only works for OpenJDK 8, not OpenJDK 11 and beyond.

Includes the autoimport utility for looking up packages, given the start of a class name.

Experimental functionality for organizing imports is also included.

Example use

With OpenJDK 8 installed

$ autoimport FilePe
import java.io.*; // FilePermissionCollection
import java.io.*; // FilePermission
import sun.security.tools.policytool.*; // FilePerm
import net.rubygrapefruit.platform.*; // FilePermissionException

With OpenJDK 19 and openjdk-src installed

$ autoimport -e FileSystem
import java.io.*; // FileSystem

Given a Java file without imports

Main.java:

package com.example.demo;

public class Main {
    public static void main(String[] args) {
        List<String> names = new ArrayList<>();
        names.add("Alice");
        names.add("Bob");

        Map<String, Integer> ageMapping = new HashMap<>();
        ageMapping.put("Alice", 30);
        ageMapping.put("Bob", 25);

        for (String name : names) {
            System.out.println(name + " is " + ageMapping.get(name) + " years old.");
        }
    }
}

Features and limitation

  • Searches directories of .jar files for class names.
  • Given the start of the class name, searches for the matching shortest class, and also returns the import path (like java.io.*).
  • Also searches */lib/src.zip files, if found.
  • Intended to be used for simple autocompletion of class names.

General info

autoimport's People

Contributors

xyproto avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.