Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable type parameter traversal in exact type patterns #222

Merged
merged 7 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Lint: minor structural refactoring
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
  • Loading branch information
kriegaex committed Apr 12, 2024
commit ca720596d242680781aa7603ab6509e5012dab04
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,15 @@ ajcore.*.txt
# When using a RAM disk to speed up development, see how-to in docs/developer/ram-disk/settings-ramdisk.xml
/.mvn/maven.config
/.mvn/settings-ramdisk.xml

_maven-test-it/
_x/
_tmp/
/PatternNode.*
aj-build.zip
/_ltw/
/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TraceVisitor.java
/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/VoidArrayFinder.java
/tests/features1919/github_216/IllegalVoidArrays.aj
/.editorconfig-test.editorconfig
/antora-log.json
92 changes: 36 additions & 56 deletions org.aspectj.matcher/src/main/java/org/aspectj/weaver/Lint.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
package org.aspectj.weaver;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.HashMap;
Expand Down Expand Up @@ -138,70 +138,55 @@ public class Lint {
public final Kind missingAspectForReweaving = new Kind("missingAspectForReweaving",
"aspect {0} cannot be found when reweaving {1}");

private static Trace trace = TraceFactory.getTraceFactory().getTrace(Lint.class);
private static final Trace trace = TraceFactory.getTraceFactory().getTrace(Lint.class);

public Lint(World world) {
if (trace.isTraceEnabled()) {
if (trace.isTraceEnabled())
trace.enter("<init>", this, world);
}
this.world = world;
if (trace.isTraceEnabled()) {
if (trace.isTraceEnabled())
trace.exit("<init>");
}
}

public void setAll(String messageKind) {
if (trace.isTraceEnabled()) {
if (trace.isTraceEnabled())
trace.enter("setAll", this, messageKind);
}
setAll(getMessageKind(messageKind));
if (trace.isTraceEnabled()) {
if (trace.isTraceEnabled())
trace.exit("setAll");
}
}

private void setAll(IMessage.Kind messageKind) {
for (Kind kind : kinds.values()) {
for (Kind kind : kinds.values())
kind.setKind(messageKind);
}
}

public void setFromMap(Map<String,String> lintOptionsMap) {
for (String key: lintOptionsMap.keySet()) {
String value = lintOptionsMap.get(key);
Kind kind = kinds.get(key);
if (kind == null) {
if (kind == null)
MessageUtil.error(world.getMessageHandler(), WeaverMessages.format(WeaverMessages.XLINT_KEY_ERROR, key));
} else {
else
kind.setKind(getMessageKind(value));
}
}
}

public void setFromProperties(File file) {
if (trace.isTraceEnabled()) {
if (trace.isTraceEnabled())
trace.enter("setFromProperties", this, file);
}
InputStream s = null;
try {
s = new FileInputStream(file);
try (InputStream s = Files.newInputStream(file.toPath())) {
setFromProperties(s);
} catch (IOException ioe) {
MessageUtil.error(world.getMessageHandler(),
WeaverMessages.format(WeaverMessages.XLINT_LOAD_ERROR, file.getPath(), ioe.getMessage()));
} finally {
if (s != null) {
try {
s.close();
} catch (IOException e) {
// ignore
}
}
}
catch (IOException ioe) {
MessageUtil.error(
world.getMessageHandler(),
WeaverMessages.format(WeaverMessages.XLINT_LOAD_ERROR, file.getPath(), ioe.getMessage())
);
}

if (trace.isTraceEnabled()) {
if (trace.isTraceEnabled())
trace.exit("setFromProperties");
}
}

public void loadDefaultProperties() {
Expand All @@ -212,7 +197,8 @@ public void loadDefaultProperties() {
}
try {
setFromProperties(s);
} catch (IOException ioe) {
}
catch (IOException ioe) {
MessageUtil.error(world.getMessageHandler(),
WeaverMessages.format(WeaverMessages.XLINTDEFAULT_LOAD_PROBLEM, ioe.getMessage()));
} finally {
Expand All @@ -234,11 +220,10 @@ private void setFromProperties(InputStream s) throws IOException {
public void setFromProperties(Properties properties) {
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
Kind kind = kinds.get(entry.getKey());
if (kind == null) {
if (kind == null)
MessageUtil.error(world.getMessageHandler(), WeaverMessages.format(WeaverMessages.XLINT_KEY_ERROR, entry.getKey()));
} else {
else
kind.setKind(getMessageKind((String) entry.getValue()));
}
}
}

Expand All @@ -252,34 +237,31 @@ public Kind getLintKind(String name) {

// temporarily suppress the given lint messages
public void suppressKinds(Collection<Kind> lintKind) {
if (lintKind.isEmpty()) {
if (lintKind.isEmpty())
return;
}
for (Kind k : lintKind) {
for (Kind k : lintKind)
k.setSuppressed(true);
}
}

// remove any suppression of lint warnings in place
public void clearAllSuppressions() {
for (Kind k : kinds.values()) {
for (Kind k : kinds.values())
k.setSuppressed(false);
}
}

public void clearSuppressions(Collection<Lint.Kind> lintKinds) {
for (Kind k : lintKinds) {
for (Kind k : lintKinds)
k.setSuppressed(false);
}
}

private IMessage.Kind getMessageKind(String v) {
if (v.equals("ignore")) {
return null;
} else if (v.equals("warning")) {
return IMessage.WARNING;
} else if (v.equals("error")) {
return IMessage.ERROR;
switch (v) {
case "ignore":
return null;
case "warning":
return IMessage.WARNING;
case "error":
return IMessage.ERROR;
}

MessageUtil.error(world.getMessageHandler(), WeaverMessages.format(WeaverMessages.XLINT_VALUE_ERROR, v));
Expand Down Expand Up @@ -328,19 +310,17 @@ public void setKind(IMessage.Kind kind) {
}

public void signal(String info, ISourceLocation location) {
if (kind == null) {
if (kind == null)
return;
}

String text = MessageFormat.format(message, new Object[] { info });
String text = MessageFormat.format(message, info);
text += " [Xlint:" + name + "]";
world.getMessageHandler().handleMessage(new LintMessage(text, kind, location, null, getLintKind(name)));
}

public void signal(String[] infos, ISourceLocation location, ISourceLocation[] extraLocations) {
if (kind == null) {
if (kind == null)
return;
}

String text = MessageFormat.format(message, (Object[]) infos);
text += " [Xlint:" + name + "]";
Expand Down