[vfs] localizable fsnotifier messages

GitOrigin-RevId: 4757b274e7b87548d6110b0372b2c64d8fae6db5
This commit is contained in:
Roman Shevchenko
2020-08-27 18:50:39 +02:00
committed by intellij-monorepo-bot
parent 2e7b1ffa65
commit 7a47d99d43
8 changed files with 23 additions and 44 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -2,21 +2,14 @@
#pragma once #pragma once
#define VERSION "20191018.1702" #define VERSION "20200827.1844"
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
// messaging // messaging and logging
typedef enum { void message(const char *text);
MSG_INSTANCE_LIMIT, MSG_WATCH_LIMIT
} MSG;
void message(MSG id);
// logging
void userlog(int priority, const char* format, ...); void userlog(int priority, const char* format, ...);
#define CHECK_NULL(p, r) if (p == NULL) { userlog(LOG_ERR, "out of memory"); return r; } #define CHECK_NULL(p, r) if (p == NULL) { userlog(LOG_ERR, "out of memory"); return r; }

View File

@@ -62,7 +62,7 @@ bool init_inotify() {
int e = errno; int e = errno;
userlog(LOG_ERR, "inotify_init: %s", strerror(e)); userlog(LOG_ERR, "inotify_init: %s", strerror(e));
if (e == EMFILE) { if (e == EMFILE) {
message(MSG_INSTANCE_LIMIT); message("inotify.instance.limit");
} }
return false; return false;
} }
@@ -189,7 +189,7 @@ static int add_watch(int path_len, watch_node* parent) {
static void watch_limit_reached() { static void watch_limit_reached() {
if (!limit_reached) { if (!limit_reached) {
limit_reached = true; limit_reached = true;
message(MSG_WATCH_LIMIT); message("inotify.watch.limit");
} }
} }

View File

@@ -33,14 +33,6 @@
#define HELP_MSG \ #define HELP_MSG \
"Try 'fsnotifier --help' for more information.\n" "Try 'fsnotifier --help' for more information.\n"
#define INSTANCE_LIMIT_TEXT \
"The <b>inotify</b>(7) instances limit reached. " \
"<a href=\"https://confluence.jetbrains.com/display/IDEADEV/Inotify+Instances+Limit\">More details.</a>\n"
#define WATCH_LIMIT_TEXT \
"The current <b>inotify</b>(7) watch limit is too low. " \
"<a href=\"https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit\">More details.</a>\n"
#define MISSING_ROOT_TIMEOUT 1 #define MISSING_ROOT_TIMEOUT 1
#define UNFLATTEN(root) (root[0] == '|' ? root + 1 : root) #define UNFLATTEN(root) (root[0] == '|' ? root + 1 : root)
@@ -152,16 +144,8 @@ static void init_log() {
} }
void message(MSG id) { void message(const char *text) {
if (id == MSG_INSTANCE_LIMIT) { output("MESSAGE\n%s\n", text);
output("MESSAGE\n" INSTANCE_LIMIT_TEXT);
}
else if (id == MSG_WATCH_LIMIT) {
output("MESSAGE\n" WATCH_LIMIT_TEXT);
}
else {
userlog(LOG_ERR, "unknown message: %d", id);
}
} }

View File

@@ -640,6 +640,12 @@ watcher.exe.not.exe=Native file watcher is not executable: <a href="{0}">{0}</a>
watcher.failed.to.start=File watcher failed to start watcher.failed.to.start=File watcher failed to start
watcher.gave.up=File watcher gave up to operate watcher.gave.up=File watcher gave up to operate
watcher.non.watchable.project=Project files cannot be watched (are they under network mount?) watcher.non.watchable.project=Project files cannot be watched (are they under network mount?)
# suppress inspection "UnusedProperty"
inotify.instance.limit=The <b>inotify</b>(7) instances limit reached. \
<a href="https://confluence.jetbrains.com/display/IDEADEV/Inotify+Instances+Limit">More details.</a>
# suppress inspection "UnusedProperty"
inotify.watch.limit=The current <b>inotify</b>(7) watch limit is too low. \
<a href="https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit">More details.</a>
fs.case.sensitivity.mismatch.title=Filesystem Case-Sensitivity Mismatch fs.case.sensitivity.mismatch.title=Filesystem Case-Sensitivity Mismatch
fs.case.sensitivity.mismatch.message=\ fs.case.sensitivity.mismatch.message=\
@@ -967,4 +973,4 @@ custom.option.description=Set custom page size
intentions.are.not.available.message=Intentions are not available while indices are updating. intentions.are.not.available.message=Intentions are not available while indices are updating.
settings.code.style.formatter.control.do.not.format.title=Do not format: settings.code.style.formatter.control.do.not.format.title=Do not format:
settings.code.style.formatter.control.tab.title=Formatter Control settings.code.style.formatter.control.tab.title=Formatter Control
settings.code.style.general.tab.title=General settings.code.style.general.tab.title=General

View File

@@ -2,10 +2,7 @@
package com.intellij.openapi.application; package com.intellij.openapi.application;
import com.intellij.DynamicBundle; import com.intellij.DynamicBundle;
import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.*;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.PropertyKey;
import java.util.function.Supplier; import java.util.function.Supplier;
@@ -13,20 +10,18 @@ import java.util.function.Supplier;
* Provides access to localized properties of the IntelliJ Platform. * Provides access to localized properties of the IntelliJ Platform.
*/ */
public final class ApplicationBundle extends DynamicBundle { public final class ApplicationBundle extends DynamicBundle {
@NonNls public static final String BUNDLE = "messages.ApplicationBundle"; public static final String BUNDLE = "messages.ApplicationBundle";
private static final ApplicationBundle INSTANCE = new ApplicationBundle(); public static final ApplicationBundle INSTANCE = new ApplicationBundle();
private ApplicationBundle() { private ApplicationBundle() {
super(BUNDLE); super(BUNDLE);
} }
@NotNull public static @NotNull @Nls String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) {
public static @Nls String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) {
return INSTANCE.getMessage(key, params); return INSTANCE.getMessage(key, params);
} }
@NotNull public static @NotNull Supplier<@Nls String> messagePointer(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) {
public static Supplier<@Nls String> messagePointer(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) {
return INSTANCE.getLazyMessage(key, params); return INSTANCE.getLazyMessage(key, params);
} }
} }

View File

@@ -364,8 +364,9 @@ public class NativeFileWatcherImpl extends PluggableFileWatcher {
} }
} }
else if (myLastOp == WatcherOp.MESSAGE) { else if (myLastOp == WatcherOp.MESSAGE) {
LOG.warn(line); String localized = Objects.requireNonNullElse(ApplicationBundle.INSTANCE.messageOrNull(line), line); //NON-NLS
notifyOnFailure(line, NotificationListener.URL_OPENING_LISTENER); LOG.warn(localized);
notifyOnFailure(localized, NotificationListener.URL_OPENING_LISTENER);
myLastOp = null; myLastOp = null;
} }
else if (myLastOp == WatcherOp.REMAP || myLastOp == WatcherOp.UNWATCHEABLE) { else if (myLastOp == WatcherOp.REMAP || myLastOp == WatcherOp.UNWATCHEABLE) {
@@ -494,4 +495,4 @@ public class NativeFileWatcherImpl extends PluggableFileWatcher {
} }
} }
} }
} }