mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SSR: rename method
This commit is contained in:
@@ -156,6 +156,7 @@ public class MatchOptions implements JDOMExternalizable {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(Element element) {
|
||||
element.setAttribute(TEXT_ATTRIBUTE_NAME, pattern);
|
||||
if (!looseMatching) {
|
||||
@@ -184,6 +185,7 @@ public class MatchOptions implements JDOMExternalizable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(Element element) {
|
||||
pattern = element.getAttribute(TEXT_ATTRIBUTE_NAME).getValue();
|
||||
|
||||
@@ -212,8 +214,7 @@ public class MatchOptions implements JDOMExternalizable {
|
||||
|
||||
attr = element.getAttribute(FILE_TYPE_ATTR_NAME);
|
||||
if (attr!=null) {
|
||||
String value = attr.getValue();
|
||||
myFileType = getFileTypeByName(value);
|
||||
myFileType = getFileTypeByName(attr.getValue());
|
||||
}
|
||||
|
||||
attr = element.getAttribute(DIALECT_ATTR_NAME);
|
||||
@@ -223,13 +224,10 @@ public class MatchOptions implements JDOMExternalizable {
|
||||
|
||||
// @TODO deserialize scope
|
||||
|
||||
List<Element> elements = element.getChildren(CONSTRAINT_TAG_NAME);
|
||||
if (elements!=null && !elements.isEmpty()) {
|
||||
for (final Element element1 : elements) {
|
||||
final MatchVariableConstraint constraint = new MatchVariableConstraint();
|
||||
constraint.readExternal(element1);
|
||||
addVariableConstraint(constraint);
|
||||
}
|
||||
for (final Element element1 : element.getChildren(CONSTRAINT_TAG_NAME)) {
|
||||
final MatchVariableConstraint constraint = new MatchVariableConstraint();
|
||||
constraint.readExternal(element1);
|
||||
addVariableConstraint(constraint);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -141,7 +141,7 @@ public class SSBasedInspection extends LocalInspectionTool {
|
||||
private static LocalQuickFix createQuickFix(final Project project, final MatchResult matchResult, final Configuration configuration) {
|
||||
if (!(configuration instanceof ReplaceConfiguration)) return null;
|
||||
ReplaceConfiguration replaceConfiguration = (ReplaceConfiguration)configuration;
|
||||
final Replacer replacer = new Replacer(project, replaceConfiguration.getOptions());
|
||||
final Replacer replacer = new Replacer(project, replaceConfiguration.getReplaceOptions());
|
||||
final ReplacementInfo replacementInfo = replacer.buildReplacement(matchResult);
|
||||
|
||||
return new LocalQuickFix() {
|
||||
|
||||
+19
-1
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.structuralsearch.plugin.replace.ui;
|
||||
|
||||
import org.jdom.Element;
|
||||
@@ -14,19 +29,22 @@ public class ReplaceConfiguration extends Configuration {
|
||||
private final ReplaceOptions options = new ReplaceOptions();
|
||||
public static final String REPLACEMENT_VARIABLE_SUFFIX = "$replacement";
|
||||
|
||||
public ReplaceOptions getOptions() {
|
||||
public ReplaceOptions getReplaceOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MatchOptions getMatchOptions() {
|
||||
return options.getMatchOptions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(Element element) {
|
||||
super.readExternal(element);
|
||||
options.readExternal(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(Element element) {
|
||||
super.writeExternal(element);
|
||||
options.writeExternal(element);
|
||||
|
||||
+20
-5
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.structuralsearch.plugin.replace.ui;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
@@ -110,17 +125,17 @@ public class ReplaceDialog extends SearchDialog {
|
||||
|
||||
if (configuration instanceof ReplaceConfiguration) {
|
||||
final ReplaceConfiguration config = (ReplaceConfiguration)configuration;
|
||||
final ReplaceOptions options = config.getOptions();
|
||||
final ReplaceOptions options = config.getReplaceOptions();
|
||||
super.setValuesFromConfig(config);
|
||||
|
||||
UIUtil.setContent(replaceCriteriaEdit, config.getOptions().getReplacement(), 0, replaceCriteriaEdit.getDocument().getTextLength(),
|
||||
UIUtil.setContent(replaceCriteriaEdit, config.getReplaceOptions().getReplacement(), 0, replaceCriteriaEdit.getDocument().getTextLength(),
|
||||
searchContext.getProject());
|
||||
|
||||
shortenFQN.setSelected(options.isToShortenFQN());
|
||||
formatAccordingToStyle.setSelected(options.isToReformatAccordingToStyle());
|
||||
useStaticImport.setSelected(options.isToUseStaticImport());
|
||||
|
||||
ReplaceOptions newReplaceOptions = ((ReplaceConfiguration)model.getConfig()).getOptions();
|
||||
ReplaceOptions newReplaceOptions = ((ReplaceConfiguration)model.getConfig()).getReplaceOptions();
|
||||
newReplaceOptions.clearVariableDefinitions();
|
||||
|
||||
for (ReplacementVariableDefinition def : options.getReplacementVariableDefinitions()) {
|
||||
@@ -140,7 +155,7 @@ public class ReplaceDialog extends SearchDialog {
|
||||
super.setValuesToConfig(config);
|
||||
|
||||
final ReplaceConfiguration replaceConfiguration = (ReplaceConfiguration)config;
|
||||
final ReplaceOptions options = replaceConfiguration.getOptions();
|
||||
final ReplaceOptions options = replaceConfiguration.getReplaceOptions();
|
||||
|
||||
options.setMatchOptions(replaceConfiguration.getMatchOptions());
|
||||
options.setReplacement(replaceCriteriaEdit.getDocument().getText());
|
||||
@@ -175,7 +190,7 @@ public class ReplaceDialog extends SearchDialog {
|
||||
if (!super.isValid()) return false;
|
||||
|
||||
try {
|
||||
Replacer.checkSupportedReplacementPattern(searchContext.getProject(), ((ReplaceConfiguration)model.getConfig()).getOptions());
|
||||
Replacer.checkSupportedReplacementPattern(searchContext.getProject(), ((ReplaceConfiguration)model.getConfig()).getReplaceOptions());
|
||||
}
|
||||
catch (UnsupportedPatternException ex) {
|
||||
reportMessage("unsupported.replacement.pattern.message", replaceCriteriaEdit, ex.getMessage());
|
||||
|
||||
+16
-1
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.structuralsearch.plugin.replace.ui;
|
||||
|
||||
import com.intellij.history.LocalHistory;
|
||||
@@ -23,7 +38,7 @@ import java.util.Set;
|
||||
|
||||
class ReplaceUsageViewContext extends UsageViewContext {
|
||||
private final HashMap<Usage,ReplacementInfo> usage2ReplacementInfo = new HashMap<>();
|
||||
private final Replacer replacer = new Replacer(mySearchContext.getProject(), ((ReplaceConfiguration)myConfiguration).getOptions());
|
||||
private final Replacer replacer = new Replacer(mySearchContext.getProject(), ((ReplaceConfiguration)myConfiguration).getReplaceOptions());
|
||||
private UsageView myUsageView;
|
||||
private Set<Usage> myExcludedSet;
|
||||
|
||||
|
||||
+2
-2
@@ -369,7 +369,7 @@ class EditVarConstraintsDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
private static ReplacementVariableDefinition getOrAddReplacementVariableDefinition(String varName, Configuration configuration) {
|
||||
final ReplaceOptions replaceOptions = ((ReplaceConfiguration)configuration).getOptions();
|
||||
final ReplaceOptions replaceOptions = ((ReplaceConfiguration)configuration).getReplaceOptions();
|
||||
final String realVariableName = stripReplacementVarDecoration(varName);
|
||||
ReplacementVariableDefinition variableDefinition = replaceOptions.getVariableDefinition(realVariableName);
|
||||
|
||||
@@ -390,7 +390,7 @@ class EditVarConstraintsDialog extends DialogWrapper {
|
||||
|
||||
if (isReplacementVariable(varName)) {
|
||||
final ReplacementVariableDefinition definition =
|
||||
((ReplaceConfiguration)myConfiguration).getOptions().getVariableDefinition(stripReplacementVarDecoration(varName));
|
||||
((ReplaceConfiguration)myConfiguration).getReplaceOptions().getVariableDefinition(stripReplacementVarDecoration(varName));
|
||||
|
||||
restoreScriptCode(definition);
|
||||
setSearchConstraintsVisible(false);
|
||||
|
||||
+1
-1
@@ -259,7 +259,7 @@ public class SelectTemplateDialog extends DialogWrapper {
|
||||
String replacement;
|
||||
|
||||
if (configuration instanceof ReplaceConfiguration) {
|
||||
replacement = ((ReplaceConfiguration)configuration).getOptions().getReplacement();
|
||||
replacement = ((ReplaceConfiguration)configuration).getReplaceOptions().getReplacement();
|
||||
}
|
||||
else {
|
||||
replacement = configuration.getMatchOptions().getSearchPattern();
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -145,7 +145,7 @@ class StructuralSearchUsageTarget implements ConfigurableUsageTarget, ItemPresen
|
||||
final String result;
|
||||
if (myConfiguration instanceof ReplaceConfiguration) {
|
||||
final ReplaceConfiguration replaceConfiguration = (ReplaceConfiguration)myConfiguration;
|
||||
final String replacement = replaceConfiguration.getOptions().getReplacement();
|
||||
final String replacement = replaceConfiguration.getReplaceOptions().getReplacement();
|
||||
result = SSRBundle.message("replace.occurrences.of.0.with.1.in.2", pattern, replacement, scope);
|
||||
}
|
||||
else {
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ public class UIUtil {
|
||||
NamedScriptableDefinition namedScriptableDefinition = options == null ? null : options.getVariableConstraint(varname);
|
||||
|
||||
final ReplacementVariableDefinition replacementVariableDefinition =
|
||||
config instanceof ReplaceConfiguration ? ((ReplaceConfiguration)config).getOptions().getVariableDefinition(varname) : null;
|
||||
config instanceof ReplaceConfiguration ? ((ReplaceConfiguration)config).getReplaceOptions().getVariableDefinition(varname) : null;
|
||||
if (replacementVariableDefinition != null) namedScriptableDefinition = replacementVariableDefinition;
|
||||
|
||||
return getShortParamString(namedScriptableDefinition);
|
||||
|
||||
Reference in New Issue
Block a user