if (file != null) {
VirtualFile vFile = file.getVirtualFile();
if (vFile != null) {
- String schema = FileTypeUsageCounterCollector.findSchema(vFile);
+ String schema = FileTypeUsageCounterCollector.findSchema(myLookup.getProject(), vFile);
if (schema != null) {
data.addData("schema", schema);
}
}
public static void triggerOpen(@NotNull Project project, @NotNull VirtualFile file) {
- OPEN.log(project, ArrayUtil.append(buildCommonEventPairs(file), IS_WRITABLE.with(file.isWritable())));
+ OPEN.log(project, ArrayUtil.append(buildCommonEventPairs(project, file), IS_WRITABLE.with(file.isWritable())));
}
public static void triggerClosed(@NotNull Project project, @NotNull VirtualFile file) {
- CLOSE.log(project, ArrayUtil.append(buildCommonEventPairs(file), IS_WRITABLE.with(file.isWritable())));
+ CLOSE.log(project, ArrayUtil.append(buildCommonEventPairs(project, file), IS_WRITABLE.with(file.isWritable())));
}
private static void log(@NotNull VarargEventId eventId, @NotNull Project project, @NotNull VirtualFile file) {
- eventId.log(project, buildCommonEventPairs(file));
+ eventId.log(project, buildCommonEventPairs(project, file));
}
- private static EventPair<?> @NotNull [] buildCommonEventPairs(@NotNull VirtualFile file) {
+ private static EventPair<?> @NotNull [] buildCommonEventPairs(@NotNull Project project,
+ @NotNull VirtualFile file) {
FileType fileType = file.getFileType();
return new EventPair[]{EventFields.PluginInfoFromInstance.with(fileType),
FILE_TYPE.with(FileTypeUsagesCollector.getSafeFileTypeName(fileType)),
EventFields.AnonymizedPath.with(file.getPath()),
- SCHEMA.with(findSchema(file))};
+ SCHEMA.with(findSchema(project, file))};
}
private static void logEmptyFile() {
SELECT.log(EventFields.AnonymizedPath.with(null));
}
- public static @Nullable String findSchema(@NotNull VirtualFile file) {
+ public static @Nullable String findSchema(@NotNull Project project,
+ @NotNull VirtualFile file) {
for (FileTypeUsageSchemaDescriptorEP<FileTypeUsageSchemaDescriptor> ext : EP.getExtensionList()) {
FileTypeUsageSchemaDescriptor instance = ext.getInstance();
if (ext.schema == null) {
continue;
}
- if(instance.describes(file)) {
+ if (instance.describes(project, file)) {
return getPluginInfo(instance.getClass()).isSafeToReport() ? ext.schema : "third.party";
}
}
-// Copyright 2000-2019 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-2020 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.internal.statistic.collectors.fus.fileTypes;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
public interface FileTypeUsageSchemaDescriptor {
+ /**
+ * @deprecated use {@link FileTypeUsageSchemaDescriptor#describes(Project, VirtualFile)}
+ */
+ @Deprecated
+ default boolean describes(@NotNull VirtualFile file) {
+ return false;
+ }
+
/**
* Is used to categorise file types usage statistics.
* If a file has some generic file type (e.g. XML), this method allow specifying its 'schema' more precisely, e.g `Maven` or `Spring`.
*
* @return true if the given file has the schema name, given in the `schema` attribute of the `FileTypeUsageSchemaDescriptor` extension.
*/
- boolean describes(@NotNull VirtualFile file);
+ default boolean describes(@NotNull Project project, @NotNull VirtualFile file) {
+ return describes(file);
+ }
}
-// Copyright 2000-2019 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-2020 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.plugins.gradle.config;
import com.intellij.internal.statistic.collectors.fus.fileTypes.FileTypeUsageSchemaDescriptor;
import com.intellij.openapi.fileTypes.FileTypeRegistry;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.gradle.util.GradleConstants;
}
@Override
- public boolean describes(@NotNull VirtualFile file) {
+ public boolean describes(@NotNull Project project, @NotNull VirtualFile file) {
String name = file.getName();
return FileTypeRegistry.getInstance().isFileOfType(file, GroovyFileType.GROOVY_FILE_TYPE) &&
(name.equals(GradleConstants.DEFAULT_SCRIPT_NAME) || name.equals(GradleConstants.SETTINGS_FILE_NAME));
import com.intellij.internal.statistic.collectors.fus.fileTypes.FileTypeUsageSchemaDescriptor;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeManager;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NonNls;
public final class JavaFxFileTypeFactory implements FileTypeUsageSchemaDescriptor {
@Override
- public boolean describes(@NotNull VirtualFile file) {
+ public boolean describes(@NotNull Project project, @NotNull VirtualFile file) {
return isFxml(file);
}
-/*
- * Copyright 2000-2016 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-2020 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.maven.plugins.groovy;
import com.intellij.internal.statistic.collectors.fus.fileTypes.FileTypeUsageSchemaDescriptor;
import com.intellij.openapi.fileTypes.FileTypeRegistry;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.GroovyFileType;
}
@Override
- public boolean describes(@NotNull VirtualFile file) {
+ public boolean describes(@NotNull Project project, @NotNull VirtualFile file) {
return isMavenGroovyScript(file);
}
-/*
- * 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.
- */
+// Copyright 2000-2020 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.maven.utils;
import com.intellij.ide.highlighter.XmlFileType;
import com.intellij.internal.statistic.collectors.fus.fileTypes.FileTypeUsageSchemaDescriptor;
import com.intellij.openapi.fileTypes.FileTypeRegistry;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
*/
public class MavenFileTypeFactory implements FileTypeUsageSchemaDescriptor {
@Override
- public boolean describes(@NotNull VirtualFile file) {
+ public boolean describes(@NotNull Project project, @NotNull VirtualFile file) {
return FileTypeRegistry.getInstance().isFileOfType(file, XmlFileType.INSTANCE) && FileUtil.namesEqual(file.getName(), MavenConstants.POM_XML);
}
}