Merge remote branch 'origin/master'

This commit is contained in:
Dmitry Jemerov
2012-01-13 17:25:15 +01:00
12 changed files with 189 additions and 103 deletions
@@ -212,9 +212,6 @@ public class JavaBuilder extends Builder{
final ProjectPaths paths = context.getProjectPaths();
final Mappings delta = context.createDelta();
DELTA_MAPPINGS_CALLBACK_KEY.set(context, delta.getCallback());
// todo: consider corresponding setting in CompilerWorkspaceConfiguration
final boolean addNotNullAssertions = true;
@@ -226,6 +223,8 @@ public class JavaBuilder extends Builder{
// begin compilation round
final DiagnosticSink diagnosticSink = new DiagnosticSink(context);
final OutputFilesSink outputSink = new OutputFilesSink(context);
final Mappings delta = context.createDelta();
DELTA_MAPPINGS_CALLBACK_KEY.set(context, delta.getCallback());
try {
if (hasSourcesToCompile) {
final Set<File> sourcePath = TEMPORARY_SOURCE_ROOTS_KEY.get(context,Collections.<File>emptySet());
@@ -69,14 +69,14 @@ public class Mappings {
myRootDir.mkdirs();
//createImplementation(myRootDir, myIsTansient);
createImplementation(myRootDir, true);
myClassToSubclasses = new TransientMultiMaplet<DependencyContext.S, DependencyContext.S>(ourStringSetConstructor);
mySourceFileToClasses = new TransientMultiMaplet<DependencyContext.S, ClassRepr>(ourClassSetConstructor);
mySourceFileToUsages = new TransientMaplet<DependencyContext.S, UsageRepr.Cluster>();
mySourceFileToAnnotationUsages = new TransientMultiMaplet<DependencyContext.S, UsageRepr.Usage>(ourUsageSetConstructor);
myClassToSourceFile = new TransientMaplet<DependencyContext.S, DependencyContext.S>();
myClassToClassDependency = new TransientMultiMaplet<DependencyContext.S, DependencyContext.S>(ourStringSetConstructor);
//myClassToSubclasses = new TransientMultiMaplet<DependencyContext.S, DependencyContext.S>(ourStringSetConstructor);
//mySourceFileToClasses = new TransientMultiMaplet<DependencyContext.S, ClassRepr>(ourClassSetConstructor);
//mySourceFileToUsages = new TransientMaplet<DependencyContext.S, UsageRepr.Cluster>();
//mySourceFileToAnnotationUsages = new TransientMultiMaplet<DependencyContext.S, UsageRepr.Usage>(ourUsageSetConstructor);
//myClassToSourceFile = new TransientMaplet<DependencyContext.S, DependencyContext.S>();
//myClassToClassDependency = new TransientMultiMaplet<DependencyContext.S, DependencyContext.S>(ourStringSetConstructor);
}
public Mappings(final File rootDir) throws IOException {
@@ -1264,74 +1264,79 @@ public class Mappings {
}
public void integrate(final Mappings delta, final Collection<File> compiled, final Collection<String> removed) {
if (removed != null) {
for (String file : removed) {
final DependencyContext.S key = myContext.get(file);
final Set<ClassRepr> classes = (Set<ClassRepr>)mySourceFileToClasses.get(key);
final UsageRepr.Cluster cluster = mySourceFileToUsages.get(key);
final Set<UsageRepr.Usage> usages = cluster == null ? null : cluster.getUsages();
try {
if (removed != null) {
for (String file : removed) {
final DependencyContext.S key = myContext.get(file);
final Set<ClassRepr> classes = (Set<ClassRepr>)mySourceFileToClasses.get(key);
final UsageRepr.Cluster cluster = mySourceFileToUsages.get(key);
final Set<UsageRepr.Usage> usages = cluster == null ? null : cluster.getUsages();
if (classes != null) {
for (ClassRepr cr : classes) {
myClassToSubclasses.remove(cr.name);
myClassToSourceFile.remove(cr.name);
myClassToClassDependency.remove(cr.name);
if (classes != null) {
for (ClassRepr cr : classes) {
myClassToSubclasses.remove(cr.name);
myClassToSourceFile.remove(cr.name);
myClassToClassDependency.remove(cr.name);
for (DependencyContext.S superSomething : cr.getSupers()) {
myClassToSubclasses.removeFrom(superSomething, cr.name);
}
for (DependencyContext.S superSomething : cr.getSupers()) {
myClassToSubclasses.removeFrom(superSomething, cr.name);
}
if (usages != null) {
for (UsageRepr.Usage u : usages) {
if (u instanceof UsageRepr.ClassUsage) {
final Set<DependencyContext.S> residents = cluster.getResidence(u);
if (usages != null) {
for (UsageRepr.Usage u : usages) {
if (u instanceof UsageRepr.ClassUsage) {
final Set<DependencyContext.S> residents = cluster.getResidence(u);
if (residents != null && residents.contains(cr.name)) {
myClassToClassDependency.removeFrom(((UsageRepr.ClassUsage)u).className, cr.name);
if (residents != null && residents.contains(cr.name)) {
myClassToClassDependency.removeFrom(((UsageRepr.ClassUsage)u).className, cr.name);
}
}
}
}
}
}
}
mySourceFileToClasses.remove(key);
mySourceFileToUsages.remove(key);
mySourceFileToClasses.remove(key);
mySourceFileToUsages.remove(key);
}
}
//final Set<ClassRepr> cl = (Set<ClassRepr>) delta.mySourceFileToClasses.get(new DependencyContext.S(352));
//System.out.println("There: " + (cl == null ? "wow..." : cl.size()));
myClassToSubclasses.putAll(delta.myClassToSubclasses);
mySourceFileToClasses.putAll(delta.mySourceFileToClasses);
mySourceFileToUsages.putAll(delta.mySourceFileToUsages);
mySourceFileToAnnotationUsages.putAll(delta.mySourceFileToAnnotationUsages);
myClassToSourceFile.putAll(delta.myClassToSourceFile);
for (DependencyContext.S file : delta.myClassToClassDependency.keyCollection()) {
final Collection<DependencyContext.S> now = delta.myClassToClassDependency.get(file);
final Collection<DependencyContext.S> past = myClassToClassDependency.get(file);
if (past == null) {
myClassToClassDependency.put(file, now);
}
else {
final Collection<DependencyContext.S> removeSet = new HashSet<DependencyContext.S>();
for (File c : compiled) {
removeSet.add(myContext.get(FileUtil.toSystemIndependentName(c.getAbsolutePath())));
}
removeSet.removeAll(now);
past.addAll(now);
past.removeAll(removeSet);
myClassToClassDependency.remove(file);
myClassToClassDependency.put(file, past);
}
}
}
//final Set<ClassRepr> cl = (Set<ClassRepr>) delta.mySourceFileToClasses.get(new DependencyContext.S(352));
//System.out.println("There: " + (cl == null ? "wow..." : cl.size()));
myClassToSubclasses.putAll(delta.myClassToSubclasses);
mySourceFileToClasses.putAll(delta.mySourceFileToClasses);
mySourceFileToUsages.putAll(delta.mySourceFileToUsages);
mySourceFileToAnnotationUsages.putAll(delta.mySourceFileToAnnotationUsages);
myClassToSourceFile.putAll(delta.myClassToSourceFile);
for (DependencyContext.S file : delta.myClassToClassDependency.keyCollection()) {
final Collection<DependencyContext.S> now = delta.myClassToClassDependency.get(file);
final Collection<DependencyContext.S> past = myClassToClassDependency.get(file);
if (past == null) {
myClassToClassDependency.put(file, now);
}
else {
final Collection<DependencyContext.S> removeSet = new HashSet<DependencyContext.S>();
for (File c : compiled) {
removeSet.add(myContext.get(FileUtil.toSystemIndependentName(c.getAbsolutePath())));
}
removeSet.removeAll(now);
past.addAll(now);
past.removeAll(removeSet);
myClassToClassDependency.remove(file);
myClassToClassDependency.put(file, past);
}
finally {
delta.close();
}
}
@@ -1170,7 +1170,6 @@ public class ProjectWrapper {
}
dependencyMapping.integrate(delta, files, removed);
delta.close();
if (!incremental) {
affectedFiles.addAll(sources);
@@ -1285,7 +1284,6 @@ public class ProjectWrapper {
}
dependencyMapping.integrate(delta, files, removedSources);
delta.close();
for (Module m : chunkModules) {
Reporter.reportBuildSuccess(m, flags.tests());
@@ -27,7 +27,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.VcsConfiguration;
@@ -75,7 +74,7 @@ public abstract class AbstractVcsTestCase {
}
Collections.addAll(arguments, commandLine);
if (myTraceClient) {
System.out.println("*** running:\n" + StringUtil.join(arguments," "));
System.out.println("*** running:\n" + arguments);
}
final ProcessBuilder builder = new ProcessBuilder().command(arguments);
if (workingDir != null) {
@@ -327,6 +327,7 @@ public class PersistentHashMap<Key, Value> extends PersistentEnumeratorDelegate<
public final boolean processKeysWithExistingMapping(Processor<Key> processor) throws IOException {
synchronized (myEnumerator) {
myAppendCache.clear();
return myEnumerator.processAllDataObject(processor, new PersistentEnumerator.DataFilter() {
public boolean accept(final int id) {
return readValueId(id).address != NULL_ADDR;
@@ -375,10 +375,6 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
}
private void updateImmediately() {
if (DEBUG) {
System.out.println("ChangeListManagerImpl.updateImmediately");
}
final DataHolder dataHolder;
final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
@@ -124,6 +124,7 @@ public class LocalChangeListImpl extends LocalChangeList {
synchronized Change removeChange(Change change) {
if (ChangeListManagerImpl.DEBUG) {
System.out.println("LocalChangeListImpl.removeChange: this = " + this + ", change = " + change);
System.out.println("myChanges.size() = " + myChanges.size());
}
for (Change localChange : myChanges) {
if (localChange.equals(change)) {
@@ -387,6 +387,16 @@ public class GitMergeProvider implements MergeProvider2 {
throw new IllegalStateException("Unknown status " + s + " for file " + file.getPath());
}
}
@Override
public String getMaxStringValue() {
return GitBundle.message("merge.tool.column.status.modified");
}
@Override
public int getAdditionalWidth() {
return 10;
}
}
}
}
@@ -0,0 +1,71 @@
/*
* 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 org.jetbrains.idea.maven.dom.references;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.ElementManipulators;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
import com.intellij.psi.PsiReferenceProvider;
import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.idea.maven.dom.MavenDomUtil;
import org.jetbrains.idea.maven.dom.MavenPropertyResolver;
import org.jetbrains.idea.maven.project.MavenProject;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class MavenFilteredPropertyPsiReferenceProvider extends PsiReferenceProvider {
private static final Pattern PATTERN = Pattern.compile("\\$\\{([^\\}]+?)\\}|@([^@]+?)@");
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
if (!MavenDomUtil.isFilteredResourceFile(element)) return PsiReference.EMPTY_ARRAY;
String text = element.getText();
if (StringUtil.isEmptyOrSpaces(text)) return PsiReference.EMPTY_ARRAY;
MavenProject mavenProject = MavenDomUtil.findContainingProject(element);
if (mavenProject == null) return PsiReference.EMPTY_ARRAY;
List<PsiReference> result = new ArrayList<PsiReference>();
Matcher matcher = PATTERN.matcher(text);
while (matcher.find()) {
String propertyName = matcher.group(1);
int from;
if (propertyName == null) {
propertyName = matcher.group(2);
from = matcher.start(2);
}
else {
from = matcher.start(1);
}
TextRange range = TextRange.from(from, propertyName.length());
result.add(new MavenFilteredPropertyPsiReference(mavenProject, element, propertyName, range, MavenPropertyPsiReferenceProvider.SOFT_DEFAULT));
}
return result.toArray(new PsiReference[result.size()]);
}
}
@@ -27,9 +27,9 @@ public class MavenPropertyPsiReferenceContributor extends PsiReferenceContributo
@Override
public void registerReferenceProviders(PsiReferenceRegistrar registrar) {
ElementPattern pattern = XmlPatterns.xmlTag().withParent(DomPatterns.withDom(DomPatterns.domElement(MavenDomProperties.class)));
registrar.registerReferenceProvider(pattern, new MavenPropertyPsiReferenceProvider(false), PsiReferenceRegistrar.DEFAULT_PRIORITY);
registrar.registerReferenceProvider(pattern, new MavenPropertyPsiReferenceProvider(), PsiReferenceRegistrar.DEFAULT_PRIORITY);
registrar.registerReferenceProvider(PlatformPatterns.psiElement(),
new MavenPropertyPsiReferenceProvider(true),
new MavenFilteredPropertyPsiReferenceProvider(),
PsiReferenceRegistrar.DEFAULT_PRIORITY);
}
}
@@ -33,29 +33,19 @@ import java.util.regex.Matcher;
public class MavenPropertyPsiReferenceProvider extends PsiReferenceProvider {
public static final boolean SOFT_DEFAULT = false;
private final boolean myFiltered;
public MavenPropertyPsiReferenceProvider(boolean filtered) {
myFiltered = filtered;
}
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
if (myFiltered) {
if (!MavenDomUtil.isFilteredResourceFile(element)) return PsiReference.EMPTY_ARRAY;
return getReferences(element, element.getText(), 0, true, SOFT_DEFAULT);
}
return getReferences(element, SOFT_DEFAULT);
}
public static PsiReference[] getReferences(PsiElement element, boolean isSoft) {
String text = ElementManipulators.getValueText(element);
int textStart = ElementManipulators.getValueTextRange(element).getStartOffset();
return getReferences(element, text, textStart, false, isSoft);
}
TextRange textRange = ElementManipulators.getValueTextRange(element);
if (textRange.isEmpty()) return PsiReference.EMPTY_ARRAY;
String text = element.getText();
private static PsiReference[] getReferences(PsiElement element, String text, int textStart, boolean isFiltered, boolean isSoft) {
if (StringUtil.isEmptyOrSpaces(text)) return PsiReference.EMPTY_ARRAY;
MavenProject mavenProject = MavenDomUtil.findContainingProject(element);
@@ -63,20 +53,13 @@ public class MavenPropertyPsiReferenceProvider extends PsiReferenceProvider {
List<PsiReference> result = new ArrayList<PsiReference>();
Matcher matcher = MavenPropertyResolver.PATTERN.matcher(text);
Matcher matcher = MavenPropertyResolver.PATTERN.matcher(textRange.substring(text));
while (matcher.find()) {
String propertyName = matcher.group(1);
int from = textStart + matcher.start(1);
int from = textRange.getStartOffset() + matcher.start(1);
TextRange range = TextRange.from(from, propertyName.length());
MavenPropertyPsiReference ref;
if (isFiltered) {
ref = new MavenFilteredPropertyPsiReference(mavenProject, element, propertyName, range, isSoft);
}
else {
ref = new MavenPropertyPsiReference(mavenProject, element, propertyName, range, isSoft);
}
result.add(ref);
result.add(new MavenPropertyPsiReference(mavenProject, element, propertyName, range, isSoft));
}
return result.toArray(new PsiReference[result.size()]);
@@ -47,6 +47,28 @@ public class MavenFilteredPropertiesCompletionAndResolutionTest extends MavenDom
assertResolved(f, findTag("project.version"));
}
public void testBasicAt() throws Exception {
createProjectSubDir("res");
importProject("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
"<version>1</version>" +
"<build>" +
" <resources>" +
" <resource>" +
" <directory>res</directory>" +
" <filtering>true</filtering>" +
" </resource>" +
" </resources>" +
"</build>");
VirtualFile f = createProjectSubFile("res/foo.properties",
"foo=abc@project<caret>.version@abc");
assertResolved(f, findTag("project.version"));
}
public void testCorrectlyCalculatingBaseDir() throws Exception {
createProjectSubDir("res");
@@ -136,7 +158,7 @@ public class MavenFilteredPropertiesCompletionAndResolutionTest extends MavenDom
importProjectWithProfiles("one");
VirtualFile f = createProjectSubFile("res/foo.properties",
"foo=${profileProp<caret>}");
"foo=@profileProp<caret>@");
assertResolved(f, findTag(profiles, "profilesXml.profiles[0].properties.profileProp", MavenDomProfilesModel.class));
}
@@ -258,10 +280,11 @@ public class MavenFilteredPropertiesCompletionAndResolutionTest extends MavenDom
"</build>");
VirtualFile f = createProjectSubFile("res/foo.properties",
"foo=${xxx}");
"foo=${xxx}\n" +
"foo2=@xxx@");
VirtualFile filter = createProjectSubFile("filters/filter.properties", "xx<caret>x=1");
assertSearchResultsInclude(filter, MavenDomUtil.findPropertyValue(myProject, f, "foo"));
assertSearchResultsInclude(filter, MavenDomUtil.findPropertyValue(myProject, f, "foo"), MavenDomUtil.findPropertyValue(myProject, f, "foo2"));
}
public void testCompletionAfterOpenBrace() throws Exception {