diff --git a/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java b/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java index 073e65944268..cbfef7d662ad 100644 --- a/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java +++ b/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.List; public class NameUtil { @@ -635,7 +636,18 @@ public class NameUtil { return myPattern.length == 0 ? Collections.emptyList() : null; } - return matchName(name, 0, 0); + final FList ranges = matchName(name, 0, 0); + if (ranges != null) { + final List list = new ArrayList(ranges); + Collections.sort(list, new Comparator() { + @Override + public int compare(TextRange o1, TextRange o2) { + return o1.getStartOffset() - o2.getStartOffset(); + } + }); + return list; + } + return ranges; } } }