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

DWR-660 retain member order in generated scripts between runs #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions core/impl/main/java/org/directwebremoting/impl/DefaultRemoter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.directwebremoting.impl;

import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.Map.Entry;

Expand Down Expand Up @@ -64,6 +66,18 @@ public String generateInterfaceJavaScript(String scriptName, String indent, Stri
Module module = moduleManager.getModule(scriptName, false);

MethodDeclaration[] methods = module.getMethods();
Arrays.sort(methods, new Comparator<MethodDeclaration>()
{
@Override
public int compare(MethodDeclaration m1, MethodDeclaration m2)
{
int i = m1.getName().compareTo(m2.getName());
if (i != 0) {
return i;
}
return Integer.compare(m1.getParameterTypes().length, m2.getParameterTypes().length);
}
});
for (MethodDeclaration method : methods)
{
String methodName = method.getName();
Expand Down