mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
exclude excluded from validation files from checking groovy resources (IDEA-159538)
This commit is contained in:
@@ -25,6 +25,7 @@ import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
import org.jetbrains.jps.model.serialization.java.compiler.JpsCompilerValidationExcludeSerializer;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -76,6 +77,9 @@ public class ValidationConfiguration implements PersistentStateComponent<Validat
|
||||
XmlSerializerUtil.copyBean(state, this);
|
||||
}
|
||||
|
||||
@State(name = "ExcludeFromValidation", storages = @Storage("excludeFromValidation.xml"))
|
||||
@State(
|
||||
name = JpsCompilerValidationExcludeSerializer.COMPONENT_NAME,
|
||||
storages = @Storage(JpsCompilerValidationExcludeSerializer.CONFIG_FILE_NAME)
|
||||
)
|
||||
public static class ExcludedFromValidationConfiguration extends ExcludedEntriesConfiguration {}
|
||||
}
|
||||
|
||||
+3
@@ -40,6 +40,9 @@ public interface JpsJavaCompilerConfiguration extends JpsElement {
|
||||
@NotNull
|
||||
JpsCompilerExcludes getCompilerExcludes();
|
||||
|
||||
@NotNull
|
||||
JpsCompilerExcludes getValidationExcludes();
|
||||
|
||||
@NotNull
|
||||
ProcessorConfigProfile getDefaultAnnotationProcessingProfile();
|
||||
ProcessorConfigProfile addAnnotationProcessingProfile();
|
||||
|
||||
+7
@@ -38,6 +38,7 @@ public class JpsJavaCompilerConfigurationImpl extends JpsCompositeElementBase<Jp
|
||||
private List<String> myNotNullAnnotations = Collections.singletonList(NotNull.class.getName());
|
||||
private boolean myClearOutputDirectoryOnRebuild = true;
|
||||
private final JpsCompilerExcludes myCompilerExcludes = new JpsCompilerExcludesImpl();
|
||||
private final JpsCompilerExcludes myValidationExcludes = new JpsCompilerExcludesImpl();
|
||||
private final List<String> myResourcePatterns = new ArrayList<String>();
|
||||
private final List<ProcessorConfigProfile> myAnnotationProcessingProfiles = new ArrayList<ProcessorConfigProfile>();
|
||||
private final ProcessorConfigProfileImpl myDefaultAnnotationProcessingProfile = new ProcessorConfigProfileImpl("Default");
|
||||
@@ -97,6 +98,12 @@ public class JpsJavaCompilerConfigurationImpl extends JpsCompositeElementBase<Jp
|
||||
return myCompilerExcludes;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsCompilerExcludes getValidationExcludes() {
|
||||
return myValidationExcludes;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ProcessorConfigProfile getDefaultAnnotationProcessingProfile() {
|
||||
|
||||
+1
@@ -92,6 +92,7 @@ public class JpsJavaModelSerializerExtension extends JpsModelSerializerExtension
|
||||
return Arrays.asList(new JavaProjectExtensionSerializer(),
|
||||
new JpsJavaCompilerConfigurationSerializer(),
|
||||
new JpsJavaCompilerNotNullableSerializer(),
|
||||
new JpsCompilerValidationExcludeSerializer(),
|
||||
new JpsJavaCompilerWorkspaceConfigurationSerializer(),
|
||||
new JpsJavaCompilerOptionsSerializer("JavacSettings", "Javac"),
|
||||
new JpsEclipseCompilerOptionsSerializer("EclipseCompilerSettings", "Eclipse"),
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.jetbrains.jps.model.serialization.java.compiler;
|
||||
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsProject;
|
||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
|
||||
import org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration;
|
||||
import org.jetbrains.jps.model.serialization.JpsProjectExtensionSerializer;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class JpsCompilerValidationExcludeSerializer extends JpsProjectExtensionSerializer {
|
||||
public static final String COMPONENT_NAME = "ExcludeFromValidation";
|
||||
public static final String CONFIG_FILE_NAME = "excludeFromValidation.xml";
|
||||
|
||||
public JpsCompilerValidationExcludeSerializer() {
|
||||
super(CONFIG_FILE_NAME, COMPONENT_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadExtension(@NotNull JpsProject project, @NotNull Element componentTag) {
|
||||
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
|
||||
JpsJavaCompilerConfigurationSerializer.readExcludes(componentTag, configuration.getValidationExcludes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveExtension(@NotNull JpsProject project, @NotNull Element componentTag) {}
|
||||
}
|
||||
+6
-1
@@ -66,7 +66,12 @@ public class GreclipseBuilder extends ModuleLevelBuilder {
|
||||
* All Groovy-Eclipse stuff is contained in a separate classLoader to avoid clashes with ecj.jar being in the classpath of the builder process
|
||||
*/
|
||||
private ClassLoader myGreclipseLoader;
|
||||
private final CompilingGroovycRunner myHelper = new CompilingGroovycRunner(true);
|
||||
private final CompilingGroovycRunner myHelper = new CompilingGroovycRunner(true) {
|
||||
@Override
|
||||
protected boolean acceptsFileType(String path) {
|
||||
return super.acceptsFileType(path) || path.endsWith(".java");
|
||||
}
|
||||
};
|
||||
|
||||
protected GreclipseBuilder() {
|
||||
super(BuilderCategory.TRANSLATOR);
|
||||
|
||||
@@ -136,6 +136,7 @@ public class GroovyBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
|
||||
public static boolean isGroovyFile(String path) {
|
||||
//todo file type check
|
||||
return path.endsWith("." + GROOVY_EXTENSION);
|
||||
}
|
||||
|
||||
|
||||
+9
@@ -26,6 +26,7 @@ import org.jetbrains.jps.incremental.*;
|
||||
import org.jetbrains.jps.model.java.JpsJavaClasspathKind;
|
||||
import org.jetbrains.jps.model.java.JpsJavaDependenciesEnumerator;
|
||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
|
||||
import org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
|
||||
import java.io.File;
|
||||
@@ -84,6 +85,14 @@ public class GroovyResourceChecker extends TargetBuilder<GroovyResourceRootDescr
|
||||
return Collections.singletonMap(myTarget, myTarget.getOutputRoot(context).getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldProcessSourceFile(File file,
|
||||
GroovyResourceRootDescriptor sourceRoot,
|
||||
String path,
|
||||
JpsJavaCompilerConfiguration configuration) {
|
||||
return GroovyBuilder.isGroovyFile(path) && !configuration.getValidationExcludes().isExcluded(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkChunkRebuildNeeded(CompileContext context, GroovycOutputParser parser) {
|
||||
return false;
|
||||
|
||||
+12
-4
@@ -318,10 +318,7 @@ public abstract class JpsGroovycRunner<R extends BuildRootDescriptor, T extends
|
||||
final List<File> toCompile = new ArrayList<File>();
|
||||
dirtyFilesHolder.processDirtyFiles(new FileProcessor<R, T>() {
|
||||
public boolean apply(T target, File file, R sourceRoot) throws IOException {
|
||||
final String path = file.getPath();
|
||||
//todo file type check
|
||||
if ((GroovyBuilder.isGroovyFile(path) || forEclipse && path.endsWith(".java")) &&
|
||||
!configuration.isResourceFile(file, sourceRoot.getRootFile())) {
|
||||
if (shouldProcessSourceFile(file, sourceRoot, file.getPath(), configuration)) {
|
||||
if (forStubs && settings.isExcludedFromStubGeneration(file)) {
|
||||
hasExcludes.set(true);
|
||||
return true;
|
||||
@@ -335,6 +332,17 @@ public abstract class JpsGroovycRunner<R extends BuildRootDescriptor, T extends
|
||||
return toCompile;
|
||||
}
|
||||
|
||||
protected boolean shouldProcessSourceFile(File file,
|
||||
R sourceRoot,
|
||||
String path,
|
||||
JpsJavaCompilerConfiguration configuration) {
|
||||
return acceptsFileType(path) && !configuration.isResourceFile(file, sourceRoot.getRootFile());
|
||||
}
|
||||
|
||||
protected boolean acceptsFileType(String path) {
|
||||
return GroovyBuilder.isGroovyFile(path);
|
||||
}
|
||||
|
||||
void updateDependencies(CompileContext context,
|
||||
List<File> toCompile,
|
||||
MultiMap<T, GroovycOutputParser.OutputItem> successfullyCompiled,
|
||||
|
||||
+9
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.compiler
|
||||
|
||||
import com.intellij.compiler.options.ValidationConfiguration
|
||||
import com.intellij.openapi.compiler.CompilerMessage
|
||||
import com.intellij.openapi.compiler.options.ExcludeEntryDescription
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.roots.ModuleRootManager
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil
|
||||
@@ -68,4 +70,11 @@ class GroovyResourceCheckerTest extends GroovyCompilerTestCase {
|
||||
assertEmpty checkResources()
|
||||
}
|
||||
|
||||
void "test exclude from validation"() {
|
||||
checkResources()
|
||||
def file = myFixture.addFileToProject('res/a.groovy', 'class Foo extends Bar {}')
|
||||
ValidationConfiguration.getExcludedEntriesConfiguration(project).addExcludeEntryDescription(new ExcludeEntryDescription(file.virtualFile, false, true, project))
|
||||
assertEmpty checkResources()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user