blob: c77d0b7ce1f1d05a357db55fff986082e263e48b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
package com.intellij.structuralsearch.plugin.replace.impl;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import com.intellij.structuralsearch.MatchResult;
import com.intellij.structuralsearch.StructuralSearchUtil;
import com.intellij.structuralsearch.plugin.replace.ReplaceOptions;
import java.util.HashMap;
import java.util.Map;
/**
* Created by IntelliJ IDEA.
* User: Maxim.Mossienko
* Date: 27.09.2005
* Time: 14:27:20
* To change this template use File | Settings | File Templates.
*/
public class ReplacementContext {
ReplacementInfoImpl replacementInfo;
ReplaceOptions options;
Project project;
public ReplaceOptions getOptions() {
return options;
}
public Project getProject() {
return project;
}
ReplacementContext(ReplaceOptions _options, Project _project) {
options = _options;
project = _project;
}
public Map<String, String> getNewName2PatternNameMap() {
Map<String, String> newNameToSearchPatternNameMap = new HashMap<String, String>(1);
final Map<String, MatchResult> variableMap = replacementInfo.getVariableMap();
if (variableMap != null) {
for (String s : variableMap.keySet()) {
final MatchResult matchResult = replacementInfo.getVariableMap().get(s);
PsiElement match = matchResult.getMatchRef() != null ? matchResult.getMatch() : null;
if (StructuralSearchUtil.isIdentifier(match)) match = match.getParent();
if (match instanceof PsiNamedElement) {
final String name = ((PsiNamedElement)match).getName();
newNameToSearchPatternNameMap.put(name, s);
}
}
}
return newNameToSearchPatternNameMap;
}
}
|