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

Fix issue 170 #181

Merged
merged 12 commits into from
Apr 15, 2019
Merged
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: 8 additions & 0 deletions edu.cuny.hunter.log.core/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@
<?eclipse version="3.4"?>
<plugin>

<extension
point="org.eclipse.ltk.core.refactoring.refactoringContributions">
<contribution
class="edu.cuny.hunter.log.core.contributions.LogRejuvenationContributions"
id="org.eclipse.log.rejuvenation.contribution">
</contribution>
</extension>

khatchad marked this conversation as resolved.
Show resolved Hide resolved
</plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.EnumDeclaration;
import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.MethodInvocation;
import org.eclipse.jdt.core.dom.Name;
import org.eclipse.jdt.core.dom.QualifiedName;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.jdt.internal.corext.dom.ASTNodes;
import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package edu.cuny.hunter.log.core.contributions;

import java.util.Map;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.refactoring.descriptors.JavaRefactoringDescriptor;
import org.eclipse.jdt.internal.corext.refactoring.scripting.JavaUIRefactoringContribution;
import org.eclipse.ltk.core.refactoring.Refactoring;
import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;

import edu.cuny.hunter.log.core.descriptors.LogDescriptor;

@SuppressWarnings("restriction")
public class LogRejuvenationContributions extends JavaUIRefactoringContribution {

/*
* (non-Javadoc)
*
* @see
* org.eclipse.ltk.core.refactoring.RefactoringContribution#createDescriptor
* (java.lang.String, java.lang.String, java.lang.String, java.lang.String,
* java.util.Map, int)
*/
@Override
public RefactoringDescriptor createDescriptor(String id, String project, String description, String comment,
@SuppressWarnings("rawtypes") Map arguments, int flags) throws IllegalArgumentException {
return new LogDescriptor(id, project, description, comment, arguments, flags);
}

@Override
public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status)
throws CoreException {
return descriptor.createRefactoring(status);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public static void clearTaskContext() throws NonActiveMylynTaskException {
* @return logging level
*/
// if isTest == 1, then it is junit test
@SuppressWarnings("unchecked")
public static Level isLogExpression(MethodInvocation node, boolean isTest) {
if (!isTest) {
IMethodBinding methodBinding = node.resolveMethodBinding();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@ protected ICompilationUnit createCUfromTestFile(IPackageFragment pack, String cu
return unit;
}

@SuppressWarnings("deprecation")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which deprecated method is being used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field AST.JLS8 is deprecated

private void helper(LogInvocationExpectedResult... expectedResults) throws Exception {

// compute the actual results.
ICompilationUnit cu = this.createCUfromTestFile(this.getPackageP(), "A");

ASTParser parser = ASTParser.newParser(AST.JLS8);
ASTParser parser = ASTParser.newParser(AST.JLS10);
parser.setResolveBindings(true);
parser.setSource(cu);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
Expand Down
4 changes: 3 additions & 1 deletion edu.cuny.hunter.log.ui/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<!DOCTYPE xml>
<plugin>

<extension
Expand Down Expand Up @@ -53,7 +54,8 @@
</visibleWhen>
</command>
</menuContribution>
<menuContribution

<menuContribution
allPopups="false"
locationURI="popup:org.eclipse.jdt.ui.refactoring.menu?after=additions">
<command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ private void removeMethodInRevisionB(MethodDeclaration targetMethodDec,
/**
* Check whether the two methods have the same parameter types.
*/
@SuppressWarnings("unchecked")
private boolean isSameParameterType(MethodDeclaration methodA, MethodDeclaration methodB) {
List<SingleVariableDeclaration> parametersA = methodA.parameters();
List<SingleVariableDeclaration> parametersB = methodB.parameters();
Expand Down Expand Up @@ -988,8 +989,9 @@ private Collection<String> getMethodSignatures(Collection<HashSet<MethodDeclarat
/**
* Parse a Java file, and let visitor to visit declaring methods.
*/
@SuppressWarnings("deprecation")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the deprecated method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field AST.JLS8 is deprecated

private void parseJavaFile(String fileContent, String newDirectory) throws IOException {
ASTParser parser = ASTParser.newParser(AST.JLS8);
ASTParser parser = ASTParser.newParser(AST.JLS10);
parser.setResolveBindings(true);
parser.setSource(fileContent.toCharArray());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ private Set<Vertex> updateEntryVertices() {
return this.headVertices;
}

@SuppressWarnings("unused")
private Set<Vertex> getHeadVertices() {
return this.headVertices;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class Util {
/**
* Return a method signature
*/
@SuppressWarnings("unchecked")
public static String getMethodSignature(MethodDeclaration methodDeclaration) {
String signature = "";
signature += methodDeclaration.getName() + "(";
Expand Down Expand Up @@ -147,8 +148,9 @@ private static File findEvaluationPropertiesFile(IJavaProject project, String fi
/**
* Create CompilationUnit from ICompilationUnit.
*/
@SuppressWarnings("deprecation")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field AST.JLS8 is deprecated

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then use the non-deprecated one rather than suppressing this warning. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried AST.JLS11, but it could fail building.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. Looks like the tests are failing with the newer Eclipse version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the warning caused by JDK version?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

public static CompilationUnit getCompilationUnit(ICompilationUnit unit) {
ASTParser parser = ASTParser.newParser(AST.JLS8);
ASTParser parser = ASTParser.newParser(AST.JLS10);
parser.setResolveBindings(true);
parser.setSource(unit);
return (CompilationUnit) parser.createAST(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,12 @@ public String getFile() {
public String getMethod() {
return method;
}

public int getCommit() {
return commit;
}

public void setCommit(int commit) {
this.commit = commit;
}
khatchad marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.logging.Logger;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMethod;
Expand Down Expand Up @@ -48,7 +46,6 @@ public class EvaluationHandler extends AbstractHandler {

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Optional<IProgressMonitor> monitor = Optional.empty();
ISelection currentSelection = HandlerUtil.getCurrentSelectionChecked(event);
List<?> list = SelectionUtil.toList(currentSelection);

Expand Down
3 changes: 1 addition & 2 deletions edu.cuny.hunter.mylyngit.tests/build.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml
.,
5 changes: 0 additions & 5 deletions edu.cuny.hunter.mylyngit.tests/plugin.xml

This file was deleted.