mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed some cases of file references renaming
added find usages to django templates(PY-1081) added navigation to files
This commit is contained in:
@@ -36,8 +36,8 @@ import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Mar 28, 2008
|
||||
*/
|
||||
* Date: Mar 28, 2008
|
||||
*/
|
||||
public final class FileContent extends UserDataHolderBase {
|
||||
private final VirtualFile myFile;
|
||||
private final String fileName;
|
||||
@@ -67,7 +67,7 @@ public final class FileContent extends UserDataHolderBase {
|
||||
if (project == null) {
|
||||
project = ProjectManager.getInstance().getDefaultProject();
|
||||
}
|
||||
final Language language = ((LanguageFileType)getFileType()).getLanguage();
|
||||
final Language language = ((LanguageFileType)getFileTypeWithoutSubstitution()).getLanguage();
|
||||
final Language substitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, getFile(), project);
|
||||
psi = PsiFileFactory.getInstance(project).createFileFromText(getFileName(), substitutedLanguage, getContentAsText(), false, false);
|
||||
|
||||
@@ -77,7 +77,7 @@ public final class FileContent extends UserDataHolderBase {
|
||||
return psi;
|
||||
}
|
||||
|
||||
public static class IllegalDataException extends RuntimeException{
|
||||
public static class IllegalDataException extends RuntimeException {
|
||||
public IllegalDataException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
@@ -86,13 +86,13 @@ public final class FileContent extends UserDataHolderBase {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public FileContent(@NotNull final VirtualFile file, @NotNull final CharSequence contentAsText, final Charset charset) {
|
||||
this(file);
|
||||
myContentAsText = contentAsText;
|
||||
myCharset = charset;
|
||||
}
|
||||
|
||||
|
||||
public FileContent(@NotNull final VirtualFile file, @NotNull final byte[] content) {
|
||||
this(file);
|
||||
myContent = content;
|
||||
@@ -106,10 +106,40 @@ public final class FileContent extends UserDataHolderBase {
|
||||
fileName = file.getName();
|
||||
}
|
||||
|
||||
public FileType getFileType() {
|
||||
|
||||
|
||||
FileType substituteFileType(VirtualFile file, FileType fileType) {
|
||||
Project project = getProject();
|
||||
return substituteFileType(file, fileType, project);
|
||||
}
|
||||
|
||||
public static FileType substituteFileType(VirtualFile file, FileType fileType, Project project) {
|
||||
if (project == null) {
|
||||
project = ProjectManager.getInstance().getDefaultProject();
|
||||
}
|
||||
if (fileType instanceof LanguageFileType) {
|
||||
final Language language = ((LanguageFileType)fileType).getLanguage();
|
||||
final Language substitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, file, project);
|
||||
if (substitutedLanguage != null) {
|
||||
return substitutedLanguage.getAssociatedFileType();
|
||||
}
|
||||
}
|
||||
|
||||
return fileType;
|
||||
}
|
||||
|
||||
public FileType getSubstitutedFileType() {
|
||||
return substituteFileType(myFile, myFileType);
|
||||
}
|
||||
|
||||
public FileType getFileTypeWithoutSubstitution() {
|
||||
return myFileType;
|
||||
}
|
||||
|
||||
public FileType getFileType() {
|
||||
return getSubstitutedFileType();
|
||||
}
|
||||
|
||||
public VirtualFile getFile() {
|
||||
return myFile;
|
||||
}
|
||||
@@ -126,7 +156,7 @@ public final class FileContent extends UserDataHolderBase {
|
||||
if (myContent == null) {
|
||||
if (myContentAsText != null) {
|
||||
try {
|
||||
myContent = myCharset != null? myContentAsText.toString().getBytes(myCharset.name()) : myContentAsText.toString().getBytes();
|
||||
myContent = myCharset != null ? myContentAsText.toString().getBytes(myCharset.name()) : myContentAsText.toString().getBytes();
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@@ -36,10 +36,13 @@ public class HtmlFileType extends XmlLikeFileType {
|
||||
@NonNls public static final String DOT_DEFAULT_EXTENSION = ".html";
|
||||
private static final Icon ICON = IconLoader.getIcon("/fileTypes/html.png");
|
||||
|
||||
public HtmlFileType() {
|
||||
public final static HtmlFileType INSTANCE = new HtmlFileType();
|
||||
|
||||
private HtmlFileType() {
|
||||
super(HTMLLanguage.INSTANCE);
|
||||
}
|
||||
public HtmlFileType(Language language) {
|
||||
|
||||
HtmlFileType(Language language) {
|
||||
super(language);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class XmlFileTypeFactory extends FileTypeFactory {
|
||||
public void createFileTypes(final @NotNull FileTypeConsumer consumer) {
|
||||
consumer.consume(new HtmlFileType(), "html;htm;sht;shtm;shtml");
|
||||
consumer.consume(HtmlFileType.INSTANCE, "html;htm;sht;shtm;shtml");
|
||||
consumer.consume(XHtmlFileType.INSTANCE, "xhtml");
|
||||
consumer.consume(new DTDFileType(), "dtd;ent;mod");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user