Merge branch 'master' of git.labs.intellij.net:idea/community

This commit is contained in:
Bas Leijdekkers
2009-10-31 09:25:49 +01:00
36 changed files with 333 additions and 243 deletions
@@ -41,7 +41,6 @@ public class CompositeBuildTarget extends CompositeGenerator {
final String depends, @Nullable String jarPath) {
final File moduleBaseDir = parameters.getChunk().getBaseDir();
final Module containingModule = parameters.getContainingModule();
final Target buildTarget = new Target(targetName, depends, targetDescription, null);
final BuildConfiguration buildConfiguration = parameters.getBuildConfiguration();
@@ -21,7 +21,6 @@ import com.intellij.compiler.make.ExplodedAndJarBuildGenerator;
import com.intellij.compiler.make.MakeUtil;
import com.intellij.openapi.compiler.make.*;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.util.Ref;
import com.intellij.util.SmartList;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -105,58 +104,4 @@ public class DefaultExplodedAndJarBuildGenerator extends ExplodedAndJarBuildGene
}
@NotNull
public ZipFileSet[] generateTagsForJarTarget(@NotNull final BuildInstruction instruction, @NotNull final ExplodedAndJarTargetParameters parameters,
final Ref<Boolean> tempDirUsed)
throws Exception {
final List<ZipFileSet> zipFileSetTags = new SmartList<ZipFileSet>();
final String tempDirProperty = BuildProperties.getTempDirForModuleProperty(parameters.getContainingModule().getName());
final File moduleBaseDir = parameters.getChunk().getBaseDir();
instruction.accept(new BuildInstructionVisitor() {
public boolean visitFileCopyInstruction(FileCopyInstruction instruction) throws RuntimeException {
if (instruction.isExternalDependencyInstruction()) return true;
final File sourceFile = instruction.getFile();
final Module instructionModule = instruction.getModule();
final String sourceLocation = GenerationUtils.toRelativePath(sourceFile.getPath(), moduleBaseDir, instructionModule,
parameters.getGenerationOptions());
final ZipFileSet fileSet = new ZipFileSet(sourceLocation, instruction.getOutputRelativePath(), instruction.isDirectory());
zipFileSetTags.add(fileSet);
return true;
}
public boolean visitJarAndCopyBuildInstruction(JarAndCopyBuildInstruction instruction) throws RuntimeException {
if (instruction.isExternalDependencyInstruction()) return true;
tempDirUsed.set(true);
final String jarName = new File(instruction.getOutputRelativePath()).getName();
final String destJarPath = BuildProperties.propertyRef(tempDirProperty)+"/"+jarName;
zipFileSetTags.add(new ZipFileSet(destJarPath, instruction.getOutputRelativePath(), false));
return true;
}
});
return zipFileSetTags.toArray(new ZipFileSet[zipFileSetTags.size()]);
}
@NotNull
public Tag[] generateJarBuildPrepareTags(@NotNull final BuildInstruction instruction, @NotNull final ExplodedAndJarTargetParameters parameters)
throws Exception {
final List<Tag> prepareTags = new SmartList<Tag>();
final String tempDirProperty = BuildProperties.getTempDirForModuleProperty(parameters.getContainingModule().getName());
final File moduleBaseDir = parameters.getChunk().getBaseDir();
instruction.accept(new BuildInstructionVisitor() {
public boolean visitJarAndCopyBuildInstruction(JarAndCopyBuildInstruction instruction) throws RuntimeException {
if (instruction.isExternalDependencyInstruction()) return true;
final String jarName = new File(instruction.getOutputRelativePath()).getName();
final String destJarPath = BuildProperties.propertyRef(tempDirProperty)+"/"+jarName;
prepareTags.add(generateJarTag(instruction, destJarPath, moduleBaseDir, parameters.getGenerationOptions()));
return true;
}
});
return prepareTags.toArray(new Tag[prepareTags.size()]);
}
}
@@ -478,7 +478,8 @@ public class CompileDriver {
// in case another project was opened in the frame while the compiler was working (See SCR# 28591)
statusBar.setInfo(statusMessage);
if (duration > ONE_MINUTE_MS) {
ToolWindowManager.getInstance(myProject).notifyByBalloon(ToolWindowId.MESSAGES_WINDOW, MessageType.INFO, statusMessage);
final MessageType messageType = errorCount > 0 ? MessageType.ERROR : warningCount > 0 ? MessageType.WARNING : MessageType.INFO;
ToolWindowManager.getInstance(myProject).notifyByBalloon(ToolWindowId.MESSAGES_WINDOW, messageType, statusMessage);
}
}
if (_status != ExitStatus.UP_TO_DATE && compileContext.getMessageCount(null) > 0) {
@@ -169,18 +169,22 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
if (_forceCompile || pathsToRecompile != null && !pathsToRecompile.isEmpty()) {
while (scopeSrcIterator.hasNext()) {
final VirtualFile file = scopeSrcIterator.next();
if (!file.isValid() || configuration.isExcludedFromCompilation(file) || !compiler.isCompilableFile(file, context)) {
if (!file.isValid()) {
continue;
}
final int fileId = getFileId(file);
if (_forceCompile) {
toCompile.add(file);
if (pathsToRecompile == null || !pathsToRecompile.contains(fileId)) {
addSourceForRecompilation(projectId, file, null);
if (compiler.isCompilableFile(file, context) && !configuration.isExcludedFromCompilation(file)) {
toCompile.add(file);
if (pathsToRecompile == null || !pathsToRecompile.contains(fileId)) {
addSourceForRecompilation(projectId, file, null);
}
}
}
else if (pathsToRecompile.contains(fileId)) {
toCompile.add(file);
if (compiler.isCompilableFile(file, context) && !configuration.isExcludedFromCompilation(file)) {
toCompile.add(file);
}
}
}
}
@@ -37,15 +37,4 @@ public abstract class ExplodedAndJarBuildGenerator {
return null;
}
@Nullable
public ZipFileSet[] generateTagsForJarTarget(@NotNull BuildInstruction instruction, @NotNull ExplodedAndJarTargetParameters parameters,
final Ref<Boolean> tempDirUsed) throws Exception {
return null;
}
@Nullable
public Tag[] generateJarBuildPrepareTags(@NotNull BuildInstruction instruction, @NotNull ExplodedAndJarTargetParameters parameters) throws Exception {
return null;
}
}
@@ -56,22 +56,7 @@ public abstract class BuildParticipantBase extends BuildParticipant {
final ConfigFile[] deploymentDescriptors = getDeploymentDescriptors();
ApplicationManager.getApplication().runReadAction(new Runnable() {
public void run() {
for (ConfigFile descriptor : deploymentDescriptors) {
VirtualFile virtualFile = descriptor.getVirtualFile();
if (virtualFile != null) {
ConfigFileMetaData metaData = descriptor.getMetaData();
final File file = VfsUtil.virtualToIoFile(virtualFile);
final String fileName;
if (metaData.isFileNameFixed()) {
fileName = metaData.getFileName();
}
else {
fileName = virtualFile.getName();
}
instructions.addFileCopyInstruction(file, false, myModule, metaData.getDirectoryPath() + "/" + fileName, null);
}
}
registerDescriptorCopyingInstructions(BuildParticipantBase.this.myModule, deploymentDescriptors, instructions);
final CustomConfigFile[] customDescriptors = getCustomDescriptors();
@@ -87,6 +72,25 @@ public abstract class BuildParticipantBase extends BuildParticipant {
});
}
public static void registerDescriptorCopyingInstructions(Module module, ConfigFile[] deploymentDescriptors, BuildRecipe instructions) {
for (ConfigFile descriptor : deploymentDescriptors) {
VirtualFile virtualFile = descriptor.getVirtualFile();
if (virtualFile != null) {
ConfigFileMetaData metaData = descriptor.getMetaData();
final File file = VfsUtil.virtualToIoFile(virtualFile);
final String fileName;
if (metaData.isFileNameFixed()) {
fileName = metaData.getFileName();
}
else {
fileName = virtualFile.getName();
}
instructions.addFileCopyInstruction(file, false, module, metaData.getDirectoryPath() + "/" + fileName, null);
}
}
}
protected CustomConfigFile[] getCustomDescriptors() {
return CustomConfigFile.EMPTY_ARRAY;
}
@@ -46,8 +46,11 @@ import com.intellij.execution.CantRunException;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.ExecutionResult;
import com.intellij.execution.Executor;
import com.intellij.execution.configurations.CommandLineState;
import com.intellij.execution.configurations.RemoteConnection;
import com.intellij.execution.configurations.RunProfileState;
import com.intellij.execution.filters.ExceptionFilter;
import com.intellij.execution.filters.TextConsoleBuilder;
import com.intellij.execution.process.ProcessAdapter;
import com.intellij.execution.process.ProcessEvent;
import com.intellij.execution.process.ProcessListener;
@@ -1621,6 +1624,12 @@ public abstract class DebugProcessImpl implements DebugProcess {
try {
synchronized (myProcessListeners) {
if (state instanceof CommandLineState) {
final TextConsoleBuilder consoleBuilder = ((CommandLineState)state).getConsoleBuilder();
if (consoleBuilder != null) {
consoleBuilder.addFilter(new ExceptionFilter(session.getSearchScope()));
}
}
myExecutionResult = state.execute(executor, runner);
if (myExecutionResult == null) {
fail();
@@ -341,11 +341,10 @@ public class DebuggerSession implements AbstractDebuggerSession {
@Nullable
protected ExecutionResult attach(@NotNull final Executor executor, @NotNull final ProgramRunner runner, final ModuleRunProfile profile, final RunProfileState state, final RemoteConnection remoteConnection, final boolean pollConnection) throws ExecutionException {
final ExecutionResult executionResult = myDebugProcess.attachVirtualMachine(executor, runner, this, state, remoteConnection, pollConnection);
final String addressDisplayName = DebuggerBundle.getAddressDisplayName(remoteConnection);
final String transportName = DebuggerBundle.getTransportName(remoteConnection);
final Module[] modules = profile.getModules();
if (modules == null || modules.length == 0) {
if (modules.length == 0) {
mySearchScope = GlobalSearchScope.allScope(getProject());
}
else {
@@ -356,6 +355,7 @@ public class DebuggerSession implements AbstractDebuggerSession {
}
mySearchScope = scope;
}
final ExecutionResult executionResult = myDebugProcess.attachVirtualMachine(executor, runner, this, state, remoteConnection, pollConnection);
getContextManager().setState(SESSION_EMPTY_CONTEXT, STATE_WAITING_ATTACH, EVENT_START_WAIT_ATTACH, DebuggerBundle.message("status.waiting.attach", addressDisplayName, transportName));
return executionResult;
}
@@ -33,6 +33,8 @@ import com.intellij.debugger.ui.impl.watch.*;
import com.intellij.execution.*;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.filters.ExceptionFilter;
import com.intellij.execution.filters.TextConsoleBuilder;
import com.intellij.execution.filters.TextConsoleBuilderFactory;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.ProgramRunner;
@@ -511,7 +513,9 @@ public class DebuggerSessionTab extends DebuggerLogConsoleManagerBase implements
public void addThreadDump(List<ThreadState> threads) {
final Project project = getProject();
final ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();
final TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
consoleBuilder.addFilter(new ExceptionFilter(myDebuggerSession.getSearchScope()));
final ConsoleView consoleView = consoleBuilder.getConsole();
final DefaultActionGroup toolbarActions = new DefaultActionGroup();
final ThreadDumpPanel panel = new ThreadDumpPanel(project, consoleView, toolbarActions, threads);
@@ -39,9 +39,16 @@ public class ExceptionFilter implements Filter, DumbAware {
private static final String AT_PREFIX = AT + " ";
private static final String STANDALONE_AT = " " + AT + " ";
private static final TextAttributes HYPERLINK_ATTRIBUTES = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.HYPERLINK_ATTRIBUTES);
private final GlobalSearchScope mySearchScope;
public ExceptionFilter(@NotNull final Project project) {
myProject = project;
mySearchScope = GlobalSearchScope.allScope(myProject);
}
public ExceptionFilter(@NotNull final GlobalSearchScope scope) {
myProject = scope.getProject();
mySearchScope = scope;
}
public Result applyFilter(final String line, final int textEndOffset) {
@@ -81,7 +88,7 @@ public class ExceptionFilter implements Filter, DumbAware {
try{
final int lineNumber = Integer.parseInt(lineString);
final PsiManager manager = PsiManager.getInstance(myProject);
PsiClass aClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(className, GlobalSearchScope.allScope(myProject));
PsiClass aClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(className, mySearchScope);
if (aClass == null) return null;
final PsiFile file = (PsiFile) aClass.getContainingFile().getNavigationElement();
if (file == null) return null;
@@ -27,6 +27,7 @@ import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.ModuleRootModel;
import com.intellij.openapi.roots.OrderEntry;
import com.intellij.openapi.roots.impl.ModuleRootManagerImpl;
import com.intellij.openapi.roots.libraries.Library;
@@ -144,6 +145,13 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
return myModifiableRootModelProxy;
}
public ModuleRootModel getRootModel() {
if (myModifiableRootModel != null) {
return getModifiableRootModelProxy();
}
return ModuleRootManager.getInstance(myModule);
}
public boolean isModified() {
for (ModuleConfigurationEditor moduleElementsEditor : myEditors) {
if (moduleElementsEditor.isModified()) {
@@ -151,11 +151,11 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change
final ModuleEditor editor = getModuleEditor(module);
ModuleRootModel rootModel = null;
if (editor != null) {
rootModel = editor.getModifiableRootModel();
rootModel = editor.getRootModel();
}
if (rootModel == null && getModule(module.getName()) != null) {
createModuleEditor(module);
rootModel = getModuleEditor(module).getModifiableRootModel();
rootModel = getModuleEditor(module).getRootModel();
}
return rootModel;
@@ -148,7 +148,7 @@ public class AnnotationsHighlightUtil {
if (annotation == annotationToCheck) continue;
PsiJavaCodeReferenceElement nameRef = annotation.getNameReferenceElement();
if (nameRef == null) continue;
PsiClass aClass = (PsiClass)nameRef.resolve();
PsiElement aClass = nameRef.resolve();
if (resolved.equals(aClass)) {
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, element, JavaErrorMessages.message("annotation.duplicate.annotation"));
}
@@ -93,7 +93,9 @@ public class ClassResolverProcessor extends BaseScopeProcessor implements NameHi
}
private static boolean isOnDemand(PsiElement fileContext, PsiClass psiClass) {
if (fileContext instanceof PsiImportStatementBase && ((PsiImportStatementBase)fileContext).isOnDemand()) return true;
if (fileContext instanceof PsiImportStatementBase) {
return ((PsiImportStatementBase)fileContext).isOnDemand();
}
String fqn = psiClass.getQualifiedName();
if (fqn == null) return false;
return "java.lang".equals(StringUtil.getPackageName(fqn));
@@ -99,7 +99,7 @@ public class PushDownConflicts {
}
if (!InheritanceUtil.isInheritorOrSelf(aClass, targetClass, true)) {
myConflicts.putValue(aClass, RefactoringBundle.message("pushed.members.will.not.be.visible.from.certain.call.sites"));
myConflicts.putValue(referenceExpression, RefactoringBundle.message("pushed.members.will.not.be.visible.from.certain.call.sites"));
break Members;
}
}
@@ -244,7 +244,10 @@ public class AnnotationUtil {
fqns = new ArrayList<String>();
final PsiAnnotation[] annos = modList.getAnnotations();
for (PsiAnnotation anno : annos) {
fqns.add(anno.getQualifiedName());
final String qName = anno.getQualifiedName();
if (qName != null) {
fqns.add(qName);
}
}
if (fqns.isEmpty()) return false;
}
Binary file not shown.
@@ -73,7 +73,7 @@ public abstract class CommandLineState implements RunnableState {
return new AnAction[]{new PauseOutputAction(console, processHandler)};
}
protected TextConsoleBuilder getConsoleBuilder() {
public TextConsoleBuilder getConsoleBuilder() {
return myConsoleBuilder;
}
@@ -593,7 +593,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
@NotNull
@TestOnly
public static List<HighlightInfo> getFileLeveleHighlights(Project project,PsiFile file ) {
public static List<HighlightInfo> getFileLevelHighlights(Project project,PsiFile file ) {
return UpdateHighlightersUtil.getFileLeveleHighlights(project, file);
}
}
@@ -470,22 +470,23 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
InspectionManager inspectionManager = InspectionManager.getInstance(injectedPsi.getProject());
final ProblemsHolder problemsHolder = new ProblemsHolder(inspectionManager, injectedPsi);
final PsiElement host = injectedPsi.getContext();
for (LocalInspectionTool tool : tools) {
if (host != null && InspectionManagerEx.inspectionResultSuppressed(host, tool)) {
continue;
}
final PsiElementVisitor visitor = tool.buildVisitor(problemsHolder, true);
assert !(visitor instanceof PsiRecursiveElementVisitor) : "The visitor returned from LocalInspectionTool.buildVisitor() must not be recursive. "+tool;
injectedPsi.accept(new PsiRecursiveElementWalkingVisitor() {
@Override public void visitElement(PsiElement element) {
final PsiElement[] elements = getElementsIntersectingRange(injectedPsi, 0, injectedPsi.getTextLength());
if (elements.length != 0) {
for (LocalInspectionTool tool : tools) {
if (host != null && InspectionManagerEx.inspectionResultSuppressed(host, tool)) {
continue;
}
final PsiElementVisitor visitor = tool.buildVisitor(problemsHolder, true);
assert !(visitor instanceof PsiRecursiveElementVisitor) : "The visitor returned from LocalInspectionTool.buildVisitor() must not be recursive. "+tool;
for (PsiElement element : elements) {
element.accept(visitor);
super.visitElement(element);
}
List<ProblemDescriptor> problems = problemsHolder.getResults();
if (problems != null && !problems.isEmpty()) {
InjectedPsiInspectionResult res = new InjectedPsiInspectionResult(tool, injectedPsi, new SmartList<ProblemDescriptor>(problems));
result.add(res);
}
});
List<ProblemDescriptor> problems = problemsHolder.getResults();
if (problems != null && !problems.isEmpty()) {
InjectedPsiInspectionResult res = new InjectedPsiInspectionResult(tool, injectedPsi, new SmartList<ProblemDescriptor>(problems));
result.add(res);
}
}
}
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.diagnostic.logging.LogConsoleBase">
<grid id="27dc6" binding="mySearchComponent" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="mySearchComponent" layout-manager="GridLayoutManager" row-count="1" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="213" height="28"/>
@@ -10,7 +10,7 @@
<children>
<component id="8b9ce" class="javax.swing.JComboBox" binding="myLogFilterCombo">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="100" height="-1"/>
</grid>
</constraints>
@@ -18,7 +18,7 @@
</component>
<grid id="c36b9" binding="myTextFilterWrapper" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -29,6 +29,14 @@
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="1e89b" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/DiagnosticBundle" key="log.console.filter.show.prefix"/>
</properties>
</component>
</children>
</grid>
</form>
@@ -181,7 +181,8 @@ public final class ConsoleViewImpl extends JPanel implements ConsoleView, Observ
}
};
private final CompositeFilter myMessageFilter;
private final CompositeFilter myPredefinedMessageFilter;
private final CompositeFilter myCustomFilter;
private ArrayList<String> myHistory = new ArrayList<String>();
private int myHistorySize = 20;
@@ -239,12 +240,11 @@ public final class ConsoleViewImpl extends JPanel implements ConsoleView, Observ
myProject = project;
myFileType = fileType;
myMessageFilter = new CompositeFilter(project);
final ConsoleFilterProvider[] filterProviders = Extensions.getExtensions(ConsoleFilterProvider.FILTER_PROVIDERS);
for (ConsoleFilterProvider filterProvider : filterProviders) {
final Filter[] defaultFilters = filterProvider.getDefaultFilters(project);
for (Filter filter : defaultFilters) {
addMessageFilter(filter);
myCustomFilter = new CompositeFilter(project);
myPredefinedMessageFilter = new CompositeFilter(project);
for (ConsoleFilterProvider filterProvider : Extensions.getExtensions(ConsoleFilterProvider.FILTER_PROVIDERS)) {
for (Filter filter : filterProvider.getDefaultFilters(project)) {
myPredefinedMessageFilter.addFilter(filter);
}
}
@@ -533,7 +533,7 @@ public final class ConsoleViewImpl extends JPanel implements ConsoleView, Observ
}
public void addMessageFilter(final Filter filter) {
myMessageFilter.addFilter(filter);
myCustomFilter.addFilter(filter);
}
public void printHyperlink(final String hyperlinkText, final HyperlinkInfo info) {
@@ -782,28 +782,29 @@ public final class ConsoleViewImpl extends JPanel implements ConsoleView, Observ
}
private void highlightHyperlinks(final int line1, final int line2){
if (myMessageFilter != null){
ApplicationManager.getApplication().assertIsDispatchThread();
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
final Document document = myEditor.getDocument();
final CharSequence chars = document.getCharsSequence();
final TextAttributes hyperlinkAttributes = getHyperlinkAttributes();
ApplicationManager.getApplication().assertIsDispatchThread();
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
final Document document = myEditor.getDocument();
final CharSequence chars = document.getCharsSequence();
final TextAttributes hyperlinkAttributes = getHyperlinkAttributes();
for(int line = line1; line <= line2; line++) {
if (line < 0) continue;
final int startOffset = document.getLineStartOffset(line);
int endOffset = document.getLineEndOffset(line);
if (endOffset < document.getTextLength()){
endOffset++; // add '\n'
}
final String text = chars.subSequence(startOffset, endOffset).toString();
final Filter.Result result = myMessageFilter.applyFilter(text, endOffset);
if (result != null){
final int highlightStartOffset = result.highlightStartOffset;
final int highlightEndOffset = result.highlightEndOffset;
final HyperlinkInfo hyperlinkInfo = result.hyperlinkInfo;
addHyperlink(highlightStartOffset, highlightEndOffset, result.highlightAttributes, hyperlinkInfo, hyperlinkAttributes);
}
for(int line = line1; line <= line2; line++) {
if (line < 0) continue;
final int startOffset = document.getLineStartOffset(line);
int endOffset = document.getLineEndOffset(line);
if (endOffset < document.getTextLength()){
endOffset++; // add '\n'
}
final String text = chars.subSequence(startOffset, endOffset).toString();
Filter.Result result = myCustomFilter.applyFilter(text, endOffset);
if (result == null) {
result = myPredefinedMessageFilter.applyFilter(text, endOffset);
}
if (result != null){
final int highlightStartOffset = result.highlightStartOffset;
final int highlightEndOffset = result.highlightEndOffset;
final HyperlinkInfo hyperlinkInfo = result.hyperlinkInfo;
addHyperlink(highlightStartOffset, highlightEndOffset, result.highlightAttributes, hyperlinkInfo, hyperlinkAttributes);
}
}
}
@@ -40,9 +40,8 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.LinkedHashSet;
import java.util.regex.Pattern;
public class ConflictsDialog extends DialogWrapper{
@@ -55,7 +54,7 @@ public class ConflictsDialog extends DialogWrapper{
public ConflictsDialog(Project project, MultiMap<PsiElement, String> conflictDescriptions) {
super(project, true);
myProject = project;
List<String> conflicts = new ArrayList<String>();
final LinkedHashSet<String> conflicts = new LinkedHashSet<String>();
for (String conflict : conflictDescriptions.values()) {
conflicts.add(conflict);
@@ -182,7 +181,8 @@ public class ConflictsDialog extends DialogWrapper{
}
private UsagePresentation getPresentation(final UsagePresentation usagePresentation, PsiElement element) {
final String conflictDescription = " (" + Pattern.compile("<[^<>]*>").matcher(StringUtil.join(myElementConflictDescription.get(element), "\n")).replaceAll("") + ")";
final Collection<String> elementConflicts = new LinkedHashSet<String>(myElementConflictDescription.get(element));
final String conflictDescription = " (" + Pattern.compile("<[^<>]*>").matcher(StringUtil.join(elementConflicts, "\n")).replaceAll("") + ")";
return new UsagePresentation() {
@NotNull
public TextChunk[] getText() {
@@ -207,7 +207,7 @@ public class ConflictsDialog extends DialogWrapper{
}
private class DescriptionOnlyUsage implements Usage {
private final String myConflictDescription = Pattern.compile("<[^<>]*>").matcher(StringUtil.join(myElementConflictDescription.get(null), "\n")).replaceAll("");
private final String myConflictDescription = Pattern.compile("<[^<>]*>").matcher(StringUtil.join(new LinkedHashSet<String>(myElementConflictDescription.get(null)), "\n")).replaceAll("");
@NotNull
public UsagePresentation getPresentation() {
@@ -1038,51 +1038,66 @@ public class FileBasedIndex implements ApplicationComponent {
}
}
// returns false if doc was not indexed because the file does not fit in scope
private boolean indexUnsavedDocument(final Document document, final ID<?, ?> requestedIndexId, Project project, GlobalSearchScope filter) throws StorageException {
final VirtualFile vFile = myFileDocumentManager.getFile(document);
if (!(vFile instanceof VirtualFileWithId) || !vFile.isValid()) {
return true;
}
if (filter != null && !filter.accept(vFile)) {
return false;
}
final PsiFile dominantContentFile = findDominantPsiForDocument(document, project);
DocumentContent content;
if (dominantContentFile != null && dominantContentFile.getModificationStamp() != document.getModificationStamp()) {
content = new PsiContent(document, dominantContentFile);
}
else {
content = new AuthenticContent(document);
}
final long currentDocStamp = content.getModificationStamp();
if (currentDocStamp != myLastIndexedDocStamps.getAndSet(document, requestedIndexId, currentDocStamp).longValue()) {
final FileContent newFc = new FileContent(vFile, content.getText(), vFile.getCharset());
if (dominantContentFile != null) {
dominantContentFile.putUserData(PsiFileImpl.BUILDING_STUB, true);
newFc.putUserData(PSI_FILE, dominantContentFile);
}
if (content instanceof AuthenticContent) {
newFc.putUserData(EDITOR_HIGHLIGHTER, document instanceof DocumentImpl
? ((DocumentImpl)document).getEditorHighlighterForCachesBuilding() : null);
}
if (getInputFilter(requestedIndexId).acceptInput(vFile)) {
newFc.putUserData(PROJECT, project);
final int inputId = Math.abs(getFileId(vFile));
getIndex(requestedIndexId).update(inputId, newFc);
}
if (dominantContentFile != null) {
dominantContentFile.putUserData(PsiFileImpl.BUILDING_STUB, null);
}
}
// returns false if doc was not indexed because the file does not fit in scope
private boolean indexUnsavedDocument(final Document document, final ID<?, ?> requestedIndexId, final Project project,
GlobalSearchScope filter) throws StorageException {
final VirtualFile vFile = myFileDocumentManager.getFile(document);
if (!(vFile instanceof VirtualFileWithId) || !vFile.isValid()) {
return true;
}
if (filter != null && !filter.accept(vFile)) {
return false;
}
final PsiFile dominantContentFile = findDominantPsiForDocument(document, project);
final DocumentContent content;
if (dominantContentFile != null && dominantContentFile.getModificationStamp() != document.getModificationStamp()) {
content = new PsiContent(document, dominantContentFile);
}
else {
content = new AuthenticContent(document);
}
final long currentDocStamp = content.getModificationStamp();
if (currentDocStamp != myLastIndexedDocStamps.getAndSet(document, requestedIndexId, currentDocStamp).longValue()) {
final Ref<StorageException> exRef = new Ref<StorageException>(null);
ProgressManager.getInstance().executeNonCancelableSection(new Runnable() {
public void run() {
try {
final FileContent newFc = new FileContent(vFile, content.getText(), vFile.getCharset());
if (dominantContentFile != null) {
dominantContentFile.putUserData(PsiFileImpl.BUILDING_STUB, true);
newFc.putUserData(PSI_FILE, dominantContentFile);
}
if (content instanceof AuthenticContent) {
newFc.putUserData(EDITOR_HIGHLIGHTER, document instanceof DocumentImpl
? ((DocumentImpl)document).getEditorHighlighterForCachesBuilding() : null);
}
if (getInputFilter(requestedIndexId).acceptInput(vFile)) {
newFc.putUserData(PROJECT, project);
final int inputId = Math.abs(getFileId(vFile));
getIndex(requestedIndexId).update(inputId, newFc);
}
if (dominantContentFile != null) {
dominantContentFile.putUserData(PsiFileImpl.BUILDING_STUB, null);
}
}
catch (StorageException e) {
exRef.set(e);
}
}
});
final StorageException storageException = exRef.get();
if (storageException != null) {
throw storageException;
}
}
return true;
}
public static final Key<PsiFile> PSI_FILE = new Key<PsiFile>("PSI for stubs");
public static final Key<EditorHighlighter> EDITOR_HIGHLIGHTER = new Key<EditorHighlighter>("Editor");
@@ -1257,7 +1272,21 @@ public class FileBasedIndex implements ApplicationComponent {
final UpdatableIndex<?, ?, FileContent> index = getIndex(indexId);
assert index != null;
index.update(inputId, currentFC);
final Ref<StorageException> exRef = new Ref<StorageException>(null);
ProgressManager.getInstance().executeNonCancelableSection(new Runnable() {
public void run() {
try {
index.update(inputId, currentFC);
}
catch (StorageException e) {
exRef.set(e);
}
}
});
final StorageException storageException = exRef.get();
if (storageException != null) {
throw storageException;
}
ApplicationManager.getApplication().runReadAction(new Runnable() {
public void run() {
if (file.isValid()) {
@@ -163,12 +163,14 @@ public class SimpleClasspathPanel extends JPanel {
list.scrollRectToVisible(cellRect);
}
private static Collection<Library> ensureApplicationLevel(final Library library, final Set<VirtualFile> existingFiles) {
private static Collection<Library> ensureApplicationLevel(final Library library, final Set<VirtualFile> existingFiles,
final Disposable parentDisposable) {
if (library.getTable() == null || !LibraryTablesRegistrar.APPLICATION_LEVEL.equals(library.getTable().getTableLevel())) {
final ArrayList<Library> result = new ArrayList<Library>();
for (VirtualFile file : library.getFiles(OrderRootType.CLASSES)) {
if (!existingFiles.add(file)) continue;
final Library newLibrary = LibraryTableImplUtil.createModuleLevelLibrary(null, null);
Disposer.register(parentDisposable, newLibrary);
final Library.ModifiableModel libModel = newLibrary.getModifiableModel();
libModel.addRoot(file, OrderRootType.CLASSES);
libModel.commit();
@@ -264,7 +266,7 @@ public class SimpleClasspathPanel extends JPanel {
final List<Library> libraries = dialog.getSelectedLibraries();
final ArrayList<Library> result = new ArrayList<Library>();
for (Library o : libraries) {
result.addAll(ensureApplicationLevel(o, existingFiles));
result.addAll(ensureApplicationLevel(o, existingFiles, myDisposable));
}
return result;
}
@@ -237,7 +237,7 @@ public class AbstractTreeUpdater implements Disposable, Activatable {
}
};
invokeLater(runnable);
myTreeBuilder.getReady(this).doWhenDone(runnable);
}
}
@@ -56,8 +56,9 @@ log.monitor.edit.aliases.title=Edit Log Files Aliases
log.monitor.edit.aliases.name=&Alias:
log.monitor.edit.aliases.location=&Log File Location:
log.monitor.edit.aliases.show.all.checkbox.title=&Show All Files Coverable By Pattern
log.console.filter.show.errors=Show errors only
log.console.filter.show.errors.and.warnings=Show errors and warnings
log.console.filter.show.all=Show all
log.console.filter.show.errors=errors
log.console.filter.show.errors.and.warnings=warnings
log.console.filter.show.all=all
title.submitting.error.report=Submitting error report
log.console.filter.show.errors.warnings.and.infos=Show errors, warnings and infos
log.console.filter.show.errors.warnings.and.infos=infos
log.console.filter.show.prefix=Show
@@ -101,7 +101,7 @@ public class ExpectedHighlightingData {
PsiFile file) {
myFile = file;
myText = document.getText();
highlightingTypes = new THashMap<String,ExpectedHighlightingSet>();
highlightingTypes = new LinkedHashMap<String,ExpectedHighlightingSet>();
highlightingTypes.put(ERROR_MARKER, new ExpectedHighlightingSet(HighlightInfoType.ERROR, HighlightSeverity.ERROR, false, true));
highlightingTypes.put(WARNING_MARKER, new ExpectedHighlightingSet(HighlightInfoType.WARNING, HighlightSeverity.WARNING, false, checkWarnings));
highlightingTypes.put(INFORMATION_MARKER, new ExpectedHighlightingSet(HighlightInfoType.INFO, HighlightSeverity.INFO, false, checkWeakWarnings));
@@ -185,10 +185,7 @@ public class ExpectedHighlightingData {
String text = document.getText();
final Set<String> markers = highlightingTypes.keySet();
String typesRegex = "";
for (String marker : markers) {
typesRegex += (typesRegex.length() == 0 ? "" : "|") + "(?:" + marker + ")";
}
String typesRegex = "(?:"+StringUtil.join(markers, ")|(?:")+")";
// er...
// any code then <marker> (with optional descr="...") then any code then </marker> then any code
@@ -196,7 +193,7 @@ public class ExpectedHighlightingData {
//"(.+?)</" + marker + ">).*";
Pattern p = Pattern.compile(pat, Pattern.DOTALL);
Out:
for (; ;) {
while (true) {
Matcher m = p.matcher(text);
if (!m.matches()) break;
int startOffset = m.start(1);
@@ -209,7 +206,7 @@ public class ExpectedHighlightingData {
startOffset = m.start(1);
expectedHighlightingSet = highlightingTypes.get(marker);
}
int pos=3;
int pos = 3;
@NonNls String descr = m.group(pos++);
if (descr == null) {
// no descr means any string by default
@@ -241,20 +238,19 @@ public class ExpectedHighlightingData {
final Matcher matcher2 = pat2.matcher(rest);
LOG.assertTrue(matcher2.matches(), "Cannot find closing </" + marker + ">");
content = matcher2.group(1);
endOffset = m.start(pos-1) + matcher2.start(2);
endOffset = m.start(pos - 1) + matcher2.start(2);
}
else {
// <XXX/>
content = "";
endOffset = m.start(pos-1);
endOffset = m.start(pos - 1);
}
document.replaceString(startOffset, endOffset, content);
TextAttributes forcedAttributes = null;
if (foregroundColor != null) {
forcedAttributes = new TextAttributes(Color.decode(foregroundColor), Color.decode(backgroundColor),
Color.decode(effectColor), EffectType.valueOf(effectType),
Integer.parseInt(fontType));
forcedAttributes = new TextAttributes(Color.decode(foregroundColor), Color.decode(backgroundColor), Color.decode(effectColor),
EffectType.valueOf(effectType), Integer.parseInt(fontType));
}
TextRange textRange = new TextRange(startOffset, startOffset + content.length());
@@ -273,9 +269,9 @@ public class ExpectedHighlightingData {
}
HighlightInfo highlightInfo = new HighlightInfo(forcedAttributes, type, textRange.getStartOffset(), textRange.getEndOffset(), descr,
descr, expectedHighlightingSet.severity, expectedHighlightingSet.endOfLine, null,
false);
HighlightInfo highlightInfo =
new HighlightInfo(forcedAttributes, type, textRange.getStartOffset(), textRange.getEndOffset(), descr, descr,
expectedHighlightingSet.severity, expectedHighlightingSet.endOfLine, null, false);
expectedHighlightingSet.infos.add(highlightInfo);
text = document.getText();
}
@@ -1133,7 +1133,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
List<IntentionAction> result = new ArrayList<IntentionAction>();
List<HighlightInfo> infos = DaemonCodeAnalyzerImpl.getFileLeveleHighlights(file.getProject(), file);
List<HighlightInfo> infos = DaemonCodeAnalyzerImpl.getFileLevelHighlights(file.getProject(), file);
for (HighlightInfo info : infos) {
for (Pair<HighlightInfo.IntentionActionDescriptor, TextRange> pair : info.quickFixActionRanges) {
HighlightInfo.IntentionActionDescriptor actionInGroup = pair.first;
@@ -864,12 +864,14 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
return myUsageSearcherFactory != null;
}
private void checkReadonlyUsages() {
private boolean checkReadonlyUsages() {
final Set<VirtualFile> readOnlyUsages = getReadOnlyUsagesFiles();
if (!readOnlyUsages.isEmpty()) {
ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(readOnlyUsages.toArray(new VirtualFile[readOnlyUsages.size()]));
return
!ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(readOnlyUsages.toArray(new VirtualFile[readOnlyUsages.size()])).hasReadonlyFiles();
}
return true;
}
private Set<Usage> getReadOnlyUsages() {
@@ -1268,7 +1270,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
}
public void run() {
checkReadonlyUsages();
if (!checkReadonlyUsages()) return;
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
if (myCannotMakeString != null && myChangesDetected) {
if (canPerformReRun() && allTargetsAreValid()) {
@@ -90,6 +90,7 @@ public class TestStateUpdater implements PacketConsumer {
state.setMagitude(myInstanceMagnitude);
state.initializeFrom(reader);
testProxy.setState(state);
complete(testProxy);
}
public void setMagnitude(final int magnitude) {
@@ -105,21 +106,25 @@ public class TestStateUpdater implements PacketConsumer {
}
testProxy.setState(state);
testProxy.setStatistics(new Statistics(reader));
final int magnitude = state.getMagnitude();
complete(testProxy);
}
}
TestProxy parent = testProxy.getParent();
TestProxy child = testProxy;
while (parent != null) {
final List<TestProxy> children = parent.getChildren();
final TestState parentState = parent.getState();
LOG.assertTrue(parentState instanceof SuiteState);
if (child.equals(children.get(children.size() - 1))) {
((SuiteState)parentState).setRunning(false);
}
((SuiteState)parentState).updateMagnitude(magnitude);
child = parent;
parent = parent.getParent();
private static void complete(TestProxy testProxy) {
final int magnitude = testProxy.getState().getMagnitude();
TestProxy parent = testProxy.getParent();
TestProxy child = testProxy;
while (parent != null) {
final List<TestProxy> children = parent.getChildren();
final TestState parentState = parent.getState();
LOG.assertTrue(parentState instanceof SuiteState);
if (child.equals(children.get(children.size() - 1))) {
((SuiteState)parentState).setRunning(false);
}
((SuiteState)parentState).updateMagnitude(magnitude);
child = parent;
parent = parent.getParent();
}
}
@@ -19,7 +19,6 @@ import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
import static com.intellij.openapi.util.text.StringUtil.isEmptyOrSpaces;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.impl.source.parsing.xml.XmlBuilder;
@@ -53,6 +52,8 @@ import java.io.File;
import java.io.IOException;
import java.util.*;
import static com.intellij.openapi.util.text.StringUtil.isEmptyOrSpaces;
public class MavenProjectReader {
private static final String UNKNOWN = MavenId.UNKNOWN_VALUE;
@@ -453,8 +454,8 @@ public class MavenProjectReader {
}
private boolean resolveInheritance(final MavenGeneralSettings generalSettings,
Model model,
VirtualFile file,
final Model model,
final VirtualFile file,
final List<String> activeProfiles,
final Set<VirtualFile> recursionGuard,
final MavenProjectReaderProjectLocator locator) {
@@ -528,7 +529,7 @@ public class MavenProjectReader {
Properties context = MavenEmbedderFactory.collectSystemProperties();
ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setExecutionProperties(context);
model = interpolator.interpolate(model, basedir, config, false);
model = interpolator.interpolate(ModelUtils.cloneModel(model), basedir, config, false);
}
catch (ModelInterpolationException e) {
MavenLog.LOG.warn(e);
@@ -297,6 +297,52 @@ public class DependenciesImportingTest extends MavenImportingTestCase {
assertModuleModuleDeps("m1", "m2");
}
public void testInterModuleDependenciesIfThereArePropertiesInArtifactHeaderDefinedInParent() throws Exception {
createProjectPom("<groupId>${groupProp}</groupId>" +
"<artifactId>parent</artifactId>" +
"<version>${versionProp}</version>" +
"<packaging>pom</packaging>" +
"<properties>" +
" <groupProp>test</groupProp>" +
" <versionProp>1</versionProp>" +
"</properties>" +
"<modules>" +
" <module>m1</module>" +
" <module>m2</module>" +
"</modules>");
createModulePom("m1",
"<parent>" +
" <groupId>${groupProp}</groupId>" +
" <artifactId>parent</artifactId>" +
" <version>${versionProp}</version>" +
"</parent>" +
"<artifactId>m1</artifactId>" +
"<dependencies>" +
" <dependency>" +
" <groupId>${groupProp}</groupId>" +
" <artifactId>m2</artifactId>" +
" <version>${versionProp}</version>" +
" </dependency>" +
"</dependencies>");
createModulePom("m2",
"<parent>" +
" <groupId>${groupProp}</groupId>" +
" <artifactId>parent</artifactId>" +
" <version>${versionProp}</version>" +
"</parent>" +
"<artifactId>m2</artifactId>");
importProject();
assertModules("parent", "m1", "m2");
assertModuleModuleDeps("m1", "m2");
}
public void testDependencyOnSelf() throws Exception {
importProject("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
@@ -32,6 +32,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.UsefulTestCase;
import com.intellij.testFramework.fixtures.IdeaProjectTestFixture;
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
import org.intellij.lang.annotations.Language;
import org.jetbrains.idea.maven.embedder.MavenConsole;
import org.jetbrains.idea.maven.project.*;
import org.jetbrains.idea.maven.utils.MavenProgressIndicator;
@@ -737,6 +737,28 @@ public class MavenProjectReaderTest extends MavenTestCase {
assertEquals("value", p.getName());
}
public void testPropertiesFromParentInParentSection() throws Exception {
createProjectPom("<groupId>${groupProp}</groupId>" +
"<artifactId>parent</artifactId>" +
"<version>${versionProp}</version>" +
"<properties>" +
" <groupProp>test</groupProp>" +
" <versionProp>1</versionProp>" +
"</properties>");
VirtualFile module = createModulePom("module",
"<parent>" +
" <groupId>${groupProp}</groupId>" +
" <artifactId>parent</artifactId>" +
" <version>${versionProp}</version>" +
"</parent>" +
"<artifactId>module</artifactId>");
org.apache.maven.project.MavenProject p = readProject(module);
assertEquals("test:module:1", p.getGroupId() + ":" + p.getArtifactId() + ":" + p.getVersion());
}
public void testInheritingSettingsFromParentAndAlignCorrectly() throws Exception {
createProjectPom("<groupId>test</groupId>" +
"<artifactId>parent</artifactId>" +
@@ -30,11 +30,11 @@ import java.util.List;
*/
public enum ResourceRelevance {
MAPPED,
SOURCE,
LIBRARY,
NONE,
STANDARD,
NONE;
LIBRARY,
SOURCE,
MAPPED;
public static ResourceRelevance getRelevance(VirtualFile file, Module module, ProjectFileIndex fileIndex) {
Module moduleForFile = fileIndex.getModuleForFile(file);