When I do optimize imports in IntelliJ (CTRL + ALT + O) I get two (according to me) weird consequences.
The imports go from alphabetical order --> not alphabetical order
A space is added between imports and java.util imports.
Example before optimize:
import com.google.common.base.Objects;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.filter.ClientFilter;
import java.util.HashMap;
import java.util.List;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
Example after optimize:
import com.google.common.base.Objects;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.filter.ClientFilter;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import java.util.HashMap;
import java.util.List;
Why is it that java.util packages seem to get some special treatment and end up here in the bottom with an additional space before them?
The import organizing is defined at File/Settings menu, under Editor/Code Style/Java, in the Import Layout section (assuming IDEA 14). In your case I suppose it contains com.* , followed by org.* , followed by blank line, followed by java.* etc. You can customize it here according to your needs.
Related
When i'm organizing my imports in Android studio (Cmd+Opt+L). I don't understand how Android Studio define the order.
What I notice is that, imports start with common name like android.*, java.*, com.*, which are grouped alone, separated with a blank line, then all other imports are grouped bellow alphabetically.
In my project, shared with other people, androidx.* classes are also grouped alone, right after android.* classes. But in my case, these libraries aren't sorted alone but put at the end, mixed with all other imports.
Ex:
import android.app.Application;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MediatorLiveData;
import com.google.android.exoplayer2.C;
import java.util.ArrayList;
import java.util.Date;
import javax.inject.Inject;
// import other classes
Becomes for me after Reformat code :
import android.app.Application;
import android.text.TextUtils;
import com.google.android.exoplayer2.C;
import java.util.ArrayList;
import java.util.Date;
import javax.inject.Inject;
// import other classes + ANDROIDX CLASSES
This is problem, as every time me or a colleague works on a class and use the auto reformat option, git consider it legitimately as change. And sometimes, conflict occurs.
Any idea on how to fix this import order.
Finally found a solution.
The import layout can be modified in settings > Editor > Code Style > Java. Then in the Imports tab, at the bottom there's a section for the import Layout !
Si I added a new package bellow android.* and a blank line.
I got some source code for an Entertainment Game Bot (for Runescape) years ago and am trying to run it now. However, a lot of the imports are unrecognized by jGrasp and I don't know how to fix the code as I am still only a student. The code for the imports is below:
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Map;
import org.rsbot.bot.Bot;
import org.rsbot.event.events.MessageEvent;
import org.rsbot.script.util.*;
import org.rsbot.script.*;
import org.rsbot.script.wrappers.*;
import java.util.Random;
import javax.swing.JOptionPane;
import org.rsbot.event.listeners.MessageListener;
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.script.methods.Game;
import org.rsbot.util.GlobalConfiguration;
#ScriptManifest(authors = { "Enfilade" }, keywords = {"rune", "riot"}, name = "Rune Riot", version = 1.0)
The program code is not shown as it is far over the character limit of this post. When I attempt to compile the code it gets a lot of import-related errors such as:
RuneRiot.java:17: error: package org.rsbot.bot does not exist
import org.rsbot.bot.Bot;
Please tell me what I need to do to solve the import errors and get the code to run properly. Thanks!
package org.rsbot.bot does not exist means that you are missing your org.rsbot.bot package.
This can mean one of two things:
You don't have the package. Solution: get the package.
You haven't added the package correctly. You need to get your jGrasp to put the Jar or source files (whatever format they are in) for the missing packages on your build path.
I have a project using liquibase-core 2.0.3. When I updated to liquibase-core 3.3.0 I'm getting a lot of compiler class not found errors for the classes below.
Any help on info on where/what they have been replaced with is much appreciated?
import liquibase.change.core.AnonymousChange;
import liquibase.database.core.MaxDBDatabase;
import liquibase.database.typeconversion.TypeConverter;
import liquibase.database.typeconversion.core.CacheTypeConverter;
import liquibase.database.typeconversion.core.DB2TypeConverter;
import liquibase.database.typeconversion.core.DefaultTypeConverter;
import liquibase.database.typeconversion.core.DerbyTypeConverter;
import liquibase.database.typeconversion.core.FirebirdTypeConverter;
import liquibase.database.typeconversion.core.H2TypeConverter;
import liquibase.database.typeconversion.core.HsqlTypeConverter;
import liquibase.database.typeconversion.core.InformixTypeConverter;
import liquibase.database.typeconversion.core.MSSQLTypeConverter;
import liquibase.database.typeconversion.core.MaxDBTypeConverter;
import liquibase.database.typeconversion.core.MySQLTypeConverter;
import liquibase.database.typeconversion.core.OracleTypeConverter;
import liquibase.database.typeconversion.core.Postgres83TypeConverter;
import liquibase.database.typeconversion.core.PostgresTypeConverter;
import liquibase.database.typeconversion.core.SQLiteTypeConverter;
import liquibase.database.typeconversion.core.SybaseASATypeConverter;
import liquibase.database.typeconversion.core.SybaseTypeConverter;
import liquibase.snapshot.jvm.DB2DatabaseSnapshotGenerator;
import liquibase.snapshot.jvm.DerbyDatabaseSnapshotGenerator;
import liquibase.snapshot.jvm.H2DatabaseSnapshotGenerator;
import liquibase.snapshot.jvm.HsqlDatabaseSnapshotGenerator;
import liquibase.snapshot.jvm.InformixDatabaseSnapshotGenerator;
import liquibase.snapshot.jvm.MSSQLDatabaseSnapshotGenerator;
import liquibase.snapshot.jvm.MySQLDatabaseSnapshotGenerator;
import liquibase.snapshot.jvm.OracleDatabaseSnapshotGenerator;
import liquibase.snapshot.jvm.PostgresDatabaseSnapshotGenerator;
import liquibase.snapshot.jvm.SQLiteDatabaseSnapshotGenerator;
import liquibase.snapshot.jvm.StandardJdbcDatabaseSnapshotGenerator;
MaxDBDatabase was pulled into a separate extension https://github.com/liquibase/liquibase-maxdb so you will need to include that jar as well.
The TypeConverter code mainly moved to the classes in liquibase.datatype.
The database-specific SnapshotGenerator classes were replaced with a more general-purpose SnapshotGeneratorFactory and object-specific subclasses vs. database-specific subclasses.
I see you cross-posted to the liquibase forum at http://forum.liquibase.org/topic/replacement-for-missing-liquibase-classes-moving-from-liquibase-2-0-3-to-3-3-0#49382000001219004 If you have specific usage questions, that is probably the best place to follow up since it is more discussion-oriented than stackoverflow.
I want to rename entire package and it's all ocurences includeing package name and imports, change in eclipse.
For example com.google.gdata.client and its classes to com.xyz.google.gdata.client and its all occurences.
Actually, I want to customize gdata-core.1.47.jar source code as per my requirement. First thing I need to do is to change the package structure as per my requirements. But when I followed the above mentioned steps, some more imports were automatically added
For example before refctor,
For class com.google.api.gbase.client has following import
import com.google.gdata.util.common.xml.XmlWriter;
import com.google.gdata.data.Extension;
import com.google.gdata.data.ExtensionProfile;
import com.google.gdata.data.AttributeHelper;
import com.google.gdata.data.ExtensionDescription;
import com.google.gdata.util.ParseException;
import com.google.gdata.util.XmlParser;
But after after rename it to com.google.gdata.client to com.xyz.google.gdata.client it add some more imports like below,
import com.google.api.gbase.client.AddValueHandler;
import com.google.api.gbase.client.AttributeHistogram;
import com.google.api.gbase.client.GoogleBaseAttributeId;
import com.google.api.gbase.client.GoogleBaseAttributeType;
import com.google.api.gbase.client.GoogleBaseEntry;
import com.google.api.gbase.client.UniqueValue;
import com.google.gdata.util.XmlWriter;
import com.xyz.google.gdata.data.AttributeHelper;
import com.xyz.google.gdata.data.Extension;
import com.xyz.google.gdata.data.ExtensionDescription;
import com.xyz.google.gdata.data.ExtensionProfile;
import com.xyz.google.gdata.util.ParseException;
import com.xyz.google.gdata.util.XmlParser;
In the Project Explorer, right click the package name and choose Refactor->Rename.
I have an element defined as a HTML element, namely <canvas id = 'foo' width = '25' height = '40'></canvas>. I am trying to draw to it like this:
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM;
Canvas canvas2 = Canvas.createIfSupported();
Element el = DOM.getElementById("foo");
canvas2.setElement(el);
The last line is throwing an error in Eclipse, error message being The method setElement(Element) from the type UIObject is not visible. What should I do to correct it? This is the list of classes I am importing, is there any JAR conflict?
import com.google.gwt.canvas.client.Canvas;
import com.google.gwt.canvas.dom.client.Context2d;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
Unfortunately there is no easy way to do this currently. Issue #6683 is open for that in GWT's issue tracker. The suggested workaround is to copy the Canvas widget class and loose the visibility of the constructor... not very convenient I admit.