本文整理汇总了Java中com.intellij.util.text.UniqueNameGenerator类的典型用法代码示例。如果您正苦于以下问题:Java UniqueNameGenerator类的具体用法?Java UniqueNameGenerator怎么用?Java UniqueNameGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UniqueNameGenerator类属于com.intellij.util.text包,在下文中一共展示了UniqueNameGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveMaps
import com.intellij.util.text.UniqueNameGenerator; //导入依赖的package包/类
public void saveMaps() throws IOException{
File dir = getMapDirectory();
if (dir == null) {
return;
}
File[] files = getMapFiles();
@NonNls String[] filePaths = new String[myMaps.size()];
Document[] documents = new Document[myMaps.size()];
UniqueNameGenerator namesProvider = new UniqueNameGenerator();
for(int i = 0; i < myMaps.size(); i++){
MigrationMap map = myMaps.get(i);
filePaths[i] = dir + File.separator + namesProvider.generateUniqueName(FileUtil.sanitizeFileName(map.getName(), false)) + ".xml";
documents[i] = saveMap(map);
}
JDOMUtil.updateFileSet(files, filePaths, documents, CodeStyleSettingsManager.getSettings(null).getLineSeparator());
}
示例2: actionPerformed
import com.intellij.util.text.UniqueNameGenerator; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
String name = UniqueNameGenerator.generateUniqueName(myServerType.getPresentableName(), new Condition<String>() {
@Override
public boolean value(String s) {
for (NamedConfigurable<RemoteServer<?>> configurable : getConfiguredServers()) {
if (configurable.getDisplayName().equals(s)) {
return false;
}
}
return true;
}
});
MyNode node = addServerNode(myServersManager.createServer(myServerType, name), true);
selectNodeInTree(node);
}
示例3: doSetup
import com.intellij.util.text.UniqueNameGenerator; //导入依赖的package包/类
protected void doSetup(ModifiableModelsProvider modifiableModelsProvider, final Module module) {
final ModifiableFacetModel model = modifiableModelsProvider.getFacetModifiableModel(module);
final String name = UniqueNameGenerator.generateUniqueName(myFacetType.getDefaultFacetName(), new Condition<String>() {
@Override
public boolean value(String s) {
return FacetManager.getInstance(module).findFacet(myFacetType.getId(), s) == null;
}
});
final F facet = FacetManager.getInstance(module).createFacet(myFacetType, name, myConfiguration,
findUnderlyingFacet(module));
model.addFacet(facet);
modifiableModelsProvider.commitFacetModifiableModel(module, model);
final ModifiableRootModel rootModel = modifiableModelsProvider.getModuleModifiableModel(module);
myDetector.setupFacet(facet, rootModel);
modifiableModelsProvider.commitModuleModifiableModel(rootModel);
}
示例4: checkFileNameIsFree
import com.intellij.util.text.UniqueNameGenerator; //导入依赖的package包/类
@Nonnull
private String checkFileNameIsFree(@Nonnull String subPath, @Nonnull String schemeName) {
for (Named scheme : mySchemes) {
if (scheme instanceof ExternalizableScheme) {
String name = ((ExternalizableScheme)scheme).getExternalInfo().getCurrentFileName();
if (name != null &&
!schemeName.equals(scheme.getName()) &&
subPath.length() == (name.length() + mySchemeExtension.length()) &&
subPath.startsWith(name) &&
subPath.endsWith(mySchemeExtension)) {
return UniqueNameGenerator.generateUniqueName(FileUtil.sanitizeName(schemeName), collectAllFileNames());
}
}
}
return subPath;
}
示例5: addNewScheme
import com.intellij.util.text.UniqueNameGenerator; //导入依赖的package包/类
@Override
public void addNewScheme(@Nonnull T scheme, boolean replaceExisting) {
int toReplace = -1;
for (int i = 0; i < mySchemes.size(); i++) {
T existingScheme = mySchemes.get(i);
if (existingScheme.getName().equals(scheme.getName())) {
toReplace = i;
break;
}
}
if (toReplace == -1) {
mySchemes.add(scheme);
}
else if (replaceExisting || !(scheme instanceof ExternalizableScheme)) {
mySchemes.set(toReplace, scheme);
}
else {
//noinspection unchecked
renameScheme((ExternalizableScheme)scheme, UniqueNameGenerator.generateUniqueName(scheme.getName(), collectExistingNames(mySchemes)));
mySchemes.add(scheme);
}
schemeAdded(scheme);
checkCurrentScheme(scheme);
}
示例6: overriddenParameters
import com.intellij.util.text.UniqueNameGenerator; //导入依赖的package包/类
public static PsiParameter[] overriddenParameters(PsiParameter[] parameters,
@NotNull JVMElementFactory factory,
@NotNull JavaCodeStyleManager codeStyleManager,
@NotNull PsiSubstitutor substitutor,
PsiElement target) {
PsiParameter[] result = new PsiParameter[parameters.length];
UniqueNameGenerator generator = new UniqueNameGenerator();
for (int i = 0; i < parameters.length; i++) {
PsiParameter parameter = parameters[i];
final PsiType parameterType = parameter.getType();
final PsiType substituted = substituteType(substitutor, parameterType, (PsiMethod)parameter.getDeclarationScope());
String paramName = parameter.getName();
boolean isBaseNameGenerated = true;
final boolean isSubstituted = substituted.equals(parameterType);
if (!isSubstituted && isBaseNameGenerated(codeStyleManager, TypeConversionUtil.erasure(parameterType), paramName)) {
isBaseNameGenerated = false;
}
if (paramName == null ||
isBaseNameGenerated && !isSubstituted && isBaseNameGenerated(codeStyleManager, parameterType, paramName) ||
!factory.isValidParameterName(paramName)) {
String[] names = codeStyleManager.suggestVariableName(VariableKind.PARAMETER, null, null, substituted).names;
if (names.length > 0) {
paramName = generator.generateUniqueName(names[0]);
}
else {
paramName = generator.generateUniqueName("p");
}
}
else if (!generator.value(paramName)) {
paramName = generator.generateUniqueName(paramName);
}
generator.addExistingName(paramName);
result[i] = factory.createParameter(paramName, substituted, target);
}
return result;
}
示例7: getUniqueLibraryName
import com.intellij.util.text.UniqueNameGenerator; //导入依赖的package包/类
private static String getUniqueLibraryName(final String baseName, final LibraryTable.ModifiableModel model) {
return UniqueNameGenerator.generateUniqueName(baseName, "", "", " (", ")", new Condition<String>() {
@Override
public boolean value(String s) {
return model.getLibraryByName(s) == null;
}
});
}
示例8: splitState
import com.intellij.util.text.UniqueNameGenerator; //导入依赖的package包/类
@Override
public final List<Pair<Element, String>> splitState(@NotNull Element state) {
UniqueNameGenerator generator = new UniqueNameGenerator();
List<Pair<Element, String>> result = new SmartList<Pair<Element, String>>();
for (Iterator<Element> iterator = state.getChildren(getSubStateTagName()).iterator(); iterator.hasNext(); ) {
Element element = iterator.next();
iterator.remove();
result.add(createItem(getSubStateFileName(element), generator, element));
}
if (!JDOMUtil.isEmpty(state)) {
result.add(createItem(getComponentStateFileName(), generator, state));
}
return result;
}
示例9: splitState
import com.intellij.util.text.UniqueNameGenerator; //导入依赖的package包/类
@NotNull
protected static List<Pair<Element, String>> splitState(@NotNull Element state, @NotNull String attributeName) {
UniqueNameGenerator generator = new UniqueNameGenerator();
List<Pair<Element, String>> result = new SmartList<Pair<Element, String>>();
for (Element subState : state.getChildren()) {
result.add(createItem(generator, subState, attributeName));
}
return result;
}
示例10: generateServerName
import com.intellij.util.text.UniqueNameGenerator; //导入依赖的package包/类
private String generateServerName() {
return UniqueNameGenerator.generateUniqueName(myCloudType.getPresentableName(), new Condition<String>() {
@Override
public boolean value(String s) {
for (RemoteServer<?> server : RemoteServersManager.getInstance().getServers()) {
if (server.getName().equals(s)) {
return false;
}
}
return true;
}
});
}
示例11: generateServerName
import com.intellij.util.text.UniqueNameGenerator; //导入依赖的package包/类
private static String generateServerName(ServerType<?> cloudType) {
return UniqueNameGenerator.generateUniqueName(cloudType.getPresentableName(), new Condition<String>() {
@Override
public boolean value(String s) {
for (RemoteServer<?> server : RemoteServersManager.getInstance().getServers()) {
if (server.getName().equals(s)) {
return false;
}
}
return true;
}
});
}
示例12: SaveSchemeDialog
import com.intellij.util.text.UniqueNameGenerator; //导入依赖的package包/类
public SaveSchemeDialog(@NotNull Component parent, String title, @NotNull List<String> existingNames, @NotNull String selectedName) {
super(parent, false);
myExistingNames = existingNames;
setTitle(title);
mySchemeName.setText(UniqueNameGenerator.generateUniqueName(selectedName + " copy", existingNames));
init();
}
示例13: generateUniqueSchemePatchDir
import com.intellij.util.text.UniqueNameGenerator; //导入依赖的package包/类
@NotNull
private File generateUniqueSchemePatchDir(@NotNull final String defaultName, boolean createResourceDirectory) {
ignoreShelfDirectoryIfFirstShelf();
String uniqueName = UniqueNameGenerator
.generateUniqueName(shortenAndSanitize(defaultName), mySchemeManager.getAllSchemeNames());
File dir = new File(myFileProcessor.getBaseDir(), uniqueName);
if (createResourceDirectory && !dir.exists()) {
//noinspection ResultOfMethodCallIgnored
dir.mkdirs();
}
return dir;
}
示例14: ExportRunConfigurationTableModel
import com.intellij.util.text.UniqueNameGenerator; //导入依赖的package包/类
ExportRunConfigurationTableModel(List<RunConfiguration> configurations) {
enabled = new Boolean[configurations.size()];
names = new String[configurations.size()];
paths = new String[configurations.size()];
UniqueNameGenerator nameGenerator = new UniqueNameGenerator();
for (int i = 0; i < configurations.size(); i++) {
RunConfiguration config = configurations.get(i);
enabled[i] = false;
names[i] = config.getName();
paths[i] =
nameGenerator.generateUniqueName(FileUtil.sanitizeFileName(config.getName()), "", ".xml");
}
}
示例15: splitState
import com.intellij.util.text.UniqueNameGenerator; //导入依赖的package包/类
@Override
public List<Pair<Element, String>> splitState(Element e) {
final UniqueNameGenerator generator = new UniqueNameGenerator();
final List<Pair<Element, String>> result = new ArrayList<Pair<Element, String>>();
result.add(new Pair<Element, String>(e, generator.generateUniqueName("template_variable_settings") + ".xml"));
return result;
}