Skip to content

Commit

Permalink
Merge pull request #5850 from apache/delivery
Browse files Browse the repository at this point in the history
Sync delivery to release180 for 18-rc2
  • Loading branch information
neilcsmith-net authored Apr 26, 2023
2 parents 9314593 + f2c685a commit 5032357
Show file tree
Hide file tree
Showing 62 changed files with 1,589 additions and 432 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,9 @@ jobs:
- name: ide/javascript2.debug
run: ant $OPTS -f ide/javascript2.debug test

- name: ide/languages.hcl
run: ant $OPTS -f ide/languages.hcl test

- name: ide/languages.toml
run: ant $OPTS -f ide/languages.toml test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,12 @@ private void dumpContainerProperties(Map<String, ?> m, String prefix, Map<String
String k = it.getKey();
String newPrefix = prefix + "." + k + "."; // NOI18N
Object v = it.getValue();
defaultValues.put(prefix + "." + k, Objects.toString(v)); // NOI18N
inspectObjectAndValues(v.getClass(), v, newPrefix, globalTypes, propertyTypes, defaultValues, null, false);
if (v == null) {
defaultValues.put(prefix + "." + k, null); // NOI18N
} else {
defaultValues.put(prefix + "." + k, Objects.toString(v)); // NOI18N
inspectObjectAndValues(v.getClass(), v, newPrefix, globalTypes, propertyTypes, defaultValues, null, false);
}
}
}

Expand Down Expand Up @@ -766,8 +770,12 @@ private boolean dumpValue(Object value, String prefix, Map<String, String> prope
for (String k : m.keySet()) {
newPrefix = prefix + "." + k + "."; // NOI18N
Object v = m.get(k);
defaultValues.put(prefix + "." + k, Objects.toString(v)); // NOI18N
inspectObjectAndValues(v.getClass(), v, newPrefix, globalTypes, propertyTypes, defaultValues, null, false);
if (v == null) {
defaultValues.put(prefix + "." + k, null); // NOI18N
} else {
defaultValues.put(prefix + "." + k, Objects.toString(v)); // NOI18N
inspectObjectAndValues(v.getClass(), v, newPrefix, globalTypes, propertyTypes, defaultValues, null, false);
}
}
dumped = true;
} else if (Iterable.class.isAssignableFrom(t)) {
Expand All @@ -794,8 +802,12 @@ private boolean dumpValue(Object value, String prefix, Map<String, String> prope
try {
for (Object o : (Iterable)value) {
String newPrefix = prefix + "[" + index + "]."; // NOI18N
defaultValues.put(prefix + "[" + index + "]", Objects.toString(o)); //NOI18N
inspectObjectAndValues(o.getClass(), o, newPrefix, globalTypes, propertyTypes, defaultValues, null, false);
if (o == null) {
defaultValues.put(prefix + "[" + index + "]", null); //NOI18N
} else {
defaultValues.put(prefix + "[" + index + "]", Objects.toString(o)); //NOI18N
inspectObjectAndValues(o.getClass(), o, newPrefix, globalTypes, propertyTypes, defaultValues, null, false);
}
index++;
}
} catch (RuntimeException ex) {
Expand Down Expand Up @@ -838,8 +850,12 @@ private boolean dumpValue(Object value, String prefix, Map<String, String> prope
String k = o.toString();
String newPrefix = prefix + "[" + k + "]"; // NOI18N
Object v = mvalue.get(o);
defaultValues.put(newPrefix, Objects.toString(v)); // NOI18N
inspectObjectAndValues(v.getClass(), v, newPrefix + ".", globalTypes, propertyTypes, defaultValues, null, itemClass == null);
if (v == null) {
defaultValues.put(newPrefix, null); // NOI18N
} else {
defaultValues.put(newPrefix, Objects.toString(v)); // NOI18N
inspectObjectAndValues(v.getClass(), v, newPrefix + ".", globalTypes, propertyTypes, defaultValues, null, itemClass == null);
}
}
dumped = true;
}
Expand Down
5 changes: 3 additions & 2 deletions ide/editor.codetemplates/arch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ JRE is sufficient.
is required.
</api>
</li>
<li><api type='import' group='java' category='private' name='org.openide.options' url='../org-openide-options/overview-summary.html' >
<!-- deprecated <li><api type='import' group='java' category='private' name='org.openide.options' url='../org-openide-options/overview-summary.html' >
The module is needed for compilation.
The module is used during runtime.
Expand All @@ -485,7 +485,8 @@ JRE is sufficient.
6.2
is required.
</api>
</li>
</li>
-->
<li><api type='import' group='java' category='official' name='EditorAPI' url='../org-openide-text/overview-summary.html' >
The module is needed for compilation.

Expand Down
9 changes: 9 additions & 0 deletions ide/languages.hcl/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,15 @@
</run-dependency>
</dependency>
</module-dependencies>
<test-dependencies>
<test-type>
<name>unit</name>
<test-dependency>
<code-name-base>org.netbeans.libs.junit4</code-name-base>
<compile-dependency/>
</test-dependency>
</test-type>
</test-dependencies>
<public-packages/>
</data>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ protected Token<HCLTokenId> mapToken(org.antlr.v4.runtime.Token antlrToken) {
case PERCENT:
case PLUS:
case QUESTION:
case SLASH:
case STAR:
return token(OPERATOR);

case QUOTE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ protected void popHereDocVar() {
protected boolean heredocEndAhead(String partialHeredoc) {
int n = 1;
int c = _input.LA(1);
// NewLines are part of heredoc content, but
// heredoc marker and it's leading space are not
while (Character.isWhitespace(c) && c != '\n') {
c = _input.LA(++n);
}
if (c == '\n') {
//NewLines are part of heredoc content
return false;
}
// heredoc marker and it's leading space are not part of the heredoc content
while (Character.isWhitespace(c)) {
c = _input.LA(++n);
}
for (int v = 0; v < currentHereDocVar.length(); v++) {
if (this._input.LA(n + v) != currentHereDocVar.charAt(v)) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ options { tokenVocab = HCLLexer; }

expression
: exprTerm
| operation
| <assoc=right> expression QUESTION expression COLON expression
| <assoc=right> op=(NOT | MINUS) right=expression
| left=expression op=(STAR | SLASH | PERCENT) right=expression
| left=expression op=(PLUS | MINUS) right=expression
| left=expression op=(AND | OR) right=expression
| left=expression op=(LTE | GTE | LT | GT | EQUALS | NOT_EQUALS) right=expression
| exprCond=expression QUESTION (exprTrue=expression COLON exprFalse=expression)
;

exprTerm
Expand Down Expand Up @@ -148,44 +152,3 @@ attrSplat
fullSplat
: LBRACK STAR RBRACK (getAttr | index)*
;

operation
: unaryOp
| binaryOp
;

unaryOp
: (MINUS | NOT) exprTerm
;

binaryOp
: exprTerm binaryOperator exprTerm
;

binaryOperator
: compareOperator
| arithmeticOperator
| logicOperator
;

compareOperator
: EQUALS
| NOT_EQUALS
| LT
| GT
| LTE
| GTE
;

arithmeticOperator
: PLUS
| MINUS
| STAR
| SLASH
| PERCENT
;

logicOperator
: AND
| OR
;
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ protected Token<HCLTokenId> mapToken(org.antlr.v4.runtime.Token antlrToken) {
case PERCENT:
case PLUS:
case QUESTION:
case SLASH:
case STAR:
return token(OPERATOR);

case QUOTE:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*
* 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.grammar;

import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.junit.Test;
import static org.junit.Assert.*;
import org.netbeans.modules.languages.hcl.grammar.HCLExpressionParser.ExpressionContext;

/**
*
* @author lkishalmi
*/
public class HCLExpressionParserTest {

public HCLExpressionParserTest() {
}

@Test
public void testTerminals() {
assertEquals("42", parse(" 42 ").exprTerm().literalValue().NUMERIC_LIT().getText());
}

@Test
public void testCompoundExpr1() {
ExpressionContext expr = parse("1 + 2 / 3");
assertEquals("1", expr.left.getText());
assertEquals("+", expr.op.getText());
assertEquals("2/3", expr.right.getText());
}

@Test
public void testCompoundExpr2() {
ExpressionContext expr = parse("(1 + 2) / 3");
assertEquals("(1+2)", expr.left.getText());
assertEquals("/", expr.op.getText());
assertEquals("3", expr.right.getText());

ExpressionContext left = expr.left.exprTerm().expression();
assertEquals("1", left.left.getText());
assertEquals("+", left.op.getText());
assertEquals("2", left.right.getText());
}

@Test
public void testCompoundExpr3() {
ExpressionContext expr = parse("1 + -2");
assertEquals("1", expr.left.getText());
assertEquals("+", expr.op.getText());
assertEquals("-2", expr.right.getText());

ExpressionContext right = expr.right;
assertNull(right.left);
assertEquals("-", right.op.getText());
assertEquals("2", right.right.getText());
}

@Test
public void testConditionalq() {
ExpressionContext expr = parse("1 == 2 ? 3 : 4");
assertEquals("1==2", expr.exprCond.getText());
assertEquals("3", expr.exprTrue.getText());
assertEquals("4", expr.exprFalse.getText());
}

@Test
public void testConditional2() {
ExpressionContext expr = parse("(a <= b) && !c ? 0 : 1");
assertEquals("(a<=b)&&!c", expr.exprCond.getText());
assertEquals("0", expr.exprTrue.getText());
assertEquals("1", expr.exprFalse.getText());

ExpressionContext cond = expr.exprCond;
assertEquals("a<=b", cond.left.exprTerm().expression().getText());
assertEquals("!", cond.right.op.getText());
assertEquals("c", cond.right.right.getText());

}

@Test
public void testConditional3() {
ExpressionContext expr = parse("a ? b ? 0 : 1 : 2");
assertEquals("a", expr.exprCond.getText());
assertEquals("b?0:1", expr.exprTrue.getText());
assertEquals("2", expr.exprFalse.getText());

ExpressionContext exprTrue = expr.exprTrue;
assertEquals("b", exprTrue.exprCond.getText());
assertEquals("0", exprTrue.exprTrue.getText());
assertEquals("1", exprTrue.exprFalse.getText());

}

private static HCLExpressionParser.ExpressionContext parse(String expr){
HCLLexer lexer = new HCLLexer(CharStreams.fromString(expr));
HCLExpressionParser parser = new HCLExpressionParser(new CommonTokenStream(lexer));
return parser.expression();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
Expand Down Expand Up @@ -100,6 +101,7 @@ public CompilePanel(ModelHandle2 handle, Project prj, MavenProjectPropertiesUiSu
comJavaPlatform.setRenderer(new PlatformsRenderer());

origComPlatformFore = comJavaPlatform.getForeground();
/* @TODO reinstate if a new link created, or remove
btnLearnMore.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
btnLearnMore.addActionListener(new ActionListener() {
@Override
Expand All @@ -111,6 +113,8 @@ public void actionPerformed(ActionEvent e) {
}
}
});
*/
btnLearnMore.setVisible(false);
initValues();
}

Expand Down Expand Up @@ -162,15 +166,18 @@ public Boolean getValue() {
public void setValue(Boolean v) {
handle.removePOMModification(operation);
modifiedValue = null;
String value = v != null ? (v ? "all" : "none") : "all";
boolean cosEnabled = v != null ? v : getDefaultValue();
String value = cosEnabled ? "all" : "none";
if ("all".equals(value)) {
if (!warningShown && DontShowAgainSettings.getDefault().showWarningAboutApplicationCoS()) {
WarnPanel panel = new WarnPanel(NbBundle.getMessage(CompilePanel.class, "HINT_ApplicationCoS"));
NotifyDescriptor dd = new NotifyDescriptor.Message(panel, NotifyDescriptor.PLAIN_MESSAGE);
DialogDisplayer.getDefault().notify(dd);
if (panel.disabledWarning()) {
DontShowAgainSettings.getDefault().dontshowWarningAboutApplicationCoSAnymore();
}
EventQueue.invokeLater(() -> {
WarnPanel panel = new WarnPanel(NbBundle.getMessage(CompilePanel.class, "HINT_ApplicationCoS"));
NotifyDescriptor dd = new NotifyDescriptor.Message(panel, NotifyDescriptor.PLAIN_MESSAGE);
DialogDisplayer.getDefault().notify(dd);
if (panel.disabledWarning()) {
DontShowAgainSettings.getDefault().dontshowWarningAboutApplicationCoSAnymore();
}
});
warningShown = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,11 +548,11 @@ private static List<String> searchMavenRuntimes(String[] paths, boolean stopOnFi
* <ul>
* <li>MAVEN_HOME</li>
* <li>M2_HOME</li>
* <li>PATH</li></ul>
* </p>
* <li>PATH</li>
* </ul>
* <p>Only the first appereance will be appended.</p>
*
* @returns the default external Maven runtime on the path.
* @return the default external Maven runtime on the path.
*/
public static String getDefaultExternalMavenRuntime() {
String paths = System.getenv("PATH"); // NOI18N
Expand Down
Loading

0 comments on commit 5032357

Please sign in to comment.