mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
mark PropertiesFileProcessor as @FunctionalInterface
This commit is contained in:
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package org.jetbrains.idea.devkit.dom.impl;
|
||||
|
||||
@@ -122,15 +110,13 @@ public class I18nReferenceContributor extends PsiReferenceContributor {
|
||||
final Project project = myElement.getProject();
|
||||
PropertiesReferenceManager referenceManager = PropertiesReferenceManager.getInstance(project);
|
||||
final List<LookupElement> variants = new ArrayList<>();
|
||||
referenceManager.processPropertiesFiles(GlobalSearchScopesCore.projectProductionScope(project), new PropertiesFileProcessor() {
|
||||
public boolean process(String baseName, PropertiesFile propertiesFile) {
|
||||
final Icon icon = propertiesFile.getContainingFile().getIcon(Iconable.ICON_FLAG_READ_STATUS);
|
||||
final String relativePath = ProjectUtil.calcRelativeToProjectPath(propertiesFile.getVirtualFile(), project);
|
||||
variants.add(LookupElementBuilder.create(propertiesFile, baseName)
|
||||
.withIcon(icon)
|
||||
.withTailText(" (" + relativePath + ")", true));
|
||||
return true;
|
||||
}
|
||||
referenceManager.processPropertiesFiles(GlobalSearchScopesCore.projectProductionScope(project), (baseName, propertiesFile) -> {
|
||||
final Icon icon = propertiesFile.getContainingFile().getIcon(Iconable.ICON_FLAG_READ_STATUS);
|
||||
final String relativePath = ProjectUtil.calcRelativeToProjectPath(propertiesFile.getVirtualFile(), project);
|
||||
variants.add(LookupElementBuilder.create(propertiesFile, baseName)
|
||||
.withIcon(icon)
|
||||
.withTailText(" (" + relativePath + ")", true));
|
||||
return true;
|
||||
}, this);
|
||||
return variants.toArray(new LookupElement[variants.size()]);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.codeInspection.i18n;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
@@ -220,21 +222,18 @@ public class JavaI18nUtil extends I18nUtil {
|
||||
@Nullable
|
||||
private static ResourceBundle resolveResourceBundleByKey(@NotNull final String key, @NotNull final Project project) {
|
||||
final Ref<ResourceBundle> bundleRef = Ref.create();
|
||||
final boolean r = PropertiesReferenceManager.getInstance(project).processAllPropertiesFiles(new PropertiesFileProcessor() {
|
||||
@Override
|
||||
public boolean process(String baseName, PropertiesFile propertiesFile) {
|
||||
if (propertiesFile.findPropertyByKey(key) != null) {
|
||||
if (bundleRef.get() == null) {
|
||||
bundleRef.set(propertiesFile.getResourceBundle());
|
||||
}
|
||||
else {
|
||||
if (!bundleRef.get().equals(propertiesFile.getResourceBundle())) {
|
||||
return false;
|
||||
}
|
||||
final boolean r = PropertiesReferenceManager.getInstance(project).processAllPropertiesFiles((baseName, propertiesFile) -> {
|
||||
if (propertiesFile.findPropertyByKey(key) != null) {
|
||||
if (bundleRef.get() == null) {
|
||||
bundleRef.set(propertiesFile.getResourceBundle());
|
||||
}
|
||||
else {
|
||||
if (!bundleRef.get().equals(propertiesFile.getResourceBundle())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return r ? bundleRef.get() : null;
|
||||
}
|
||||
|
||||
+2
-13
@@ -1,22 +1,11 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.lang.properties;
|
||||
|
||||
import com.intellij.lang.properties.psi.PropertiesFile;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface PropertiesFileProcessor {
|
||||
boolean process(String baseName, PropertiesFile propertiesFile);
|
||||
}
|
||||
|
||||
+5
-19
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.lang.properties;
|
||||
|
||||
@@ -74,13 +62,11 @@ public class PropertiesReferenceManager {
|
||||
|
||||
|
||||
final ArrayList<PropertiesFile> result = new ArrayList<>();
|
||||
processPropertiesFiles(searchScope, new PropertiesFileProcessor() {
|
||||
public boolean process(String baseName, PropertiesFile propertiesFile) {
|
||||
if (baseName.equals(bundleName)) {
|
||||
result.add(propertiesFile);
|
||||
}
|
||||
return true;
|
||||
processPropertiesFiles(searchScope, (baseName, propertiesFile) -> {
|
||||
if (baseName.equals(bundleName)) {
|
||||
result.add(propertiesFile);
|
||||
}
|
||||
return true;
|
||||
}, bundleNameEvaluator);
|
||||
return result;
|
||||
}
|
||||
|
||||
+11
-15
@@ -1,6 +1,6 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o.
|
||||
// Use of this source code is governed by the Apache 2.0 license that can be
|
||||
// found in the LICENSE file.
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.lang.properties.references;
|
||||
|
||||
import com.intellij.lang.injection.InjectedLanguageManager;
|
||||
@@ -78,20 +78,16 @@ public class I18nUtil {
|
||||
final List<String> paths = new ArrayList<>();
|
||||
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
|
||||
PropertiesReferenceManager.getInstance(project).processAllPropertiesFiles(new PropertiesFileProcessor() {
|
||||
|
||||
@Override
|
||||
public boolean process(String baseName, PropertiesFile propertiesFile) {
|
||||
if (propertiesFile instanceof XmlPropertiesFile) {
|
||||
return true;
|
||||
}
|
||||
VirtualFile virtualFile = propertiesFile.getVirtualFile();
|
||||
if (projectFileIndex.isInContent(virtualFile)) {
|
||||
String path = FileUtil.toSystemDependentName(virtualFile.getPath());
|
||||
paths.add(path);
|
||||
}
|
||||
PropertiesReferenceManager.getInstance(project).processAllPropertiesFiles((baseName, propertiesFile) -> {
|
||||
if (propertiesFile instanceof XmlPropertiesFile) {
|
||||
return true;
|
||||
}
|
||||
VirtualFile virtualFile = propertiesFile.getVirtualFile();
|
||||
if (projectFileIndex.isInContent(virtualFile)) {
|
||||
String path = FileUtil.toSystemDependentName(virtualFile.getPath());
|
||||
paths.add(path);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return paths;
|
||||
}
|
||||
|
||||
+3
-18
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.lang.properties.references;
|
||||
|
||||
@@ -59,13 +47,10 @@ public class PropertiesPsiCompletionUtil {
|
||||
List<PropertiesFile> propertiesFileList = propertyReference.getPropertiesFiles();
|
||||
if (propertiesFileList == null) {
|
||||
PropertiesReferenceManager
|
||||
.getInstance(propertyReference.getElement().getProject()).processAllPropertiesFiles(new PropertiesFileProcessor() {
|
||||
@Override
|
||||
public boolean process(String baseName, PropertiesFile propertiesFile) {
|
||||
.getInstance(propertyReference.getElement().getProject()).processAllPropertiesFiles((baseName, propertiesFile) -> {
|
||||
addVariantsFromFile(propertyReference, propertiesFile, variants);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
for (PropertiesFile propFile : propertiesFileList) {
|
||||
|
||||
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.lang.properties;
|
||||
|
||||
@@ -127,18 +115,15 @@ public class ResourceBundleReference extends PsiReferenceBase<PsiElement>
|
||||
|
||||
final Set<String> bundleNames = new HashSet<>();
|
||||
final List<LookupElement> variants = new SmartList<>();
|
||||
PropertiesFileProcessor processor = new PropertiesFileProcessor() {
|
||||
@Override
|
||||
public boolean process(String baseName, PropertiesFile propertiesFile) {
|
||||
if (!bundleNames.add(baseName)) return true;
|
||||
PropertiesFileProcessor processor = (baseName, propertiesFile) -> {
|
||||
if (!bundleNames.add(baseName)) return true;
|
||||
|
||||
final LookupElementBuilder builder =
|
||||
LookupElementBuilder.create(baseName)
|
||||
.withIcon(AllIcons.Nodes.ResourceBundle);
|
||||
boolean isInContent = projectFileIndex.isInContent(propertiesFile.getVirtualFile());
|
||||
variants.add(isInContent ? PrioritizedLookupElement.withPriority(builder, Double.MAX_VALUE) : builder);
|
||||
return true;
|
||||
}
|
||||
final LookupElementBuilder builder =
|
||||
LookupElementBuilder.create(baseName)
|
||||
.withIcon(AllIcons.Nodes.ResourceBundle);
|
||||
boolean isInContent = projectFileIndex.isInContent(propertiesFile.getVirtualFile());
|
||||
variants.add(isInContent ? PrioritizedLookupElement.withPriority(builder, Double.MAX_VALUE) : builder);
|
||||
return true;
|
||||
};
|
||||
|
||||
referenceManager.processPropertiesFiles(myElement.getResolveScope(), processor, this);
|
||||
|
||||
+9
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.lang.properties.create;
|
||||
|
||||
@@ -423,16 +423,14 @@ public class CreateResourceBundleDialogComponent {
|
||||
private MyExistLocalesListModel() {
|
||||
myLocales = new ArrayList<>();
|
||||
myLocales.add(PropertiesUtil.DEFAULT_LOCALE);
|
||||
PropertiesReferenceManager.getInstance(myProject).processPropertiesFiles(GlobalSearchScope.projectScope(myProject), new PropertiesFileProcessor() {
|
||||
@Override
|
||||
public boolean process(String baseName, PropertiesFile propertiesFile) {
|
||||
final Locale locale = propertiesFile.getLocale();
|
||||
if (locale != PropertiesUtil.DEFAULT_LOCALE && !myLocales.contains(locale)) {
|
||||
myLocales.add(locale);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}, BundleNameEvaluator.DEFAULT);
|
||||
PropertiesReferenceManager.getInstance(myProject).processPropertiesFiles(GlobalSearchScope.projectScope(myProject),
|
||||
(baseName, propertiesFile) -> {
|
||||
final Locale locale = propertiesFile.getLocale();
|
||||
if (locale != PropertiesUtil.DEFAULT_LOCALE && !myLocales.contains(locale)) {
|
||||
myLocales.add(locale);
|
||||
}
|
||||
return true;
|
||||
}, BundleNameEvaluator.DEFAULT);
|
||||
Collections.sort(myLocales, LOCALE_COMPARATOR);
|
||||
}
|
||||
|
||||
|
||||
+3
-6
@@ -228,12 +228,9 @@ public class PropertiesCopyHandler extends CopyHandlerDelegateBase {
|
||||
PropertiesReferenceManager
|
||||
.getInstance(myProject)
|
||||
.processPropertiesFiles(searchScope,
|
||||
new PropertiesFileProcessor() {
|
||||
@Override
|
||||
public boolean process(String baseName, PropertiesFile propertiesFile) {
|
||||
propertiesFiles.add(propertiesFile);
|
||||
return true;
|
||||
}
|
||||
(baseName, propertiesFile) -> {
|
||||
propertiesFiles.add(propertiesFile);
|
||||
return true;
|
||||
}, BundleNameEvaluator.BASE_NAME);
|
||||
|
||||
final List<PsiFileSystemItem> resourceBundlesAsFileSystemItems = propertiesFiles
|
||||
|
||||
Reference in New Issue
Block a user