mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
File Encoding Macro (useful for external encoding converters, like iconv)
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
*/
|
||||
|
||||
package com.intellij.ide.macro;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
public final class FileEncodingMacro extends Macro {
|
||||
public String getName() {
|
||||
return "FileEncoding";
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return IdeBundle.message("macro.file.encoding");
|
||||
}
|
||||
|
||||
public String expand(DataContext dataContext) {
|
||||
VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
|
||||
if (file == null) return null;
|
||||
return file.getCharset().displayName();
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,7 @@ public final class MacroManager {
|
||||
registerMacro(new FileNameMacro());
|
||||
registerMacro(new FileNameWithoutExtension());
|
||||
registerMacro(new FilePathMacro());
|
||||
registerMacro(new FileEncodingMacro());
|
||||
registerMacro(new FileDirRelativeToProjectRootMacro());
|
||||
registerMacro(new FilePathRelativeToProjectRootMacro());
|
||||
registerMacro(new FileDirRelativeToSourcepathMacro());
|
||||
|
||||
@@ -104,6 +104,7 @@ public class PathMacrosImpl extends PathMacros implements ApplicationComponent,
|
||||
"/FileRelativeDir",
|
||||
"FileRelativePath",
|
||||
"/FileRelativePath",
|
||||
"FileEncoding",
|
||||
"JavaDocPath",
|
||||
"JDKPath",
|
||||
"LineNumber",
|
||||
|
||||
@@ -449,6 +449,7 @@ macro.file.directory.relative=File directory relative to the project file
|
||||
macro.file.directory.relative.fwd.slash=File directory relative to the project file (with forward slashes)
|
||||
macro.file.path.relative=File path relative to the project file
|
||||
macro.file.path.relative.fwd.slash=File path relative to the project file (with forward slashes)
|
||||
macro.file.encoding=File encoding
|
||||
macro.javadoc.output.directory=JavaDoc output directory
|
||||
macro.jdk.path=JDK path
|
||||
macro.line.number=Line number
|
||||
|
||||
Reference in New Issue
Block a user