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

Version upgrades #1

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,7 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

# Spoon
spooned/

# End of https://www.gitignore.io/api/linux,macos,windows,intellij+iml
32 changes: 18 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>nl.rug.search</groupId>
<artifactId>spoon-pttgrime</artifactId>
<version>0.1.0</version>
<version>0.2.0</version>
<packaging>jar</packaging>

<name>spoon-grime</name>
Expand All @@ -28,37 +28,37 @@
</developers>

<properties>
<java-version>1.8</java-version>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<spoon-core.version>5.6.0</spoon-core.version>
<xstream.version>1.4.9</xstream.version>
<spoon-core.version>11.0.0</spoon-core.version>
<xstream.version>1.4.20</xstream.version>

<jcommander.version>1.68</jcommander.version>
<commons-io.version>2.5</commons-io.version>
<jcommander.version>1.82</jcommander.version>
<commons-io.version>2.16.1</commons-io.version>

<log4j.version>2.8.2</log4j.version>
<log4j.version>2.23.1</log4j.version>

<junit.version>4.12</junit.version>
<xmlunit.version>2.3.0</xmlunit.version>
<junit.version>4.13.2</junit.version>
<xmlunit.version>2.10.0</xmlunit.version>
</properties>

<repositories>
<repository>
<id>mavencentral</id>
<name>Maven Central</name>
<url>http://central.maven.org/maven2/</url>
<url>https://repo1.maven.org/maven2/</url>
</repository>
<repository>
<id>gforge.inria.fr-snapshot</id>
<name>Maven Repository for Spoon Snapshots</name>
<url>http://spoon.gforge.inria.fr/repositories/snapshots/</url>
<url>https://spoon.gforge.inria.fr/repositories/snapshots/</url>
<snapshots />
</repository>
<repository>
<id>jcenter</id>
<name>JCenter Repository</name>
<url>http://jcenter.bintray.com/</url>
<url>https://jcenter.bintray.com/</url>
<snapshots />
</repository>
<repository>
Expand Down Expand Up @@ -108,6 +108,11 @@
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j.version}</version>
</dependency>


<!-- Testing -->
Expand All @@ -128,8 +133,7 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<release>21</release>
<encoding>${project.build.sourceEncoding}</encoding>
<compilerArgs>-Xlint:all</compilerArgs>
<showWarnings>true</showWarnings>
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/nl/rug/search/patterngrime/CLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.junit.Assert;
import spoon.Launcher;
import spoon.SpoonAPI;
import spoon.support.Level;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -80,6 +81,8 @@ private void run(){
spoon.addProcessor(String.format("%s.OgCaProcessor", processorPackge));
spoon.addProcessor(String.format("%s.OgNpProcessor", processorPackge));

spoon.getEnvironment().setLevel("INFO");

spoon.addInputResource(srcDir.getAbsolutePath());
spoon.run();

Expand Down
1 change: 1 addition & 0 deletions src/main/java/nl/rug/search/patterngrime/GoFUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public List<String> getPackagesOfInstance(Instance i) {
.map(ClassRole.class::cast)
.map(ClassRole::getPackage)
.distinct()
.filter(s -> !s.isEmpty())
.collect(Collectors.toList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import nl.rug.search.ssap.model.Instance;
import spoon.reflect.reference.CtTypeReference;
import spoon.support.Level;

import java.util.HashSet;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ public class OgCaProcessor extends PatternGrimeProcessor {

void calculateMetric() {
// Find pattern instances this class is part of
Stream<Instance> instances = patterns.getInstancesWithClass(element.getQualifiedName());
instances.forEach(this::calculateOgCa);
List<Instance> instances = patterns.getInstancesWithClass(element.getQualifiedName())
.collect(Collectors.toList());
if (!instances.isEmpty()) {
instances.forEach(this::calculateOgCa);
}
}

private void calculateOgCa(Instance i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import nl.rug.search.patterngrime.GoFUtil;
import nl.rug.search.patterngrime.Util;
import org.apache.log4j.Level;

import spoon.support.Level;
import spoon.processing.AbstractProcessor;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtInterface;
Expand All @@ -25,9 +26,13 @@ public abstract class PatternGrimeProcessor extends AbstractProcessor<CtType> {
GoFUtil patterns = null;
CtType element = null;

@Override
public void init() {
super.init();
}

@Override
public void process(CtType element) {

if(!CtClass.class.isInstance(element) && !CtInterface.class.isInstance(element))
return;

Expand All @@ -42,7 +47,7 @@ public void process(CtType element) {
try {
patterns = GoFUtil.getInstance();
} catch (IOException e) {
getFactory().getEnvironment().report(this, Level.FATAL, "Cannot load Pattern Instances. Check stack trace for details");
getFactory().getEnvironment().report(this, Level.ERROR, "Cannot load Pattern Instances. Check stack trace for details");
e.printStackTrace();
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/nl/rug/search/ssap/XMLUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class XMLUtil {
private static class SingletonHelper{
private static final XStream INSTANCE = new XStream();
static {
INSTANCE.allowTypesByWildcard(new String[]{"nl.rug.**"});
INSTANCE.processAnnotations(System.class);
INSTANCE.processAnnotations(Pattern.class);
INSTANCE.processAnnotations(Instance.class);
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/nl/rug/search/ssap/model/parser/ClassRole.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@ public String getClassQualifiedName() {
return getRole().getElement();
}

public String getPackage() { return getMatcher().group(2); }
public String getPackage() {
if (getMatcher().matches()) {
return getMatcher().group(2);
}
return "";
}

public String getClassSimpleName() { return getMatcher().group(4); }
public String getClassSimpleName() {
if (getMatcher().matches()) {
return getMatcher().group(4);
}
return "";
}
}
13 changes: 13 additions & 0 deletions src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="Console">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="trace">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>