diff --git a/enterprise/j2ee.dd/src/org/netbeans/modules/j2ee/dd/impl/resources/jakartaee_11.xsd b/enterprise/j2ee.dd/src/org/netbeans/modules/j2ee/dd/impl/resources/jakartaee_11.xsd
index 4f8e7c01a084..72df2d15ca84 100644
--- a/enterprise/j2ee.dd/src/org/netbeans/modules/j2ee/dd/impl/resources/jakartaee_11.xsd
+++ b/enterprise/j2ee.dd/src/org/netbeans/modules/j2ee/dd/impl/resources/jakartaee_11.xsd
@@ -52,7 +52,7 @@
+ schemaLocation="xml.xsd"/>
diff --git a/enterprise/web.monitor/src/org/netbeans/modules/web/monitor/client/MonitorAction.java b/enterprise/web.monitor/src/org/netbeans/modules/web/monitor/client/MonitorAction.java
index 7d1ae2973d2d..328d33599b5b 100644
--- a/enterprise/web.monitor/src/org/netbeans/modules/web/monitor/client/MonitorAction.java
+++ b/enterprise/web.monitor/src/org/netbeans/modules/web/monitor/client/MonitorAction.java
@@ -108,8 +108,5 @@ private static void openTransactionView() {
tv.requestActive();
}
- public static void log(String s) {
- log("MonitorAction::" + s); //NOI18N
- }
}
diff --git a/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/provider/GroovyCompletionCollector.java b/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/provider/GroovyCompletionCollector.java
index 033690b97b01..ab7853c61572 100644
--- a/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/provider/GroovyCompletionCollector.java
+++ b/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/completion/provider/GroovyCompletionCollector.java
@@ -539,7 +539,7 @@ public boolean isPrefixMatch() {
@Override
public boolean isCaseSensitive() {
- return isCaseSensitive();
+ return GroovyCompletionCollector.isCaseSensitive();
}
}
diff --git a/ide/csl.api/src/org/netbeans/modules/csl/editor/completion/MethodParamsTipPaintComponent.java b/ide/csl.api/src/org/netbeans/modules/csl/editor/completion/MethodParamsTipPaintComponent.java
index 0231eeb96724..e7085e2f3226 100644
--- a/ide/csl.api/src/org/netbeans/modules/csl/editor/completion/MethodParamsTipPaintComponent.java
+++ b/ide/csl.api/src/org/netbeans/modules/csl/editor/completion/MethodParamsTipPaintComponent.java
@@ -39,9 +39,9 @@ public class MethodParamsTipPaintComponent extends JToolTip {
private int descent;
private FontMetrics fontMetrics;
- private List> params;
- private int idx;
- private JTextComponent component;
+ private final List> params;
+ private final int idx;
+ private final JTextComponent component;
public MethodParamsTipPaintComponent(List> params, int idx, JTextComponent component){
super();
@@ -123,11 +123,6 @@ protected int getWidth(String s, Font font) {
return getFontMetrics(font).stringWidth(s);
}
- protected int getHeight(String s, Font font) {
- if (font == null) return fontMetrics.stringWidth(s);
- return getFontMetrics(font).stringWidth(s);
- }
-
public @Override void setFont(Font font) {
super.setFont(font);
fontMetrics = this.getFontMetrics(font);
diff --git a/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldOptionsPanel.java b/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldOptionsPanel.java
index bb0b4c92f8f3..0487324dfbcf 100644
--- a/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldOptionsPanel.java
+++ b/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldOptionsPanel.java
@@ -172,14 +172,14 @@ public void preferenceChange(PreferenceChangeEvent evt) {
foldedSummary.setEnabled(enabled);
useDefaults.setEnabled(enabled);
}
- if (k == null || FoldUtilitiesImpl.PREF_CONTENT_PREVIEW.equals(FoldUtilitiesImpl.PREF_CONTENT_PREVIEW)) {
+ if (k == null || k.equals(FoldUtilitiesImpl.PREF_CONTENT_PREVIEW)) {
contentPreview.setSelected(currentPreferences.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_PREVIEW, true));
}
- if (k == null || FoldUtilitiesImpl.PREF_CONTENT_SUMMARY.equals(FoldUtilitiesImpl.PREF_CONTENT_SUMMARY)) {
+ if (k == null || k.equals(FoldUtilitiesImpl.PREF_CONTENT_SUMMARY)) {
foldedSummary.setSelected(currentPreferences.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_SUMMARY, true));
}
// must not replicate defaults over current settings if unspecified key arrives.
- if (k != null && FoldUtilitiesImpl.PREF_OVERRIDE_DEFAULTS.equals(k)) {
+ if (FoldUtilitiesImpl.PREF_OVERRIDE_DEFAULTS.equals(k)) {
boolean b = parentPrefs == null || !currentPreferences.getBoolean(FoldUtilitiesImpl.PREF_OVERRIDE_DEFAULTS, true);
if (parentPrefs != null) {
if (b) {
diff --git a/ide/editor.lib/src/org/netbeans/modules/editor/lib/drawing/CollapsedView.java b/ide/editor.lib/src/org/netbeans/modules/editor/lib/drawing/CollapsedView.java
deleted file mode 100644
index 2c0020aa1395..000000000000
--- a/ide/editor.lib/src/org/netbeans/modules/editor/lib/drawing/CollapsedView.java
+++ /dev/null
@@ -1,712 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-
-package org.netbeans.modules.editor.lib.drawing;
-
-import java.awt.Container;
-import java.awt.FontMetrics;
-import java.awt.Graphics;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.Shape;
-import javax.swing.JComponent;
-import javax.swing.SwingUtilities;
-import javax.swing.event.DocumentEvent;
-import javax.swing.text.AttributeSet;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.Caret;
-import javax.swing.text.Document;
-import javax.swing.text.Element;
-import javax.swing.text.JTextComponent;
-import javax.swing.text.Position;
-import javax.swing.text.View;
-import javax.swing.text.ViewFactory;
-import org.netbeans.api.editor.mimelookup.MimeLookup;
-import org.netbeans.api.editor.settings.AttributesUtilities;
-import org.netbeans.api.editor.settings.FontColorNames;
-import org.netbeans.api.editor.settings.FontColorSettings;
-import org.netbeans.editor.BaseKit;
-import org.netbeans.editor.BaseTextUI;
-import org.netbeans.editor.Coloring;
-import org.netbeans.editor.EditorUI;
-import org.netbeans.editor.FoldingToolTip;
-import org.netbeans.editor.FontMetricsCache;
-import org.netbeans.editor.PopupManager;
-import org.netbeans.editor.Utilities;
-import org.netbeans.editor.ext.ToolTipSupport;
-import org.netbeans.editor.view.spi.LockView;
-import org.openide.util.Lookup;
-import org.openide.util.LookupEvent;
-import org.openide.util.LookupListener;
-import org.openide.util.WeakListeners;
-
-/**
- * View over collapsed area of the fold.
- *
- * The collapsed area spans one or more lines and it is presented as three dots.
- *
- * @author Martin Roskanin
- */
-/* package */ @Deprecated class CollapsedView extends View {
-
- private static final int MARGIN_WIDTH = 4;
-
- private final Position startPos;
-
- private final Position endPos;
-
- private final String foldDescription;
-
- private volatile AttributeSet attribs;
- private Lookup.Result extends FontColorSettings> fcsLookupResult;
- private final LookupListener fcsTracker = new LookupListener() {
- public void resultChanged(LookupEvent ev) {
- attribs = null;
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- JTextComponent jtc = CollapsedView.this.getComponent();
- if (jtc != null) {
- CollapsedView.this.getBaseTextUI().damageRange(
- jtc, CollapsedView.this.getStartOffset(), CollapsedView.this.getEndOffset());
- }
- }
- });
- }
- };
-
- /** Creates a new instance of CollapsedView */
- public CollapsedView(Element elem, Position startPos, Position endPos, String foldDescription) {
- super(elem);
-
- this.startPos = startPos;
- this.endPos = endPos;
- this.foldDescription = foldDescription;
- }
-
- private Coloring getColoring() {
- if (attribs == null) {
- if (fcsLookupResult == null) {
- fcsLookupResult = MimeLookup.getLookup(org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(getComponent()))
- .lookupResult(FontColorSettings.class);
- fcsLookupResult.addLookupListener(WeakListeners.create(LookupListener.class, fcsTracker, fcsLookupResult));
- }
-
- FontColorSettings fcs = fcsLookupResult.allInstances().iterator().next();
- AttributeSet attr = fcs.getFontColors(FontColorNames.CODE_FOLDING_COLORING);
- if (attr == null) {
- attr = fcs.getFontColors(FontColorNames.DEFAULT_COLORING);
- } else {
- attr = AttributesUtilities.createComposite(attr, fcs.getFontColors(FontColorNames.DEFAULT_COLORING));
- }
-
- attribs = attr;
- }
- return Coloring.fromAttributeSet(attribs);
- }
-
- private JTextComponent getComponent() {
- return (JTextComponent)getContainer();
- }
-
- private BaseTextUI getBaseTextUI(){
- JTextComponent comp = getComponent();
- return (comp!=null)?(BaseTextUI)comp.getUI():null;
- }
-
- private EditorUI getEditorUI(){
- BaseTextUI btui = getBaseTextUI();
- return (btui!=null) ? btui.getEditorUI() : null;
- }
-
- public @Override Document getDocument() {
- View parent = getParent();
- return (parent == null) ? null : parent.getDocument();
- }
-
- public @Override int getStartOffset() {
- return startPos.getOffset();
- }
-
- public @Override int getEndOffset() {
- return endPos.getOffset();
- }
-
- public @Override float getAlignment(int axis) {
- return 0f;
- }
-
- public float getPreferredSpan(int axis){
- switch (axis) {
- case Y_AXIS:
- return getEditorUI().getLineHeight();
- case X_AXIS:
- return getCollapsedFoldStringWidth();
- }
- return 1f;
- }
-
- private int getCollapsedFoldStringWidth() {
- JTextComponent comp = getComponent();
- if (comp==null) return 0;
- FontMetrics fm = FontMetricsCache.getFontMetrics(getColoring().getFont(), comp);
- if (fm==null) return 0;
- return fm.stringWidth(foldDescription) + 2 * MARGIN_WIDTH;
- }
-
- public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException {
- return new Rectangle(a.getBounds().x, a.getBounds().y, getCollapsedFoldStringWidth(), getEditorUI().getLineHeight());
- }
-
- public int viewToModel(float x, float y, Shape a, Position.Bias[] biasReturn) {
- return getStartOffset();
- }
-
- public void paint(Graphics g, Shape allocation){
- Rectangle r = allocation.getBounds();
- Coloring coloring = getColoring();
-
- g.setColor(coloring.getBackColor());
- g.fillRect(r.x, r.y, r.width, r.height);
-
- g.setColor(coloring.getForeColor());
- g.drawRect(r.x, r.y, r.width - 1, r.height - 1);
-
- g.setFont(coloring.getFont());
- g.drawString(foldDescription, r.x + MARGIN_WIDTH, r.y + getEditorUI().getLineAscent() - 1);
- }
-
- public @Override int getNextVisualPositionFrom(
- int pos, Position.Bias b, Shape a,
- int direction, Position.Bias[] biasRet
- ) throws BadLocationException {
- biasRet[0] = Position.Bias.Forward;
- switch (direction) {
- case NORTH:
- case SOUTH:
- {
- JTextComponent target = (JTextComponent) getContainer();
- Caret c = (target != null) ? target.getCaret() : null;
- // YECK! Ideally, the x location from the magic caret position
- // would be passed in.
- Point mcp;
- if (c != null) {
- mcp = c.getMagicCaretPosition();
- }
- else {
- mcp = null;
- }
- int x;
- if (mcp == null) {
- Rectangle loc = target.modelToView(pos);
- x = (loc == null) ? 0 : loc.x;
- }
- else {
- x = mcp.x;
- }
- if (direction == NORTH) {
- pos = Utilities.getPositionAbove(target, pos, x);
- }
- else {
- pos = Utilities.getPositionBelow(target, pos, x);
- }
- }
- break;
- case WEST:
- if(pos == -1) {
- pos = Math.max(0, getStartOffset());
- }
- else {
- if (b == Position.Bias.Backward){
- pos = Math.max(0, getStartOffset());
- }else{
- pos = Math.max(0, getStartOffset() - 1);
- }
- }
- break;
- case EAST:
- if(pos == -1) {
- pos = getStartOffset();
- }
- else {
- pos = Math.min(getEndOffset(), getDocument().getLength());
- //JTextComponent target = (JTextComponent) getContainer();
- //if (target!=null && Utilities.getRowEnd(target, pos) == pos) pos = Math.min(pos+1, getDocument().getLength());
- }
- break;
- default:
- throw new IllegalArgumentException("Bad direction: " + direction); // NOI18N
- }
- return pos;
- }
-
- private View getExpandedView(){
- Element parentElem = getElement().getParentElement();
- int sei = parentElem.getElementIndex(getStartOffset());
- int so = parentElem.getElement(sei).getStartOffset();
-
- int eei = parentElem.getElementIndex(getEndOffset());
- int eo = parentElem.getElement(eei).getEndOffset();
-
- LockView fakeView = new LockView(
- new DrawEngineFakeDocView(parentElem, so, eo, false, true)
- );
- RootView rootView = new RootView();
- rootView.setView(fakeView);
- return fakeView;
- }
-
- public @Override String getToolTipText(float x, float y, Shape allocation){
- ToolTipSupport tts = getEditorUI().getToolTipSupport();
- JComponent toolTip = new FoldingToolTip(getExpandedView(), getEditorUI());
- tts.setToolTip(toolTip, PopupManager.ScrollBarBounds, PopupManager.Largest, -FoldingToolTip.BORDER_WIDTH, 0);
- return ""; //NOI18N
- }
-
- class RootView extends View {
-
- RootView() {
- super(null);
- }
-
- void setView(View v) {
- if (view != null) {
- // get rid of back reference so that the old
- // hierarchy can be garbage collected.
- view.setParent(null);
- }
- view = v;
- if (view != null) {
- view.setParent(this);
- }
- }
-
- /**
- * Fetches the attributes to use when rendering. At the root
- * level there are no attributes. If an attribute is resolved
- * up the view hierarchy this is the end of the line.
- */
- public @Override AttributeSet getAttributes() {
- return null;
- }
-
- /**
- * Determines the preferred span for this view along an axis.
- *
- * @param axis may be either X_AXIS or Y_AXIS
- * @return the span the view would like to be rendered into.
- * Typically the view is told to render into the span
- * that is returned, although there is no guarantee.
- * The parent may choose to resize or break the view.
- */
- public float getPreferredSpan(int axis) {
- if (view != null) {
- return view.getPreferredSpan(axis);
- } else {
- return 10;
- }
- }
-
- /**
- * Determines the minimum span for this view along an axis.
- *
- * @param axis may be either X_AXIS or Y_AXIS
- * @return the span the view would like to be rendered into.
- * Typically the view is told to render into the span
- * that is returned, although there is no guarantee.
- * The parent may choose to resize or break the view.
- */
- public @Override float getMinimumSpan(int axis) {
- if (view != null) {
- return view.getMinimumSpan(axis);
- } else {
- return 10;
- }
- }
-
- /**
- * Determines the maximum span for this view along an axis.
- *
- * @param axis may be either X_AXIS or Y_AXIS
- * @return the span the view would like to be rendered into.
- * Typically the view is told to render into the span
- * that is returned, although there is no guarantee.
- * The parent may choose to resize or break the view.
- */
- public @Override float getMaximumSpan(int axis) {
- return Integer.MAX_VALUE;
- }
-
- /**
- * Determines the desired alignment for this view along an axis.
- *
- * @param axis may be either X_AXIS or Y_AXIS
- * @return the desired alignment, where 0.0 indicates the origin
- * and 1.0 the full span away from the origin
- */
- public @Override float getAlignment(int axis) {
- if (view != null) {
- return view.getAlignment(axis);
- } else {
- return 0;
- }
- }
-
- /**
- * Renders the view.
- *
- * @param g the graphics context
- * @param allocation the region to render into
- */
- public void paint(Graphics g, Shape allocation) {
- if (view != null) {
- Rectangle alloc = (allocation instanceof Rectangle) ?
- (Rectangle)allocation : allocation.getBounds();
- setSize(alloc.width, alloc.height);
- view.paint(g, allocation);
- }
- }
-
- /**
- * Sets the view parent.
- *
- * @param parent the parent view
- */
- public @Override void setParent(View parent) {
- throw new Error("Can't set parent on root view"); // NOI18N
- }
-
- /**
- * Returns the number of views in this view. Since
- * this view simply wraps the root of the view hierarchy
- * it has exactly one child.
- *
- * @return the number of views
- * @see #getView
- */
- public @Override int getViewCount() {
- return 1;
- }
-
- /**
- * Gets the n-th view in this container.
- *
- * @param n the number of the view to get
- * @return the view
- */
- public @Override View getView(int n) {
- return view;
- }
-
- /**
- * Returns the child view index representing the given position in
- * the model. This is implemented to return the index of the only
- * child.
- *
- * @param pos the position >= 0
- * @return index of the view representing the given position, or
- * -1 if no view represents that position
- * @since 1.3
- */
- public @Override int getViewIndex(int pos, Position.Bias b) {
- return 0;
- }
-
- /**
- * Fetches the allocation for the given child view.
- * This enables finding out where various views
- * are located, without assuming the views store
- * their location. This returns the given allocation
- * since this view simply acts as a gateway between
- * the view hierarchy and the associated component.
- *
- * @param index the index of the child
- * @param a the allocation to this view.
- * @return the allocation to the child
- */
- public @Override Shape getChildAllocation(int index, Shape a) {
- return a;
- }
-
- /**
- * Provides a mapping from the document model coordinate space
- * to the coordinate space of the view mapped to it.
- *
- * @param pos the position to convert
- * @param a the allocated region to render into
- * @return the bounding box of the given position
- */
- public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException {
- if (view != null) {
- return view.modelToView(pos, a, b);
- } else {
- return null;
- }
- }
-
- /**
- * Provides a mapping from the document model coordinate space
- * to the coordinate space of the view mapped to it.
- *
- * @param p0 the position to convert >= 0
- * @param b0 the bias toward the previous character or the
- * next character represented by p0, in case the
- * position is a boundary of two views.
- * @param p1 the position to convert >= 0
- * @param b1 the bias toward the previous character or the
- * next character represented by p1, in case the
- * position is a boundary of two views.
- * @param a the allocated region to render into
- * @return the bounding box of the given position is returned
- * @exception BadLocationException if the given position does
- * not represent a valid location in the associated document
- * @exception IllegalArgumentException for an invalid bias argument
- * @see View#viewToModel
- */
- public @Override Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1, Shape a) throws BadLocationException {
- if (view != null) {
- return view.modelToView(p0, b0, p1, b1, a);
- } else {
- return null;
- }
- }
-
- /**
- * Provides a mapping from the view coordinate space to the logical
- * coordinate space of the model.
- *
- * @param x x coordinate of the view location to convert
- * @param y y coordinate of the view location to convert
- * @param a the allocated region to render into
- * @return the location within the model that best represents the
- * given point in the view
- */
- public int viewToModel(float x, float y, Shape a, Position.Bias[] bias) {
- if (view != null) {
- int retValue = view.viewToModel(x, y, a, bias);
- return retValue;
- } else {
- return -1;
- }
- }
-
- /**
- * Provides a way to determine the next visually represented model
- * location that one might place a caret. Some views may not be visible,
- * they might not be in the same order found in the model, or they just
- * might not allow access to some of the locations in the model.
- *
- * @param pos the position to convert >= 0
- * @param a the allocated region to render into
- * @param direction the direction from the current position that can
- * be thought of as the arrow keys typically found on a keyboard.
- * This may be SwingConstants.WEST, SwingConstants.EAST,
- * SwingConstants.NORTH, or SwingConstants.SOUTH.
- * @return the location within the model that best represents the next
- * location visual position.
- * @exception BadLocationException
- * @exception IllegalArgumentException for an invalid direction
- */
- public @Override int getNextVisualPositionFrom(
- int pos, Position.Bias b, Shape a,
- int direction, Position.Bias[] biasRet
- ) throws BadLocationException {
- if( view != null ) {
- int nextPos = view.getNextVisualPositionFrom(pos, b, a, direction, biasRet);
- if(nextPos != -1) {
- pos = nextPos;
- } else {
- biasRet[0] = b;
- }
- }
- return pos;
- }
-
- /**
- * Gives notification that something was inserted into the document
- * in a location that this view is responsible for.
- *
- * @param e the change information from the associated document
- * @param a the current allocation of the view
- * @param f the factory to use to rebuild if the view has children
- */
- public @Override void insertUpdate(DocumentEvent e, Shape a, ViewFactory f) {
- if (view != null) {
- view.insertUpdate(e, a, f);
- }
- }
-
- /**
- * Gives notification that something was removed from the document
- * in a location that this view is responsible for.
- *
- * @param e the change information from the associated document
- * @param a the current allocation of the view
- * @param f the factory to use to rebuild if the view has children
- */
- public @Override void removeUpdate(DocumentEvent e, Shape a, ViewFactory f) {
- if (view != null) {
- view.removeUpdate(e, a, f);
- }
- }
-
- /**
- * Gives notification from the document that attributes were changed
- * in a location that this view is responsible for.
- *
- * @param e the change information from the associated document
- * @param a the current allocation of the view
- * @param f the factory to use to rebuild if the view has children
- */
- public @Override void changedUpdate(DocumentEvent e, Shape a, ViewFactory f) {
- if (view != null) {
- view.changedUpdate(e, a, f);
- }
- }
-
- /**
- * Returns the document model underlying the view.
- *
- * @return the model
- */
- public @Override Document getDocument() {
- EditorUI editorUI = getEditorUI();
- return (editorUI == null) ? null : editorUI.getDocument();
- }
-
- /**
- * Returns the starting offset into the model for this view.
- *
- * @return the starting offset
- */
- public @Override int getStartOffset() {
- if (view != null) {
- return view.getStartOffset();
- } else {
- return getElement().getStartOffset();
- }
- }
-
- /**
- * Returns the ending offset into the model for this view.
- *
- * @return the ending offset
- */
- public @Override int getEndOffset() {
- if (view != null) {
- return view.getEndOffset();
- } else {
- return getElement().getEndOffset();
- }
- }
-
- /**
- * Gets the element that this view is mapped to.
- *
- * @return the view
- */
- public @Override Element getElement() {
- if (view != null) {
- return view.getElement();
- } else {
- return view.getDocument().getDefaultRootElement();
- }
- }
-
- /**
- * Breaks this view on the given axis at the given length.
- *
- * @param axis may be either X_AXIS or Y_AXIS
- * @param len specifies where a break is desired in the span
- * @param the current allocation of the view
- * @return the fragment of the view that represents the given span
- * if the view can be broken, otherwise null
- */
- public View breakView(int axis, float len, Shape a) {
- throw new Error("Can't break root view"); // NOI18N
- }
-
- /**
- * Determines the resizability of the view along the
- * given axis. A value of 0 or less is not resizable.
- *
- * @param axis may be either X_AXIS or Y_AXIS
- * @return the weight
- */
- public @Override int getResizeWeight(int axis) {
- if (view != null) {
- return view.getResizeWeight(axis);
- } else {
- return 0;
- }
- }
-
- /**
- * Sets the view size.
- *
- * @param width the width
- * @param height the height
- */
- public @Override void setSize(float width, float height) {
- if (view != null) {
- view.setSize(width, height);
- }
- }
-
- /**
- * Fetches the container hosting the view. This is useful for
- * things like scheduling a repaint, finding out the host
- * components font, etc. The default implementation
- * of this is to forward the query to the parent view.
- *
- * @return the container
- */
- public @Override Container getContainer() {
- EditorUI editorUI = getEditorUI();
- return (editorUI == null) ? null : editorUI.getComponent();
- }
-
- /**
- * Fetches the factory to be used for building the
- * various view fragments that make up the view that
- * represents the model. This is what determines
- * how the model will be represented. This is implemented
- * to fetch the factory provided by the associated
- * EditorKit unless that is null, in which case this
- * simply returns the BasicTextUI itself which allows
- * subclasses to implement a simple factory directly without
- * creating extra objects.
- *
- * @return the factory
- */
- public @Override ViewFactory getViewFactory() {
- EditorUI editorUI = getEditorUI();
- if (editorUI != null) {
- BaseKit kit = Utilities.getKit(editorUI.getComponent());
- ViewFactory f = kit.getViewFactory();
- if (f != null) {
- return f;
- }
- }
- return getBaseTextUI();
- }
-
- private View view;
- } // End of RootView class
-
-}
diff --git a/ide/hudson.ui/src/org/netbeans/modules/hudson/ui/impl/HudsonFailureDisplayer.java b/ide/hudson.ui/src/org/netbeans/modules/hudson/ui/impl/HudsonFailureDisplayer.java
index 31e2449f1885..7cacb2b2920d 100644
--- a/ide/hudson.ui/src/org/netbeans/modules/hudson/ui/impl/HudsonFailureDisplayer.java
+++ b/ide/hudson.ui/src/org/netbeans/modules/hudson/ui/impl/HudsonFailureDisplayer.java
@@ -231,7 +231,7 @@ Action[] getActions(boolean context) {
OpenUrlAction.forOpenable(new OpenableInBrowser() {
public @Override
String getUrl() {
- return getUrl() + "testReport/"
+ return job.getUrl() + "testReport/"
+ testcase.getClassName().replaceFirst("[.][^.]+$", "") + "/" + testcase.getClassName().replaceFirst(".+[.]", "") + "/" + testcase.getName() + "/"; //NOI18N
}
}),
diff --git a/ide/jumpto/src/org/netbeans/modules/jumpto/type/FilteredListModel.java b/ide/jumpto/src/org/netbeans/modules/jumpto/type/FilteredListModel.java
index b657e5b8c1b3..f4af4c09a32c 100644
--- a/ide/jumpto/src/org/netbeans/modules/jumpto/type/FilteredListModel.java
+++ b/ide/jumpto/src/org/netbeans/modules/jumpto/type/FilteredListModel.java
@@ -316,7 +316,7 @@ public Object getElementAt(int index) {
int myMinIndex = getExternal (minIndex) + 1; // one after the index of the first non-1 index
int myMaxIndex = getExternal (maxIndex);
- assert myMaxIndex >= myMaxIndex : "Must be greater"; // NOI18N
+ assert myMaxIndex >= myMinIndex : "Must be greater"; // NOI18N
if (myMaxIndex != myMinIndex) {
int myIndex = myMinIndex + (index - minIndex) - 1;
if (myIndex >= myMaxIndex) {
diff --git a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLArithmeticOperation.java b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLArithmeticOperation.java
index c8b5468beafb..fcf2b6a248be 100644
--- a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLArithmeticOperation.java
+++ b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLArithmeticOperation.java
@@ -19,6 +19,8 @@
package org.netbeans.modules.languages.hcl.ast;
import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
/**
*
@@ -64,24 +66,26 @@ public String toString() {
public record Binary(Operator op, HCLExpression left, HCLExpression right) implements HCLArithmeticOperation {
@Override
public String asString() {
- return left.toString() + op.toString() + right.toString();
+ return HCLExpression.asString(left) + op.toString() + HCLExpression.asString(right);
}
@Override
public List extends HCLExpression> elements() {
- return List.of(left, right);
+ return Stream.of(left, right)
+ .filter(Objects::nonNull)
+ .toList();
}
}
public record Unary(Operator op, HCLExpression operand) implements HCLArithmeticOperation {
@Override
public String asString() {
- return op.toString() + operand.toString();
+ return op.toString() + HCLExpression.asString(operand);
}
@Override
public List extends HCLExpression> elements() {
- return List.of(operand);
+ return operand != null ? List.of(operand) : List.of();
}
}
}
diff --git a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLAttribute.java b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLAttribute.java
index 0ad41a869a8f..729eb893ffc2 100644
--- a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLAttribute.java
+++ b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLAttribute.java
@@ -19,6 +19,7 @@
package org.netbeans.modules.languages.hcl.ast;
import java.util.List;
+import java.util.Objects;
/**
@@ -27,6 +28,10 @@
*/
public record HCLAttribute(HCLIdentifier name, HCLExpression value) implements HCLElement {
+ public HCLAttribute {
+ Objects.requireNonNull(name, "name cannot be null");
+ }
+
public String id() {
return name.id();
}
diff --git a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLBlock.java b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLBlock.java
index e6478044acdb..a3f8b42072b0 100644
--- a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLBlock.java
+++ b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLBlock.java
@@ -34,6 +34,10 @@ public final class HCLBlock extends HCLContainer {
public HCLBlock(List declaration, List elements) {
super(elements);
+ Objects.requireNonNull(declaration, "declaration cannot be null");
+ if (declaration.isEmpty()) {
+ throw new IllegalArgumentException("declaration cannot be empty");
+ }
this.declaration = List.copyOf(declaration);
this.id = declaration.stream().map(d -> d.id()).collect(Collectors.joining("."));
}
diff --git a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLCollection.java b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLCollection.java
index 02acecad405b..15ad667b3d14 100644
--- a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLCollection.java
+++ b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLCollection.java
@@ -19,7 +19,9 @@
package org.netbeans.modules.languages.hcl.ast;
import java.util.List;
+import java.util.Objects;
import java.util.StringJoiner;
+import java.util.stream.Stream;
/**
*
@@ -37,7 +39,7 @@ public record Tuple(List elements) implements HCLCollection elements() {
- return List.of(key, value);
+ return Stream.of(key, value)
+ .filter(Objects::nonNull)
+ .toList();
}
}
@@ -66,7 +70,7 @@ public record Object(List elements) implements HCLCollection elements() {
- return Arrays.asList(condition, trueValue, falseValue);
+ return Stream.of(condition, trueValue, falseValue)
+ .filter(Objects::nonNull)
+ .toList();
}
diff --git a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLContainer.java b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLContainer.java
index 9b0ca868f5b1..658d9cabb55d 100644
--- a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLContainer.java
+++ b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLContainer.java
@@ -19,6 +19,7 @@
package org.netbeans.modules.languages.hcl.ast;
import java.util.List;
+import java.util.Objects;
/**
*
@@ -31,6 +32,7 @@ public sealed abstract class HCLContainer implements HCLElement permits HCLBlock
private final List attributes;
protected HCLContainer(List elements) {
+ Objects.requireNonNull(elements, "elements can be empty, but cannot be null");
this.elements = List.copyOf(elements);
this.blocks = elements.stream().filter(HCLBlock.class::isInstance).map(HCLBlock.class::cast).toList();
this.attributes = elements.stream().filter(HCLAttribute.class::isInstance).map(HCLAttribute.class::cast).toList();
diff --git a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLElement.java b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLElement.java
index 017efae28b4c..124067b49cbe 100644
--- a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLElement.java
+++ b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLElement.java
@@ -24,6 +24,6 @@
*
* @author Laszlo Kishalmi
*/
-public sealed interface HCLElement permits HCLExpression, HCLIdentifier, HCLContainer, HCLAttribute {
+public sealed interface HCLElement permits HCLExpression, HCLContainer, HCLAttribute {
List extends HCLElement> elements();
}
diff --git a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLExpression.java b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLExpression.java
index 344f029dbaa3..9464c9d48907 100644
--- a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLExpression.java
+++ b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLExpression.java
@@ -36,17 +36,18 @@ public sealed interface HCLExpression extends HCLElement permits
HCLConditionalOperation,
HCLForExpression,
HCLFunction,
+ HCLIdentifier,
HCLLiteral,
HCLResolveOperation,
HCLTemplate,
HCLVariable {
- public static HCLExpression parse(String expr) {
- HCLLexer lexer = new HCLLexer(CharStreams.fromString(expr));
- HCLParser parser = new HCLParser(new CommonTokenStream(lexer));
- return new HCLExpressionFactory().process(parser.expression());
+
+ public static String asString(HCLExpression expr) {
+ return expr != null ? expr.asString() : "";
}
+ @Override
default List extends HCLExpression> elements() {
return Collections.emptyList();
}
diff --git a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLExpressionFactory.java b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLExpressionFactory.java
index cca7c870261f..235dc6bb00e9 100644
--- a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLExpressionFactory.java
+++ b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLExpressionFactory.java
@@ -18,16 +18,14 @@
*/
package org.netbeans.modules.languages.hcl.ast;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
+import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import org.antlr.v4.runtime.NoViableAltException;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.tree.ParseTree;
-import org.antlr.v4.runtime.tree.TerminalNode;
import org.netbeans.modules.languages.hcl.grammar.HCLLexer;
import static org.netbeans.modules.languages.hcl.grammar.HCLLexer.*;
import org.netbeans.modules.languages.hcl.grammar.HCLParser;
@@ -150,7 +148,10 @@ protected HCLExpression expr(HCLParser.CollectionValueContext ctx) throws Unsupp
HCLParser.TupleContext tuple = ctx.tuple();
List elements = new LinkedList<>();
for (HCLParser.ExpressionContext ec : tuple.expression()) {
- elements.add(expr(ec));
+ HCLExpression e = expr(ec);
+ if (e != null) {
+ elements.add(created(e, ec));
+ }
}
return new HCLCollection.Tuple(elements);
}
@@ -184,6 +185,7 @@ protected HCLExpression expr(HCLParser.FunctionCallContext ctx) {
if (ctx.arguments() != null) {
args = ctx.arguments().expression().stream()
.map(this::expr)
+ .filter(Objects::nonNull)
.toList();
expand = ctx.arguments().ELLIPSIS() != null;
}
diff --git a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLForExpression.java b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLForExpression.java
index 43266854888e..13c6afaa8aa5 100644
--- a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLForExpression.java
+++ b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLForExpression.java
@@ -19,6 +19,8 @@
package org.netbeans.modules.languages.hcl.ast;
import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
/**
*
@@ -39,10 +41,10 @@ public String asString() {
StringBuilder sb = new StringBuilder();
sb.append("[for ");
if (keyVar != null) {
- sb.append(keyVar).append(',');
+ sb.append(keyVar.asString()).append(',');
}
- sb.append(valueVar).append(" in ").append(iterable.asString()).append(':');
- sb.append(result.asString());
+ sb.append(HCLExpression.asString(valueVar)).append(" in ").append(HCLExpression.asString(iterable)).append(':');
+ sb.append(HCLExpression.asString(result));
if (condition != null) {
sb.append(" if ").append(condition.asString());
}
@@ -52,7 +54,9 @@ public String asString() {
@Override
public List extends HCLExpression> elements() {
- return List.of(iterable, result, condition);
+ return Stream.of(iterable, result, condition)
+ .filter(Objects::nonNull)
+ .toList();
}
}
@@ -62,10 +66,10 @@ public String asString() {
StringBuilder sb = new StringBuilder();
sb.append("{for ");
if (keyVar != null) {
- sb.append(keyVar).append(',');
+ sb.append(keyVar.asString()).append(',');
}
- sb.append(valueVar).append(" in ").append(iterable.asString()).append(':');
- sb.append(resultKey.asString()).append("=>").append(resultValue.asString());
+ sb.append(HCLExpression.asString(valueVar)).append(" in ").append(HCLExpression.asString(iterable)).append(':');
+ sb.append(HCLExpression.asString(resultKey)).append("=>").append(HCLExpression.asString(resultValue));
if (grouping) {
sb.append("...");
}
@@ -78,7 +82,9 @@ public String asString() {
@Override
public List extends HCLExpression> elements() {
- return List.of(iterable, resultKey, resultValue, condition);
+ return Stream.of(iterable, resultKey, resultValue, condition)
+ .filter(Objects::nonNull)
+ .toList();
}
}
diff --git a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLFunction.java b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLFunction.java
index f2556a5384c1..1c91c9b1e278 100644
--- a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLFunction.java
+++ b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLFunction.java
@@ -19,6 +19,7 @@
package org.netbeans.modules.languages.hcl.ast;
import java.util.List;
+import java.util.Objects;
import java.util.StringJoiner;
/**
@@ -28,14 +29,16 @@
public record HCLFunction(HCLIdentifier name, List args, boolean expand) implements HCLExpression {
public HCLFunction {
+ Objects.requireNonNull(name, "name cannot be null");
+ Objects.requireNonNull(args, "args can be empty, but cannot be null");
args = List.copyOf(args);
}
@Override
public String asString() {
StringJoiner sargs = new StringJoiner(",", "(", expand ? "...)" : ")");
- args.forEach((arg) -> sargs.add(arg.toString()));
- return name + sargs.toString();
+ args.forEach((arg) -> sargs.add(arg.asString()));
+ return name.asString() + sargs.toString();
}
@Override
diff --git a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLIdentifier.java b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLIdentifier.java
index ad25ab30e01a..6782f8766b3d 100644
--- a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLIdentifier.java
+++ b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLIdentifier.java
@@ -24,18 +24,36 @@
*
* @author Laszlo Kishalmi
*/
-public sealed interface HCLIdentifier extends HCLElement {
+public sealed interface HCLIdentifier extends HCLExpression {
String id();
@Override
- default List extends HCLElement> elements() {
+ default List extends HCLExpression> elements() {
return List.of();
}
- public record SimpleId(String id) implements HCLIdentifier {}
+ public record SimpleId(String id) implements HCLIdentifier {
- public record StringId(String id) implements HCLIdentifier {}
+ @Override
+ public String asString() {
+ return id;
+ }
+ }
+
+ public record StringId(String id) implements HCLIdentifier {
+
+ @Override
+ public String asString() {
+ return id;
+ }
+ }
+
+ public record ScopedId(HCLIdentifier parent, String id) implements HCLIdentifier {
- public record ScopedId(HCLIdentifier parent, String id) implements HCLIdentifier {}
+ @Override
+ public String asString() {
+ return HCLExpression.asString(parent) + "::" + id;
+ }
+ }
}
diff --git a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLResolveOperation.java b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLResolveOperation.java
index 4e721f89b353..21a381c3458f 100644
--- a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLResolveOperation.java
+++ b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLResolveOperation.java
@@ -19,6 +19,7 @@
package org.netbeans.modules.languages.hcl.ast;
import java.util.List;
+import java.util.Objects;
/**
*
@@ -26,25 +27,37 @@
*/
public sealed interface HCLResolveOperation extends HCLExpression {
-
HCLExpression base();
+
default List extends HCLExpression> elements() {
return List.of(base());
}
public record Attribute(HCLExpression base, HCLIdentifier attr) implements HCLResolveOperation {
+
+ public Attribute {
+ Objects.requireNonNull(base, "base cannot be null");
+ }
+
@Override
public String asString() {
- return base.asString() + "." + attr;
+ return base.asString() + "." + HCLExpression.asString(attr);
}
}
public record Index(HCLExpression base, HCLExpression index, boolean legacy) implements HCLResolveOperation {
+
+ public Index {
+ Objects.requireNonNull(base, "base cannot be null");
+ Objects.requireNonNull(index, "index cannot be null");
+ }
+
@Override
public String asString() {
- return base.asString() + (legacy ? "." + index : "[" + index + "]");
+ return base.asString() + (legacy ? "." + index.asString() : "[" + index.asString() + "]");
}
+
@Override
public List extends HCLExpression> elements() {
return List.of(base, index);
@@ -52,6 +65,11 @@ public List extends HCLExpression> elements() {
}
public record AttrSplat(HCLExpression base) implements HCLResolveOperation {
+
+ public AttrSplat {
+ Objects.requireNonNull(base, "base cannot be null");
+ }
+
@Override
public String asString() {
return base.asString() + ".*";
@@ -59,6 +77,11 @@ public String asString() {
}
public record FullSplat(HCLExpression base) implements HCLResolveOperation {
+
+ public FullSplat {
+ Objects.requireNonNull(base, "base cannot be null");
+ }
+
@Override
public String asString() {
return base.asString() + "[*]";
diff --git a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLVariable.java b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLVariable.java
index 84f2779ec691..f1b8c7206882 100644
--- a/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLVariable.java
+++ b/ide/languages.hcl/src/org/netbeans/modules/languages/hcl/ast/HCLVariable.java
@@ -26,6 +26,6 @@ public record HCLVariable(HCLIdentifier name) implements HCLExpression {
@Override
public String asString() {
- return name.id();
+ return HCLExpression.asString(name);
}
}
diff --git a/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLCollectionTest.java b/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLCollectionTest.java
new file mode 100644
index 000000000000..3e9e9ac9b93c
--- /dev/null
+++ b/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLCollectionTest.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.netbeans.modules.languages.hcl.ast;
+
+import static org.netbeans.modules.languages.hcl.ast.HCLExpressionTestSupport.*;
+import org.junit.Test;
+
+/**
+ *
+ * @author lkishalmi
+ */
+public class HCLCollectionTest {
+
+ @Test
+ public void testTupleSelf() {
+ assertExpr("[]");
+ assertExpr("[a]");
+ assertExpr("[a,b]");
+ }
+
+ @Test
+ public void testObjectSelf() {
+ assertExpr("{}");
+ assertExpr("{a=b}");
+ assertExpr("{a=b,b=c}");
+ }
+}
diff --git a/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLExpressionTestSupport.java b/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLExpressionTestSupport.java
new file mode 100644
index 000000000000..9bdcbda465a1
--- /dev/null
+++ b/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLExpressionTestSupport.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.netbeans.modules.languages.hcl.ast;
+
+import org.antlr.v4.runtime.CharStreams;
+import org.antlr.v4.runtime.CommonTokenStream;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import org.netbeans.modules.languages.hcl.grammar.HCLLexer;
+import org.netbeans.modules.languages.hcl.grammar.HCLParser;
+
+/**
+ *
+ * @author lkishalmi
+ */
+public class HCLExpressionTestSupport {
+ private HCLExpressionTestSupport() {}
+
+ public static HCLExpression parse(String expr) {
+ HCLLexer lexer = new HCLLexer(CharStreams.fromString(expr));
+ HCLParser parser = new HCLParser(new CommonTokenStream(lexer));
+ return new HCLExpressionFactory().process(parser.expression());
+ }
+
+ public static void assertExpr(String expected, HCLExpression expr) {
+ assertNotNull(expr);
+ assertEquals(expected, expr.asString());
+ }
+
+ public static void assertExpr(String expected) {
+ assertExpr(expected, parse(expected));
+ }
+}
diff --git a/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLForExpressionTest.java b/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLForExpressionTest.java
new file mode 100644
index 000000000000..95feb2713635
--- /dev/null
+++ b/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLForExpressionTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.netbeans.modules.languages.hcl.ast;
+
+import static org.junit.Assert.*;
+import static org.netbeans.modules.languages.hcl.ast.HCLExpressionTestSupport.*;
+import org.junit.Test;
+
+/**
+ *
+ * @author lkishalmi
+ */
+public class HCLForExpressionTest {
+
+ @Test
+ public void testForTuple() {
+ HCLExpression expr = parse("[for i in local.t : i]");
+ if (expr instanceof HCLForExpression.Tuple t) {
+ assertNull(t.keyVar());
+ assertNull(t.condition());
+ } else {
+ fail();
+ }
+ }
+
+ @Test
+ public void testForTupleSelf() {
+ assertExpr("[for i in l:i]");
+ assertExpr("[for i,j in l:i]");
+ assertExpr("[for i in l:i if i>0]");
+ }
+
+ @Test
+ public void testForObjectSelf() {
+ assertExpr("{for k,v in l:k=>v}");
+ assertExpr("{for k,v in l:k=>v if v!=null}");
+ assertExpr("{for k,v in l:k=>v... if v!=null}");
+ }
+
+ @Test
+ public void testForObject() {
+ HCLExpression expr = parse("{for k, v in local.m : k => v}");
+ if (expr instanceof HCLForExpression.Object o) {
+ assertEquals("k", HCLExpression.asString(o.keyVar()));
+ assertNull(o.condition());
+ } else {
+ fail();
+ }
+ }
+
+ @Test
+ public void testForObjectCondition() {
+ HCLExpression expr = parse("{for k, v in local.m : k => v if v > 0}");
+ if (expr instanceof HCLForExpression.Object o) {
+ assertExpr("k", o.keyVar());
+ assertExpr("v>0", o.condition());
+ } else {
+ fail();
+ }
+ }
+
+}
diff --git a/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLFunctionTest.java b/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLFunctionTest.java
new file mode 100644
index 000000000000..d86a6e138c2b
--- /dev/null
+++ b/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLFunctionTest.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.netbeans.modules.languages.hcl.ast;
+
+import static org.netbeans.modules.languages.hcl.ast.HCLExpressionTestSupport.*;
+import org.junit.Test;
+
+/**
+ *
+ * @author lkishalmi
+ */
+public class HCLFunctionTest {
+
+ @Test
+ public void testFunctionSelf() {
+ assertExpr("min()");
+ assertExpr("min([1,b]...)");
+ assertExpr("local::min()");
+ }
+}
diff --git a/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLLiteralsTest.java b/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLLiteralsTest.java
index d25afd1a87b1..77d3a9bf49f0 100644
--- a/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLLiteralsTest.java
+++ b/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLLiteralsTest.java
@@ -21,7 +21,7 @@
import org.junit.Test;
import static org.junit.Assert.*;
-import static org.netbeans.modules.languages.hcl.ast.HCLExpression.parse;
+import static org.netbeans.modules.languages.hcl.ast.HCLExpressionTestSupport.*;
/**
*
diff --git a/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLOperationsTest.java b/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLOperationsTest.java
index 95d794667fba..5917a9e8ea01 100644
--- a/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLOperationsTest.java
+++ b/ide/languages.hcl/test/unit/src/org/netbeans/modules/languages/hcl/ast/HCLOperationsTest.java
@@ -21,7 +21,7 @@
import org.junit.Test;
import static org.junit.Assert.*;
-import static org.netbeans.modules.languages.hcl.ast.HCLExpression.parse;
+import static org.netbeans.modules.languages.hcl.ast.HCLExpressionTestSupport.*;
/**
*
@@ -39,6 +39,16 @@ public void testResolveVar() throws Exception {
assertEquals("var", ((HCLVariable)resolve.base()).name().id());
}
+ @Test
+ public void testResolveIncomplete() throws Exception {
+ HCLExpression exp = parse("var.");
+ assertTrue(exp instanceof HCLResolveOperation.Attribute);
+ HCLResolveOperation.Attribute resolve = (HCLResolveOperation.Attribute) exp;
+ assertNull(resolve.attr());
+ assertTrue(resolve.base() instanceof HCLVariable);
+ assertEquals("var", ((HCLVariable)resolve.base()).name().id());
+ }
+
@Test
public void testResolveIndex1() throws Exception {
HCLExpression exp = parse("a[0]");
@@ -70,7 +80,36 @@ public void testConditional() throws Exception {
assertTrue(cond.condition() instanceof HCLArithmeticOperation.Binary);
assertTrue(cond.trueValue() instanceof HCLLiteral.NumericLit);
assertTrue(cond.falseValue() instanceof HCLVariable);
-
-
+ }
+
+ @Test
+ public void testConditionalSelf() throws Exception {
+ assertExpr("a?b:c");
+ assertExpr("a>b?1:0");
+ }
+
+ @Test
+ public void testBinaryOperationSelf() throws Exception {
+ assertExpr("a+b");
+ assertExpr("a-b");
+ assertExpr("a*b");
+ assertExpr("a/b");
+ assertExpr("a%b");
+
+ assertExpr("a||b");
+ assertExpr("a&&b");
+
+ assertExpr("ab");
+ assertExpr("a<=b");
+ assertExpr("a>=b");
+ assertExpr("a==b");
+ assertExpr("a!=b");
+ }
+
+ @Test
+ public void testUnaryOperationSelf() throws Exception {
+ assertExpr("!a");
+ assertExpr("-a");
}
}
diff --git a/ide/parsing.nb/src/org/netbeans/modules/parsing/nb/EditorMimeTypesImpl.java b/ide/parsing.nb/src/org/netbeans/modules/parsing/nb/EditorMimeTypesImpl.java
index 180c70bba8c2..b7a12db60218 100644
--- a/ide/parsing.nb/src/org/netbeans/modules/parsing/nb/EditorMimeTypesImpl.java
+++ b/ide/parsing.nb/src/org/netbeans/modules/parsing/nb/EditorMimeTypesImpl.java
@@ -68,6 +68,6 @@ public void addPropertyChangeListener(@NonNull final PropertyChangeListener list
@Override
public void removePropertyChangeListener(@NonNull final PropertyChangeListener listener) {
Parameters.notNull("listener", listener); //NOI18N
- listeners.addPropertyChangeListener(listener);
+ listeners.removePropertyChangeListener(listener);
}
}
diff --git a/ide/properties/src/org/netbeans/modules/properties/BundleStructure.java b/ide/properties/src/org/netbeans/modules/properties/BundleStructure.java
index 81b2c25e60af..4b04bf0ecd13 100644
--- a/ide/properties/src/org/netbeans/modules/properties/BundleStructure.java
+++ b/ide/properties/src/org/netbeans/modules/properties/BundleStructure.java
@@ -419,8 +419,13 @@ public void setAllData(String key, String[] data) {
if (getEntryCount() > data.length/3) {
for (int j=0; j < getEntryCount(); j++) {
PropertiesFileEntry pfe = getNthEntry(j);
+ if (pfe == null) {
+ continue;
+ }
PropertiesStructure ps = pfe.getHandler().getStructure();
- if (pfe == null || ps == null) continue;
+ if (ps == null) {
+ continue;
+ }
boolean found = false;
for (int i=0; i < data.length; i+=3) {
diff --git a/ide/subversion/src/org/netbeans/modules/subversion/ui/browser/BrowserPanel.java b/ide/subversion/src/org/netbeans/modules/subversion/ui/browser/BrowserPanel.java
index 044ad0a3308f..f157d74479ac 100644
--- a/ide/subversion/src/org/netbeans/modules/subversion/ui/browser/BrowserPanel.java
+++ b/ide/subversion/src/org/netbeans/modules/subversion/ui/browser/BrowserPanel.java
@@ -161,11 +161,7 @@ private class BrowserOutlineView extends OutlineView {
BrowserOutlineView() {
setupColumns();
}
-
- public void startEditingAtPath(TreePath path) {
- startEditingAtPath(path);
- }
-
+
@Override
public void addNotify() {
super.addNotify();
diff --git a/ide/subversion/src/org/netbeans/modules/subversion/ui/update/RevertModifications.java b/ide/subversion/src/org/netbeans/modules/subversion/ui/update/RevertModifications.java
index e962ed445607..cedb52324794 100644
--- a/ide/subversion/src/org/netbeans/modules/subversion/ui/update/RevertModifications.java
+++ b/ide/subversion/src/org/netbeans/modules/subversion/ui/update/RevertModifications.java
@@ -384,7 +384,7 @@ public void actionPerformed(ActionEvent e) {
private RevisionInterval getResortedRevisionInterval(SVNRevision revision1, SVNRevision revision2) {
RevisionInterval ret;
- if(revision1.equals(SVNRevision.HEAD) && revision1.equals(SVNRevision.HEAD)) {
+ if (revision1.equals(SVNRevision.HEAD) && revision2.equals(SVNRevision.HEAD)) {
ret = new RevisionInterval (revision1, revision2);
} else if (revision1.equals(SVNRevision.HEAD)) {
ret = new RevisionInterval (revision2, revision1);
diff --git a/ide/versioning.ui/src/org/netbeans/modules/versioning/ui/history/HistoryDiffView.java b/ide/versioning.ui/src/org/netbeans/modules/versioning/ui/history/HistoryDiffView.java
index 9bac954b92eb..f3e1bd714fb2 100644
--- a/ide/versioning.ui/src/org/netbeans/modules/versioning/ui/history/HistoryDiffView.java
+++ b/ide/versioning.ui/src/org/netbeans/modules/versioning/ui/history/HistoryDiffView.java
@@ -126,8 +126,8 @@ private void refresh(Node[] newSelection) {
file2 = file1 = getFile(newSelection[1], entry2);
}
- if(entry1 != null && entry2 != null && file1 != null && file2 != null) {
- if(entry1.getDateTime().getTime() > entry1.getDateTime().getTime()) {
+ if (entry1 != null && entry2 != null && file1 != null && file2 != null) {
+ if (entry1.getDateTime().getTime() > entry2.getDateTime().getTime()) {
refreshRevisionDiffPanel(entry1, entry2, file1, file2);
} else {
refreshRevisionDiffPanel(entry2, entry1, file2, file1);
diff --git a/ide/xml.axi/src/org/netbeans/modules/xml/axi/impl/SchemaReferenceProxy.java b/ide/xml.axi/src/org/netbeans/modules/xml/axi/impl/SchemaReferenceProxy.java
index f4a100e8124d..d438c4e18aff 100644
--- a/ide/xml.axi/src/org/netbeans/modules/xml/axi/impl/SchemaReferenceProxy.java
+++ b/ide/xml.axi/src/org/netbeans/modules/xml/axi/impl/SchemaReferenceProxy.java
@@ -18,7 +18,6 @@
*/
package org.netbeans.modules.xml.axi.impl;
-import org.netbeans.modules.xml.axi.AXIComponent;
import org.netbeans.modules.xml.axi.AXIModel;
import org.netbeans.modules.xml.axi.SchemaReference;
import org.netbeans.modules.xml.axi.visitor.AXIVisitor;
@@ -28,7 +27,7 @@
* @author sdedic
*/
public class SchemaReferenceProxy extends SchemaReference implements AXIComponentProxy {
- public SchemaReferenceProxy(AXIModel model, AXIComponent sharedComponent) {
+ public SchemaReferenceProxy(AXIModel model, SchemaReference sharedComponent) {
super(model, sharedComponent);
}
@@ -38,7 +37,7 @@ public ComponentType getComponentType() {
}
private SchemaReference getShared() {
- return (SchemaReference)getShared();
+ return (SchemaReference) getSharedComponent();
}
@Override
diff --git a/java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/SourcesModel.java b/java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/SourcesModel.java
index 21334125444c..d7d507577702 100644
--- a/java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/SourcesModel.java
+++ b/java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/SourcesModel.java
@@ -709,7 +709,7 @@ private Listener (
private SourcesModel getModel () {
SourcesModel tm = model.get ();
- if (tm == null) {
+ if (tm != null) {
tm.sourcePath.removePropertyChangeListener (this);
tm.debugger.getSmartSteppingFilter ().
removePropertyChangeListener (this);
diff --git a/java/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/JPDAThreadImpl.java b/java/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/JPDAThreadImpl.java
index 757efd6e0d5b..53e14f9410f9 100644
--- a/java/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/JPDAThreadImpl.java
+++ b/java/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/JPDAThreadImpl.java
@@ -2325,7 +2325,7 @@ void unsetStepSuspendedByBpIn(JPDAThreadImpl thread) {
if (logger.isLoggable(Level.FINER)) {
logger.finer("unsetStepSuspendedByBp("+threadReference+"): stepSuspendedByBreakpoint = "+stepSuspendedByBreakpoint);
}
- if (this.suspendedSteppingThreads == null) {
+ if (this.suspendedSteppingThreads != null) {
this.suspendedSteppingThreads.remove(thread);
if (this.suspendedSteppingThreads.isEmpty()) {
this.suspendedSteppingThreads = null;
diff --git a/java/form/src/org/netbeans/modules/form/layoutdesign/LayoutFeeder.java b/java/form/src/org/netbeans/modules/form/layoutdesign/LayoutFeeder.java
index 1c3e30d360fa..d1dfa9aa8e7e 100644
--- a/java/form/src/org/netbeans/modules/form/layoutdesign/LayoutFeeder.java
+++ b/java/form/src/org/netbeans/modules/form/layoutdesign/LayoutFeeder.java
@@ -3657,7 +3657,7 @@ else if (!group2.isParentOf(group1) && iDesc.distance < best.distance) {
if (!compatibleInclusions(iDesc, best, dimension)) {
it.remove();
} else if (iDesc.parent == best.parent && iDesc.neighbor == best.neighbor
- && (iDesc.neighbor != null || iDesc.index == iDesc.index)) {
+ && (iDesc.neighbor != null || iDesc.index == best.index)) {
it.remove(); // same inclusion twice (detect for better robustness)
} else if (iDesc.newSubGroup && LayoutUtils.contentOverlap(iDesc.parent, best.parent, dimension^1)) {
it.remove(); // don't try to solve what is already overlapping
diff --git a/java/form/src/org/netbeans/modules/form/layoutsupport/delegates/BorderLayoutSupport.java b/java/form/src/org/netbeans/modules/form/layoutsupport/delegates/BorderLayoutSupport.java
index f70bac7b87de..f28e0a5cf31b 100644
--- a/java/form/src/org/netbeans/modules/form/layoutsupport/delegates/BorderLayoutSupport.java
+++ b/java/form/src/org/netbeans/modules/form/layoutsupport/delegates/BorderLayoutSupport.java
@@ -260,7 +260,7 @@ else if (BorderLayout.LINE_END.equals(position) || BorderLayout.EAST.equals(posi
}
if (y1 >= y2) {
y1 = contInsets.top;
- x2 = contSize.height - contInsets.bottom;
+ y2 = contSize.height - contInsets.bottom;
if (y1 >= y2) return true; // container is too small
}
diff --git a/java/gradle.java/src/org/netbeans/modules/gradle/java/customizer/SourceSetPanel.java b/java/gradle.java/src/org/netbeans/modules/gradle/java/customizer/SourceSetPanel.java
index bc7d2fc54f14..eb9c7a2ff401 100644
--- a/java/gradle.java/src/org/netbeans/modules/gradle/java/customizer/SourceSetPanel.java
+++ b/java/gradle.java/src/org/netbeans/modules/gradle/java/customizer/SourceSetPanel.java
@@ -82,21 +82,26 @@ public String toString() {
/**
* Creates new form SourceSetPanel
*/
+ @Messages({
+ "# {0} - platform home",
+ "LBL_BrokenPlatform=Broken Platform at {0}"
+ })
public SourceSetPanel(GradleJavaSourceSet sourceSet, File relativeTo) {
this.sourceSet = sourceSet;
relativeRoot = relativeTo.toPath();
initComponents();
File javaHome = sourceSet.getCompilerJavaHome(GradleJavaSourceSet.SourceType.JAVA);
- JavaPlatform platform =JavaPlatform.getDefault();
- if (javaHome != null) {
- platform = JavaToolchainSupport.getDefault().platformByHome(javaHome);
- }
- jtPlatform.setText(platform.getDisplayName());
-
- if (platform.isValid()) {
+ JavaPlatform platform = javaHome != null
+ ? JavaToolchainSupport.getDefault().platformByHome(javaHome)
+ : JavaPlatform.getDefault();
+
+ if (platform != null && platform.isValid()) {
+ jtPlatform.setText(platform.getDisplayName());
FileObject home = platform.getInstallFolders().iterator().next();
jtPlatform.setToolTipText(home.getPath());
+ } else {
+ jtPlatform.setText(Bundle.LBL_BrokenPlatform(javaHome));
}
if (sourceSet.getSourcesCompatibility().equals(sourceSet.getTargetCompatibility())) {
diff --git a/java/gradle.java/src/org/netbeans/modules/gradle/java/nodes/BootCPNodeFactory.java b/java/gradle.java/src/org/netbeans/modules/gradle/java/nodes/BootCPNodeFactory.java
index a4155d2fab4d..172100ee2126 100644
--- a/java/gradle.java/src/org/netbeans/modules/gradle/java/nodes/BootCPNodeFactory.java
+++ b/java/gradle.java/src/org/netbeans/modules/gradle/java/nodes/BootCPNodeFactory.java
@@ -24,8 +24,10 @@
import org.netbeans.modules.gradle.spi.nodes.NodeUtils;
import java.awt.Image;
import java.beans.PropertyChangeEvent;
+import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
@@ -44,7 +46,6 @@
import org.netbeans.modules.gradle.java.api.GradleJavaProject;
import org.netbeans.modules.gradle.java.api.GradleJavaSourceSet;
import org.netbeans.modules.gradle.java.api.GradleJavaSourceSet.SourceType;
-import org.netbeans.modules.gradle.java.execute.JavaRunUtils;
import org.netbeans.modules.gradle.java.spi.support.JavaToolchainSupport;
import org.netbeans.spi.project.ui.PathFinder;
import org.netbeans.spi.java.project.support.ui.PackageView;
@@ -130,8 +131,9 @@ public Image getOpenedIcon(int param) {
}
+ private record PlatformSourceSet(File javaHome, JavaPlatform platform, Set sourceSets) {}
+
// XXX PlatformNode and ActionFilterNode does some of what we want, but cannot be reused
- private record PlatformSourceSet(JavaPlatform platform, Set sourceSets) {}
private static class BootCPChildren extends ChildFactory.Detachable {
private final Project project;
@@ -152,16 +154,17 @@ protected void removeNotify() {
@Override
protected boolean createKeys(List keys) {
- var toolchains = JavaToolchainSupport.getDefault();
- var pss = new HashMap>();
- var ss = GradleJavaProject.get(project).getSourceSets().values();
- for (GradleJavaSourceSet s : ss) {
- var home = s.getCompilerJavaHome(SourceType.JAVA);
- var platform = home != null ? toolchains.platformByHome(home) : JavaRunUtils.getActivePlatform(project).second();
- var groups = pss.computeIfAbsent(platform, (k) -> new TreeSet((s1, s2) -> s1.getName().compareTo(s2.getName())));
- groups.add(s);
+ JavaToolchainSupport toolchains = JavaToolchainSupport.getDefault();
+
+ var pss = new HashMap>();
+ for (GradleJavaSourceSet s : GradleJavaProject.get(project).getSourceSets().values()) {
+ File home = s.getCompilerJavaHome(SourceType.JAVA);
+ if (home != null) {
+ var groups = pss.computeIfAbsent(home, (k) -> new TreeSet<>(Comparator.comparing(GradleJavaSourceSet::getName)));
+ groups.add(s);
+ }
}
- pss.forEach((platform, groups) -> keys.add(new PlatformSourceSet(platform, groups)));
+ pss.forEach((home, groups) -> keys.add(new PlatformSourceSet(home, toolchains.platformByHome(home), groups)));
return true;
}
@@ -195,19 +198,21 @@ private JRENode(PlatformSourceSet pss) {
@Override
public String getName() {
- return pss.platform().getDisplayName();
+ return pss.platform() != null ? pss.platform().getDisplayName() : Bundle.FMT_BrokenPlatform(pss.javaHome());
}
@Override
public String getDisplayName() {
- String name = pss.platform.isValid() ? pss.platform.getDisplayName(): Bundle.FMT_BrokenPlatform(pss.platform.getDisplayName());
- String groups = pss.sourceSets.stream().map(GradleJavaSourceSet::getName).collect(Collectors.joining(", ", "[", "]"));
- return name + " " + groups;
+ String groups = pss.sourceSets.stream()
+ .map(GradleJavaSourceSet::getName)
+ .collect(Collectors.joining(", ", "[", "]"));
+ return getName() + " " + groups;
}
@Override
public String getHtmlDisplayName() {
- return null;
+ JavaPlatform platform = JavaToolchainSupport.getDefault().platformByHome(pss.javaHome());
+ return platform != null ? getDisplayName() : "" + getDisplayName() + ""; //NOI18N
}
@Override
@@ -222,14 +227,10 @@ public boolean canCopy() {
"TOOLTIP_Platform=Home: {0}
Used in: {1}"
})
public String getShortDescription() {
- if (pss.platform.isValid()) {
- FileObject installFolder = pss.platform.getInstallFolders().iterator().next();
- String groups = pss.sourceSets.stream().map(GradleJavaSourceSet::getName).collect(Collectors.joining(", "));
- return Bundle.TOOLTIP_Platform(FileUtil.getFileDisplayName(installFolder), groups);
- } else {
- return super.getShortDescription();
- }
+ String groups = pss.sourceSets.stream().map(GradleJavaSourceSet::getName).collect(Collectors.joining(", "));
+
+ return Bundle.TOOLTIP_Platform(pss.javaHome(), groups);
}
}
@@ -254,7 +255,11 @@ protected Node[] createNodes(SourceGroup sg) {
}
private List getKeys () {
- final FileObject[] roots = ((JRENode)this.getNode()).pss.platform.getBootstrapLibraries().getRoots();
+ JavaPlatform platform = ((JRENode)this.getNode()).pss.platform();
+ if (platform == null) {
+ return List.of();
+ }
+ final FileObject[] roots = platform.getBootstrapLibraries().getRoots();
final List result = new ArrayList<>(roots.length);
for (FileObject root : roots) {
var protocol = root.toURL().getProtocol();
@@ -265,12 +270,11 @@ private List getKeys () {
case "nbjrt" -> ImageUtilities.loadImageIcon(MODULE_ICON, false);
default -> null;
};
- result.add (new LibrariesSourceGroup(root,file.getNameExt(), icon, icon));
+ result.add(new LibrariesSourceGroup(root, file.getNameExt(), icon, icon));
}
}
return result;
}
-
}
private static Node jarNode(SourceGroup sg) {
diff --git a/java/gradle.java/src/org/netbeans/modules/gradle/java/queries/GradleJarArtifacts.java b/java/gradle.java/src/org/netbeans/modules/gradle/java/queries/GradleJarArtifacts.java
index a70004937e0f..b763701122da 100644
--- a/java/gradle.java/src/org/netbeans/modules/gradle/java/queries/GradleJarArtifacts.java
+++ b/java/gradle.java/src/org/netbeans/modules/gradle/java/queries/GradleJarArtifacts.java
@@ -423,7 +423,7 @@ public void propertyChange(PropertyChangeEvent evt) {
wasInitialized = artifacts != null;
List copy = this.artifacts;
artifacts = PENDING;
- if (listeners == null && listeners.isEmpty()) {
+ if (listeners == null || listeners.isEmpty()) {
return;
}
if (refreshTask != null) {
diff --git a/java/gradle.java/src/org/netbeans/modules/gradle/java/spi/support/JavaToolchainSupport.java b/java/gradle.java/src/org/netbeans/modules/gradle/java/spi/support/JavaToolchainSupport.java
index eb57f6ef69df..382d7f83915d 100644
--- a/java/gradle.java/src/org/netbeans/modules/gradle/java/spi/support/JavaToolchainSupport.java
+++ b/java/gradle.java/src/org/netbeans/modules/gradle/java/spi/support/JavaToolchainSupport.java
@@ -67,7 +67,7 @@ public static JavaToolchainSupport getDefault() {
* @return the {@linkplain JavaPlatform} representing the given directory.
*/
public JavaPlatform platformByHome(File home) {
- return platformCache.computeIfAbsent(home, this::detectPlatform);
+ return home.isDirectory() ? platformCache.computeIfAbsent(home, this::detectPlatform) : null;
}
private JavaPlatform detectPlatform(File home) {
@@ -93,7 +93,7 @@ private JavaPlatform detectPlatform(File home) {
}
return null;
}
-
+
private static final Pattern GRADLE_JDK_DIST = Pattern.compile("(\\w+)-(\\d+)-(\\w+)-(\\w+)");
@NbBundle.Messages({
"# {0} - JDK Vendor",
diff --git a/java/i18n/src/org/netbeans/modules/i18n/SelectorUtils.java b/java/i18n/src/org/netbeans/modules/i18n/SelectorUtils.java
index 975bb4f6a1e1..f975477ba54a 100644
--- a/java/i18n/src/org/netbeans/modules/i18n/SelectorUtils.java
+++ b/java/i18n/src/org/netbeans/modules/i18n/SelectorUtils.java
@@ -404,7 +404,7 @@ public String getText () {
/** Setter for text
. */
public void setText (String s) {
- setText(s);
+ text.setText(s);
}
} // End of nested class ObjectNameInputPanel
diff --git a/java/java.editor/src/org/netbeans/modules/editor/java/MethodParamsTipPaintComponent.java b/java/java.editor/src/org/netbeans/modules/editor/java/MethodParamsTipPaintComponent.java
index 2db9c3338c02..84b1cd4f2f18 100644
--- a/java/java.editor/src/org/netbeans/modules/editor/java/MethodParamsTipPaintComponent.java
+++ b/java/java.editor/src/org/netbeans/modules/editor/java/MethodParamsTipPaintComponent.java
@@ -43,7 +43,7 @@ public class MethodParamsTipPaintComponent extends JToolTip {
private List> params;
private int idx;
- private JTextComponent component;
+ private final JTextComponent component;
public MethodParamsTipPaintComponent(JTextComponent component){
super();
@@ -64,6 +64,7 @@ boolean hasData() {
return params != null;
}
+ @Override
public void paintComponent(Graphics g) {
GraphicsUtils.configureDefaultRenderingHints(g);
// clear background
@@ -134,11 +135,7 @@ protected int getWidth(String s, Font font) {
return getFontMetrics(font).stringWidth(s);
}
- protected int getHeight(String s, Font font) {
- if (font == null) return fontMetrics.stringWidth(s);
- return getFontMetrics(font).stringWidth(s);
- }
-
+ @Override
public void setFont(Font font) {
super.setFont(font);
fontMetrics = this.getFontMetrics(font);
@@ -152,6 +149,7 @@ protected Font getDrawFont(){
return drawFont;
}
+ @Override
public Dimension getPreferredSize() {
draw(null);
Insets i = getInsets();
diff --git a/java/java.hints.declarative/licenseinfo.xml b/java/java.hints.declarative/licenseinfo.xml
index 70a60c1d37ab..eb726c4427e0 100644
--- a/java/java.hints.declarative/licenseinfo.xml
+++ b/java/java.hints.declarative/licenseinfo.xml
@@ -22,6 +22,7 @@
src/org/netbeans/modules/java/hints/declarative/resources/toggle-debugging.png
+ src/org/netbeans/modules/java/hints/declarative/resources/duke.gif
diff --git a/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/DeclarativeFix.java b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/DeclarativeFix.java
index 81fe7d0381cb..849951b1189c 100644
--- a/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/DeclarativeFix.java
+++ b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/DeclarativeFix.java
@@ -59,4 +59,10 @@ public Map getOptions() {
public static DeclarativeFix create(String name, String fix, List conditions, Map options) {
return new DeclarativeFix(fix, name, conditions, options);
}
+
+ @Override
+ public String toString() {
+ return getClass().getName()+" ["+pattern+"]";
+ }
+
}
diff --git a/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/Bundle.properties b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/Bundle.properties
index 822d7fe70840..58c956b3183d 100644
--- a/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/Bundle.properties
+++ b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/Bundle.properties
@@ -20,7 +20,6 @@ OpenIDE-Module-Name=Java Declarative Hints
Services/MIMEResolver/DeclarativeHintsTestResolver.xml=DeclarativeHintsTest Files
Services/MIMEResolver/HintResolver.xml=Hint Files
-Templates/Other/DeclarativeHintsTestTemplate.test=Empty DeclarativeHintsTest file
-Templates/Other/HintTemplate.hint=Empty Hint file
-Templates/Other/HintSample.hint=Sample Hint file
+Templates/Other/HintSample.test=Declarative Hint Test
+Templates/Other/HintSample.hint=Declarative Hint File
org-netbeans-modules-java-hints/rules/hints/classpathbased=From Projects ClassPath
diff --git a/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/HintSample.hint b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/HintSample.hint
index 0cfceffcdc37..87544d1935f3 100644
--- a/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/HintSample.hint
+++ b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/HintSample.hint
@@ -16,4 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-
+
+
+// see https://netbeans.apache.org/jackpot/HintsFileFormat
+
+"use System.out for Hello World":
+System.err.println("Hello World!");
+=>
+System.out.println("Hello World!");
+;;
diff --git a/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/HintSample.test b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/HintSample.test
new file mode 100644
index 000000000000..24a61c2724f3
--- /dev/null
+++ b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/HintSample.test
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+%%TestCase hint-test-case
+package test;
+public class TestClass {
+ private static void foo() {
+ System.err.println("Hello World!");
+ }
+}
+%%=>
diff --git a/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/HintTestWizDesc.html b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/HintTestWizDesc.html
new file mode 100644
index 000000000000..bd14cdff0245
--- /dev/null
+++ b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/HintTestWizDesc.html
@@ -0,0 +1,30 @@
+
+
+
+
+
+ Declarative Hint Test File
+
+
+ Creates a test file for declarative hints (.hint).
+
+
diff --git a/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/HintWizDesc.html b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/HintWizDesc.html
new file mode 100644
index 000000000000..dd7f88147678
--- /dev/null
+++ b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/HintWizDesc.html
@@ -0,0 +1,30 @@
+
+
+
+
+
+ Declarative Hint File
+
+
+ Creates a declarative hint file for java code inspections and editor hints.
+
+
diff --git a/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/duke.gif b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/duke.gif
new file mode 100644
index 000000000000..660e641df8a8
Binary files /dev/null and b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/duke.gif differ
diff --git a/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/layer.xml b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/layer.xml
index 48830756b5b4..dcbb8fc3198e 100644
--- a/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/layer.xml
+++ b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/resources/layer.xml
@@ -96,6 +96,7 @@
+
@@ -163,29 +164,30 @@
+
-
-
+
@@ -201,8 +203,6 @@
-
-
@@ -235,6 +235,16 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/test/TestParser.java b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/test/TestParser.java
index 1ccfb1d26a92..2e470060db79 100644
--- a/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/test/TestParser.java
+++ b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/test/TestParser.java
@@ -23,6 +23,7 @@
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
+import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.lang.model.SourceVersion;
@@ -42,6 +43,7 @@
*/
public class TestParser extends Parser {
+ private static final Logger LOG = Logger.getLogger(TestParser.class.getName());
private TestResult result;
@Override
@@ -128,13 +130,19 @@ public static TestCase[] parse(String tests) {
return result.toArray(new TestCase[0]);
}
- private static @CheckForNull TestCase handleTestCase(int testCaseIndex, String testName, String options, int codeIndex, String testCase) {
+ @CheckForNull@SuppressWarnings({"AssignmentToMethodParameter", "AssignmentToForLoopParameter"})
+ private static TestCase handleTestCase(int testCaseIndex, String testName, String options, int codeIndex, String testCase) {
+
+ int endmarker = testCase.indexOf(END_MARKER);
+ if (endmarker != -1) {
+ testCase = testCase.substring(0, endmarker);
+ }
+
Matcher m = LEADS_TO_HEADER.matcher(testCase);
String code = null;
List results = new LinkedList<>();
List startIndices = new LinkedList<>();
List endIndices = new LinkedList<>();
- int lastStartIndex = -1;
int lastIndex = -1;
while (m.find()) {
@@ -148,7 +156,6 @@ public static TestCase[] parse(String tests) {
startIndices.add(lastIndex);
}
- lastStartIndex = m.start();
lastIndex = m.end();
}
@@ -180,37 +187,42 @@ public static TestCase[] parse(String tests) {
endIndicesArr[c++] = codeIndex + i;
}
- SourceVersion sourceLevel = DEFAULT_SOURCE_LEVEL;
+ SourceVersion sourceLevel = null;
for (String option : options.split("[ \t]+")) {
option = option.trim();
if (option.startsWith(SOURCE_LEVEL)) {
option = option.substring(SOURCE_LEVEL.length());
-
- //XXX: log if not found!
-
+ if (option.startsWith("1.")) {
+ option = option.substring(2);
+ }
for (SourceVersion v : SourceVersion.values()) {
- if (option.equals("1." + v.name().substring("RELEASE_".length()))) {
+ if (option.equals(v.name().substring("RELEASE_".length()))) {
sourceLevel = v;
break;
}
}
- }
-
- if (DISABLED.equals(option)) {
+ if (sourceLevel == null) {
+ LOG.warning("unsupported source version: " + option);
+ }
+ } else if (DISABLED.equals(option)) {
return null;
}
}
-
+
+ if (sourceLevel == null) {
+ sourceLevel = SourceVersion.RELEASE_8;
+ }
+
return new TestCase(testName, sourceLevel, code, results.toArray(new String[0]), testCaseIndex, codeIndex, startIndicesArr, endIndicesArr);
}
private static final Pattern TEST_CASE_HEADER = Pattern.compile("%%TestCase[ \t]+([^ \t\n]*)(([ \t]+[^ \t\n]*)*)\n");
private static final Pattern LEADS_TO_HEADER = Pattern.compile("%%=>\n");
+ private static final String END_MARKER = "%%\n";
private static final String SOURCE_LEVEL = "source-level=";
private static final String DISABLED = "DISABLED";
- private static final SourceVersion DEFAULT_SOURCE_LEVEL = SourceVersion.RELEASE_5;
public static final class TestCase {
private final String name;
diff --git a/java/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/end-marker-test.hint b/java/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/end-marker-test.hint
new file mode 100644
index 000000000000..afacefb90454
--- /dev/null
+++ b/java/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/end-marker-test.hint
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+System.out.println($obj);
+=>
+System.err.println($obj);
+;;
diff --git a/java/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/end-marker-test.test b/java/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/end-marker-test.test
new file mode 100644
index 000000000000..dde0724be5fc
--- /dev/null
+++ b/java/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/end-marker-test.test
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+%%TestCase test-1
+package test;
+public class Test {
+ private void t() {
+ System.out.println("Hello");
+ }
+}
+%%=>
+package test;
+public class Test {
+ private void t() {
+ System.err.println("Hello");
+ }
+}
+%%
+// section after end-marker and before next test case
+// does not belong to any test
+%%TestCase test-2
+package test;
+public class Test {
+ private void t() {
+ System.out.println(1);
+ }
+}
+%%=>
+package test;
+public class Test {
+ private void t() {
+ System.err.println(1);
+ }
+}
+%%
+
+// same here
diff --git a/java/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/test/TestParserTest.java b/java/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/test/TestParserTest.java
index d0d20ce060e0..809b668429b0 100644
--- a/java/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/test/TestParserTest.java
+++ b/java/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/test/TestParserTest.java
@@ -70,7 +70,7 @@ public void testNoResults() {
}
@Test
- public void testSourceLevelOption() {
+ public void testSourceLevelOptionOld() {
String code = "%%TestCase name source-level=1.4\ncode\n%%=>\nfixed1\n%%=>\nfixed2\n";
TestCase[] tests = TestParser.parse(code);
@@ -79,4 +79,15 @@ public void testSourceLevelOption() {
assertEquals(SourceVersion.RELEASE_4, tests[0].getSourceLevel());
assertEquals("name:code\n:[fixed1\n, fixed2\n]:0:33:[43, 55]", tests[0].toString());
}
+
+ @Test
+ public void testSourceLevelOptionNew() {
+ String code = "%%TestCase name source-level=21\ncode\n%%=>\nfixed1\n%%=>\nfixed2\n";
+ TestCase[] tests = TestParser.parse(code);
+
+ assertEquals(1, tests.length);
+
+ assertEquals(SourceVersion.RELEASE_21, tests[0].getSourceLevel());
+ assertEquals("name:code\n:[fixed1\n, fixed2\n]:0:32:[42, 54]", tests[0].toString());
+ }
}
\ No newline at end of file
diff --git a/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/queries/SourceJavadocAttacherUtil.java b/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/queries/SourceJavadocAttacherUtil.java
index a1a63c15f787..d6183954bbe2 100644
--- a/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/queries/SourceJavadocAttacherUtil.java
+++ b/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/queries/SourceJavadocAttacherUtil.java
@@ -138,7 +138,7 @@ public void run() {
return;
}
List extends URL> s = source ? d.getSources(root, this) : d.getJavadoc(root, this);
- if (s != null || s.isEmpty()) {
+ if (!s.isEmpty()) {
List r = new ArrayList<>();
for (URL u : s) {
try {
diff --git a/java/java.j2seproject/src/org/netbeans/modules/java/j2seproject/problems/ModulePathsProblemsProvider.java b/java/java.j2seproject/src/org/netbeans/modules/java/j2seproject/problems/ModulePathsProblemsProvider.java
index bdec805d364f..515d777a5dec 100644
--- a/java/java.j2seproject/src/org/netbeans/modules/java/j2seproject/problems/ModulePathsProblemsProvider.java
+++ b/java/java.j2seproject/src/org/netbeans/modules/java/j2seproject/problems/ModulePathsProblemsProvider.java
@@ -87,11 +87,7 @@ public final class ModulePathsProblemsProvider implements ProjectProblemsProvide
public ModulePathsProblemsProvider(@NonNull final Lookup baseLkp) {
this.project = baseLkp.lookup(J2SEProject.class);
if (this.project == null) {
- throw new IllegalArgumentException(String.format(
- "Unsupported project: %s of type: %s", //NOI18N
- project,
- project.getClass()
- ));
+ throw new IllegalArgumentException("No project of type J2SEProject in lookup: "+baseLkp);
}
this.moduleInfoListeners = new HashSet<>();
this.listeners = new PropertyChangeSupport(this);
diff --git a/java/java.source.base/manifest.mf b/java/java.source.base/manifest.mf
index 8e95ab8e592a..e47516a822f0 100644
--- a/java/java.source.base/manifest.mf
+++ b/java/java.source.base/manifest.mf
@@ -3,3 +3,4 @@ OpenIDE-Module: org.netbeans.modules.java.source.base
OpenIDE-Module-Implementation-Version: 6
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/source/base/Bundle.properties
OpenIDE-Module-Layer: org/netbeans/modules/java/source/base/layer.xml
+OpenIDE-Module-Recommends: org.netbeans.libs.nbjavac
diff --git a/java/maven/src/org/netbeans/modules/maven/queries/MavenArtifactsImplementation.java b/java/maven/src/org/netbeans/modules/maven/queries/MavenArtifactsImplementation.java
index 02bba75ba182..b791b1b141d7 100644
--- a/java/maven/src/org/netbeans/modules/maven/queries/MavenArtifactsImplementation.java
+++ b/java/maven/src/org/netbeans/modules/maven/queries/MavenArtifactsImplementation.java
@@ -610,7 +610,7 @@ public void propertyChange(PropertyChangeEvent evt) {
synchronized (this) {
artifacts = null;
- if (listeners == null && listeners.isEmpty()) {
+ if (listeners == null || listeners.isEmpty()) {
return;
}
if (refreshTask != null) {
diff --git a/platform/core.startup/test/unit/src/org/netbeans/core/startup/layers/CountingSecurityManager.java b/platform/core.startup/test/unit/src/org/netbeans/core/startup/layers/CountingSecurityManager.java
index 8d5e5668d0c3..ed12ee2376c2 100644
--- a/platform/core.startup/test/unit/src/org/netbeans/core/startup/layers/CountingSecurityManager.java
+++ b/platform/core.startup/test/unit/src/org/netbeans/core/startup/layers/CountingSecurityManager.java
@@ -31,6 +31,7 @@
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
+import java.util.Objects;
import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
@@ -109,7 +110,7 @@ public boolean equals(Object obj) {
@Override
public int hashCode() {
- return this.hashCode();
+ return Objects.hashCode(this);
}
@Override
diff --git a/platform/openide.explorer/src/org/openide/explorer/propertysheet/PropertyPanel.java b/platform/openide.explorer/src/org/openide/explorer/propertysheet/PropertyPanel.java
index 736f13da8f8d..7d1db747e76a 100644
--- a/platform/openide.explorer/src/org/openide/explorer/propertysheet/PropertyPanel.java
+++ b/platform/openide.explorer/src/org/openide/explorer/propertysheet/PropertyPanel.java
@@ -161,8 +161,6 @@ public class PropertyPanel extends JComponent implements javax.accessibility.Acc
Object[] beans = null;
private ReusablePropertyEnv reusableEnv = new ReusablePropertyEnv();
private ReusablePropertyModel reusableModel = new ReusablePropertyModel(reusableEnv);
- private final boolean isGtk = "GTK".equals(UIManager.getLookAndFeel().getID()) || //NOI18N
- (UIManager.getLookAndFeel().getClass().getSuperclass().getName().indexOf("Synth") != -1); //NOI18N
private boolean ignoreCommit;
/** Creates new PropertyPanel backed by a dummy property */
@@ -1151,13 +1149,12 @@ private static String prefsToString(int prefs) {
}
/*
- * Overridden to fill in the background color, since Synth/GTKLookAndFeel ignores
- * setOpaque(true).
- * @see https://bz.apache.org/netbeans/show_bug.cgi?id=43024
+ * This method is overridden to customize the painting behavior.
+ * It ensures that the background color is filled when setOpaque is true.
*/
@Override
public void paint(Graphics g) {
- if (isGtk) {
+ if (isOpaque()) {
//Presumably we can get this fixed for JDK 1.5.1
Color c = getBackground();