本文整理汇总了Java中com.intellij.refactoring.ui.NameSuggestionsGenerator类的典型用法代码示例。如果您正苦于以下问题:Java NameSuggestionsGenerator类的具体用法?Java NameSuggestionsGenerator怎么用?Java NameSuggestionsGenerator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NameSuggestionsGenerator类属于com.intellij.refactoring.ui包,在下文中一共展示了NameSuggestionsGenerator类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createNameSuggestionGenerator
import com.intellij.refactoring.ui.NameSuggestionsGenerator; //导入依赖的package包/类
protected static NameSuggestionsGenerator createNameSuggestionGenerator(final PsiExpression expr,
final String propName,
final Project project,
final String enteredName) {
return new NameSuggestionsGenerator() {
public SuggestedNameInfo getSuggestedNameInfo(PsiType type) {
final JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(project);
SuggestedNameInfo info = codeStyleManager.suggestVariableName(VariableKind.PARAMETER, propName, expr != null && expr.isValid() ? expr : null, type);
if (expr != null && expr.isValid()) {
info = codeStyleManager.suggestUniqueVariableName(info, expr, true);
}
final String[] strings = AbstractJavaInplaceIntroducer.appendUnresolvedExprName(JavaCompletionUtil
.completeVariableNameForRefactoring(codeStyleManager, type, VariableKind.LOCAL_VARIABLE, info), expr);
return new SuggestedNameInfo.Delegate(enteredName != null ? ArrayUtil.mergeArrays(new String[]{enteredName}, strings): strings, info);
}
};
}
示例2: createNameSuggestionGenerator
import com.intellij.refactoring.ui.NameSuggestionsGenerator; //导入依赖的package包/类
protected static NameSuggestionsGenerator createNameSuggestionGenerator(final String propertyName,
final PsiExpression psiExpression,
final JavaCodeStyleManager codeStyleManager,
final String enteredName, final PsiClass parentClass) {
return new NameSuggestionsGenerator() {
public SuggestedNameInfo getSuggestedNameInfo(PsiType type) {
SuggestedNameInfo nameInfo =
codeStyleManager.suggestVariableName(VariableKind.STATIC_FINAL_FIELD, propertyName, psiExpression, type);
if (psiExpression != null) {
String[] names = nameInfo.names;
for (int i = 0, namesLength = names.length; i < namesLength; i++) {
String name = names[i];
if (parentClass.findFieldByName(name, false) != null) {
names[i] = codeStyleManager.suggestUniqueVariableName(name, psiExpression, true);
}
}
}
final String[] strings = AbstractJavaInplaceIntroducer.appendUnresolvedExprName(JavaCompletionUtil
.completeVariableNameForRefactoring(codeStyleManager, type, VariableKind.LOCAL_VARIABLE, nameInfo), psiExpression);
return new SuggestedNameInfo.Delegate(enteredName != null ? ArrayUtil.mergeArrays(new String[]{enteredName}, strings): strings, nameInfo);
}
};
}
示例3: IntroduceParameterDialog
import com.intellij.refactoring.ui.NameSuggestionsGenerator; //导入依赖的package包/类
IntroduceParameterDialog(@NotNull Project project,
@NotNull List<UsageInfo> classMembersList,
PsiExpression[] occurences,
PsiLocalVariable onLocalVariable,
PsiExpression onExpression,
@NotNull NameSuggestionsGenerator generator,
@NotNull TypeSelectorManager typeSelectorManager,
@NotNull PsiMethod methodToSearchFor,
@NotNull PsiMethod methodToReplaceIn,
@NotNull TIntArrayList parametersToRemove,
final boolean mustBeFinal) {
super(project, true);
myPanel = new IntroduceParameterSettingsPanel(onLocalVariable, onExpression, methodToReplaceIn, parametersToRemove);
myProject = project;
myClassMembersList = classMembersList;
myOccurenceNumber = occurences.length;
for (PsiExpression occurence : occurences) {
if (PsiUtil.isAccessedForWriting(occurence)) {
myHasWriteAccess = true;
break;
}
}
myExpression = onExpression;
myLocalVar = onLocalVariable;
myMethodToReplaceIn = methodToReplaceIn;
myMustBeFinal = mustBeFinal;
myMethodToSearchFor = methodToSearchFor;
myNameSuggestionsGenerator = generator;
myTypeSelectorManager = typeSelectorManager;
setTitle(REFACTORING_NAME);
init();
}
示例4: createGenerator
import com.intellij.refactoring.ui.NameSuggestionsGenerator; //导入依赖的package包/类
static NameSuggestionsGenerator createGenerator(final boolean willBeDeclaredStatic,
final PsiLocalVariable localVariable,
final PsiExpression initializerExpression,
final boolean isInvokedOnDeclaration,
@Nullable final String enteredName,
final PsiClass parentClass,
final Project project) {
return new NameSuggestionsGenerator() {
private final JavaCodeStyleManager myCodeStyleManager = JavaCodeStyleManager.getInstance(project);
public SuggestedNameInfo getSuggestedNameInfo(PsiType type) {
VariableKind variableKind = willBeDeclaredStatic ? VariableKind.STATIC_FIELD : VariableKind.FIELD;
String propertyName = null;
if (isInvokedOnDeclaration) {
propertyName = myCodeStyleManager.variableNameToPropertyName(localVariable.getName(), VariableKind.LOCAL_VARIABLE);
}
final SuggestedNameInfo nameInfo = myCodeStyleManager.suggestVariableName(variableKind, propertyName, initializerExpression, type);
if (initializerExpression != null) {
String[] names = nameInfo.names;
for (int i = 0, namesLength = names.length; i < namesLength; i++) {
String name = names[i];
if (parentClass.findFieldByName(name, false) != null) {
names[i] = myCodeStyleManager.suggestUniqueVariableName(name, initializerExpression, true);
}
}
}
final String[] strings = AbstractJavaInplaceIntroducer.appendUnresolvedExprName(JavaCompletionUtil.completeVariableNameForRefactoring(myCodeStyleManager, type, VariableKind.LOCAL_VARIABLE, nameInfo), initializerExpression);
return new SuggestedNameInfo.Delegate(enteredName != null ? ArrayUtil.mergeArrays(new String[]{enteredName}, strings) : strings, nameInfo);
}
};
}
示例5: createNorthPanel
import com.intellij.refactoring.ui.NameSuggestionsGenerator; //导入依赖的package包/类
protected JComponent createNorthPanel() {
myNameField = new NameSuggestionsField(myProject);
myNameChangedListener = new NameSuggestionsField.DataChanged() {
public void dataChanged() {
updateOkStatus();
}
};
myNameField.addDataChangedListener(myNameChangedListener);
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints gbConstraints = new GridBagConstraints();
gbConstraints.insets = new Insets(4, 4, 4, 4);
gbConstraints.anchor = GridBagConstraints.WEST;
gbConstraints.fill = GridBagConstraints.BOTH;
gbConstraints.gridwidth = 1;
gbConstraints.weightx = 0;
gbConstraints.weighty = 0;
gbConstraints.gridx = 0;
gbConstraints.gridy = 0;
JLabel type = new JLabel(RefactoringBundle.message("variable.of.type"));
panel.add(type, gbConstraints);
gbConstraints.gridx++;
myTypeSelector = myTypeSelectorManager.getTypeSelector();
panel.add(myTypeSelector.getComponent(), gbConstraints);
gbConstraints.gridwidth = 1;
gbConstraints.weightx = 0;
gbConstraints.weighty = 0;
gbConstraints.gridx = 0;
gbConstraints.gridy = 1;
JLabel namePrompt = new JLabel(RefactoringBundle.message("name.prompt"));
namePrompt.setLabelFor(myNameField.getComponent());
panel.add(namePrompt, gbConstraints);
gbConstraints.gridwidth = 1;
gbConstraints.weightx = 1;
gbConstraints.gridx = 1;
gbConstraints.gridy = 1;
panel.add(myNameField.getComponent(), gbConstraints);
myNameSuggestionsManager = new NameSuggestionsManager(myTypeSelector, myNameField,
new NameSuggestionsGenerator() {
public SuggestedNameInfo getSuggestedNameInfo(PsiType type) {
return IntroduceVariableBase.getSuggestedName(type, myExpression);
}
});
myNameSuggestionsManager.setLabelsFor(type, namePrompt);
return panel;
}