Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
27,000
void () { doTestHL("x y", new String[]{ "Properties:KEY_CHARACTERS", "x", "WHITE_SPACE", " ", "Properties:VALUE_CHARACTERS", "y" }); }
testHighlighting
27,001
void () { doTestHL("x\\n\\kz y", new String[]{ "Properties:KEY_CHARACTERS", "x", "VALID_STRING_ESCAPE_TOKEN", "\\n", "VALID_STRING_ESCAPE_TOKEN", "\\k", "Properties:KEY_CHARACTERS", "z", "WHITE_SPACE", " ", "Properties:VALUE_CHARACTERS", "y" }); }
testHighlighting2
27,002
void () { doTestHL("x \\uxyzt\\pz\\tp", new String[]{ "Properties:KEY_CHARACTERS", "x", "WHITE_SPACE", " ", "INVALID_UNICODE_ESCAPE_TOKEN", "\\uxyzt", "VALID_STRING_ESCAPE_TOKEN", "\\p", "Properties:VALUE_CHARACTERS", "z", "VALID_STRING_ESCAPE_TOKEN", "\\t", "Properties:VALUE_CHARACTERS", "p", }); }
testHighlighting3
27,003
void () { doTestHL("\\ x\\ y\\ =\\ z\\ t\\ \\ ", new String[]{ "VALID_STRING_ESCAPE_TOKEN", "\\ ", "Properties:KEY_CHARACTERS", "x", "VALID_STRING_ESCAPE_TOKEN", "\\ ", "Properties:KEY_CHARACTERS", "y", "VALID_STRING_ESCAPE_TOKEN", "\\ ", "Properties:KEY_VALUE_SEPARATOR", "=", "VALID_STRING_ESCAPE_TOKEN", "\\ ", "Properties:VALUE_CHARACTERS", "z", "VALID_STRING_ESCAPE_TOKEN", "\\ ", "Properties:VALUE_CHARACTERS", "t", "VALID_STRING_ESCAPE_TOKEN", "\\ ", "VALID_STRING_ESCAPE_TOKEN", "\\ ", }); }
testFramingSpaces
27,004
void () { doTestHL("xxx=\\ x\\ y\\!\\=\\#\\:\\z", new String[]{ "Properties:KEY_CHARACTERS", "xxx", "Properties:KEY_VALUE_SEPARATOR", "=", "VALID_STRING_ESCAPE_TOKEN", "\\ ", "Properties:VALUE_CHARACTERS", "x", "VALID_STRING_ESCAPE_TOKEN", "\\ ", "Properties:VALUE_CHARACTERS", "y", "VALID_STRING_ESCAPE_TOKEN", "\\!", "VALID_STRING_ESCAPE_TOKEN", "\\=", "VALID_STRING_ESCAPE_TOKEN", "\\#", "VALID_STRING_ESCAPE_TOKEN", "\\:", "VALID_STRING_ESCAPE_TOKEN", "\\z", }); }
testSpecialCharsInValue
27,005
void () { doTest(); }
testProp1
27,006
void () { doTest(); }
testUncomment
27,007
void () { doTest(); }
testExclamationMark
27,008
void () { doTest(); }
testEmptyLineDuringUncomment
27,009
String () { return PluginPathManager.getPluginHomePath("properties") + "/tests/testData"; }
getTestDataPath
27,010
void () { configureByFile("/propertiesFile/comment/before" + getTestName(false) + ".properties"); PlatformTestUtil.invokeNamedAction(IdeActions.ACTION_COMMENT_LINE); checkResultByFile("/propertiesFile/comment/after" + getTestName(false) + ".properties"); }
doTest
27,011
void () { assertBaseNameEquals("property-file.properties", "property-file"); }
testBaseNameWithoutLocale
27,012
void () { assertBaseNameEquals("property-file_en._fr.asd_ru.properties", "property-file_en._fr.asd"); }
testBaseNameWithLocale
27,013
void () { assertBaseNameEquals("property-file.utf8.properties", "property-file.utf8"); }
testBaseNameWithoutLocaleWithAdditionalExtension
27,014
void () { assertBaseNameEquals("property-file_fr.file_en.utf8.properties", "property-file_fr.file.utf8"); }
testBaseNameWithLocaleWithAdditionalExtension
27,015
void () { assertBaseNameEquals("property_latin.properties", "property_latin"); }
testBaseNameWithLongLocale
27,016
void () { assertBaseNameEquals("property-file_fr.file_en_GB_UNIX.utf8.properties", "property-file_fr.file.utf8"); }
testBaseNameWithCountryAndVariant
27,017
void () { assertBaseNameEquals("property-file_fr.file_en_GB.utf8.properties", "property-file_fr.file.utf8"); }
testBaseNameWithCountry
27,018
void () { assertBaseNameEquals("Base_Properties.utf8.properties", "Base_Properties.utf8"); }
testBaseName
27,019
void (final String propertyFileName, final String expectedBaseName) { final String actualBaseName = ResourceBundleManager.getInstance(getProject()).getBaseName(myFixture.configureByText(propertyFileName, "")); assertEquals(expectedBaseName, actualBaseName); }
assertBaseNameEquals
27,020
String () { return PluginPathManager.getPluginHomePath("properties") + "/tests/testData/propertiesFile/folding/"; }
getTestDataPath
27,021
void () { myFixture.testFolding(getTestDataPath() + getTestName(true) + ".test.properties"); }
doTest
27,022
void () { doTest(); }
testCustomFolding
27,023
boolean () { return true; }
isCommunity
27,024
Property () { final Property property = CopyPropertyValueToClipboardIntention.getProperty(myFixture.getActionContext()); assert property != null : "A property at the caret not found"; return property; }
getProperty
27,025
IntentionAction (String actionText) { final List<IntentionAction> intentions = CodeInsightTestFixtureImpl.getAvailableIntentions(myFixture.getEditor(), myFixture.getFile()); final Optional<IntentionAction> maybeIntention = intentions.stream().filter(e -> e.getText().equals(actionText)).findAny(); assert maybeIntention.isPresent() : "The '" + actionText + "' intention hasn't been found among available intentions. Available intentions: " + intentions; return maybeIntention.get(); }
getAction
27,026
void () { myFixture.configureByFile("module/gradle.properties"); myFixture.checkHighlighting(); }
testUnusedOutsideOfSourceRoots
27,027
void () { myFixture.configureByFile("src/gradle.properties"); myFixture.checkHighlighting(); }
testUnusedInsideOfSourceRoots
27,028
String () { return PluginPathManager.getPluginHomePathRelative("properties") + "/tests/testData/propertiesFile/unused"; }
getBasePath
27,029
String () { return PluginPathManager.getPluginHomePathRelative("properties") + "/tests/testData/propertiesFile/ellipsis"; }
getBasePath
27,030
void () { EncodingProjectManager.getInstance(getProject()).setDefaultCharsetForPropertiesFiles(null, StandardCharsets.UTF_8); UIUtil.dispatchAllInvocationEvents(); String filePath = "threeDots.properties"; myFixture.configureByFile(filePath); List<IntentionAction> fixes = myFixture.getAllQuickFixes(filePath); IntentionAction fix = assertOneElement(fixes); myFixture.launchAction(fix); myFixture.checkResultByFile("threeDotsCorrect.properties"); }
testSimple
27,031
void () { myFixture.configureByFile("root_project.properties"); myFixture.checkHighlighting(); }
testUnused
27,032
String () { return PluginPathManager.getPluginHomePathRelative("properties") + "/tests/testData/propertiesFile/unused"; }
getBasePath
27,033
void () { String in = """ # comment # another x=y """; findMatchesText(in, "# '_c", "# comment", "# another"); findMatchesText(in, "# comment", "# comment"); }
testFindComments
27,034
void () { String in = """ # comment x key=value """; findMatchesText(in, "x", "x"); findMatchesText(in, "key", "key=value"); findMatchesText(in, "'_x", "x", "key=value"); }
testFindPropertyKeys
27,035
void () { String in = """ # comment this.is.a.key=one two three """; findMatchesText(in, "'_key=one '_x three", "this.is.a.key=one two three"); }
testFindPropertyValues
27,036
void () { PropertyChecker.checkScenarios(actionsOnPropertiesFiles(CheckHighlighterConsistency.randomEditsWithHighlighterChecks)); }
testIncrementalHighlighterUpdate
27,037
void () { PropertyChecker.checkScenarios(actionsOnPropertiesFiles(MadTestingUtil::randomEditsWithReparseChecks)); }
testReparse
27,038
void () { MadTestingUtil.enableAllInspections(getProject(), PropertiesLanguage.INSTANCE); Function<PsiFile, Generator<? extends MadTestingAction>> fileActions = file -> Generator.sampledFrom(new InvokeIntention(file, new IntentionPolicy() { @Override protected boolean shouldSkipIntention(@NotNull String actionText) { return actionText.equals("Sort resource bundle files") || // todo IDEA-194044 actionText.startsWith("Suppress for"); // todo IDEA-193419, IDEA-193420 } }), new StripTestDataMarkup(file), new DeleteRange(file)); PropertyChecker.checkScenarios(actionsOnPropertiesFiles(fileActions)); }
testRandomActivity
27,039
boolean (@NotNull String actionText) { return actionText.equals("Sort resource bundle files") || // todo IDEA-194044 actionText.startsWith("Suppress for"); // todo IDEA-193419, IDEA-193420 }
shouldSkipIntention
27,040
Supplier<MadTestingAction> (Function<? super PsiFile, ? extends Generator<? extends MadTestingAction>> fileActions) { return MadTestingUtil.actionsOnFileContents(myFixture, PathManager.getHomePath(), f -> f.getName().endsWith(PropertiesFileType.DOT_DEFAULT_EXTENSION), fileActions); }
actionsOnPropertiesFiles
27,041
void () { EncodingProjectManager.getInstance(getProject()).setDefaultCharsetForPropertiesFiles(null, StandardCharsets.UTF_8); UIUtil.dispatchAllInvocationEvents(); checkBidiRunBoundaries("# |R", "properties"); }
testComment
27,042
void () { for (String[] entry : TEST_DATA) { assertEquals( "Expected property value differs from the one converted from value editor text", entry[0], PropertiesResourceBundleUtil.convertValueToFileFormat(entry[1], '=', PropertyKeyValueFormat.PRESENTABLE) ); assertEquals( "Expected value editor text differs from the one converted from property value", entry[1], PropertiesResourceBundleUtil.fromPropertyValueToValueEditor(entry[0]) ); } }
checkConvertToPresentableFormat
27,043
String () { return PluginPathManager.getPluginHomePath("properties") + "/tests/testData/xml/"; }
getTestDataPath
27,044
void () { myFixture.configureByFile("foo.xml"); List<PropertiesFile> files = PropertiesReferenceManager.getInstance(getProject()).findPropertiesFiles(getModule(), "foo"); assertEquals(1, files.size()); PropertiesFile file = files.get(0); assertEquals(1, file.findPropertiesByKey("foo").size()); List<IProperty> properties = PropertiesImplUtil.findPropertiesByKey(getProject(), "foo"); assertEquals(1, properties.size()); }
testXmlProperties
27,045
void () { PsiFile psiFile = myFixture.configureByFile("wrong.xml"); PropertiesFile file = PropertiesImplUtil.getPropertiesFile(psiFile); assertNull(file); }
testWrongFile
27,046
void () { myFixture.testHighlighting("foo.xml"); }
testHighlighting
27,047
void () { final PsiFile psiFile = myFixture.configureByFile("foo.xml"); final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(psiFile); assertNotNull(propertiesFile); WriteCommandAction.runWriteCommandAction(getProject(), () -> { propertiesFile.addProperty("kkk", "vvv"); }); final IProperty property = propertiesFile.findPropertyByKey("kkk"); assertNotNull(property); assertEquals("vvv", property.getValue()); }
testAddProperty
27,048
void () { final PsiFile psiFile = myFixture.configureByFile("foo.xml"); final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(psiFile); assertNotNull(propertiesFile); WriteCommandAction.runWriteCommandAction(getProject(), () -> { propertiesFile.addProperty("kkk", "vvv"); }); final IProperty property = propertiesFile.findPropertyByKey("kkk"); assertNotNull(property); assertEquals("vvv", property.getValue()); WriteCommandAction.runWriteCommandAction(getProject(), () -> { propertiesFile.addProperty("kkk2", "vvv"); }); final IProperty property2 = propertiesFile.findPropertyByKey("kkk2"); assertNotNull(property2); assertEquals("vvv", property2.getValue()); }
testAddProperty2
27,049
void () { final PsiFile psiFile = myFixture.configureByFile("bar.xml"); final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(psiFile); assertNotNull(propertiesFile); WriteCommandAction.runWriteCommandAction(getProject(), () -> { propertiesFile.addProperty("d", "vvv"); propertiesFile.addProperty("a", "vvv"); propertiesFile.addProperty("l", "vvv"); propertiesFile.addProperty("v", "vvv"); }); assertTrue(propertiesFile.isAlphaSorted()); assertTrue(PropertiesImplUtil.getPropertiesFile(psiFile).isAlphaSorted()); }
testAddPropertyInAlphaOrder
27,050
String () { return PluginPathManager.getPluginHomePath("properties") + "/tests/testData/xml/"; }
getTestDataPath
27,051
boolean (Class<? extends PsiElement> elementClass) { return ReflectionUtil.isAssignable(PsiFile.class, elementClass); }
canResolveTo
27,052
PsiElement () { ResolveResult[] resolveResults = multiResolve(false); return resolveResults.length == 1 ? resolveResults[0].getElement() : null; }
resolve
27,053
String () { return myBundleName; }
getCanonicalText
27,054
char () { return getValue().indexOf('/') != -1 ? '/' : '.'; }
getPackageDelimiter
27,055
boolean (@NotNull PsiElement element) { if (element instanceof PropertiesFile) { final String name = ResourceBundleManager.getInstance(element.getProject()).getFullName((PropertiesFile)element); if (name != null && name.equals(myBundleName)) { return true; } } return false; }
isReferenceTo
27,056
String (final PsiFile psiFile) { return BundleNameEvaluator.DEFAULT.evaluateBundleName(psiFile); }
evaluateBundleName
27,057
HtmlChunk (IProperty prop) { final String raw = prop.getValue(); if (raw != null) return HtmlChunk.text(raw); return new HtmlBuilder() .append(PropertiesBundle.message("i18n.message.empty")) .wrapWith("i"); }
renderPropertyValue
27,058
LocalQuickFix (PsiElement element, String key, List<PropertiesFile> files) { return new CreatePropertyFix(element, key, files); }
createCreatePropertyFix
27,059
IntentionAction (@NotNull Property property) { return new RemovePropertyFix(property).asIntention(); }
createRemovePropertyFix
27,060
LocalQuickFix (@NotNull Property property) { return LocalQuickFix.from(new RemovePropertyFix(property)); }
createRemovePropertyLocalFix
27,061
boolean (final IElementType element) { return super.isWordCompletionEnabledIn(element) || element == PropertiesElementTypes.PROPERTY; }
isWordCompletionEnabledIn
27,062
LastSelectedPropertiesFileStore () { return ApplicationManager.getApplication().getService(LastSelectedPropertiesFileStore.class); }
getInstance
27,063
String (PsiFile context) { VirtualFile virtualFile = context.getVirtualFile(); while (virtualFile != null) { String contextUrl = virtualFile.getUrl(); String url = lastSelectedUrls.get(contextUrl); if (url != null) { return url; } virtualFile = virtualFile.getParent(); } if (lastSelectedFileUrl != null) { VirtualFile lastFile = VirtualFileManager.getInstance().findFileByUrl(lastSelectedFileUrl); final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(context.getProject()).getFileIndex(); if (lastFile != null && ModuleUtilCore.findModuleForPsiElement(context) == fileIndex.getModuleForFile(lastFile)) { return lastSelectedFileUrl; } } return null; }
suggestLastSelectedPropertiesFileUrl
27,064
void (PsiFile context, PropertiesFile file) { VirtualFile virtualFile = context.getVirtualFile(); if (virtualFile instanceof VirtualFileWindow) { virtualFile = ((VirtualFileWindow)virtualFile).getDelegate(); } assert virtualFile != null; String contextUrl = virtualFile.getUrl(); final VirtualFile vFile = file.getVirtualFile(); if (vFile != null) { String url = vFile.getUrl(); lastSelectedUrls.put(contextUrl, url); VirtualFile containingDir = virtualFile.getParent(); lastSelectedUrls.put(containingDir.getUrl(), url); lastSelectedFileUrl = url; } }
saveLastSelectedPropertiesFile
27,065
Element () { Element state = new Element("state"); for (Map.Entry<String, String> entry : lastSelectedUrls.entrySet()) { Element child = new Element("entry"); child.setAttribute("context", entry.getKey()); child.setAttribute("url", entry.getValue()); state.addContent(child); } if (lastSelectedFileUrl != null) { state.setAttribute("lastSelectedFileUrl", lastSelectedFileUrl); } return state; }
getState
27,066
void (@NotNull Element state) { lastSelectedUrls.clear(); for (Element child : state.getChildren("entry")) { String context = child.getAttributeValue("context"); String url = child.getAttributeValue("url"); VirtualFile propFile = VirtualFileManager.getInstance().findFileByUrl(url); VirtualFile contextFile = VirtualFileManager.getInstance().findFileByUrl(context); if (propFile != null && contextFile != null) { lastSelectedUrls.put(context, url); } } lastSelectedFileUrl = state.getAttributeValue("lastSelectedFileUrl"); }
loadState
27,067
String (@NotNull final PsiElement element, @Nullable final ElementDescriptionLocation location) { if (element instanceof IProperty) { if (location instanceof DeleteTypeDescriptionLocation) { int count = ((DeleteTypeDescriptionLocation) location).isPlural() ? 2 : 1; return IdeBundle.message("prompt.delete.property", count); } if (location instanceof UsageViewLongNameLocation) { return ((IProperty) element).getKey(); } } return null; }
getElementDescription
27,068
int (@NotNull final Document doc, @NotNull final PsiFile psiFile, int start, int end) { if (!(psiFile instanceof PropertiesFile)) return -1; final String documentText = doc.getText(); final String documentTextTillEndOfFirstLine = documentText.substring(0, start + 1); if (!PropertiesUtil.isUnescapedBackSlashAtTheEnd(documentTextTillEndOfFirstLine)) return CANNOT_JOIN; if (end < documentText.length() && startsWithEscapedWhitespace(documentText.substring(end))) { // if the second line starts with escaped whitespace (e.g. '\ '), then remove it too end ++; } // strip the continuation char '\', // the leading whitespaces on the second line and // the optional '\' if the text on the second line starts with '\ ' doc.deleteString(start, end); return start; }
tryJoinLines
27,069
boolean (@Nullable String text) { if (text == null) return false; if (text.length() < 2) return false; final char backslash = text.charAt(0); final char whitespace = text.charAt(1); return backslash == '\\' && (whitespace == ' ' || whitespace == '\t'); }
startsWithEscapedWhitespace
27,070
Result (@NotNull final PsiFile file, @NotNull final Editor editor, @NotNull final Ref<Integer> caretOffsetRef, final @NotNull Ref<Integer> caretAdvance, @NotNull final DataContext dataContext, final EditorActionHandler originalHandler) { if (file instanceof PropertiesFile) { int caretOffset = caretOffsetRef.get().intValue(); Document document = editor.getDocument(); PsiDocumentManager.getInstance(file.getProject()).commitDocument(document); PsiElement psiAtOffset = file.findElementAt(caretOffset); handleEnterInPropertiesFile(editor, document, psiAtOffset, caretOffset); return Result.Stop; } return Result.Continue; }
preprocessEnter
27,071
void (final Editor editor, final Document document, final PsiElement psiAtOffset, int caretOffset) { String text = document.getText(); String line = text.substring(0, caretOffset); int i = line.lastIndexOf('\n'); if (i > 0) { line = line.substring(i); } final String toInsert; if (PropertiesUtil.isUnescapedBackSlashAtTheEnd(line)) { toInsert = "\n "; } else { final IElementType elementType = psiAtOffset == null ? null : psiAtOffset.getNode().getElementType(); if (elementType == PropertiesTokenTypes.VALUE_CHARACTERS) { if (text.charAt(caretOffset) == ' ' || text.charAt(caretOffset) == '\t') { // escape the whitespace on the next line like "\ " toInsert = "\\\n \\"; } else { toInsert = "\\\n "; } } else if (elementType == PropertiesTokenTypes.END_OF_LINE_COMMENT && "#!".indexOf(document.getText().charAt(caretOffset)) == -1) { toInsert = "\n#"; } else { toInsert = "\n"; } } document.insertString(caretOffset, toInsert); caretOffset+=toInsert.length(); editor.getCaretModel().moveToOffset(caretOffset); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); editor.getSelectionModel().removeSelection(); }
handleEnterInPropertiesFile
27,072
String () { return OptionsBundle.message("properties.options.display.name"); }
getDisplayName
27,073
Icon () { return AllIcons.FileTypes.Properties; }
getIcon
27,074
SyntaxHighlighter () { return new PropertiesHighlighter(); }
getHighlighter
27,075
String () { return """ # This comment starts with '#' greetings=Hello ! This comment starts with '!' what\\=to\\=greet : \\'W\\o\\rld\\',\\tUniverse\\n\\uXXXX """ ; }
getDemoText
27,076
boolean (@NotNull final String name, final Project project) { return false; }
isKeyword
27,077
boolean (@NotNull final String name, final Project project) { return true; }
isIdentifier
27,078
void (@Nullable Document document, @NotNull String propertyName, Object oldValue, Object newValue) { if (EncodingManager.PROP_NATIVE2ASCII_SWITCH.equals(propertyName) || EncodingManager.PROP_PROPERTIES_FILES_ENCODING.equals(propertyName) ) { DumbService.getInstance(myProject).smartInvokeLater(() -> ApplicationManager.getApplication().runWriteAction(() -> { Collection<VirtualFile> filesToRefresh = FileTypeIndex.getFiles(PropertiesFileType.INSTANCE, GlobalSearchScope.allScope(myProject)); VirtualFile[] virtualFiles = VfsUtilCore.toVirtualFileArray(filesToRefresh); FileDocumentManager.getInstance().saveAllDocuments(); //force to re-detect encoding for (VirtualFile virtualFile : virtualFiles) { virtualFile.setCharset(null); } FileDocumentManager.getInstance().reloadFiles(virtualFiles); })); } }
propertyChanged
27,079
String () { return suggestedName; }
getSuggestedName
27,080
void (ActionEvent e) { TreeFileChooserFactory chooserFactory = TreeFileChooserFactory.getInstance(myProject); final PropertiesFile propertiesFile = getPropertiesFile(); TreeFileChooser fileChooser = chooserFactory.createFileChooser( PropertiesBundle.message("i18nize.dialog.property.file.chooser.title"), propertiesFile != null ? propertiesFile.getContainingFile() : null, PropertiesFileType.INSTANCE, null); fileChooser.showDialog(); PsiFile selectedFile = fileChooser.getSelectedFile(); if (selectedFile == null) return; String selectedPath = selectedFile.getVirtualFile().getPath(); myPropertiesFile.setText(FileUtil.toSystemDependentName(selectedPath)); myPropertiesFile.setSelectedItem(FileUtil.toSystemDependentName(selectedPath)); }
actionPerformed
27,081
void (@NotNull DocumentEvent e) { propertiesFileChanged(); somethingChanged(); }
textChanged
27,082
void (@NotNull DocumentEvent e) { somethingChanged(); }
textChanged
27,083
void (@NotNull DocumentEvent e) { somethingChanged(); }
textChanged
27,084
void (ActionEvent e) { PropertiesComponent.getInstance().setValue(KEY, Boolean.valueOf(myUseResourceBundle.isSelected()).toString()); }
actionPerformed
27,085
void (@NotNull JList<? extends IProperty> list, IProperty value, int index, boolean selected, boolean hasFocus) { if (value != null) { append(Objects.requireNonNull(value.getUnescapedKey())); append(" ("); append(value.getPropertiesFile().getName()); append(")"); } }
customizeCellRenderer
27,086
void (ActionEvent e) { somethingChanged(); }
actionPerformed
27,087
void (ActionEvent e) { myExistingProperties.setEnabled(myUseExistingPropertyRb.isSelected()); UIUtil.setEnabled(myNewPanel, myCreateNewPropertyRb.isSelected(), true); somethingChanged(); }
actionPerformed
27,088
String (String value, @NotNull PsiFile context) { return value; }
escapeValue
27,089
void () { populatePropertiesFiles(); propertiesFileChanged(); setKeyValueEditBoxes(); super.init(); somethingChanged(); }
init
27,090
JTextField () { return myKey; }
getKeyTextField
27,091
List<IProperty> (String value) { if(!myCustomization.suggestExistingProperties) { return Collections.emptyList(); } final ArrayList<IProperty> result = new ArrayList<>(); // check if property value already exists among properties file values and suggest corresponding key List<String> propertyFiles = suggestPropertiesFiles(); if (!propertyFiles.isEmpty()) { String selectedPath = FileUtil.toSystemIndependentName(getPropertiesFilePath()); propertyFiles.remove(selectedPath); propertyFiles.add(0, selectedPath); for (String path : propertyFiles) { PropertiesFile propertiesFile = getPropertyFileByPath(path); if (propertiesFile != null) { for (IProperty property : propertiesFile.getProperties()) { if (Comparing.strEqual(property.getUnescapedValue(), value) && property.getUnescapedKey() != null) { result.add(property); } } } } } return result; }
getExistingProperties
27,092
String (String value) { if (myCustomization.suggestedName != null) { return myCustomization.suggestedName; } return suggestUniquePropertyKey(value, defaultSuggestPropertyKey(value), getPropertiesFile()); }
suggestPropertyKey
27,093
String (String value, String defaultKey, PropertiesFile propertiesFile) { // suggest property key not existing in this file if (defaultKey == null) { defaultKey = generateDefaultPropertyKey(value); } if (propertiesFile != null) { if (propertiesFile.findPropertyByKey(defaultKey) == null) return defaultKey; int suffix = 1; while (propertiesFile.findPropertyByKey(defaultKey + suffix) != null) { suffix++; } return defaultKey + suffix; } else { return defaultKey; } }
suggestUniquePropertyKey
27,094
String (@NotNull String rawValue) { String value = PATTERN.matcher(Normalizer.normalize(rawValue, Normalizer.Form.NFD)).replaceAll(""); String defaultKey; final StringBuilder result = new StringBuilder(); boolean insertDotBeforeNextWord = false; for (int i = 0; i < value.length(); i++) { final char c = value.charAt(i); if (Character.isLetterOrDigit(c)) { if (insertDotBeforeNextWord) { result.append('.'); } result.append(Character.toLowerCase(c)); insertDotBeforeNextWord = false; } else if (c == '&') { //do not insert dot if there is letter after the amp if (insertDotBeforeNextWord) continue; if (i == value.length() - 1) { continue; } if (Character.isLetter(value.charAt(i + 1))) { continue; } insertDotBeforeNextWord = true; } else { if (result.length() > 0) { insertDotBeforeNextWord = true; } } } defaultKey = result.toString(); return defaultKey; }
generateDefaultPropertyKey
27,095
String (String value) { return null; }
defaultSuggestPropertyKey
27,096
void () { PropertiesFile propertiesFile = getPropertiesFile(); boolean hasResourceBundle = propertiesFile != null && propertiesFile.getResourceBundle().getPropertiesFiles().size() > 1; myUseResourceBundle.setEnabled(hasResourceBundle); }
propertiesFileChanged
27,097
void () { getKeyTextField().setText(suggestPropertyKey(myDefaultPropertyValue)); final @NotNull List<IProperty> existingValueKeys = getExistingProperties(myDefaultPropertyValue); if (!existingValueKeys.isEmpty()) { for (IProperty key : existingValueKeys) { myExistingProperties.addItem(key); } myExistingProperties.setSelectedItem(existingValueKeys.get(0)); } myUseExistingPropertyRb.setEnabled(!existingValueKeys.isEmpty()); myValue.setText(escapeLineBreaks(myDefaultPropertyValue)); }
setKeyValueEditBoxes
27,098
String (String value) { return StringUtil.escapeLineBreak(StringUtil.escapeBackSlashes(value)); }
escapeLineBreaks
27,099
String (String value) { StringBuilder buffer = new StringBuilder(value.length()); int length = value.length(); int last = length - 1; for (int i = 0; i < length; i++) { char ch = value.charAt(i); if (ch == '\\' && i != last) { i++; ch = value.charAt(i); if (ch == 'n') { buffer.append('\n'); } else if (ch == 'r') { buffer.append('\n'); } else if (ch == '\\') { buffer.append('\\'); } else { buffer.append('\\'); buffer.append(ch); } } else { buffer.append(ch); } } return buffer.toString(); }
unescapeLineBreaks