Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions java/maven.osgi/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,6 @@
<specification-version>1.6</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.netbinox</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.33</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.projectapi</code-name-base>
<build-prerequisite/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@

package org.netbeans.modules.maven.osgi;

import java.lang.ref.WeakReference;
import java.util.List;
import java.util.StringTokenizer;
import java.util.regex.Pattern;
import org.netbeans.modules.maven.api.NbMavenProject;
import org.netbeans.api.project.Project;
import org.netbeans.modules.maven.api.PluginPropertyUtils;
Expand All @@ -38,13 +35,12 @@
public class AccessQueryImpl implements AccessibilityQueryImplementation {

private final Project prj;
private WeakReference<List<Pattern>> ref;
private static final String DEFAULT_IMP = "*";

public AccessQueryImpl(Project prj) {
this.prj = prj;
}

/**
*
* @param pkg
Expand All @@ -60,10 +56,10 @@ public Boolean isPubliclyAccessible(FileObject pkg) {
return check(name);
}
}

return null;
}

private Boolean check(String value) {
String[] exps = PluginPropertyUtils.getPluginPropertyList(prj,
OSGiConstants.GROUPID_FELIX, OSGiConstants.ARTIFACTID_BUNDLE_PLUGIN,
Expand Down Expand Up @@ -99,44 +95,44 @@ private Boolean check(String value) {
}
return result;
}
static boolean testPackagePatterns(String patterns, String value) {
boolean matches = false;

static boolean testPackagePatterns(String patterns, String value) {
boolean matches = false;
if (patterns != null) {
patterns = PackageDefinitionUtil.omitDirectives(patterns);
StringTokenizer tok = new StringTokenizer(patterns, " ,", false); //NOI18N
String onlyPackagesPatterns = PackageDefinitionUtil.omitDirectives(patterns);
StringTokenizer tok = new StringTokenizer(onlyPackagesPatterns, " ,", false); //NOI18N
while (tok.hasMoreTokens() && !matches) {
String token = tok.nextToken();
token = token.trim();
if ("*".equals(token)) { //NOI18N
return true;
}
if ("*".equals(token)) { //NOI18N
return true;
}

boolean recursive = false;
boolean exclusivePattern = false;
if (token.startsWith("!")) {
token = token.substring(1);
exclusivePattern = true;
}
if (token.endsWith("*")) { //NOI18N
// The following cases are tested with maven-bundle-plugin
// a.* or a* -> recursive
// a. -> non-recursive
token = token.substring(0, token.length() - "*".length()); //NOI18N
recursive = true;
if (token.endsWith(".")) {
// Removes the last dot also
token = token.substring(0, token.length() - 1);
}
boolean exclusivePattern = false;
if (token.startsWith("!")) {
token = token.substring(1);
exclusivePattern = true;
}
if (token.endsWith("*")) { //NOI18N
// The following cases are tested with maven-bundle-plugin
// a.* or a* -> recursive
// a. -> non-recursive
token = token.substring(0, token.length() - "*".length()); //NOI18N
recursive = true;
if (token.endsWith(".")) {
// Removes the last dot also
token = token.substring(0, token.length() - 1);
}
}
matches = recursive ? value.startsWith(token) : value.equals(token);
if (matches && exclusivePattern) {
// only excluding when it matches
matches = !matches;
}
matches = recursive ? value.startsWith(token) : value.equals(token);
if (matches && exclusivePattern) {
// only excluding when it matches
matches = !matches;
}
}
}
return matches;
}
return matches;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ public class FelixPluginGrammarExtension implements GrammarExtensionProvider {
};

@Override
@NonNull
@NonNull
public List<GrammarResult> getDynamicCompletion(String path, HintContext hintCtx, Element parent) {
//TODO also plugin/executions/execution/configuration should apply
if (path.endsWith("plugins/plugin/configuration") && isFelixPlugin(hintCtx.getParentNode())) { //NOI18N
List<GrammarResult> result = new ArrayList<GrammarResult>();
List<GrammarResult> result = new ArrayList<>();
result.add(new AbstractSchemaBasedGrammar.MyTextElement(OSGiConstants.PARAM_INSTRUCTIONS, hintCtx.getCurrentPrefix()));
return result;
}

if (path.endsWith("plugins/plugin/configuration/" + OSGiConstants.PARAM_INSTRUCTIONS) &&
isFelixPlugin(hintCtx.getParentNode().getParentNode())) { //NOI18N
List<GrammarResult> result = new ArrayList<GrammarResult>();
List<GrammarResult> result = new ArrayList<>();
for (String curInst : txtInstructions) {
result.add(new AbstractSchemaBasedGrammar.MyTextElement(curInst, hintCtx.getCurrentPrefix()));
}
Expand All @@ -89,7 +89,7 @@ private static boolean isFelixPlugin (Node configNode) {
Node curNode = pluginChildren.item(i);
if ("groupId".equals(curNode.getNodeName())) {
NodeList children = curNode.getChildNodes();
if (children.getLength() > 0 &&
if (children.getLength() > 0 &&
OSGiConstants.GROUPID_FELIX.equals(children.item(0).getNodeValue())) {
felixGroupId = true;
} else {
Expand All @@ -98,7 +98,7 @@ private static boolean isFelixPlugin (Node configNode) {
}
if ("artifactId".equals(curNode.getNodeName())) {
NodeList children = curNode.getChildNodes();
if (children.getLength() > 0 &&
if (children.getLength() > 0 &&
OSGiConstants.ARTIFACTID_BUNDLE_PLUGIN.equals(children.item(0).getNodeValue())) {
felixArtifactId = true;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,26 @@
public class ForeignClassBundlerImpl implements ForeignClassBundler, ProjectProblemsProvider { // #179521
private static final ProjectProblem PROBLEM_REPORT = ProjectProblem.createWarning(PRBL_Name(), PRBL_DESC());
private static final RequestProcessor RP = new RequestProcessor(ForeignClassBundlerImpl.class);

private final AtomicBoolean hasProblem = new AtomicBoolean(false);

private final Project project;
private boolean calculated = false;
private boolean calculatedValue = false;
@SuppressWarnings({"this-escape"})
private final PropertyChangeSupport pchs = new PropertyChangeSupport(this);


public ForeignClassBundlerImpl(Project p) {
project = p;
}
@Override

@Override
public synchronized boolean preferSources() {
if (calculated) {
return calculatedValue;
}
calculatedValue = calculateValue();
calculatedValue = calculateValue();
calculated = true;
return calculatedValue;
}
Expand Down Expand Up @@ -119,15 +120,12 @@ private boolean calculateValue() {
} finally {
if (newVal != oldVal) {
hasProblem.set(newVal);
RP.post(new Runnable() {
@Override
public void run() {
pchs.firePropertyChange(ProjectProblemsProvider.PROP_PROBLEMS, null, null);
}
RP.post(() -> {
pchs.firePropertyChange(ProjectProblemsProvider.PROP_PROBLEMS, null, null);
});
}
}
//according to http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html default value is just
//according to http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html default value is just
//project's own sources
return true;
}
Expand All @@ -152,5 +150,5 @@ public Collection<? extends ProjectProblem> getProblems() {
return hasProblem.get() ? Collections.singleton(PROBLEM_REPORT) : Collections.<ProjectProblem>emptySet();
}


}
32 changes: 14 additions & 18 deletions java/maven.osgi/src/org/netbeans/modules/maven/osgi/Matcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*
*/
class Matcher {

/**
* Auxiliary class for each of the PATTERNs in the LIST.
*/
Expand Down Expand Up @@ -74,9 +74,9 @@ boolean matches(String packageName) {

/**
* Precompiled PATTERNs on the LIST.
*/
*/
private final Item[] items;

/**
* Value to be returned when package is not matched by any of items.
*/
Expand Down Expand Up @@ -116,20 +116,16 @@ private static Pattern toPattern(String value) {
for (int i = 0; i < l; ++i) {
final char c = value.charAt(i);
switch (c) {
case '.':
sb.append("\\.");
break;
case '*':
case '.' -> sb.append("\\.");
case '*' -> {
sb.append(".*");
hasWildcards = true;
break;
case '?':
}
case '?' -> {
sb.append(".?");
hasWildcards = true;
break;
default:
sb.append(c);
break;
}
default -> sb.append(c);
}
}
if (hasWildcards) {
Expand All @@ -149,10 +145,10 @@ private static Pattern toPattern(String value) {
// use a simple equals test.
return null; // No pattern needed.
}
}
}

Matcher(String pattern) {
List<Item> list = new ArrayList<Item>();
List<Item> list = new ArrayList<>();
boolean unmatched = false; // Default for no items.
if (pattern != null && !pattern.contains("${")) {
String[] strItems = pattern.split(",");
Expand Down Expand Up @@ -182,11 +178,11 @@ private static Pattern toPattern(String value) {
}
}
}
items = list.toArray(new Item[0]);
items = list.toArray(Item[]::new);
unmatchedValue = unmatched;
}


boolean matches(String packageName) {
for (Item item : items) {
if (item.matches(packageName)) {
Expand Down
Loading
Loading