Skip to content

Commit

Permalink
Merge branch 'apache:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Honza-cz authored Oct 10, 2023
2 parents 9810035 + 1c9eeab commit a04f20e
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 628 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ jobs:

- name: Tidy up and display artifacts
run: |
cp myfiles/nativeexecution-external-sources/LICENSE myfiles/LICENSE
cp myfiles/nativeexecution-external-sources/NOTICE myfiles/NOTICE
rm -rf myfiles/*sources*
ls -l -R
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/native-binary-build-lib.profiler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ jobs:
SOURCES="profiler/lib.profiler/build/sources"
mkdir -p ${SOURCES}/profiler/lib.profiler
cp -r profiler/lib.profiler/native/ ${SOURCES}/profiler/lib.profiler/
find profiler/lib.profiler/release/lib/deployed -type d -exec mkdir -p "${SOURCES}/{}" \; -exec touch "${SOURCES}/{}/PLACEHOLDER" \;
cp LICENSE ${SOURCES}/LICENSE
cp NOTICE ${SOURCES}/NOTICE
ls -l -R ${SOURCES}
Expand Down Expand Up @@ -316,6 +315,8 @@ jobs:

- name: Tidy up and display artifacts
run: |
cp myfiles/lib/deployed/jdk16/profiler-external-sources-ASF/LICENSE myfiles/LICENSE
cp myfiles/lib/deployed/jdk16/profiler-external-sources-ASF/NOTICE myfiles/NOTICE
rm -rf myfiles/lib/deployed/jdk16/*sources*
ls -l -R
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.ContinueTree;
import com.sun.source.tree.ExpressionTree;
import com.sun.source.tree.InstanceOfTree;
import com.sun.source.tree.LabeledStatementTree;
import com.sun.source.tree.MemberReferenceTree;
import com.sun.source.tree.MemberSelectTree;
Expand Down Expand Up @@ -667,11 +666,11 @@ public static boolean isPrivateElement(Element el) {
}

public static Element toRecordComponent(Element el) {
if (el == null ||el.getKind() != ElementKind.FIELD) {
if (el == null || el.getKind() != ElementKind.FIELD) {
return el;
}
TypeElement owner = (TypeElement) el.getEnclosingElement();
if (!"RECORD".equals(owner.getKind().name())) {
if (!ElementKind.RECORD.equals(owner.getKind())) {
return el;
}
for (Element encl : owner.getEnclosedElements()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ private boolean process() {
}
private boolean process(TreePath path) {

Element resolved = TreeShims.toRecordComponent(info.getTrees().getElement(path));
Element resolved = org.netbeans.modules.java.editor.base.semantic.Utilities.toRecordComponent(info.getTrees().getElement(path));
if (toFind.equals(resolved)) {
found = getCurrentPath();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import com.sun.source.tree.BlockTree;
import com.sun.source.tree.CaseTree;
import com.sun.source.tree.ExpressionStatementTree;
import com.sun.source.tree.ExpressionTree;
import com.sun.source.tree.IdentifierTree;
import com.sun.source.tree.IfTree;
import com.sun.source.tree.InstanceOfTree;
import com.sun.source.tree.ParenthesizedTree;
Expand All @@ -32,21 +30,17 @@
import com.sun.source.tree.Tree;
import com.sun.source.tree.VariableTree;
import com.sun.source.util.TreePath;
import com.sun.tools.javac.tree.JCTree;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.Name;
import javax.lang.model.type.TypeMirror;
import org.netbeans.api.java.source.CompilationInfo;
import org.netbeans.api.java.source.TreeMaker;
import org.netbeans.api.java.source.WorkingCopy;
import org.netbeans.modules.java.source.TreeShims;
import org.netbeans.spi.editor.hints.ErrorDescription;
import org.netbeans.spi.editor.hints.Fix;
import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
Expand All @@ -57,7 +51,6 @@
import org.netbeans.spi.java.hints.TriggerPattern;
import org.netbeans.spi.java.hints.TriggerPatterns;
import org.netbeans.spi.java.hints.TriggerTreeKind;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle;

/**
Expand Down Expand Up @@ -274,9 +267,7 @@ protected void performRewrite(JavaFix.TransformationContext ctx) {
public static ErrorDescription switchPatternMatchToSwitchNull(HintContext ctx) {

SwitchTree switchTree = (SwitchTree) ctx.getPath().getLeaf();
boolean isPatternMatch = false;
isPatternMatch = TreeShims.isPatternMatch(switchTree);
if (!isPatternMatch) {
if (!isPatternMatch(switchTree)) {
return null;
}
Tree expression = ((ParenthesizedTree) switchTree.getExpression()).getExpression();
Expand All @@ -297,6 +288,16 @@ public static ErrorDescription switchPatternMatchToSwitchNull(HintContext ctx) {

}

public static boolean isPatternMatch(Tree node) {
try {
return node.getClass().getField("patternSwitch").getBoolean(node);
} catch (NoSuchFieldException e){
return false;
} catch (IllegalArgumentException | IllegalAccessException | SecurityException ex) {
throw new RuntimeException(ex);
}
}

private static final class FixSwitchPatternMatchToSwitchNull extends JavaFix {

private final int indexOf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import org.netbeans.junit.NbTestCase;
import org.netbeans.modules.java.hints.test.api.HintTest;
import javax.lang.model.SourceVersion;
import org.testng.annotations.Test;

/**
Expand Down
Loading

0 comments on commit a04f20e

Please sign in to comment.