Skip to content

Commit

Permalink
Merge pull request #7597 from BradWalker/cleanup_raw_type_Result
Browse files Browse the repository at this point in the history
Cleanup warnings that are related to the use of a Result raw type..

Warnings like this:

[repeat] /home/bwalker/src/netbeans/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldViewFactory.java:107: warning: [rawtypes] found raw type: Result
[repeat] private Lookup.Result colorSource;
[repeat] ^
[repeat] missing type arguments for generic class Result
[repeat] where T is a type-variable:
[repeat] T extends Object declared in class Result

This pull request reduces many of those warnings.
  • Loading branch information
BradWalker authored Jan 14, 2025
2 parents 1057945 + 27a48fc commit b3bdee7
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.netbeans.modules.websvc.spi.client.WebServicesClientSupportImpl;
import org.netbeans.modules.websvc.spi.client.WebServicesClientSupportProvider;
import org.netbeans.modules.websvc.client.WebServicesClientSupportAccessor;
import org.netbeans.modules.websvc.spi.client.WebServicesClientViewProvider;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.util.NbBundle;
Expand All @@ -56,7 +57,7 @@ public final class WebServicesClientSupport {
public static final String WSCLIENTUPTODATE_CLASSPATH = "wsclientuptodate.classpath";

private WebServicesClientSupportImpl impl;
private static final Lookup.Result implementations =
private static final Lookup.Result<WebServicesClientSupportProvider> implementations =
Lookup.getDefault().lookupResult(WebServicesClientSupportProvider.class);

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
public final class WebServicesClientView {

private WebServicesClientViewImpl impl;
private static final Lookup.Result implementations =
private static final Lookup.Result<WebServicesClientViewProvider> implementations =
Lookup.getDefault().lookupResult(WebServicesClientViewProvider.class);

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
public final class JAXWSClientSupport {

private JAXWSClientSupportImpl impl;
private static final Lookup.Result implementations =
private static final Lookup.Result<WebServicesClientSupportProvider> implementations =
Lookup.getDefault().lookupResult(WebServicesClientSupportProvider.class);

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.util.Iterator;
import org.netbeans.modules.websvc.jaxws.client.JAXWSClientViewAccessor;
import org.netbeans.modules.websvc.spi.client.WebServicesClientViewProvider;
import org.netbeans.modules.websvc.spi.jaxws.client.JAXWSClientViewImpl;
import org.netbeans.modules.websvc.spi.jaxws.client.JAXWSClientViewProvider;
import org.openide.util.Lookup;
Expand All @@ -39,7 +40,7 @@
public final class JAXWSClientView {

private JAXWSClientViewImpl impl;
private static final Lookup.Result implementations =
private static final Lookup.Result<JAXWSClientViewProvider> implementations =
Lookup.getDefault().lookupResult(JAXWSClientViewProvider.class);

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class ProjectTestRestServicesAction extends AbstractAction implements Pre
private JMenuItem menuPresenter;
private Lookup lookup;
private Class<?>[] watch;
private Lookup.Result results[];
private Lookup.Result<?>[] results;
private boolean needsRefresh = true;
private boolean initialized = false;
private boolean refreshing = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static TopComponentGroup getCssStylesTCGroup() {
public final void resultChanged(LookupEvent ev) {
PageInspector pageInspector = PageInspector.getDefault();
if (pageInspector != null) {
Lookup.Result lookupResult = (Lookup.Result) ev.getSource();
Lookup.Result<?> lookupResult = (Lookup.Result<?>) ev.getSource();
lookupResult.removeLookupListener(this);
pageInspector.addPropertyChangeListener(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static void register() {
/**
* Lookup results for color settings, being listened for changes.
*/
private Lookup.Result colorSource;
private Lookup.Result<FontColorSettings> colorSource;

private Preferences prefs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private static class DefaultQueryManager extends GrammarQueryManager {

private static final String FOLDER = "Plugins/XML/GrammarQueryManagers";// NOI18N

private Lookup.Result registrations;
private Lookup.Result<GrammarQueryManager> registrations;

private static ThreadLocal<GrammarQueryManager> transaction =
new ThreadLocal<GrammarQueryManager>();
Expand Down Expand Up @@ -145,8 +145,9 @@ public GrammarQuery getGrammar(GrammarEnvironment ctx) {
}
}

@Override
public Enumeration enabled(GrammarEnvironment ctx) {
Iterator<GrammarQueryManager> it = getRegistrations();
Iterator<? extends GrammarQueryManager> it = getRegistrations();
transaction.set(null);
List list = new ArrayList<>(5);
{
Expand All @@ -172,7 +173,7 @@ public Enumeration enabled(GrammarEnvironment ctx) {
return null;
}

private synchronized Iterator getRegistrations() {
private synchronized Iterator<? extends GrammarQueryManager> getRegistrations() {
if (registrations != null) {
return registrations.allInstances().iterator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class DefaultEMLookup extends ProxyLookup implements LookupListener, Prope
private LookupListener listener;

/** Map of (Node -> node Lookup.Result) the above lookup listener is attached to */
private Map<Lookup, Lookup.Result> attachedTo;
private Map<Lookup, Lookup.Result<?>> attachedTo;

/** action map for the top component */
private Lookup actionMap;
Expand Down Expand Up @@ -78,7 +78,7 @@ public void updateLookups(Node[] arr) {

Lookup[] lookups = new Lookup[arr.length];

Map<Lookup, Lookup.Result> copy;
Map<Lookup, Lookup.Result<?>> copy;

synchronized (this) {
if (attachedTo == null) {
Expand All @@ -97,8 +97,8 @@ public void updateLookups(Node[] arr) {
}
}

for (Iterator<Lookup.Result> it = copy.values().iterator(); it.hasNext();) {
Lookup.Result res = it.next();
for (Iterator<Lookup.Result<?>> it = copy.values().iterator(); it.hasNext();) {
Lookup.Result<?> res = it.next();
res.removeLookupListener(listener);
}

Expand Down Expand Up @@ -126,10 +126,10 @@ protected synchronized void beforeLookup(Template<?> t) {
if ((attachedTo == null) && isNodeQuery(t.getType())) {
Lookup[] arr = getLookups();

attachedTo = new WeakHashMap<Lookup, Lookup.Result>(arr.length * 2);
attachedTo = new WeakHashMap<>(arr.length * 2);

for (int i = 0; i < (arr.length - 2); i++) {
Lookup.Result res = arr[i].lookup(t);
Lookup.Result<?> res = arr[i].lookup(t);
res.addLookupListener(listener);
attachedTo.put(arr[i], res);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,8 @@ public Lookup getLookup() {
}
}

private Lookup.Result cookieResult = null;
private Lookup.Result nodeResult = null;
private Lookup.Result<Node.Cookie> cookieResult = null;
private Lookup.Result<InstanceCookie> nodeResult = null;
private Lookup cookiesLkp = null;
private LookupListener cookiesLsnr = null;
private LookupListener nodeLsnr = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private static class StopSaxException extends SAXException {
private Reference<XMLDataObject> xml;
private String parsedId;
private Lookup lookup;
private Lookup.Result result;
private Lookup.Result<Node.Cookie> result;
private ThreadLocal<Class<?>> QUERY = new ThreadLocal<Class<?>>();

XMLDataObjectInfoParser(XMLDataObject xml) {
Expand Down Expand Up @@ -151,7 +151,7 @@ public Object lookupCookie(final Class<?> clazz) {
break;
}
}
Lookup.Result r = result;
Lookup.Result<Node.Cookie> r = result;
if (r != null) {
if (XMLDataObject.ERR.isLoggable(Level.FINE)) {
XMLDataObject.ERR.fine("Querying the result: " + r);
Expand Down Expand Up @@ -327,7 +327,7 @@ private Lookup updateLookup(XMLDataObject realXML, String previousID, String id)
}
}
synchronized (this) {
Lookup.Result prevRes = result;
Lookup.Result<Node.Cookie> prevRes = result;
lookup = newLookup;
if (XMLDataObject.ERR.isLoggable(Level.FINE)) {
XMLDataObject.ERR.fine("Shared lookup updated: " + lookup + " for " + realXML);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ protected final void setLookups(Executor notifyIn, Lookup... lookups) {
Set<Lookup> current;
Lookup[] old;

Map<Result,LookupListener> toRemove = new IdentityHashMap<Lookup.Result, LookupListener>();
Map<Result,LookupListener> toAdd = new IdentityHashMap<Lookup.Result, LookupListener>();
Map<Result<?>,LookupListener> toRemove = new IdentityHashMap<>();
Map<Result<?>,LookupListener> toAdd = new IdentityHashMap<>();

ImmutableInternalData orig;
synchronized (ProxyLookup.this) {
Expand All @@ -211,16 +211,16 @@ protected final void setLookups(Executor notifyIn, Lookup... lookups) {
}

// better to do this later than in synchronized block
for (Map.Entry<Result, LookupListener> e : toRemove.entrySet()) {
for (Map.Entry<Result<?>, LookupListener> e : toRemove.entrySet()) {
e.getKey().removeLookupListener(e.getValue());
}
for (Map.Entry<Result, LookupListener> e : toAdd.entrySet()) {
for (Map.Entry<Result<?>, LookupListener> e : toAdd.entrySet()) {
e.getKey().addLookupListener(e.getValue());
}


// this cannot be done from the synchronized block
final ArrayList<Object> evAndListeners = new ArrayList<Object>();
final List<Object> evAndListeners = new ArrayList<>();
for (Reference<R> ref : arr) {
R<?> r = ref.get();
if (r != null) {
Expand Down Expand Up @@ -340,7 +340,7 @@ private ImmutableInternalData getData() {

private Collection<Reference<R>> setData(
ImmutableInternalData newData, Lookup[] current,
Map<Result,LookupListener> toAdd, Map<Result,LookupListener> toRemove
Map<Result<?>,LookupListener> toAdd, Map<Result<?>,LookupListener> toRemove
) {
assert Thread.holdsLock(ProxyLookup.this);
assert newData != null;
Expand Down Expand Up @@ -487,7 +487,7 @@ private Result<T>[] initResults() {
final void lookupChange(
ImmutableInternalData newData, Lookup[] current, ImmutableInternalData oldData,
Set<Lookup> added, Set<Lookup> removed,
Map<Result,LookupListener> toAdd, Map<Result,LookupListener> toRemove
Map<Result<?>,LookupListener> toAdd, Map<Result<?>,LookupListener> toRemove
) {
if (weakL.getResults() == null) {
// not computed yet, do not need to do anything
Expand All @@ -497,7 +497,7 @@ final void lookupChange(
Lookup[] old = oldData.getLookups(false);

// map (Lookup, Lookup.Result)
Map<Lookup,Result<T>> map = new IdentityHashMap<Lookup,Result<T>>(old.length * 2);
Map<Lookup, Result<T>> map = new IdentityHashMap<>(old.length * 2);

for (int i = 0; i < old.length; i++) {
if (removed.contains(old[i])) {
Expand Down Expand Up @@ -609,7 +609,7 @@ private Collection computeResult(int indexToCache, boolean callBeforeLookup) {
}
}
// if caches exist, wait for finished
Lookup.Result[] arr = myBeforeLookup(callBeforeLookup, cachedResult != null);
Lookup.Result<T>[] arr = myBeforeLookup(callBeforeLookup, cachedResult != null);
// use caches, if they exist
Collection[] cc;
synchronized (proxy()) {
Expand Down Expand Up @@ -1117,7 +1117,7 @@ private static class LazyCollection implements Collection {
private final Object[] cc;
private final int indexToCache;
private final boolean callBeforeLookup;
private final Lookup.Result[] arr;
private final Lookup.Result<?>[] arr;
/** GuardedBy("this") */
private final Collection[] computed;
/** GuardedBy("this") */
Expand Down

0 comments on commit b3bdee7

Please sign in to comment.