use of com.intellij.openapi.fileTypes.FileType in project android by JetBrains.
the class AndroidLintExternalAnnotator method doAnnotate.
@Override
public State doAnnotate(final State state) {
final LintIdeClient client = LintIdeClient.forEditor(state);
try {
final LintDriver lint = new LintDriver(new LintIdeIssueRegistry(), client);
EnumSet<Scope> scope;
VirtualFile mainFile = state.getMainFile();
final FileType fileType = mainFile.getFileType();
String name = mainFile.getName();
if (fileType == StdFileTypes.XML) {
if (name.equals(ANDROID_MANIFEST_XML)) {
scope = Scope.MANIFEST_SCOPE;
} else {
scope = Scope.RESOURCE_FILE_SCOPE;
}
} else if (fileType == StdFileTypes.JAVA) {
scope = Scope.JAVA_FILE_SCOPE;
} else if (name.equals(OLD_PROGUARD_FILE) || name.equals(FN_PROJECT_PROGUARD_FILE)) {
scope = EnumSet.of(Scope.PROGUARD_FILE);
} else if (fileType == GroovyFileType.GROOVY_FILE_TYPE) {
scope = Scope.GRADLE_SCOPE;
} else if (fileType == StdFileTypes.PROPERTIES) {
scope = Scope.PROPERTY_SCOPE;
} else {
// #collectionInformation above should have prevented this
assert false;
return state;
}
Project project = state.getModule().getProject();
if (project.isDisposed()) {
return state;
}
List<VirtualFile> files = Collections.singletonList(mainFile);
LintRequest request = new LintIdeRequest(client, project, files, Collections.singletonList(state.getModule()), true);
request.setScope(scope);
lint.analyze(request);
} finally {
Disposer.dispose(client);
}
return state;
}
use of com.intellij.openapi.fileTypes.FileType in project intellij-plugins by JetBrains.
the class CfmlBraceMatcher method isLBraceToken.
public boolean isLBraceToken(HighlighterIterator iterator, CharSequence fileText, FileType fileType) {
final IElementType tokenType = iterator.getTokenType();
PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(tokenType.getLanguage());
if (matcher != null) {
BracePair[] pairs = matcher.getPairs();
for (BracePair pair : pairs) {
if (pair.getLeftBraceType() == tokenType)
return true;
}
}
if (!tokenType.getLanguage().equals(CfmlLanguage.INSTANCE)) {
FileType tokenFileType = iterator.getTokenType().getLanguage().getAssociatedFileType();
if (tokenFileType != null && tokenFileType != CfmlFileType.INSTANCE) {
for (FileTypeExtensionPoint<BraceMatcher> ext : Extensions.getExtensions(BraceMatcher.EP_NAME)) {
if (ext.filetype != null && ext.filetype.equals(tokenFileType.getName())) {
return ext.getInstance().isLBraceToken(iterator, fileText, tokenFileType instanceof XmlFileType ? StdFileTypes.HTML : tokenFileType);
}
}
}
}
for (BracePair pair : PAIRS) {
if (pair.getLeftBraceType() == tokenType) {
return true;
}
}
return tokenType.equals(CfmlTokenTypes.OPENER) && (!CfmlUtil.isEndTagRequired(getTagName(fileText, iterator), null) || findEndTag(fileText, iterator));
}
use of com.intellij.openapi.fileTypes.FileType in project intellij-plugins by JetBrains.
the class CfmlStructureViewTest method createStructureViewModel.
private StructureView createStructureViewModel() {
VirtualFile virtualFile = myFixture.getFile().getVirtualFile();
final FileType fileType = virtualFile.getFileType();
final StructureViewBuilder structureViewBuilder;
if (fileType == CfmlFileType.INSTANCE) {
CfmlFileViewProvider viewProvider = (CfmlFileViewProvider) myFixture.getFile().getViewProvider();
structureViewBuilder = LanguageStructureViewBuilder.INSTANCE.forLanguage(viewProvider.getBaseLanguage()).getStructureViewBuilder(viewProvider.getPsi(viewProvider.getBaseLanguage()));
} else {
structureViewBuilder = StructureViewBuilder.PROVIDER.getStructureViewBuilder(fileType, virtualFile, getProject());
}
return structureViewBuilder.createStructureView(FileEditorManager.getInstance(getProject()).getSelectedEditor(virtualFile), getProject());
}
use of com.intellij.openapi.fileTypes.FileType in project intellij-plugins by JetBrains.
the class CallTreeTest method getTestXMLFile.
@NotNull
private XmlFile getTestXMLFile(String fileName) throws IOException {
File file = new File(getTestDataPath() + File.separator + fileName);
assertTrue("File doesn't exists " + fileName, file.exists());
FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(fileName);
return (XmlFile) createLightFile(fileType, FileUtil.loadFile(file));
}
use of com.intellij.openapi.fileTypes.FileType in project intellij-plugins by JetBrains.
the class KarmaUtil method listPossibleConfigFilesInProject.
@NotNull
public static List<VirtualFile> listPossibleConfigFilesInProject(@NotNull Project project) {
GlobalSearchScope contentScope = ProjectScope.getContentScope(project);
GlobalSearchScope scope = contentScope.intersectWith(GlobalSearchScope.notScope(ProjectScope.getLibrariesScope(project)));
List<VirtualFile> result = ContainerUtil.newArrayList();
List<FileType> fileTypes = JavaScriptFileType.getFileTypesCompilableToJavaScript();
for (FileType type : fileTypes) {
Collection<VirtualFile> files = FileTypeIndex.getFiles(type, scope);
for (VirtualFile file : files) {
if (file != null && file.isValid() && !file.isDirectory() && isKarmaConfigFile(file.getNameSequence(), false)) {
if (!JSLibraryUtil.isProbableLibraryFile(file)) {
result.add(file);
}
}
}
}
return result;
}
Aggregations