Skip to content

Commit 8ac1809

Browse files
authored
Fixing compilation of FormWordsScanner after changes in the platform. (#11)
1 parent 46676f3 commit 8ac1809

1 file changed

Lines changed: 58 additions & 57 deletions

File tree

src/main/java/com/intellij/uiDesigner/impl/binding/FormWordsScanner.java

Lines changed: 58 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -13,79 +13,80 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package com.intellij.uiDesigner.impl.binding;
1817

19-
import consulo.language.cacheBuilder.WordOccurrence;
20-
import consulo.application.util.function.Processor;
21-
import com.intellij.uiDesigner.lw.LwRootContainer;
22-
import com.intellij.uiDesigner.lw.IComponent;
23-
import com.intellij.uiDesigner.compiler.Utils;
2418
import com.intellij.uiDesigner.compiler.AlienFormFileException;
2519
import com.intellij.uiDesigner.compiler.UnexpectedFormElementException;
20+
import com.intellij.uiDesigner.compiler.Utils;
2621
import com.intellij.uiDesigner.impl.FormEditingUtil;
22+
import com.intellij.uiDesigner.lw.IComponent;
23+
import com.intellij.uiDesigner.lw.LwRootContainer;
2724
import consulo.language.cacheBuilder.SimpleWordsScanner;
25+
import consulo.language.cacheBuilder.WordOccurrence;
2826
import consulo.logging.Logger;
2927
import org.jdom.input.JDOMParseException;
3028

29+
import java.util.function.Predicate;
30+
3131
/**
3232
* @author yole
3333
*/
34-
public class FormWordsScanner extends SimpleWordsScanner
35-
{
36-
private static final Logger LOG = Logger.getInstance(FormWordsScanner.class);
34+
public class FormWordsScanner extends SimpleWordsScanner {
35+
private static final Logger LOG = Logger.getInstance(FormWordsScanner.class);
3736

38-
@Override
39-
public void processWords(CharSequence fileText, final Processor<WordOccurrence> processor) {
40-
super.processWords(fileText, processor);
37+
@Override
38+
public void processWords(CharSequence fileText, final Predicate<WordOccurrence> processor) {
39+
super.processWords(fileText, processor);
4140

42-
try {
43-
LwRootContainer container = Utils.getRootContainer(fileText.toString(), null/*no need component classes*/);
44-
String className = container.getClassToBind();
45-
if (className != null) {
46-
processClassAndPackagesNames(className, processor);
47-
}
41+
try {
42+
LwRootContainer container = Utils.getRootContainer(fileText.toString(), null/*no need component classes*/);
43+
String className = container.getClassToBind();
44+
if (className != null) {
45+
processClassAndPackagesNames(className, processor);
46+
}
4847

49-
FormEditingUtil.iterate(container,
50-
new FormEditingUtil.ComponentVisitor() {
51-
WordOccurrence occurence;
52-
public boolean visit(IComponent iComponent) {
53-
String componentClassName = iComponent.getComponentClassName();
54-
processClassAndPackagesNames(componentClassName, processor);
55-
final String binding = iComponent.getBinding();
56-
if (binding != null) {
57-
if (occurence == null) occurence = new WordOccurrence(binding, 0, binding.length(),WordOccurrence.Kind.FOREIGN_LANGUAGE);
58-
else occurence.init(binding, 0, binding.length(),WordOccurrence.Kind.FOREIGN_LANGUAGE);
59-
processor.process(occurence);
60-
}
61-
return true;
62-
}
63-
});
64-
}
65-
catch(AlienFormFileException ex) {
66-
// ignore
67-
}
68-
catch(UnexpectedFormElementException ex) {
69-
// ignore
70-
}
71-
catch(JDOMParseException ex) {
72-
// ignore
73-
}
74-
catch (Exception e) {
75-
LOG.error("Error indexing form file", e);
48+
FormEditingUtil.iterate(
49+
container,
50+
new FormEditingUtil.ComponentVisitor() {
51+
WordOccurrence occurence;
52+
53+
@Override
54+
public boolean visit(IComponent iComponent) {
55+
String componentClassName = iComponent.getComponentClassName();
56+
processClassAndPackagesNames(componentClassName, processor);
57+
String binding = iComponent.getBinding();
58+
if (binding != null) {
59+
if (occurence == null) {
60+
occurence = new WordOccurrence(binding, 0, binding.length(), WordOccurrence.Kind.FOREIGN_LANGUAGE);
61+
}
62+
else {
63+
occurence.init(binding, 0, binding.length(), WordOccurrence.Kind.FOREIGN_LANGUAGE);
64+
}
65+
processor.test(occurence);
66+
}
67+
return true;
68+
}
69+
}
70+
);
71+
}
72+
catch (AlienFormFileException | UnexpectedFormElementException | JDOMParseException ex) {
73+
// ignore
74+
}
75+
catch (Exception e) {
76+
LOG.error("Error indexing form file", e);
77+
}
7678
}
77-
}
7879

79-
private static void processClassAndPackagesNames(String qName, final Processor<WordOccurrence> processor) {
80-
WordOccurrence occurrence = new WordOccurrence(qName, 0, qName.length(), WordOccurrence.Kind.FOREIGN_LANGUAGE);
81-
processor.process(occurrence);
82-
int idx = qName.lastIndexOf('.');
83-
84-
while (idx > 0) {
85-
qName = qName.substring(0, idx);
86-
occurrence.init(qName, 0,qName.length(),WordOccurrence.Kind.FOREIGN_LANGUAGE);
87-
processor.process(occurrence);
88-
idx = qName.lastIndexOf('.');
80+
private static void processClassAndPackagesNames(String qName, Predicate<WordOccurrence> processor) {
81+
WordOccurrence occurrence = new WordOccurrence(qName, 0, qName.length(), WordOccurrence.Kind.FOREIGN_LANGUAGE);
82+
processor.test(occurrence);
83+
int idx = qName.lastIndexOf('.');
84+
85+
while (idx > 0) {
86+
qName = qName.substring(0, idx);
87+
occurrence.init(qName, 0, qName.length(), WordOccurrence.Kind.FOREIGN_LANGUAGE);
88+
processor.test(occurrence);
89+
idx = qName.lastIndexOf('.');
90+
}
8991
}
90-
}
9192
}

0 commit comments

Comments
 (0)