Skip to content

Commit

Permalink
Further improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsaglam committed Feb 21, 2025
1 parent 75f620b commit 3d3efae
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/de/jplag/merging/MatchMerging.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private boolean mergeOverlapsFiles(Submission leftSubmission, Submission rightSu
* @return true if FILE_END is in token
*/
private boolean containsFileEndToken(List<Token> token) {
return token.stream().map(Token::getType).anyMatch(it -> SharedTokenType.FILE_END.equals(it));
return token.stream().map(Token::getType).anyMatch(SharedTokenType.FILE_END::equals);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public MetamodelToken convertToMetadataEnrichedToken(MetamodelToken token) {
* Iterates over a model, replacing the names of all named elements by their hashcode. This allows identifying model
* elements in subsequently generated Emfatic code while avoiding name collisions.
*/
private final void replaceElementNamesWithHashes(Resource copiedResource) {
private void replaceElementNamesWithHashes(Resource copiedResource) {
AbstractMetamodelVisitor renamer = new AbstractMetamodelVisitor() {
@Override
protected void visitENamedElement(ENamedElement eNamedElement) {
Expand All @@ -103,7 +103,7 @@ protected void visitENamedElement(ENamedElement eNamedElement) {
* Generates Emfatic code from a model resource and splits it into lines with a string builder.
* @throws ParsingException if the Emfatic writer fails.
*/
private final List<String> generateEmfaticCode(StringBuilder builder, Resource modelResource) throws ParsingException {
private List<String> generateEmfaticCode(StringBuilder builder, Resource modelResource) throws ParsingException {
Writer writer = new Writer();
try {
String code = writer.write(modelResource, null, null);
Expand All @@ -117,7 +117,7 @@ private final List<String> generateEmfaticCode(StringBuilder builder, Resource m
/**
* Calculates the index of the root package declaration, as it has unique syntax in Emfatic.
*/
private final int findIndexOfRootPackage(List<String> lines) {
private int findIndexOfRootPackage(List<String> lines) {
for (int index = 0; index < lines.size(); index++) {
if (lines.get(index).matches(PACKAGE_REGEX)) {
return index;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private String featureValueToString(Object value) {
name = valueListToString(multipleValues);
} else {
name = value.toString();
name = (name.length() > ABBREVIATION_LIMIT) ? name.substring(0, ABBREVIATION_LIMIT) + ABBREVIATION_SUFFIX : name;
name = name.length() > ABBREVIATION_LIMIT ? name.substring(0, ABBREVIATION_LIMIT) + ABBREVIATION_SUFFIX : name;
name = TEXT_AFFIX + name + TEXT_AFFIX;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private void addToken(JavaTokenType tokenType, long position, int length, CodeSe
* @param end is the end position of the token for the calculation of the length.
*/
private void addToken(JavaTokenType tokenType, long start, long end, CodeSemantics semantics) {
addToken(tokenType, file, map.getLineNumber(start), map.getColumnNumber(start), (end - start), semantics);
addToken(tokenType, file, map.getLineNumber(start), map.getColumnNumber(start), end - start, semantics);
}

private boolean isMutable(Tree classTree) {
Expand Down Expand Up @@ -149,7 +149,7 @@ public Void visitClass(ClassTree node, Void unused) {
} else if (node.getKind() == Tree.Kind.ANNOTATION_TYPE) {
// The start position for the is calculated that way, because the @ is the final element in the modifier list for
// annotations
addToken(JavaTokenType.J_ANNO_T_BEGIN, start - 2, (start - 2) + 11 + nameLength, semantics);
addToken(JavaTokenType.J_ANNO_T_BEGIN, start - 2, start - 2 + 11 + nameLength, semantics);
} else if (node.getKind() == Tree.Kind.CLASS) {
addToken(JavaTokenType.J_CLASS_BEGIN, start, 5, semantics);
}
Expand Down Expand Up @@ -565,7 +565,7 @@ public Void visitDefaultCaseLabel(DefaultCaseLabelTree node, Void unused) {

@Override
public Void visitMemberSelect(MemberSelectTree node, Void unused) {
if (node.getExpression().toString().equals("this")) {
if ("this".equals(node.getExpression().toString())) {
variableRegistry.registerVariableAccess(node.getIdentifier().toString(), true);
}
variableRegistry.setIgnoreNextVariableAccess(false); // don't ignore the foo in foo.bar()
Expand Down

0 comments on commit 3d3efae

Please sign in to comment.