mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -137,6 +137,10 @@ public class CompileContextExProxy implements CompileContextEx {
|
||||
return myDelegate.isMake();
|
||||
}
|
||||
|
||||
public boolean isAnnotationProcessorsEnabled() {
|
||||
return myDelegate.isAnnotationProcessorsEnabled();
|
||||
}
|
||||
|
||||
public boolean isRebuild() {
|
||||
return myDelegate.isRebuild();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
package com.intellij.compiler.impl;
|
||||
|
||||
import com.intellij.compiler.CompilerConfiguration;
|
||||
import com.intellij.compiler.CompilerMessageImpl;
|
||||
import com.intellij.compiler.make.DependencyCache;
|
||||
import com.intellij.compiler.progress.CompilerTask;
|
||||
@@ -61,6 +62,7 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
|
||||
private final DependencyCache myDependencyCache;
|
||||
private final boolean myMake;
|
||||
private final boolean myIsRebuild;
|
||||
private final boolean myIsAnnotationProcessorsEnabled;
|
||||
private boolean myRebuildRequested = false;
|
||||
private String myRebuildReason;
|
||||
private final Map<VirtualFile, Module> myRootToModuleMap = new HashMap<VirtualFile, Module>();
|
||||
@@ -86,6 +88,7 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
|
||||
myStartCompilationStamp = System.currentTimeMillis();
|
||||
myProjectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
myProjectCompileScope = new ProjectCompileScope(myProject);
|
||||
myIsAnnotationProcessorsEnabled = CompilerConfiguration.getInstance(project).isAnnotationProcessorsEnabled();
|
||||
|
||||
if (compilerSession != null) {
|
||||
compilerSession.setContentIdKey(compileScope.getUserData(CompilerManager.CONTENT_ID_KEY));
|
||||
@@ -418,6 +421,10 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
|
||||
return myIsRebuild;
|
||||
}
|
||||
|
||||
public boolean isAnnotationProcessorsEnabled() {
|
||||
return myIsAnnotationProcessorsEnabled;
|
||||
}
|
||||
|
||||
public void addScope(final CompileScope additionalScope) {
|
||||
myCompileScope = new CompositeScope(myCompileScope, additionalScope);
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ public class CompileDriver {
|
||||
task.start(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
myAllOutputDirectories = getAllOutputDirectories();
|
||||
myAllOutputDirectories = getAllOutputDirectories(compileContext);
|
||||
// need this for updating zip archives experiment, uncomment if the feature is turned on
|
||||
//myOutputFinder = new OutputPathFinder(myAllOutputDirectories);
|
||||
status.set(doCompile(compileContext, false, false, false, true));
|
||||
@@ -500,7 +500,7 @@ public class CompileDriver {
|
||||
return;
|
||||
}
|
||||
|
||||
myAllOutputDirectories = getAllOutputDirectories();
|
||||
myAllOutputDirectories = getAllOutputDirectories(compileContext);
|
||||
// need this for updating zip archives experiment, uncomment if the feature is turned on
|
||||
//myOutputFinder = new OutputPathFinder(myAllOutputDirectories);
|
||||
status = doCompile(compileContext, isRebuild, forceCompile, trackDependencies, false);
|
||||
@@ -1388,7 +1388,7 @@ public class CompileDriver {
|
||||
return isEmpty;
|
||||
}
|
||||
|
||||
private Set<File> getAllOutputDirectories() {
|
||||
private Set<File> getAllOutputDirectories(CompileContext context) {
|
||||
final Set<File> outputDirs = new OrderedSet<File>((TObjectHashingStrategy<File>)TObjectHashingStrategy.CANONICAL);
|
||||
final Module[] modules = ModuleManager.getInstance(myProject).getModules();
|
||||
for (final String path : CompilerPathsEx.getOutputPaths(modules)) {
|
||||
@@ -1399,7 +1399,7 @@ public class CompileDriver {
|
||||
outputDirs.add(new File(CompilerPaths.getGenerationOutputPath(pair.getFirst(), pair.getSecond(), true)));
|
||||
}
|
||||
final CompilerConfiguration config = CompilerConfiguration.getInstance(myProject);
|
||||
if (config.isAnnotationProcessorsEnabled()) {
|
||||
if (context.isAnnotationProcessorsEnabled()) {
|
||||
for (Module module : modules) {
|
||||
if (config.isAnnotationProcessingEnabled(module)) {
|
||||
final String path = CompilerPaths.getAnnotationProcessorsGenerationPath(module);
|
||||
|
||||
+3
-3
@@ -60,14 +60,14 @@ public class AnnotationProcessingCompiler implements TranslatingCompiler{
|
||||
}
|
||||
|
||||
public boolean isCompilableFile(VirtualFile file, CompileContext context) {
|
||||
if (!myConfig.isAnnotationProcessorsEnabled()) {
|
||||
if (!context.isAnnotationProcessorsEnabled()) {
|
||||
return false;
|
||||
}
|
||||
return file.getFileType() == StdFileTypes.JAVA && !isExcludedFromAnnotationProcessing(file, context);
|
||||
}
|
||||
|
||||
public void compile(final CompileContext context, final Chunk<Module> moduleChunk, final VirtualFile[] files, OutputSink sink) {
|
||||
if (!myConfig.isAnnotationProcessorsEnabled()) {
|
||||
if (!context.isAnnotationProcessorsEnabled()) {
|
||||
return;
|
||||
}
|
||||
final LocalFileSystem lfs = LocalFileSystem.getInstance();
|
||||
@@ -117,7 +117,7 @@ public class AnnotationProcessingCompiler implements TranslatingCompiler{
|
||||
private boolean isExcludedFromAnnotationProcessing(VirtualFile file, CompileContext context) {
|
||||
final Module module = context.getModuleByFile(file);
|
||||
if (module != null) {
|
||||
if (!myConfig.isAnnotationProcessingEnabled(module)) {
|
||||
if (!context.isAnnotationProcessorsEnabled()) {
|
||||
return true;
|
||||
}
|
||||
final String path = CompilerPaths.getAnnotationProcessorsGenerationPath(module);
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ public class CompilerAPICompiler implements BackendCompiler {
|
||||
List<String> commandLine = new ArrayList<String>();
|
||||
JavacSettings javacSettings = CompilerAPIConfiguration.getSettings(myProject, CompilerAPIConfiguration.class);
|
||||
final List<String> additionalOptions =
|
||||
JavacCompiler.addAdditionalSettings(commandLine, javacSettings, false, 6, myProject);
|
||||
JavacCompiler.addAdditionalSettings(commandLine, javacSettings, false, 6, myProject, compileContext.isAnnotationProcessorsEnabled());
|
||||
|
||||
JavacCompiler.addCommandLineOptions(chunk, commandLine, outputDir, chunk.getJdk(), false,false, null, false, false, false);
|
||||
commandLine.addAll(additionalOptions);
|
||||
|
||||
+9
-7
@@ -167,7 +167,7 @@ public class JavacCompiler extends ExternalCompiler {
|
||||
public String[] compute() {
|
||||
try {
|
||||
final List<String> commandLine = new ArrayList<String>();
|
||||
createStartupCommand(chunk, commandLine, outputPath, JavacSettings.getInstance(myProject));
|
||||
createStartupCommand(chunk, commandLine, outputPath, JavacSettings.getInstance(myProject), context.isAnnotationProcessorsEnabled());
|
||||
return ArrayUtil.toStringArray(commandLine);
|
||||
}
|
||||
catch (IOException e) {
|
||||
@@ -186,7 +186,7 @@ public class JavacCompiler extends ExternalCompiler {
|
||||
}
|
||||
|
||||
private void createStartupCommand(final ModuleChunk chunk, @NonNls final List<String> commandLine, final String outputPath,
|
||||
JavacSettings javacSettings) throws IOException {
|
||||
JavacSettings javacSettings, final boolean annotationProcessorsEnabled) throws IOException {
|
||||
final Sdk jdk = getJdkForStartupCommand(chunk);
|
||||
final String versionString = jdk.getVersionString();
|
||||
if (versionString == null || "".equals(versionString) || !(jdk.getSdkType() instanceof JavaSdkType)) {
|
||||
@@ -220,7 +220,7 @@ public class JavacCompiler extends ExternalCompiler {
|
||||
}
|
||||
|
||||
final List<String> additionalOptions =
|
||||
addAdditionalSettings(commandLine, javacSettings, myAnnotationProcessorMode, versionIndex, myProject);
|
||||
addAdditionalSettings(commandLine, javacSettings, myAnnotationProcessorMode, versionIndex, myProject, annotationProcessorsEnabled);
|
||||
|
||||
CompilerUtil.addLocaleOptions(commandLine, false);
|
||||
|
||||
@@ -281,7 +281,7 @@ public class JavacCompiler extends ExternalCompiler {
|
||||
}
|
||||
|
||||
public static List<String> addAdditionalSettings(List<String> commandLine, JavacSettings javacSettings, boolean isAnnotationProcessing,
|
||||
int versionIndex, Project project) {
|
||||
int versionIndex, Project project, final boolean annotationProcessorsEnabled) {
|
||||
final List<String> additionalOptions = new ArrayList<String>();
|
||||
StringTokenizer tokenizer = new StringTokenizer(javacSettings.getOptionsString(project), " ");
|
||||
if (versionIndex < 6) {
|
||||
@@ -319,9 +319,11 @@ public class JavacCompiler extends ExternalCompiler {
|
||||
}
|
||||
else {
|
||||
if (versionIndex > 5) {
|
||||
// Unless explicitly specified by user, disable annotation processing by default for 'java compilation' mode
|
||||
// This is needed to suppress unwanted side-effects from auto-discovered processors from compilation classpath
|
||||
additionalOptions.add("-proc:none");
|
||||
if (annotationProcessorsEnabled) {
|
||||
// Unless explicitly specified by user, disable annotation processing by default for 'java compilation' mode
|
||||
// This is needed to suppress unwanted side-effects from auto-discovered processors from compilation classpath
|
||||
additionalOptions.add("-proc:none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,4 +150,6 @@ public interface CompileContext extends UserDataHolder {
|
||||
boolean isRebuild();
|
||||
|
||||
Project getProject();
|
||||
|
||||
boolean isAnnotationProcessorsEnabled();
|
||||
}
|
||||
|
||||
@@ -80,6 +80,10 @@ public class DummyCompileContext implements CompileContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isAnnotationProcessorsEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public VirtualFile[] getSourceRoots(Module module) {
|
||||
return VirtualFile.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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 com.intellij.openapi.projectRoots.ui;
|
||||
|
||||
import com.intellij.openapi.roots.libraries.doc.DocUrlChooser;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* Note: for languages other than Java use com.intellij.openapi.roots.libraries.doc.DocUrlChooser.
|
||||
* @author MYakovlev
|
||||
* Date: Oct 29, 2002
|
||||
* Time: 8:47:43 PM
|
||||
*/
|
||||
public class Util{
|
||||
|
||||
@Nullable
|
||||
public static VirtualFile showSpecifyJavadocUrlDialog(JComponent parent) {
|
||||
return showSpecifyJavadocUrlDialog(parent, "");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static VirtualFile showSpecifyJavadocUrlDialog(JComponent parent, String initialValue){
|
||||
return DocUrlChooser.showSpecifyDocUrlDialog(parent, initialValue);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
@@ -35,6 +36,7 @@ import java.util.*;
|
||||
* @author peter
|
||||
*/
|
||||
public abstract class NonClasspathClassFinder extends PsiElementFinder {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.NonClasspathClassFinder");
|
||||
protected final Project myProject;
|
||||
|
||||
public NonClasspathClassFinder(Project project) {
|
||||
@@ -53,7 +55,8 @@ public abstract class NonClasspathClassFinder extends PsiElementFinder {
|
||||
final VirtualFile classFile = classRoot.findFileByRelativePath(qualifiedName.replace('.', '/') + ".class");
|
||||
if (classFile != null) {
|
||||
if (!classFile.isValid()) {
|
||||
throw new AssertionError("Invalid child of valid parent: " + classFile.getPath() + "; " + classRoot.isValid() + " path=" + classRoot.getPath());
|
||||
LOG.error("Invalid child of valid parent: " + classFile.getPath() + "; " + classRoot.isValid() + " path=" + classRoot.getPath());
|
||||
return null;
|
||||
}
|
||||
final PsiFile file = PsiManager.getInstance(myProject).findFile(classFile);
|
||||
if (file instanceof PsiClassOwner) {
|
||||
|
||||
@@ -1233,7 +1233,12 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
varDeclarationAlignmentStrategy = AlignmentStrategy.createAlignmentPerTypeStrategy(VAR_DECLARATION_ELEMENT_TYPES_TO_ALIGN, true);
|
||||
}
|
||||
final boolean rBrace = isRBrace(child);
|
||||
final Indent childIndent = rBrace ? Indent.getNoneIndent() : getCodeBlockInternalIndent(childrenIndent);
|
||||
Indent childIndent = rBrace ? Indent.getNoneIndent() : getCodeBlockInternalIndent(childrenIndent);
|
||||
if (!rBrace && child.getElementType() == JavaElementType.CODE_BLOCK
|
||||
&& (getBraceStyle() == CodeStyleSettings.NEXT_LINE_SHIFTED || getBraceStyle() == CodeStyleSettings.NEXT_LINE_SHIFTED2))
|
||||
{
|
||||
childIndent = Indent.getNormalIndent();
|
||||
}
|
||||
AlignmentStrategy alignmentStrategyToUse = ALIGN_IN_COLUMNS_ELEMENT_TYPES.contains(child.getElementType())
|
||||
? varDeclarationAlignmentStrategy : AlignmentStrategy.getNullStrategy();
|
||||
child = processChild(localResult, child, alignmentStrategyToUse, childWrap, childIndent);
|
||||
@@ -1270,7 +1275,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
|
||||
}
|
||||
|
||||
private SyntheticCodeBlock createCodeBlockBlock(final ArrayList<Block> localResult, final Indent indent, final int childrenIndent) {
|
||||
public SyntheticCodeBlock createCodeBlockBlock(final ArrayList<Block> localResult, final Indent indent, final int childrenIndent) {
|
||||
final SyntheticCodeBlock result = new SyntheticCodeBlock(localResult, null, getSettings(), indent, null);
|
||||
result.setChildAttributes(new ChildAttributes(getCodeBlockInternalIndent(childrenIndent), null));
|
||||
return result;
|
||||
|
||||
+35
@@ -17,6 +17,7 @@ package com.intellij.psi.formatter.java;
|
||||
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
|
||||
/**
|
||||
@@ -272,4 +273,38 @@ public class JavaFormatterIndentationTest extends AbstractJavaFormatterTest {
|
||||
"}"
|
||||
);
|
||||
}
|
||||
|
||||
public void testBracesShiftedOnNextLineOnMethodWithJavadoc() throws Exception {
|
||||
// Inspired by IDEA-62997
|
||||
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
|
||||
|
||||
String precededByJavadoc =
|
||||
"/**\n" +
|
||||
" * test\n" +
|
||||
" */\n" +
|
||||
"public int getFoo()\n" +
|
||||
" {\n" +
|
||||
" return foo;\n" +
|
||||
" }";
|
||||
|
||||
String precededBySingleLineComment =
|
||||
"// test\n" +
|
||||
"public int getFoo()\n" +
|
||||
" {\n" +
|
||||
" return foo;\n" +
|
||||
" }";
|
||||
|
||||
String precededByMultiLineComment =
|
||||
"/*\n" +
|
||||
"test\n" +
|
||||
"*/\n" +
|
||||
"public int getFoo()\n" +
|
||||
" {\n" +
|
||||
" return foo;\n" +
|
||||
" }";
|
||||
|
||||
doClassTest(precededByJavadoc, precededByJavadoc);
|
||||
doClassTest(precededBySingleLineComment, precededBySingleLineComment);
|
||||
doClassTest(precededByMultiLineComment, precededByMultiLineComment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2010 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.
|
||||
@@ -17,6 +17,7 @@ package com.intellij.psi;
|
||||
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a single element-value pair of an annotation parameter list.
|
||||
@@ -36,6 +37,7 @@ public interface PsiNameValuePair extends PsiElement {
|
||||
*
|
||||
* @return the name identifier, or null if the annotation declaration is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiIdentifier getNameIdentifier();
|
||||
|
||||
/**
|
||||
@@ -43,7 +45,7 @@ public interface PsiNameValuePair extends PsiElement {
|
||||
*
|
||||
* @return the name, or null if the annotation declaration is incomplete.
|
||||
*/
|
||||
@NonNls
|
||||
@Nullable @NonNls
|
||||
String getName();
|
||||
|
||||
/**
|
||||
@@ -51,6 +53,7 @@ public interface PsiNameValuePair extends PsiElement {
|
||||
*
|
||||
* @return the value for the element.
|
||||
*/
|
||||
@Nullable
|
||||
PsiAnnotationMemberValue getValue();
|
||||
|
||||
@NotNull PsiAnnotationMemberValue setValue(@NotNull PsiAnnotationMemberValue newValue);
|
||||
|
||||
@@ -21,14 +21,16 @@ package com.intellij.lang.annotation;
|
||||
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AnnotationSession extends UserDataHolderBase {
|
||||
private final PsiFile myFile;
|
||||
|
||||
public AnnotationSession(PsiFile file) {
|
||||
public AnnotationSession(@NotNull PsiFile file) {
|
||||
myFile = file;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiFile getFile() {
|
||||
return myFile;
|
||||
}
|
||||
|
||||
@@ -306,7 +306,10 @@ public class GeneralCodeStylePanel extends CodeStyleAbstractPanel {
|
||||
}
|
||||
else {
|
||||
FileType type = entry.getKey();
|
||||
editor.reset(settings, settings.getAdditionalIndentOptions(type));
|
||||
CodeStyleSettings.IndentOptions additionalIndentOptions = settings.getAdditionalIndentOptions(type);
|
||||
if (additionalIndentOptions != null) {
|
||||
editor.reset(settings, additionalIndentOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.RangeMarker;
|
||||
import com.intellij.openapi.editor.ex.RangeMarkerEx;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -46,7 +45,7 @@ public class CodeInsightUtilBase {
|
||||
private CodeInsightUtilBase() {
|
||||
}
|
||||
|
||||
static <T extends PsiElement> T findElementInRange(final PsiFile file,
|
||||
public static <T extends PsiElement> T findElementInRange(final PsiFile file,
|
||||
int startOffset,
|
||||
int endOffset,
|
||||
final Class<T> klass,
|
||||
|
||||
+40
-1
@@ -21,8 +21,11 @@ import com.intellij.lang.annotation.Annotation;
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.lang.annotation.AnnotationSession;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.xml.util.XmlStringUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -32,13 +35,22 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author max
|
||||
*/
|
||||
public class AnnotationHolderImpl extends SmartList<Annotation> implements AnnotationHolder {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.AnnotationHolderImpl");
|
||||
private AnnotationSession myAnnotationSession;
|
||||
|
||||
AnnotationHolderImpl() {
|
||||
}
|
||||
public AnnotationHolderImpl(@NotNull AnnotationSession session) {
|
||||
myAnnotationSession = session;
|
||||
}
|
||||
|
||||
public Annotation createErrorAnnotation(@NotNull PsiElement elt, String message) {
|
||||
assertMyFile(elt);
|
||||
return createAnnotation(elt.getTextRange(), HighlightSeverity.ERROR, message);
|
||||
}
|
||||
|
||||
public Annotation createErrorAnnotation(@NotNull ASTNode node, String message) {
|
||||
assertMyFile(node.getPsi());
|
||||
return createAnnotation(node.getTextRange(), HighlightSeverity.ERROR, message);
|
||||
}
|
||||
|
||||
@@ -47,10 +59,12 @@ public class AnnotationHolderImpl extends SmartList<Annotation> implements Annot
|
||||
}
|
||||
|
||||
public Annotation createWarningAnnotation(@NotNull PsiElement elt, String message) {
|
||||
assertMyFile(elt);
|
||||
return createAnnotation(elt.getTextRange(), HighlightSeverity.WARNING, message);
|
||||
}
|
||||
|
||||
public Annotation createWarningAnnotation(@NotNull ASTNode node, String message) {
|
||||
assertMyFile(node.getPsi());
|
||||
return createAnnotation(node.getTextRange(), HighlightSeverity.WARNING, message);
|
||||
}
|
||||
|
||||
@@ -59,10 +73,12 @@ public class AnnotationHolderImpl extends SmartList<Annotation> implements Annot
|
||||
}
|
||||
|
||||
public Annotation createInformationAnnotation(@NotNull PsiElement elt, String message) {
|
||||
assertMyFile(elt);
|
||||
return createAnnotation(elt.getTextRange(), HighlightSeverity.INFO, message);
|
||||
}
|
||||
|
||||
public Annotation createInformationAnnotation(@NotNull ASTNode node, String message) {
|
||||
assertMyFile(node.getPsi());
|
||||
return createAnnotation(node.getTextRange(), HighlightSeverity.INFO, message);
|
||||
}
|
||||
|
||||
@@ -71,13 +87,29 @@ public class AnnotationHolderImpl extends SmartList<Annotation> implements Annot
|
||||
}
|
||||
|
||||
public Annotation createInfoAnnotation(@NotNull PsiElement elt, String message) {
|
||||
assertMyFile(elt);
|
||||
return createAnnotation(elt.getTextRange(), HighlightSeverity.INFORMATION, message);
|
||||
}
|
||||
|
||||
public Annotation createInfoAnnotation(@NotNull ASTNode node, String message) {
|
||||
assertMyFile(node.getPsi());
|
||||
return createAnnotation(node.getTextRange(), HighlightSeverity.INFORMATION, message);
|
||||
}
|
||||
|
||||
private void assertMyFile(PsiElement node) {
|
||||
if (node == null) return;
|
||||
PsiFile myFile = myAnnotationSession.getFile();
|
||||
PsiFile containingFile = node.getContainingFile();
|
||||
LOG.assertTrue(containingFile != null, node);
|
||||
VirtualFile containingVFile = containingFile.getVirtualFile();
|
||||
VirtualFile myVFile = myFile.getVirtualFile();
|
||||
if (containingVFile != myVFile) {
|
||||
LOG.error(
|
||||
"Annotation must be registered for an element inside '" + myFile + "' which is in '" + myVFile + "'.\n" +
|
||||
"Element passed: '" + node + "' is inside the '" + containingFile + "' which is in '" + containingVFile + "'");
|
||||
}
|
||||
}
|
||||
|
||||
public Annotation createInfoAnnotation(@NotNull TextRange range, String message) {
|
||||
return createAnnotation(range, HighlightSeverity.INFORMATION, message);
|
||||
}
|
||||
@@ -96,12 +128,19 @@ public class AnnotationHolderImpl extends SmartList<Annotation> implements Annot
|
||||
return !isEmpty();
|
||||
}
|
||||
|
||||
public void setSession(AnnotationSession annotationSession) {
|
||||
void setSession(@NotNull AnnotationSession annotationSession) {
|
||||
myAnnotationSession = annotationSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull("it's not null during highlighting")
|
||||
public AnnotationSession getCurrentAnnotationSession() {
|
||||
return myAnnotationSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
super.clear();
|
||||
myAnnotationSession = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ class DaemonListeners implements Disposable {
|
||||
if (document == null) return true;
|
||||
if (project != null && project != myProject) return false;
|
||||
// cached is essential here since we do not want to create PSI file in alien project
|
||||
PsiFile psiFile = PsiDocumentManager.getInstance(project == null ? myProject : project).getPsiFile(document);
|
||||
PsiFile psiFile = PsiDocumentManager.getInstance(project == null ? myProject : project).getCachedPsiFile(document);
|
||||
return psiFile != null;
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -14,9 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.codeInsight.daemon.impl.analysis;
|
||||
package com.intellij.codeInsight.daemon.impl;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.*;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.ErrorQuickFixProvider;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightInfoHolder;
|
||||
import com.intellij.codeInsight.highlighting.HighlightErrorFilter;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LanguageAnnotators;
|
||||
@@ -109,7 +110,7 @@ public class DefaultHighlightVisitor implements HighlightVisitor, DumbAware {
|
||||
});
|
||||
}
|
||||
|
||||
private void runAnnotators(final PsiElement element, final HighlightInfoHolder holder, final AnnotationHolderImpl annotationHolder) {
|
||||
private void runAnnotators(PsiElement element, HighlightInfoHolder holder, AnnotationHolderImpl annotationHolder) {
|
||||
List<Annotator> annotators = cachedAnnotators.get(element.getLanguage());
|
||||
if (annotators.isEmpty()) return;
|
||||
final boolean dumb = myDumbService.isDumb();
|
||||
@@ -129,9 +130,8 @@ public class DefaultHighlightVisitor implements HighlightVisitor, DumbAware {
|
||||
for (Annotation annotation : annotationHolder) {
|
||||
holder.add(HighlightInfo.fromAnnotation(annotation));
|
||||
}
|
||||
annotationHolder.clear();
|
||||
}
|
||||
annotationHolder.setSession(null);
|
||||
annotationHolder.clear();
|
||||
}
|
||||
|
||||
private void visitErrorElement(final PsiErrorElement element, HighlightInfoHolder myHolder) {
|
||||
@@ -22,6 +22,7 @@ import com.intellij.codeInsight.daemon.impl.analysis.HighlightLevelUtil;
|
||||
import com.intellij.lang.ExternalLanguageAnnotators;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.annotation.Annotation;
|
||||
import com.intellij.lang.annotation.AnnotationSession;
|
||||
import com.intellij.lang.annotation.ExternalAnnotator;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
@@ -50,7 +51,7 @@ public class ExternalToolPass extends TextEditorHighlightingPass {
|
||||
myFile = file;
|
||||
myStartOffset = startOffset;
|
||||
myEndOffset = endOffset;
|
||||
myAnnotationHolder = new AnnotationHolderImpl();
|
||||
myAnnotationHolder = new AnnotationHolderImpl(new AnnotationSession(file));
|
||||
}
|
||||
|
||||
public void doCollectInformation(ProgressIndicator progress) {
|
||||
|
||||
+1
@@ -58,6 +58,7 @@ public class HighlightInfoHolder {
|
||||
myAnnotationSession = new AnnotationSession(contextFile);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public AnnotationSession getAnnotationSession() {
|
||||
return myAnnotationSession;
|
||||
}
|
||||
|
||||
@@ -23,10 +23,7 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInspection.ex.JobDescriptor;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.LanguageAnnotators;
|
||||
import com.intellij.lang.annotation.Annotation;
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.lang.annotation.Annotator;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.lang.annotation.*;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -87,18 +84,30 @@ public class AnnotatorBasedInspection extends GlobalInspectionTool {
|
||||
return "Annotator";
|
||||
}
|
||||
|
||||
private static class MyPsiRecursiveElementVisitor extends PsiRecursiveElementVisitor
|
||||
implements PsiLanguageInjectionHost.InjectedPsiVisitor {
|
||||
private final AnnotationHolder myHolder;
|
||||
private static class MyPsiRecursiveElementVisitor extends PsiRecursiveElementVisitor implements PsiLanguageInjectionHost.InjectedPsiVisitor {
|
||||
private AnnotationHolderImpl myHolder;
|
||||
private List<Annotator> annotators;
|
||||
private PsiFile myFile;
|
||||
private final InspectionManager myManager;
|
||||
private final GlobalInspectionContext myGlobalContext;
|
||||
private final ProblemDescriptionsProcessor myProblemDescriptionsProcessor;
|
||||
|
||||
public MyPsiRecursiveElementVisitor(final InspectionManager manager,
|
||||
final GlobalInspectionContext globalContext,
|
||||
final ProblemDescriptionsProcessor problemDescriptionsProcessor) {
|
||||
myManager = manager;
|
||||
myGlobalContext = globalContext;
|
||||
myHolder = new AnnotationHolderImpl() {
|
||||
myProblemDescriptionsProcessor = problemDescriptionsProcessor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitFile(PsiFile file) {
|
||||
myFile = file;
|
||||
final VirtualFile virtualFile = myFile.getVirtualFile();
|
||||
if (virtualFile != null) {
|
||||
myGlobalContext.incrementJobDoneAmount(ANNOTATOR, ProjectUtil.calcRelativeToProjectPath(virtualFile, myFile.getProject()));
|
||||
}
|
||||
myHolder = new AnnotationHolderImpl(new AnnotationSession(file)) {
|
||||
@Override
|
||||
public Annotation createErrorAnnotation(@NotNull PsiElement elt, String message) {
|
||||
return createProblem(elt, message, ProblemHighlightType.ERROR, HighlightSeverity.ERROR, null);
|
||||
@@ -125,7 +134,7 @@ public class AnnotatorBasedInspection extends GlobalInspectionTool {
|
||||
HighlightSeverity severity,
|
||||
TextRange range) {
|
||||
GlobalInspectionUtil
|
||||
.createProblem(elt, message, problemHighlightType, range, manager, problemDescriptionsProcessor, globalContext);
|
||||
.createProblem(elt, message, problemHighlightType, range, myManager, myProblemDescriptionsProcessor, myGlobalContext);
|
||||
return super.createAnnotation(elt.getTextRange(), severity, message);
|
||||
}
|
||||
|
||||
@@ -152,21 +161,12 @@ public class AnnotatorBasedInspection extends GlobalInspectionTool {
|
||||
@Override
|
||||
protected Annotation createAnnotation(TextRange range, HighlightSeverity severity, String message) {
|
||||
if (severity != HighlightSeverity.INFORMATION) {
|
||||
GlobalInspectionUtil.createProblem(myFile, message, HighlightInfo.convertSeverityToProblemHighlight(severity), range, manager,
|
||||
problemDescriptionsProcessor, globalContext);
|
||||
GlobalInspectionUtil.createProblem(myFile, message, HighlightInfo.convertSeverityToProblemHighlight(severity), range, myManager,
|
||||
myProblemDescriptionsProcessor, myGlobalContext);
|
||||
}
|
||||
return super.createAnnotation(range, severity, message);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitFile(PsiFile file) {
|
||||
myFile = file;
|
||||
final VirtualFile virtualFile = myFile.getVirtualFile();
|
||||
if (virtualFile != null) {
|
||||
myGlobalContext.incrementJobDoneAmount(ANNOTATOR, ProjectUtil.calcRelativeToProjectPath(virtualFile, myFile.getProject()));
|
||||
}
|
||||
super.visitFile(file);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.analysis.AnalysisScope;
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.DefaultHighlightVisitor;
|
||||
import com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor;
|
||||
import com.intellij.codeInsight.highlighting.HighlightErrorFilter;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
|
||||
@@ -44,9 +44,10 @@ public class QuickFixWrapper implements IntentionAction {
|
||||
|
||||
public static IntentionAction wrap(@NotNull ProblemDescriptor descriptor, int fixNumber) {
|
||||
LOG.assertTrue(fixNumber > -1);
|
||||
LOG.assertTrue(descriptor.getFixes() != null && descriptor.getFixes().length > fixNumber);
|
||||
QuickFix[] fixes = descriptor.getFixes();
|
||||
LOG.assertTrue(fixes != null && fixes.length > fixNumber);
|
||||
|
||||
final QuickFix fix = descriptor.getFixes()[fixNumber];
|
||||
final QuickFix fix = fixes[fixNumber];
|
||||
return fix instanceof IntentionAction ? (IntentionAction)fix : new QuickFixWrapper(descriptor, fixNumber);
|
||||
}
|
||||
|
||||
|
||||
@@ -252,9 +252,6 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
|
||||
public void showRunContent(@NotNull final Executor executor, final RunContentDescriptor descriptor) {
|
||||
if(ApplicationManager.getApplication().isUnitTestMode()) return;
|
||||
|
||||
final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(executor.getToolWindowId());
|
||||
final boolean wasInActiveWindow = toolWindow != null && toolWindow.isActive();
|
||||
|
||||
final ContentManager contentManager = getContentManagerForRunner(executor);
|
||||
RunContentDescriptor oldDescriptor = chooseReuseContentForDescriptor(contentManager, descriptor);
|
||||
|
||||
@@ -311,17 +308,13 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(executor.getToolWindowId());
|
||||
if (wasInActiveWindow) {
|
||||
window.activate(null, true, false);
|
||||
} else {
|
||||
// let's activate tool window, but don't move focus
|
||||
//
|
||||
// window.show() isn't valid here, because it will not
|
||||
// mark the window as "last activated" windows and thus
|
||||
// some action like navigation up/down in stactrace wont
|
||||
// work correctly
|
||||
window.activate(null, false, false);
|
||||
}
|
||||
// let's activate tool window, but don't move focus
|
||||
//
|
||||
// window.show() isn't valid here, because it will not
|
||||
// mark the window as "last activated" windows and thus
|
||||
// some action like navigation up/down in stactrace wont
|
||||
// work correctly
|
||||
window.activate(null, false, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+23
-27
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -13,55 +13,51 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.roots.libraries.doc;
|
||||
package com.intellij.openapi.projectRoots.ui;
|
||||
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.ui.InputValidator;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
* @author MYakovlev
|
||||
* Date: Oct 29, 2002
|
||||
* Time: 8:47:43 PM
|
||||
*/
|
||||
public class DocUrlChooser {
|
||||
public class Util{
|
||||
|
||||
private DocUrlChooser() {
|
||||
public static VirtualFile showSpecifyJavadocUrlDialog(JComponent parent) {
|
||||
return showSpecifyJavadocUrlDialog(parent, "");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static VirtualFile showSpecifyDocUrlDialog(JComponent parent) {
|
||||
return showSpecifyDocUrlDialog(parent, "");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static VirtualFile showSpecifyDocUrlDialog(JComponent parent, String initialValue) {
|
||||
public static VirtualFile showSpecifyJavadocUrlDialog(JComponent parent, String initialValue){
|
||||
final String url = Messages.showInputDialog(parent, ProjectBundle.message("sdk.configure.javadoc.url.prompt"),
|
||||
ProjectBundle.message("sdk.configure.javadoc.url.title"), Messages.getQuestionIcon(),
|
||||
initialValue, new InputValidator() {
|
||||
public boolean checkInput(String inputString) {
|
||||
ProjectBundle.message("sdk.configure.javadoc.url.title"), Messages.getQuestionIcon(), initialValue, new InputValidator() {
|
||||
public boolean checkInput(String inputString) {
|
||||
return true;
|
||||
}
|
||||
public boolean canClose(String inputString) {
|
||||
try {
|
||||
new URL(inputString);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canClose(String inputString) {
|
||||
try {
|
||||
new URL(inputString);
|
||||
return true;
|
||||
}
|
||||
catch (MalformedURLException e1) {
|
||||
Messages.showErrorDialog(e1.getMessage(), ProjectBundle.message("sdk.configure.javadoc.url.title"));
|
||||
}
|
||||
return false;
|
||||
catch (MalformedURLException e1) {
|
||||
Messages.showErrorDialog(e1.getMessage(), ProjectBundle.message("sdk.configure.javadoc.url.title"));
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (url == null) {
|
||||
return null;
|
||||
}
|
||||
return VirtualFileManager.getInstance().findFileByUrl(url);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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 com.intellij.openapi.roots.libraries.doc;
|
||||
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.PersistentOrderRootType;
|
||||
|
||||
public class DocOrderRootType extends PersistentOrderRootType {
|
||||
|
||||
private DocOrderRootType() {
|
||||
super("DOCUMENTATION", "docPath", "doc-paths", "docPathEntry");
|
||||
}
|
||||
|
||||
public static OrderRootType getInstance() {
|
||||
return getOrderRootType(DocOrderRootType.class);
|
||||
}
|
||||
|
||||
public boolean collectFromDependentModules() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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 com.intellij.openapi.roots.libraries.doc;
|
||||
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.ui.PathEditor;
|
||||
import com.intellij.openapi.roots.ui.OrderRootTypeUIFactory;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
public class DocOrderRootTypeUIFactory implements OrderRootTypeUIFactory {
|
||||
private static final Icon ICON = IconLoader.getIcon("/nodes/javaDocFolder.png");
|
||||
|
||||
@Nullable
|
||||
public PathEditor createPathEditor(Sdk sdk) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeText() {
|
||||
return ProjectBundle.message("library.docs.node");
|
||||
}
|
||||
|
||||
}
|
||||
+4
-8
@@ -18,6 +18,7 @@ package com.intellij.openapi.roots.libraries.scripting;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.roots.JavadocOrderRootType;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryTableBase;
|
||||
@@ -25,7 +26,6 @@ import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
|
||||
import com.intellij.openapi.roots.libraries.LibraryType;
|
||||
//import com.intellij.openapi.roots.libraries.doc.DocOrderRootType;
|
||||
import com.intellij.openapi.util.EmptyRunnable;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -81,7 +81,7 @@ public class ScriptingLibraryManager {
|
||||
}
|
||||
|
||||
private void updateLibraries(LibraryTable.ModifiableModel libTableModel) {
|
||||
//final OrderRootType docRootType = DocOrderRootType.getInstance();
|
||||
final OrderRootType docRootType = JavadocOrderRootType.getInstance();
|
||||
for (Library library : libTableModel.getLibraries()) {
|
||||
ScriptingLibraryTable.LibraryModel scriptingLibModel = myLibTable.getLibraryByName(library.getName());
|
||||
if (scriptingLibModel == null) {
|
||||
@@ -91,11 +91,9 @@ public class ScriptingLibraryManager {
|
||||
Library.ModifiableModel libModel = library.getModifiableModel();
|
||||
removeRoots(libModel, OrderRootType.CLASSES);
|
||||
removeRoots(libModel, OrderRootType.SOURCES);
|
||||
/*
|
||||
for (String docUrl : libModel.getUrls(DocOrderRootType.getInstance())) {
|
||||
for (String docUrl : libModel.getUrls(JavadocOrderRootType.getInstance())) {
|
||||
libModel.removeRoot(docUrl, docRootType);
|
||||
}
|
||||
*/
|
||||
addAllRoots(libModel, scriptingLibModel);
|
||||
libModel.commit();
|
||||
}
|
||||
@@ -118,14 +116,12 @@ public class ScriptingLibraryManager {
|
||||
}
|
||||
|
||||
private static void addAllRoots(Library.ModifiableModel libModel, ScriptingLibraryTable.LibraryModel srcModel) {
|
||||
//final OrderRootType docRootType = DocOrderRootType.getInstance();
|
||||
final OrderRootType docRootType = JavadocOrderRootType.getInstance();
|
||||
addRoots(libModel, srcModel, OrderRootType.CLASSES);
|
||||
addRoots(libModel, srcModel, OrderRootType.SOURCES);
|
||||
/*
|
||||
for (String docUrl : srcModel.getDocUrls()) {
|
||||
libModel.addRoot(docUrl, docRootType);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private static void addRoots(Library.ModifiableModel libModel,
|
||||
|
||||
+2
-2
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
package com.intellij.openapi.roots.libraries.scripting;
|
||||
|
||||
import com.intellij.openapi.roots.JavadocOrderRootType;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryEx;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.roots.libraries.LibraryType;
|
||||
import com.intellij.openapi.roots.libraries.doc.DocOrderRootType;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
@@ -52,7 +52,7 @@ public class ScriptingLibraryTable {
|
||||
LibraryModel libModel = new LibraryModel(library.getName());
|
||||
libModel.setSourceFiles(library.getFiles(SOURCE_ROOT_TYPE));
|
||||
libModel.setCompactFiles(library.getFiles(COMPACT_ROOT_TYPE));
|
||||
//libModel.setDocUrls(library.getUrls(DocOrderRootType.getInstance())); // TODO: Rustam, write tests first!
|
||||
libModel.setDocUrls(library.getUrls(JavadocOrderRootType.getInstance()));
|
||||
myLibraryModels.add(libModel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -464,6 +464,10 @@ public class PsiDocumentManagerImpl extends PsiDocumentManager implements Projec
|
||||
|
||||
if (file.getTextLength() != document.getTextLength()) {
|
||||
if (ApplicationManagerEx.getApplicationEx().isInternal()) {
|
||||
boolean x = false;
|
||||
if (x) {
|
||||
myBlockSupport.reparseRange(file, startOffset, endOffset, lengthShift, chars);
|
||||
}
|
||||
throw new AssertionError("commitDocument left PSI inconsistent; file len=" + file.getTextLength() +
|
||||
"; doc len=" + document.getTextLength() +
|
||||
"; file text=" + file.getText() +
|
||||
|
||||
@@ -49,7 +49,7 @@ public abstract class LightPsiFileImpl extends PsiElementBase implements PsiFile
|
||||
private final PsiManagerImpl myManager;
|
||||
private final Language myLanguage;
|
||||
|
||||
public LightPsiFileImpl(final FileViewProvider provider, final Language language) {
|
||||
public LightPsiFileImpl(@NotNull FileViewProvider provider, @NotNull Language language) {
|
||||
myViewProvider = provider;
|
||||
myManager = (PsiManagerImpl)provider.getManager();
|
||||
myLanguage = language;
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.diagnostic.PerformanceWatcher;
|
||||
import com.intellij.extapi.psi.ASTDelegatePsiElement;
|
||||
import com.intellij.lang.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.pom.tree.events.ChangeInfo;
|
||||
@@ -54,6 +55,7 @@ public class CompositeElement extends TreeElement {
|
||||
private volatile int myCachedLength = NOT_CACHED;
|
||||
private volatile int myHC = -1;
|
||||
private volatile PsiElement myWrapper = null;
|
||||
private static final boolean ASSERT_THREADING = DebugUtil.CHECK || ApplicationManagerEx.getApplicationEx().isInternal() || ApplicationManagerEx.getApplicationEx().isUnitTestMode();
|
||||
|
||||
public CompositeElement(@NotNull IElementType type) {
|
||||
super(type);
|
||||
@@ -66,13 +68,15 @@ public class CompositeElement extends TreeElement {
|
||||
public Object clone() {
|
||||
CompositeElement clone = (CompositeElement)super.clone();
|
||||
|
||||
clone.clearCaches();
|
||||
clone.firstChild = null;
|
||||
clone.lastChild = null;
|
||||
clone.myModificationsCount = 0;
|
||||
clone.myWrapper = null;
|
||||
for (ASTNode child = rawFirstChild(); child != null; child = child.getTreeNext()) {
|
||||
clone.rawAddChildren((TreeElement)child.clone());
|
||||
synchronized (PsiLock.LOCK) {
|
||||
clone.clearCaches();
|
||||
clone.firstChild = null;
|
||||
clone.lastChild = null;
|
||||
clone.myModificationsCount = 0;
|
||||
clone.myWrapper = null;
|
||||
for (ASTNode child = rawFirstChild(); child != null; child = child.getTreeNext()) {
|
||||
clone.rawAddChildren((TreeElement)child.clone());
|
||||
}
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
@@ -98,7 +102,7 @@ public class CompositeElement extends TreeElement {
|
||||
}
|
||||
|
||||
public void clearCaches() {
|
||||
if (DebugUtil.CHECK) {
|
||||
if (ASSERT_THREADING) {
|
||||
PsiElement wrapper = myWrapper;
|
||||
LOG.assertTrue(ApplicationManager.getApplication().isWriteAccessAllowed() ||
|
||||
Thread.holdsLock(PsiLock.LOCK) ||
|
||||
@@ -120,20 +124,28 @@ public class CompositeElement extends TreeElement {
|
||||
}
|
||||
|
||||
public LeafElement findLeafElementAt(int offset) {
|
||||
TreeElement child = getFirstChildNode();
|
||||
while (child != null) {
|
||||
final int textLength = child.getTextLength();
|
||||
if (textLength > offset) {
|
||||
if (child instanceof ForeignLeafPsiElement) {
|
||||
child = child.getTreeNext();
|
||||
continue;
|
||||
TreeElement element = this;
|
||||
startFind:
|
||||
while (true) {
|
||||
TreeElement child = element.getFirstChildNode();
|
||||
while (child != null) {
|
||||
final int textLength = child.getTextLength();
|
||||
if (textLength > offset) {
|
||||
if (child instanceof LeafElement) {
|
||||
if (child instanceof ForeignLeafPsiElement) {
|
||||
child = child.getTreeNext();
|
||||
continue;
|
||||
}
|
||||
return (LeafElement)child;
|
||||
}
|
||||
element = child;
|
||||
continue startFind;
|
||||
}
|
||||
return child.findLeafElementAt(offset);
|
||||
offset -= textLength;
|
||||
child = child.getTreeNext();
|
||||
}
|
||||
offset -= textLength;
|
||||
child = child.getTreeNext();
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ASTNode findChildByType(IElementType type) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiLock;
|
||||
import com.intellij.psi.impl.DebugUtil;
|
||||
import com.intellij.psi.impl.ElementBase;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
@@ -44,12 +45,14 @@ public abstract class TreeElement extends ElementBase implements ASTNode, Clonea
|
||||
|
||||
public Object clone() {
|
||||
TreeElement clone = (TreeElement)super.clone();
|
||||
clone.clearCaches();
|
||||
synchronized (PsiLock.LOCK) {
|
||||
clone.clearCaches();
|
||||
|
||||
clone.myNextSibling = null;
|
||||
clone.myPrevSibling = null;
|
||||
clone.myParent = null;
|
||||
clone.myStartOffsetInParent = -1;
|
||||
clone.myNextSibling = null;
|
||||
clone.myPrevSibling = null;
|
||||
clone.myParent = null;
|
||||
clone.myStartOffsetInParent = -1;
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ public final class FileContent extends UserDataHolderBase {
|
||||
private final VirtualFile myFile;
|
||||
private final String fileName;
|
||||
private final FileType myFileType;
|
||||
private Charset myCharset;
|
||||
private final Charset myCharset;
|
||||
private byte[] myContent;
|
||||
private CharSequence myContentAsText = null;
|
||||
private CharSequence myContentAsText;
|
||||
|
||||
public Project getProject() {
|
||||
return getUserData(FileBasedIndex.PROJECT);
|
||||
@@ -81,26 +81,25 @@ public final class FileContent extends UserDataHolderBase {
|
||||
public IllegalDataException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public IllegalDataException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
||||
public FileContent(@NotNull final VirtualFile file, @NotNull final CharSequence contentAsText, final Charset charset) {
|
||||
this(file);
|
||||
myContentAsText = contentAsText;
|
||||
myCharset = charset;
|
||||
this(file, contentAsText, null, charset);
|
||||
}
|
||||
|
||||
public FileContent(@NotNull final VirtualFile file, @NotNull final byte[] content) {
|
||||
this(file);
|
||||
myContent = content;
|
||||
myCharset = LoadTextUtil.detectCharsetAndSetBOM(file, content);
|
||||
this(file, null, content, LoadTextUtil.detectCharsetAndSetBOM(file, content));
|
||||
}
|
||||
|
||||
public FileContent(@NotNull final VirtualFile file) {
|
||||
this(file, null, null, null);
|
||||
}
|
||||
|
||||
private FileContent(@NotNull VirtualFile file, CharSequence contentAsText, byte[] content, Charset charset) {
|
||||
myFile = file;
|
||||
myContentAsText = contentAsText;
|
||||
myContent = content;
|
||||
myCharset = charset;
|
||||
myFileType = FileTypeManager.getInstance().getFileTypeByFile(file);
|
||||
// remember name explicitly because the file could be renamed afterwards
|
||||
fileName = file.getName();
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.intellij.history.integration;
|
||||
|
||||
import com.intellij.history.core.Content;
|
||||
import com.intellij.history.core.LocalHistoryFacade;
|
||||
import com.intellij.history.core.Paths;
|
||||
import com.intellij.history.core.StoredContent;
|
||||
@@ -53,7 +52,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class IdeaGateway {
|
||||
private static final Key<Pair<StoredContent, Long>> SAVED_DOCUMENT_CONTENT_AND_STAMP_KEY
|
||||
private static final Key<ContentAndTimestamps> SAVED_DOCUMENT_CONTENT_AND_STAMP_KEY
|
||||
= Key.create("LocalHistory.SAVED_DOCUMENT_CONTENT_AND_STAMP_KEY");
|
||||
|
||||
public boolean isVersioned(VirtualFile f) {
|
||||
@@ -170,17 +169,17 @@ public class IdeaGateway {
|
||||
if (!file.isDirectory()) {
|
||||
if (!isVersioned(file)) return null;
|
||||
|
||||
Content c;
|
||||
Pair<StoredContent, Long> contentAndStamps;
|
||||
if (forDeletion) {
|
||||
FileDocumentManager m = FileDocumentManager.getInstance();
|
||||
Document d = m.getCachedDocument(file); // should not try to load document
|
||||
if (d != null && !m.isDocumentUnsaved(d)) d = null;
|
||||
c = acquireAndClearCurrentContent(file, d);
|
||||
contentAndStamps = acquireAndClearCurrentContent(file, d);
|
||||
}
|
||||
else {
|
||||
c = getActualContentNoAcquire(file);
|
||||
contentAndStamps = getActualContentNoAcquire(file);
|
||||
}
|
||||
return new FileEntry(file.getName(), c, file.getTimeStamp(), !file.isWritable());
|
||||
return new FileEntry(file.getName(), contentAndStamps.first, contentAndStamps.second, !file.isWritable());
|
||||
}
|
||||
DirectoryEntry newDir = new DirectoryEntry(file.getName());
|
||||
doCreateChildren(newDir, iterateDBChildren(file), forDeletion);
|
||||
@@ -203,7 +202,6 @@ public class IdeaGateway {
|
||||
VirtualFile f = getFile(d);
|
||||
if (!shouldRegisterDocument(f)) continue;
|
||||
registerDocumentContents(vcs, f, d);
|
||||
registerDocumentContents(vcs, f, d);
|
||||
}
|
||||
vcs.endChangeSet(null);
|
||||
}
|
||||
@@ -216,70 +214,74 @@ public class IdeaGateway {
|
||||
}
|
||||
|
||||
private void registerDocumentContents(LocalHistoryFacade vcs, VirtualFile f, Document d) {
|
||||
Content content = acquireAndUpdateActualContent(f, d);
|
||||
if (content != null) {
|
||||
vcs.contentChanged(f.getPath(), content, Clock.getTime());
|
||||
Pair<StoredContent, Long> contentAndStamp = acquireAndUpdateActualContent(f, d);
|
||||
if (contentAndStamp != null) {
|
||||
vcs.contentChanged(f.getPath(), contentAndStamp.first, contentAndStamp.second);
|
||||
}
|
||||
}
|
||||
|
||||
// returns null is content has not been changes since last time
|
||||
@Nullable
|
||||
public Content acquireAndUpdateActualContent(VirtualFile f, @Nullable Document d) {
|
||||
Pair<StoredContent, Long> contentAndStamp = f.getUserData(SAVED_DOCUMENT_CONTENT_AND_STAMP_KEY);
|
||||
public Pair<StoredContent, Long> acquireAndUpdateActualContent(VirtualFile f, @Nullable Document d) {
|
||||
ContentAndTimestamps contentAndStamp = f.getUserData(SAVED_DOCUMENT_CONTENT_AND_STAMP_KEY);
|
||||
if (contentAndStamp == null) {
|
||||
if (d != null) saveDocumentContent(f, d);
|
||||
return StoredContent.acquireContent(f);
|
||||
return Pair.create(StoredContent.acquireContent(f), f.getTimeStamp());
|
||||
}
|
||||
|
||||
StoredContent content = contentAndStamp.first;
|
||||
|
||||
// if no need to save current document content when simply return and clear stored one
|
||||
if (d == null) {
|
||||
f.putUserData(SAVED_DOCUMENT_CONTENT_AND_STAMP_KEY, null);
|
||||
return content;
|
||||
return Pair.create(contentAndStamp.content, contentAndStamp.registeredTimestamp);
|
||||
}
|
||||
|
||||
// if the stored content equals the current one, do not store it and return null
|
||||
if (d.getModificationStamp() == contentAndStamp.second) return null;
|
||||
if (d.getModificationStamp() == contentAndStamp.documentModificationStamp) return null;
|
||||
|
||||
// is current content has been changed, store it and return the previous one
|
||||
saveDocumentContent(f, d);
|
||||
return content;
|
||||
return Pair.create(contentAndStamp.content, contentAndStamp.registeredTimestamp);
|
||||
}
|
||||
|
||||
private void saveDocumentContent(VirtualFile f, Document d) {
|
||||
f.putUserData(SAVED_DOCUMENT_CONTENT_AND_STAMP_KEY,
|
||||
Pair.create(StoredContent.acquireContent(bytesFromDocument(d)), d.getModificationStamp()));
|
||||
new ContentAndTimestamps(Clock.getTime(),
|
||||
StoredContent.acquireContent(bytesFromDocument(d)),
|
||||
d.getModificationStamp()));
|
||||
}
|
||||
|
||||
public Content acquireAndClearCurrentContent(VirtualFile f, @Nullable Document d) {
|
||||
Pair<StoredContent, Long> contentAndStamp = f.getUserData(SAVED_DOCUMENT_CONTENT_AND_STAMP_KEY);
|
||||
@NotNull
|
||||
public Pair<StoredContent, Long> acquireAndClearCurrentContent(VirtualFile f, @Nullable Document d) {
|
||||
ContentAndTimestamps contentAndStamp = f.getUserData(SAVED_DOCUMENT_CONTENT_AND_STAMP_KEY);
|
||||
f.putUserData(SAVED_DOCUMENT_CONTENT_AND_STAMP_KEY, null);
|
||||
|
||||
if (d != null && contentAndStamp != null) {
|
||||
// if previously stored content was not changed, return it
|
||||
if (d.getModificationStamp() == contentAndStamp.second) return contentAndStamp.first;
|
||||
if (d.getModificationStamp() == contentAndStamp.documentModificationStamp) {
|
||||
return Pair.create(contentAndStamp.content, contentAndStamp.registeredTimestamp);
|
||||
}
|
||||
}
|
||||
|
||||
// release previously stored
|
||||
if (contentAndStamp != null) {
|
||||
contentAndStamp.first.release();
|
||||
contentAndStamp.content.release();
|
||||
}
|
||||
|
||||
// take document's content if any
|
||||
if (d != null) {
|
||||
return StoredContent.acquireContent(bytesFromDocument(d));
|
||||
return Pair.create(StoredContent.acquireContent(bytesFromDocument(d)), Clock.getTime());
|
||||
}
|
||||
|
||||
return StoredContent.acquireContent(f);
|
||||
return Pair.create(StoredContent.acquireContent(f), f.getTimeStamp());
|
||||
}
|
||||
|
||||
private Content getActualContentNoAcquire(VirtualFile f) {
|
||||
Pair<StoredContent, Long> result = f.getUserData(SAVED_DOCUMENT_CONTENT_AND_STAMP_KEY);
|
||||
@NotNull
|
||||
private Pair<StoredContent, Long> getActualContentNoAcquire(VirtualFile f) {
|
||||
ContentAndTimestamps result = f.getUserData(SAVED_DOCUMENT_CONTENT_AND_STAMP_KEY);
|
||||
if (result == null) {
|
||||
return StoredContent.transientContent(f);
|
||||
return Pair.create(StoredContent.transientContent(f), f.getTimeStamp());
|
||||
}
|
||||
return result.first;
|
||||
return Pair.create(result.content, result.registeredTimestamp);
|
||||
}
|
||||
|
||||
private byte[] bytesFromDocument(Document d) {
|
||||
@@ -319,4 +321,16 @@ public class IdeaGateway {
|
||||
public FileType getFileType(String fileName) {
|
||||
return FileTypeManager.getInstance().getFileTypeByFileName(fileName);
|
||||
}
|
||||
|
||||
private static class ContentAndTimestamps {
|
||||
long registeredTimestamp;
|
||||
StoredContent content;
|
||||
long documentModificationStamp;
|
||||
|
||||
private ContentAndTimestamps(long registeredTimestamp, StoredContent content, long documentModificationStamp) {
|
||||
this.registeredTimestamp = registeredTimestamp;
|
||||
this.content = content;
|
||||
this.documentModificationStamp = documentModificationStamp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -16,12 +16,13 @@
|
||||
|
||||
package com.intellij.history.integration;
|
||||
|
||||
import com.intellij.history.core.Content;
|
||||
import com.intellij.history.core.LocalHistoryFacade;
|
||||
import com.intellij.history.core.StoredContent;
|
||||
import com.intellij.history.core.tree.Entry;
|
||||
import com.intellij.openapi.command.CommandEvent;
|
||||
import com.intellij.openapi.command.CommandListener;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
|
||||
public class LocalHistoryEventDispatcher extends VirtualFileAdapter implements VirtualFileManagerListener, CommandListener {
|
||||
@@ -102,9 +103,9 @@ public class LocalHistoryEventDispatcher extends VirtualFileAdapter implements V
|
||||
if (!areContentChangesVersioned(e)) return;
|
||||
VirtualFile f = e.getFile();
|
||||
|
||||
Content content = myGateway.acquireAndUpdateActualContent(f, null);
|
||||
Pair<StoredContent, Long> content = myGateway.acquireAndUpdateActualContent(f, null);
|
||||
if (content != null) {
|
||||
myVcs.contentChanged(f.getPath(), content, f.getTimeStamp());
|
||||
myVcs.contentChanged(f.getPath(), content.first, content.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+48
-1
@@ -19,6 +19,8 @@ package com.intellij.history.integration;
|
||||
|
||||
import com.intellij.history.FileRevisionTimestampComparator;
|
||||
import com.intellij.history.LocalHistory;
|
||||
import com.intellij.history.LocalHistoryAction;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.util.Clock;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
@@ -37,7 +39,7 @@ public class GettingContentAtDateTest extends IntegrationTestCase {
|
||||
|
||||
assertContentAt(0, null);
|
||||
assertContentAt(TIMESTAMP_INCREMENT, "1");
|
||||
assertContentAt(TIMESTAMP_INCREMENT + TIMESTAMP_INCREMENT/ 2, null);
|
||||
assertContentAt(TIMESTAMP_INCREMENT + TIMESTAMP_INCREMENT / 2, null);
|
||||
assertContentAt(TIMESTAMP_INCREMENT * 2, "2");
|
||||
assertContentAt(TIMESTAMP_INCREMENT * 3, null);
|
||||
}
|
||||
@@ -77,6 +79,51 @@ public class GettingContentAtDateTest extends IntegrationTestCase {
|
||||
assertContentAt(c, "2");
|
||||
}
|
||||
|
||||
public void testWithUnsavedDocuments() throws Exception {
|
||||
setContent(f, "FILE1", TIMESTAMP_INCREMENT);
|
||||
|
||||
Clock.setTime(TIMESTAMP_INCREMENT * 2);
|
||||
LocalHistoryAction a = LocalHistory.getInstance().startAction(null);
|
||||
setDocumentTextFor(f, "DOC1");
|
||||
a.finish();
|
||||
|
||||
Clock.setTime(TIMESTAMP_INCREMENT * 3);
|
||||
a = LocalHistory.getInstance().startAction(null);
|
||||
setDocumentTextFor(f, "DOC2");
|
||||
a.finish();
|
||||
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
setContent(f, "FILE2", TIMESTAMP_INCREMENT * 4);
|
||||
|
||||
assertContentAt(new FileRevisionTimestampComparator() {
|
||||
@Override
|
||||
public boolean isSuitable(long revisionTimestamp) {
|
||||
return revisionTimestamp == TIMESTAMP_INCREMENT * 4;
|
||||
}
|
||||
}, "FILE2");
|
||||
|
||||
assertContentAt(new FileRevisionTimestampComparator() {
|
||||
@Override
|
||||
public boolean isSuitable(long revisionTimestamp) {
|
||||
return revisionTimestamp == TIMESTAMP_INCREMENT * 3;
|
||||
}
|
||||
}, "DOC2");
|
||||
|
||||
assertContentAt(new FileRevisionTimestampComparator() {
|
||||
@Override
|
||||
public boolean isSuitable(long revisionTimestamp) {
|
||||
return revisionTimestamp == TIMESTAMP_INCREMENT * 2;
|
||||
}
|
||||
}, "DOC1");
|
||||
|
||||
assertContentAt(new FileRevisionTimestampComparator() {
|
||||
@Override
|
||||
public boolean isSuitable(long revisionTimestamp) {
|
||||
return revisionTimestamp == TIMESTAMP_INCREMENT;
|
||||
}
|
||||
}, "FILE1");
|
||||
}
|
||||
|
||||
private void assertContentAt(long timestamp, String expected) {
|
||||
assertContentAt(comparator(timestamp), expected);
|
||||
}
|
||||
|
||||
@@ -134,10 +134,10 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
String internalVersionString = pluginBean.formatVersion;
|
||||
if (internalVersionString != null) {
|
||||
try {
|
||||
final int formatVersion = Integer.parseInt(internalVersionString);
|
||||
Integer.parseInt(internalVersionString);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
LOG.error(new PluginException("Invalid value in plugin.xml format version: " + internalVersionString, e, myId));
|
||||
LOG.error(new PluginException("Invalid value in plugin.xml format version: '" + internalVersionString+"'", e, myId));
|
||||
}
|
||||
}
|
||||
myUseIdeaClassLoader = pluginBean.useIdeaClassLoader;
|
||||
@@ -189,7 +189,7 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
hsPathes.add(hsPath);
|
||||
}
|
||||
}
|
||||
myHelpSets = hsPathes.size()>0 ? hsPathes.toArray(new HelpSetPath[hsPathes.size()]) : HelpSetPath.EMPTY;
|
||||
myHelpSets = !hsPathes.isEmpty() ? hsPathes.toArray(new HelpSetPath[hsPathes.size()]) : HelpSetPath.EMPTY;
|
||||
|
||||
myAppComponents = pluginBean.applicationComponents;
|
||||
myProjectComponents = pluginBean.projectComponents;
|
||||
@@ -203,15 +203,6 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
myExtensionsPoints = copyElements(pluginBean.extensionPoints);
|
||||
myActionsElements = copyElements(pluginBean.actions);
|
||||
|
||||
if (pluginBean.extensionPoints != null) {
|
||||
myExtensionsPoints = new ArrayList<Element>();
|
||||
for (Element root : pluginBean.extensionPoints) {
|
||||
for (Object o : root.getChildren()) {
|
||||
myExtensionsPoints.add((Element)o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pluginBean.modules != null && !pluginBean.modules.isEmpty()) {
|
||||
myModules = pluginBean.modules;
|
||||
}
|
||||
@@ -393,9 +384,7 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
|
||||
final IdeaPluginDescriptorImpl pluginDescriptor = (IdeaPluginDescriptorImpl)o;
|
||||
|
||||
if (myName != null ? !myName.equals(pluginDescriptor.myName) : pluginDescriptor.myName != null) return false;
|
||||
|
||||
return true;
|
||||
return myName == null ? pluginDescriptor.myName == null : myName.equals(pluginDescriptor.myName);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
|
||||
+17
-1
@@ -28,9 +28,25 @@ import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
|
||||
/**
|
||||
* @author Kirill Kalishev
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public interface AnActionListener {
|
||||
void beforeActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event);
|
||||
|
||||
void afterActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event);
|
||||
|
||||
|
||||
void beforeEditorTyping(char c, DataContext dataContext);
|
||||
|
||||
class Adapter implements AnActionListener {
|
||||
@Override
|
||||
public void beforeActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event) {}
|
||||
|
||||
@Override
|
||||
public void afterActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event) {}
|
||||
|
||||
@Override
|
||||
public void beforeEditorTyping(char c, DataContext dataContext) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,9 +368,13 @@ public class HintManagerImpl extends HintManager implements Disposable {
|
||||
Dimension size = hint.getComponent().getPreferredSize();
|
||||
|
||||
if (hint.isRealPopup()) {
|
||||
final Point editorCorner = editor.getContentComponent().getLocation();
|
||||
SwingUtilities.convertPointToScreen(editorCorner, layeredPane);
|
||||
final Rectangle editorScreen = ScreenUtil.getScreenRectangle(editorCorner.x, editorCorner.y);
|
||||
|
||||
SwingUtilities.convertPointToScreen(p, layeredPane);
|
||||
final Rectangle rectangle = new Rectangle(p, size);
|
||||
ScreenUtil.moveRectangleToFitTheScreen(rectangle);
|
||||
ScreenUtil.moveToFit(rectangle, editorScreen, null);
|
||||
p = rectangle.getLocation();
|
||||
SwingUtilities.convertPointFromScreen(p, layeredPane);
|
||||
}
|
||||
|
||||
@@ -121,8 +121,7 @@ public class RunnerMediator {
|
||||
return true;
|
||||
}
|
||||
else if (isUnix()) {
|
||||
UnixProcessManager.sendSigKillToProcessTree(process);
|
||||
return true;
|
||||
return UnixProcessManager.sendSigKillToProcessTree(process);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
||||
@@ -71,20 +71,20 @@ public class UnixProcessManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendSigIntToProcessTree(Process process) {
|
||||
sendSignalToProcessTree(process, SIGINT);
|
||||
public static boolean sendSigIntToProcessTree(Process process) {
|
||||
return sendSignalToProcessTree(process, SIGINT);
|
||||
}
|
||||
|
||||
public static void sendSigKillToProcessTree(Process process) {
|
||||
sendSignalToProcessTree(process, SIGKILL);
|
||||
public static boolean sendSigKillToProcessTree(Process process) {
|
||||
return sendSignalToProcessTree(process, SIGKILL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends signal to every child process of a tree root process
|
||||
* @param process tree root process
|
||||
*
|
||||
* @param process tree root process
|
||||
*/
|
||||
public static void sendSignalToProcessTree(Process process, int signal) {
|
||||
public static boolean sendSignalToProcessTree(Process process, int signal) {
|
||||
checkCLib();
|
||||
|
||||
int our_pid = C_LIB.getpid();
|
||||
@@ -101,6 +101,10 @@ public class UnixProcessManager {
|
||||
InputStreamReader(p.getInputStream()));
|
||||
BufferedReader stdError = new BufferedReader(new
|
||||
InputStreamReader(p.getErrorStream()));
|
||||
|
||||
List<Integer> childrenPids = Lists.newArrayList();
|
||||
|
||||
boolean result;
|
||||
try {
|
||||
String s;
|
||||
stdInput.readLine(); //ps output header
|
||||
@@ -113,6 +117,10 @@ public class UnixProcessManager {
|
||||
|
||||
processInfo.register(pid, parent_pid);
|
||||
|
||||
if (parent_pid == process_pid) {
|
||||
childrenPids.add(pid);
|
||||
}
|
||||
|
||||
if (pid == process_pid) {
|
||||
if (parent_pid == our_pid) {
|
||||
foundPid = pid;
|
||||
@@ -125,9 +133,13 @@ public class UnixProcessManager {
|
||||
|
||||
if (foundPid != 0) {
|
||||
processInfo.killProcTree(foundPid, signal);
|
||||
result = true;
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("process not found: " + process_pid + ", idea pid =" + our_pid);
|
||||
for (Integer pid : childrenPids) {
|
||||
processInfo.killProcTree(pid, signal);
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
|
||||
StringBuffer errorStr = new StringBuffer();
|
||||
@@ -142,6 +154,7 @@ public class UnixProcessManager {
|
||||
stdInput.close();
|
||||
stdError.close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
|
||||
@@ -246,9 +246,10 @@ public class InstalledPluginsTableModel extends PluginTableModel {
|
||||
|
||||
public void setValue(final IdeaPluginDescriptorImpl ideaPluginDescriptor, Boolean value) {
|
||||
final PluginId currentPluginId = ideaPluginDescriptor.getPluginId();
|
||||
myEnabled.put(currentPluginId, myEnabled.get(currentPluginId) == null ? Boolean.FALSE : value);
|
||||
final Boolean enabled = myEnabled.get(currentPluginId) == null ? Boolean.FALSE : value;
|
||||
myEnabled.put(currentPluginId, enabled);
|
||||
updatePluginDependencies();
|
||||
if (value.booleanValue()) {
|
||||
if (enabled.booleanValue()) {
|
||||
final Set<PluginId> deps = new HashSet<PluginId>();
|
||||
PluginManager.checkDependants(ideaPluginDescriptor, new Function<PluginId, IdeaPluginDescriptor>() {
|
||||
@Nullable
|
||||
|
||||
@@ -2300,8 +2300,8 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
|
||||
private int drawStringWithSoftWraps(Graphics g,
|
||||
final char[] text,
|
||||
int start,
|
||||
int end,
|
||||
final int start,
|
||||
final int end,
|
||||
Point position,
|
||||
Rectangle clip,
|
||||
Color effectColor,
|
||||
@@ -2403,7 +2403,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
|
||||
// Draw remaining soft wrap symbols from its last line if any.
|
||||
if (softWrapSegmentStartIndex < softWrapChars.length - 1) {
|
||||
if (softWrapSegmentStartIndex < softWrapChars.length) {
|
||||
position.x += drawString(
|
||||
g, softWrapChars, softWrapSegmentStartIndex, softWrapChars.length, position, clip, effectColor, effectType,
|
||||
fontType, fontColor
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.editor.FoldRegion;
|
||||
import com.intellij.openapi.editor.RangeMarker;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.CollectionFactory;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -29,6 +30,9 @@ import java.util.Comparator;
|
||||
* User: cdr
|
||||
*/
|
||||
abstract class FoldRegionsTree {
|
||||
|
||||
public static final boolean DEBUG = Boolean.getBoolean("idea.editor.debug.folding");
|
||||
|
||||
private FoldRegion[] myCachedVisible;
|
||||
private FoldRegion[] myCachedTopLevelRegions;
|
||||
private int[] myCachedEndOffsets;
|
||||
@@ -189,6 +193,7 @@ abstract class FoldRegionsTree {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
FoldRegion fetchOutermost(int offset) {
|
||||
if (!isFoldingEnabledAndUpToDate()) return null;
|
||||
|
||||
@@ -206,6 +211,19 @@ abstract class FoldRegionsTree {
|
||||
start = i + 1;
|
||||
}
|
||||
else {
|
||||
// We encountered situation when cached data is inconsistent. It's not clear what produced that, so, the following was done:
|
||||
// 1. Corresponding check was added and cached data is rebuilt in case of inconsistency;
|
||||
// 2. Debug asserts are activated if dedicated flag is on (it's off by default);
|
||||
if (myCachedStartOffsets[i] != myCachedTopLevelRegions[i].getStartOffset()) {
|
||||
if (DEBUG) {
|
||||
assert false :
|
||||
"inconsistent cached fold data detected. Start offsets: " + Arrays.toString(myCachedStartOffsets)
|
||||
+ ", end offsets: " + Arrays.toString(myCachedEndOffsets) + ", top regions: " + Arrays.toString(myCachedTopLevelRegions)
|
||||
+ ", visible regions: " + Arrays.toString(myCachedVisible);
|
||||
}
|
||||
rebuild();
|
||||
return fetchOutermost(offset);
|
||||
}
|
||||
return myCachedTopLevelRegions[i];
|
||||
}
|
||||
}
|
||||
@@ -218,6 +236,7 @@ abstract class FoldRegionsTree {
|
||||
return myCachedVisible;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
FoldRegion[] fetchTopLevel() {
|
||||
if (!isFoldingEnabledAndUpToDate()) return null;
|
||||
return myCachedTopLevelRegions;
|
||||
|
||||
@@ -446,11 +446,14 @@ public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedDocumentLi
|
||||
if (!isInsideSoftWrap(visualCaretPosition)) {
|
||||
return;
|
||||
}
|
||||
//TODO den implement
|
||||
//if (myDocumentChangeManager.makeHardWrap(caretModel.getOffset())) {
|
||||
// // Restore caret position.
|
||||
// caretModel.moveToVisualPosition(visualCaretPosition);
|
||||
//}
|
||||
|
||||
SoftWrap softWrap = myStorage.getSoftWrap(caretModel.getOffset());
|
||||
if (softWrap == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
myEditor.getDocument().replaceString(softWrap.getStart(), softWrap.getEnd(), softWrap.getText());
|
||||
caretModel.moveToVisualPosition(visualCaretPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.ex.AnActionListener;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.ui.popup.JBPopupListener;
|
||||
@@ -367,6 +372,12 @@ public class BalloonImpl implements Disposable, Balloon, LightweightWindow, Posi
|
||||
Toolkit.getDefaultToolkit().addAWTEventListener(myAwtActivityListener, MouseEvent.MOUSE_EVENT_MASK |
|
||||
MouseEvent.MOUSE_MOTION_EVENT_MASK |
|
||||
KeyEvent.KEY_EVENT_MASK);
|
||||
ActionManager.getInstance().addAnActionListener(new AnActionListener.Adapter() {
|
||||
@Override
|
||||
public void beforeActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event) {
|
||||
hide();
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
private Rectangle getRecForPosition(Position position, boolean adjust) {
|
||||
|
||||
+30
@@ -538,6 +538,36 @@ public class SoftWrapApplianceOnDocumentModificationTest extends AbstractEditorP
|
||||
assertEquals(expectedVisualLine, caretModel.getVisualPosition().line);
|
||||
}
|
||||
|
||||
public void testSoftWrapToHardWrapConversion() throws IOException {
|
||||
String text =
|
||||
"this is line 1\n" +
|
||||
"this is line 2\n" +
|
||||
"this is line 3\n" +
|
||||
"this is line 4\n" +
|
||||
"this is line 5";
|
||||
|
||||
init(50, text);
|
||||
VisualPosition changePosition = new VisualPosition(1, 0);
|
||||
myEditor.getCaretModel().moveToVisualPosition(changePosition);
|
||||
|
||||
int logicalLinesBefore = myEditor.offsetToLogicalPosition(text.length()).line;
|
||||
int offsetBefore = myEditor.getCaretModel().getOffset();
|
||||
|
||||
LogicalPosition logicalPositionBefore = myEditor.visualToLogicalPosition(changePosition);
|
||||
assertEquals(1, logicalPositionBefore.softWrapLinesOnCurrentLogicalLine);
|
||||
assertTrue(logicalPositionBefore.column > 0);
|
||||
|
||||
SoftWrap softWrap = getSoftWrapModel().getSoftWrap(offsetBefore);
|
||||
assertNotNull(softWrap);
|
||||
|
||||
type('a');
|
||||
|
||||
LogicalPosition logicalPositionAfter = myEditor.visualToLogicalPosition(changePosition);
|
||||
assertEquals(new LogicalPosition(1, 0, 0, 0, 0, 0, 0), logicalPositionAfter);
|
||||
assertEquals(offsetBefore + softWrap.getText().length() + 1, myEditor.getCaretModel().getOffset());
|
||||
assertEquals(logicalLinesBefore + 1, myEditor.offsetToLogicalPosition(text.length()).line);
|
||||
}
|
||||
|
||||
//public void testPastingInsideSelection() throws IOException {
|
||||
// String text =
|
||||
// "this is line number 0\n" +
|
||||
|
||||
@@ -318,7 +318,7 @@
|
||||
<customScopesProvider implementation="com.intellij.packageDependencies.DefaultScopesProvider"/>
|
||||
<refactoring.elementListenerProvider implementation="com.intellij.packageDependencies.ui.RefactoringScopeElementListenerProvider"/>
|
||||
|
||||
<highlightVisitor implementation="com.intellij.codeInsight.daemon.impl.analysis.DefaultHighlightVisitor"/>
|
||||
<highlightVisitor implementation="com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor"/>
|
||||
|
||||
<liveTemplateMacro implementation="com.intellij.codeInsight.template.macro.CurrentDateMacro"/>
|
||||
<liveTemplateMacro implementation="com.intellij.codeInsight.template.macro.CurrentTimeMacro"/>
|
||||
|
||||
+10
-3
@@ -174,10 +174,17 @@ public class TestsPresentationUtil {
|
||||
SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
}
|
||||
else {
|
||||
renderer.setIcon(PoolOfTestIcons.NOT_RAN);
|
||||
renderer.append(SMTestsRunnerBundle.message(
|
||||
if (!testProxy.getChildren().isEmpty()) {
|
||||
// some times test proxy may be updated faster than tests tree
|
||||
// so let's process such situation correctly
|
||||
formatRootNodeWithChildren(testProxy, renderer);
|
||||
}
|
||||
else {
|
||||
renderer.setIcon(PoolOfTestIcons.NOT_RAN);
|
||||
renderer.append(SMTestsRunnerBundle.message(
|
||||
"sm.test.runner.ui.tests.tree.presentation.labels.no.tests.were.found"),
|
||||
SimpleTextAttributes.ERROR_ATTRIBUTES);
|
||||
SimpleTextAttributes.ERROR_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+17
@@ -536,6 +536,23 @@ public class TestsPresentationUtilTest extends BaseSMTRunnerTestCase {
|
||||
|
||||
}
|
||||
|
||||
public void testFormatRootNodeWithoutChildren_PY_2434() {
|
||||
// See [PY-2434] Unittest: Do not show "No test were found" notification before completing test suite
|
||||
mySuite.addChild(mySimpleTest);
|
||||
mySuite.setStarted();
|
||||
mySimpleTest.setStarted();
|
||||
mySimpleTest.setTestFailed("msg", "stacktrace", false);
|
||||
mySimpleTest.setFinished();
|
||||
mySuite.setFinished();
|
||||
TestsPresentationUtil.formatRootNodeWithoutChildren(mySuite, myRenderer);
|
||||
|
||||
assertEquals(PoolOfTestIcons.FAILED_ICON, myRenderer.getIcon());
|
||||
assertOneElement(myFragContainer.getFragments());
|
||||
assertEquals("Test Results:", myFragContainer.getTextAt(0));
|
||||
assertEquals(SimpleTextAttributes.REGULAR_ATTRIBUTES, myFragContainer.getAttribsAt(0));
|
||||
}
|
||||
|
||||
|
||||
public void testGetPresentableName() {
|
||||
//Test unit examples
|
||||
assertProxyPresentation("testFirst", "MyRubyTest1", "MyRubyTest1.testFirst");
|
||||
|
||||
@@ -1148,6 +1148,10 @@ public class StringUtil {
|
||||
}
|
||||
|
||||
if (name.endsWith("ies")) {
|
||||
if (name.endsWith("cookies") || name.endsWith("Cookies")) {
|
||||
return name.substring(0, name.length() - "ookies".length()) + "ookie";
|
||||
}
|
||||
|
||||
return name.substring(0, name.length() - 3) + "y";
|
||||
}
|
||||
|
||||
|
||||
@@ -219,7 +219,11 @@ public class PagedFileStorage implements Forceable {
|
||||
buffer.position(page_offset);
|
||||
}
|
||||
catch (IllegalArgumentException iae) {
|
||||
throw new IllegalArgumentException("can't position buffer to offset " + page_offset);
|
||||
throw new IllegalArgumentException("can't position buffer to offset " + page_offset + ", " +
|
||||
"buffer.limit=" + buffer.limit() + ", " +
|
||||
"page=" + page + ", " +
|
||||
"file=" + myFile.getName() + ", "+
|
||||
"file.length=" + mySize);
|
||||
}
|
||||
buffer.get(dst, o, page_len);
|
||||
|
||||
|
||||
@@ -23,16 +23,21 @@
|
||||
package com.intellij.util.messages;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Use ComponentManager.getMessageBus() to obtain one.
|
||||
*/
|
||||
public interface MessageBus {
|
||||
@NotNull
|
||||
MessageBusConnection connect();
|
||||
MessageBusConnection connect(Disposable parentDisposable);
|
||||
@NotNull
|
||||
MessageBusConnection connect(@NotNull Disposable parentDisposable);
|
||||
|
||||
<L> L syncPublisher(Topic<L> topic);
|
||||
<L> L asyncPublisher(Topic<L> topic);
|
||||
@NotNull
|
||||
<L> L syncPublisher(@NotNull Topic<L> topic);
|
||||
@NotNull
|
||||
<L> L asyncPublisher(@NotNull Topic<L> topic);
|
||||
|
||||
void dispose();
|
||||
}
|
||||
@@ -73,6 +73,11 @@ public class MessageBusConnectionImpl implements MessageBusConnection {
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
Queue<Message> jobs = myPendingMessages.get();
|
||||
if (!jobs.isEmpty()) {
|
||||
LOG.error("Not delivered events in the queue: "+jobs);
|
||||
}
|
||||
myPendingMessages.remove();
|
||||
myBus.notifyConnectionTerminated(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,14 @@
|
||||
package com.intellij.util.messages.impl;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.messages.Topic;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -38,6 +40,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public class MessageBusImpl implements MessageBus {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.util.messages.impl.MessageBusImpl");
|
||||
private final ThreadLocal<Queue<DeliveryJob>> myMessageQueue = new ThreadLocal<Queue<DeliveryJob>>() {
|
||||
@Override
|
||||
protected Queue<DeliveryJob> initialValue() {
|
||||
@@ -84,20 +87,28 @@ public class MessageBusImpl implements MessageBus {
|
||||
|
||||
public final MessageBusConnectionImpl connection;
|
||||
public final Message message;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{ DJob connection:" + connection.toString() + "; message: " + message + " }";
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public MessageBusConnection connect() {
|
||||
return new MessageBusConnectionImpl(this);
|
||||
}
|
||||
|
||||
public MessageBusConnection connect(Disposable parentDisposable) {
|
||||
@NotNull
|
||||
public MessageBusConnection connect(@NotNull Disposable parentDisposable) {
|
||||
final MessageBusConnection connection = connect();
|
||||
Disposer.register(parentDisposable, connection);
|
||||
return connection;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public <L> L syncPublisher(final Topic<L> topic) {
|
||||
public <L> L syncPublisher(@NotNull final Topic<L> topic) {
|
||||
L publisher = (L)mySyncPublishers.get(topic);
|
||||
if (publisher == null) {
|
||||
final Class<L> listenerClass = topic.getListenerClass();
|
||||
@@ -113,8 +124,9 @@ public class MessageBusImpl implements MessageBus {
|
||||
return publisher;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public <L> L asyncPublisher(final Topic<L> topic) {
|
||||
public <L> L asyncPublisher(@NotNull final Topic<L> topic) {
|
||||
L publisher = (L)myAsyncPublishers.get(topic);
|
||||
if (publisher == null) {
|
||||
final Class<L> listenerClass = topic.getListenerClass();
|
||||
@@ -131,7 +143,10 @@ public class MessageBusImpl implements MessageBus {
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
myMessageQueue.get().clear();
|
||||
Queue<DeliveryJob> jobs = myMessageQueue.get();
|
||||
if (!jobs.isEmpty()) {
|
||||
LOG.error("Not delivered events in the queue: "+jobs);
|
||||
}
|
||||
myMessageQueue.remove();
|
||||
if (myParentBus != null) {
|
||||
myParentBus.notifyChildBusDisposed(this);
|
||||
@@ -218,4 +233,4 @@ public class MessageBusImpl implements MessageBus {
|
||||
if (job == null) return;
|
||||
job.connection.deliverMessage(job.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,6 +378,9 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
myUpdateException = null;
|
||||
composite.cleanAll();
|
||||
}
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("refresh procedure started, everything = " + wasEverythingDirty);
|
||||
}
|
||||
}
|
||||
if (wasEverythingDirty) {
|
||||
changeListWorker.notifyStartProcessingChanges(null);
|
||||
@@ -450,6 +453,9 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
}
|
||||
|
||||
if (takeChanges) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("refresh procedure finished, size: " + composite.getVFHolder(FileHolder.HolderType.UNVERSIONED).getSize());
|
||||
}
|
||||
final boolean statusChanged = ! myComposite.equals(composite);
|
||||
myComposite = composite;
|
||||
if (statusChanged) {
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.SimpleToolWindowPanel;
|
||||
@@ -81,6 +82,7 @@ public class ChangesViewManager implements ChangesViewI, JDOMExternalizable, Pro
|
||||
|
||||
@NonNls private static final String ATT_FLATTENED_VIEW = "flattened_view";
|
||||
@NonNls private static final String ATT_SHOW_IGNORED = "show_ignored";
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.changes.ChangesViewManager");
|
||||
|
||||
public static ChangesViewI getInstance(Project project) {
|
||||
return PeriodicalTasksCloser.getInstance().safeGetComponent(project, ChangesViewI.class);
|
||||
@@ -208,7 +210,10 @@ public class ChangesViewManager implements ChangesViewI, JDOMExternalizable, Pro
|
||||
@Override
|
||||
public void scheduleRefresh() {
|
||||
if (ApplicationManager.getApplication().isHeadlessEnvironment()) return;
|
||||
myRepaintAlarm.cancelAllRequests();
|
||||
int was = myRepaintAlarm.cancelAllRequests();
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("schedule refresh, was " + was);
|
||||
}
|
||||
myRepaintAlarm.addRequest(new Runnable() {
|
||||
public void run() {
|
||||
refreshView();
|
||||
@@ -228,6 +233,10 @@ public class ChangesViewManager implements ChangesViewI, JDOMExternalizable, Pro
|
||||
new Trinity<List<VirtualFile>, Integer, Integer>(manyUnversioned ? Collections.<VirtualFile>emptyList() : changeListManager.getUnversionedFiles(), unv.getFirst(),
|
||||
unv.getSecond());
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("refresh view, unversioned collections size: " + unversionedPair.getFirst().size() + " unv size passed: " +
|
||||
unversionedPair.getSecond() + " dirs: " + unversionedPair.getThird());
|
||||
}
|
||||
myView.updateModel(changeListManager.getChangeListsCopy(), unversionedPair,
|
||||
changeListManager.getDeletedFiles(),
|
||||
changeListManager.getModifiedWithoutEditing(),
|
||||
|
||||
@@ -95,13 +95,19 @@ public class ApplyPatchAction extends DumbAwareAction {
|
||||
}
|
||||
};
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
final FileChooserDialog fileChooserDialog = FileChooserFactory.getInstance().createFileChooser(
|
||||
ApplyPatchDifferentiatedDialog.createSelectPatchDescriptor(), project);
|
||||
final VirtualFile[] files = fileChooserDialog.choose(null, project);
|
||||
if (files.length != 1) {
|
||||
return;
|
||||
final VirtualFile toUse;
|
||||
if (file != null) {
|
||||
toUse = file;
|
||||
} else {
|
||||
final FileChooserDialog fileChooserDialog = FileChooserFactory.getInstance().createFileChooser(
|
||||
ApplyPatchDifferentiatedDialog.createSelectPatchDescriptor(), project);
|
||||
final VirtualFile[] files = fileChooserDialog.choose(null, project);
|
||||
if (files.length != 1) {
|
||||
return;
|
||||
}
|
||||
toUse = files[0];
|
||||
}
|
||||
final ApplyPatchDifferentiatedDialog dialog = new ApplyPatchDifferentiatedDialog(project, callback, files[0]);
|
||||
final ApplyPatchDifferentiatedDialog dialog = new ApplyPatchDifferentiatedDialog(project, callback, toUse);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
|
||||
@@ -130,5 +130,5 @@ public interface XDebugSession extends AbstractDebuggerSession {
|
||||
|
||||
<V extends XSmartStepIntoVariant> void smartStepInto(XSmartStepIntoHandler<V> handler, V variant);
|
||||
|
||||
void updateExecutionPosition();
|
||||
void updateExecutionPosition(boolean updateBreakpoints);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,8 @@ import java.util.*;
|
||||
public class XDebugSessionImpl implements XDebugSession {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.xdebugger.impl.XDebugSessionImpl");
|
||||
private XDebugProcess myDebugProcess;
|
||||
private final Map<XBreakpoint<?>, CustomizedBreakpointPresentation> myRegisteredBreakpoints = new HashMap<XBreakpoint<?>, CustomizedBreakpointPresentation>();
|
||||
private final Map<XBreakpoint<?>, CustomizedBreakpointPresentation> myRegisteredBreakpoints =
|
||||
new HashMap<XBreakpoint<?>, CustomizedBreakpointPresentation>();
|
||||
private final Set<XBreakpoint<?>> myDisabledSlaveBreakpoints = new HashSet<XBreakpoint<?>>();
|
||||
private boolean myBreakpointsMuted;
|
||||
private boolean myBreakpointsDisabled;
|
||||
@@ -80,11 +81,15 @@ public class XDebugSessionImpl implements XDebugSession {
|
||||
private boolean myStopped;
|
||||
private boolean myPauseActionSupported;
|
||||
|
||||
public XDebugSessionImpl(final @NotNull ExecutionEnvironment env, final @NotNull ProgramRunner runner, XDebuggerManagerImpl debuggerManager) {
|
||||
public XDebugSessionImpl(final @NotNull ExecutionEnvironment env,
|
||||
final @NotNull ProgramRunner runner,
|
||||
XDebuggerManagerImpl debuggerManager) {
|
||||
this(env, runner, debuggerManager, env.getRunProfile().getName());
|
||||
}
|
||||
|
||||
public XDebugSessionImpl(final @Nullable ExecutionEnvironment env, final @Nullable ProgramRunner runner, XDebuggerManagerImpl debuggerManager,
|
||||
public XDebugSessionImpl(final @Nullable ExecutionEnvironment env,
|
||||
final @Nullable ProgramRunner runner,
|
||||
XDebuggerManagerImpl debuggerManager,
|
||||
final @NotNull String sessionName) {
|
||||
myEnvironment = env;
|
||||
myRunner = runner;
|
||||
@@ -189,7 +194,7 @@ public class XDebugSessionImpl implements XDebugSession {
|
||||
|
||||
private void disableSlaveBreakpoints(final XDependentBreakpointManager dependentBreakpointManager) {
|
||||
Set<XBreakpoint<?>> slaveBreakpoints = dependentBreakpointManager.getAllSlaveBreakpoints();
|
||||
Set<XBreakpointType<?,?>> breakpointTypes = new HashSet<XBreakpointType<?,?>>();
|
||||
Set<XBreakpointType<?, ?>> breakpointTypes = new HashSet<XBreakpointType<?, ?>>();
|
||||
for (XBreakpointHandler<?> handler : myDebugProcess.getBreakpointHandlers()) {
|
||||
breakpointTypes.add(getBreakpointTypeClass(handler));
|
||||
}
|
||||
@@ -204,8 +209,10 @@ public class XDebugSessionImpl implements XDebugSession {
|
||||
return XDebuggerUtil.getInstance().findBreakpointType(handler.getBreakpointTypeClass());
|
||||
}
|
||||
|
||||
private <B extends XBreakpoint<?>> void processBreakpoints(final XBreakpointHandler<B> handler, boolean register, final boolean temporary) {
|
||||
XBreakpointType<B,?> type = XDebuggerUtil.getInstance().findBreakpointType(handler.getBreakpointTypeClass());
|
||||
private <B extends XBreakpoint<?>> void processBreakpoints(final XBreakpointHandler<B> handler,
|
||||
boolean register,
|
||||
final boolean temporary) {
|
||||
XBreakpointType<B, ?> type = XDebuggerUtil.getInstance().findBreakpointType(handler.getBreakpointTypeClass());
|
||||
Collection<? extends B> breakpoints = myDebuggerManager.getBreakpointManager().getBreakpoints(type);
|
||||
for (B b : breakpoints) {
|
||||
handleBreakpoint(handler, b, register, temporary);
|
||||
@@ -247,7 +254,9 @@ public class XDebugSessionImpl implements XDebugSession {
|
||||
}
|
||||
}
|
||||
|
||||
private <B extends XBreakpoint<?>> void processBreakpoint(final XBreakpoint<?> breakpoint, final XBreakpointHandler<B> handler, boolean register) {
|
||||
private <B extends XBreakpoint<?>> void processBreakpoint(final XBreakpoint<?> breakpoint,
|
||||
final XBreakpointHandler<B> handler,
|
||||
boolean register) {
|
||||
XBreakpointType<?, ?> type = breakpoint.getType();
|
||||
if (handler.getBreakpointTypeClass().equals(type.getClass())) {
|
||||
//noinspection unchecked
|
||||
@@ -349,16 +358,19 @@ public class XDebugSessionImpl implements XDebugSession {
|
||||
* Causes the same effect as #positionReached, but without changing context,
|
||||
* only updating position highlighting and re-enabling exceptions
|
||||
*/
|
||||
public void updateExecutionPosition() {
|
||||
public void updateExecutionPosition(boolean updateBreakpoints) {
|
||||
XExecutionStack activeExecutionStack = mySuspendContext.getActiveExecutionStack();
|
||||
boolean isTopFrame = activeExecutionStack != null && activeExecutionStack.getTopFrame() == myCurrentStackFrame;
|
||||
myDebuggerManager.updateExecutionPoint(myCurrentStackFrame.getSourcePosition(), !isTopFrame);
|
||||
|
||||
|
||||
disableBreakpoints();
|
||||
enableBreakpoints();
|
||||
if (updateBreakpoints) {
|
||||
disableBreakpoints();
|
||||
enableBreakpoints();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void showExecutionPoint() {
|
||||
if (mySuspendContext != null) {
|
||||
XExecutionStack executionStack = mySuspendContext.getActiveExecutionStack();
|
||||
@@ -396,7 +408,9 @@ public class XDebugSessionImpl implements XDebugSession {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateBreakpointPresentation(@NotNull final XLineBreakpoint<?> breakpoint, @Nullable final Icon icon, @Nullable final String errorMessage) {
|
||||
public void updateBreakpointPresentation(@NotNull final XLineBreakpoint<?> breakpoint,
|
||||
@Nullable final Icon icon,
|
||||
@Nullable final String errorMessage) {
|
||||
CustomizedBreakpointPresentation presentation;
|
||||
synchronized (myRegisteredBreakpoints) {
|
||||
presentation = myRegisteredBreakpoints.get(breakpoint);
|
||||
@@ -420,8 +434,8 @@ public class XDebugSessionImpl implements XDebugSession {
|
||||
String condition = breakpoint.getCondition();
|
||||
if (condition != null && evaluator != null) {
|
||||
LOG.debug("evaluating condition: " + condition);
|
||||
boolean result = evaluator.evaluateCondition(condition);
|
||||
LOG.debug("condition evaluates to " + result);
|
||||
boolean result = evaluator.evaluateCondition(condition);
|
||||
LOG.debug("condition evaluates to " + result);
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
@@ -430,7 +444,8 @@ public class XDebugSessionImpl implements XDebugSession {
|
||||
if (breakpoint.isLogMessage()) {
|
||||
String text = StringUtil.decapitalize(XBreakpointUtil.getDisplayText(breakpoint));
|
||||
final XSourcePosition position = breakpoint.getSourcePosition();
|
||||
final OpenFileHyperlinkInfo hyperlinkInfo = position != null ? new OpenFileHyperlinkInfo(myProject, position.getFile(), position.getLine()) : null;
|
||||
final OpenFileHyperlinkInfo hyperlinkInfo =
|
||||
position != null ? new OpenFileHyperlinkInfo(myProject, position.getFile(), position.getLine()) : null;
|
||||
printMessage(XDebuggerBundle.message("xbreakpoint.reached.text") + " ", text, hyperlinkInfo);
|
||||
}
|
||||
|
||||
@@ -553,7 +568,7 @@ public class XDebugSessionImpl implements XDebugSession {
|
||||
|
||||
public void stop() {
|
||||
ProcessHandler processHandler = myDebugProcess.getProcessHandler();
|
||||
if (processHandler.isProcessTerminated() || processHandler.isProcessTerminating()) return;
|
||||
if (processHandler.isProcessTerminated() || processHandler.isProcessTerminating()) return;
|
||||
|
||||
if (processHandler.detachIsDefault()) {
|
||||
processHandler.detachProcess();
|
||||
|
||||
+14
-6
@@ -101,17 +101,17 @@ public class SimplifiableAnnotationInspection extends BaseInspection {
|
||||
return;
|
||||
}
|
||||
final PsiNameValuePair[] attributes = parameterList.getAttributes();
|
||||
|
||||
final PsiElement[] annotationChildren = annotation.getChildren();
|
||||
if (annotationChildren.length >= 2) {
|
||||
final PsiElement child = annotationChildren[1];
|
||||
if (child instanceof PsiWhiteSpace) {
|
||||
final String annotationName = nameReferenceElement.getText();
|
||||
final String replacementText;
|
||||
if (attributes.length > 0) {
|
||||
replacementText = '@' + nameReferenceElement.getText() +
|
||||
replacementText = '@' + annotationName +
|
||||
parameterList.getText();
|
||||
} else {
|
||||
replacementText = '@' + nameReferenceElement.getText();
|
||||
replacementText = '@' + annotationName;
|
||||
}
|
||||
registerError(annotation, replacementText);
|
||||
return;
|
||||
@@ -122,15 +122,23 @@ public class SimplifiableAnnotationInspection extends BaseInspection {
|
||||
if (children.length <= 0) {
|
||||
return;
|
||||
}
|
||||
registerError(annotation, '@' + nameReferenceElement.getText());
|
||||
final String annotationName = nameReferenceElement.getText();
|
||||
registerError(annotation, '@' + annotationName);
|
||||
} else if (attributes.length == 1) {
|
||||
final PsiNameValuePair attribute = attributes[0];
|
||||
@NonNls final String name = attribute.getName();
|
||||
if (!"value".equals(name)) {
|
||||
return;
|
||||
}
|
||||
registerError(annotation, '@' + nameReferenceElement.getText() +
|
||||
'(' + attribute.getValue().getText() + ')');
|
||||
final PsiAnnotationMemberValue attributeValue =
|
||||
attribute.getValue();
|
||||
if (attributeValue == null) {
|
||||
return;
|
||||
}
|
||||
final String annotationName = nameReferenceElement.getText();
|
||||
final String replacementText = '@' + annotationName +
|
||||
'(' + attributeValue.getText() + ')';
|
||||
registerError(annotation, replacementText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<${ROOT_TAG} xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</${ROOT_TAG}>
|
||||
@@ -0,0 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>This is a built-in file template used to create layout xml files in Android applications.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -15,19 +15,13 @@
|
||||
*/
|
||||
package org.jetbrains.android;
|
||||
|
||||
import com.android.sdklib.SdkConstants;
|
||||
import com.intellij.codeInsight.completion.CompletionContributor;
|
||||
import com.intellij.codeInsight.completion.CompletionParameters;
|
||||
import com.intellij.codeInsight.completion.CompletionResultSet;
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.xml.XmlAttribute;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import org.jetbrains.android.dom.AndroidDomExtender;
|
||||
@@ -38,7 +32,6 @@ import org.jetbrains.android.dom.manifest.ManifestDomFileDescription;
|
||||
import org.jetbrains.android.dom.xml.AndroidXmlResourcesUtil;
|
||||
import org.jetbrains.android.dom.xml.XmlResourceDomFileDescription;
|
||||
import org.jetbrains.android.facet.AndroidFacet;
|
||||
import org.jetbrains.android.facet.AndroidRootUtil;
|
||||
import org.jetbrains.android.util.AndroidUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -56,24 +49,6 @@ public class AndroidCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean containsNamespace(@NotNull XmlTag tag, @NotNull String namespace) {
|
||||
for (XmlAttribute attribute : tag.getAttributes()) {
|
||||
if ("xmlns:android".equals(attribute.getName()) && namespace.equals(attribute.getValue())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isXmlResource(@NotNull AndroidFacet facet, @NotNull VirtualFile file) {
|
||||
String extension = FileUtil.getExtension(file.getName());
|
||||
if (!extension.equals("xml")) return false;
|
||||
VirtualFile parent = file.getParent();
|
||||
if (parent == null) return false;
|
||||
parent = parent.getParent();
|
||||
return parent != null && facet.getLocalResourceManager().isResourceDir(parent);
|
||||
}
|
||||
|
||||
private static boolean complete(@NotNull AndroidFacet facet, PsiElement position, CompletionResultSet resultSet) {
|
||||
PsiElement parent = position.getParent();
|
||||
if (parent instanceof XmlTag) {
|
||||
@@ -90,18 +65,10 @@ public class AndroidCompletionContributor extends CompletionContributor {
|
||||
resultSet.addElement(LookupElementBuilder.create("view"));
|
||||
resultSet.addElement(LookupElementBuilder.create("merge"));
|
||||
Map<String, PsiClass> viewClassMap = AndroidDomExtender.getViewClassMap(facet);
|
||||
final PsiClass viewGroupClass = viewClassMap.get("ViewGroup");
|
||||
for (String tagName : viewClassMap.keySet()) {
|
||||
final PsiClass viewClass = viewClassMap.get(tagName);
|
||||
if (!AndroidUtils.isAbstract(viewClass)) {
|
||||
boolean inheritsViewGroup = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
|
||||
public Boolean compute() {
|
||||
return viewClass.isInheritor(viewGroupClass, true);
|
||||
}
|
||||
});
|
||||
if (inheritsViewGroup) {
|
||||
resultSet.addElement(LookupElementBuilder.create(tagName));
|
||||
}
|
||||
resultSet.addElement(LookupElementBuilder.create(tagName));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -117,27 +84,6 @@ public class AndroidCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
}
|
||||
}
|
||||
VirtualFile containingFile = parent.getContainingFile().getOriginalFile().getVirtualFile();
|
||||
if (containingFile != null &&
|
||||
(isXmlResource(facet, containingFile) || AndroidRootUtil.getManifestFile(facet.getModule()) == containingFile)) {
|
||||
if (parent instanceof XmlAttribute) {
|
||||
XmlAttribute attribute = (XmlAttribute)parent;
|
||||
XmlTag tag = attribute.getParent();
|
||||
if (!containsNamespace(tag, SdkConstants.NS_RESOURCES)) {
|
||||
String prefix = attribute.getNamespacePrefix();
|
||||
String s = null;
|
||||
if (prefix.length() == 0) {
|
||||
s = "xmlns:android";
|
||||
}
|
||||
else if (prefix.equals("xmlns")) {
|
||||
s = "android";
|
||||
}
|
||||
if (s != null) {
|
||||
resultSet.addElement(LookupElementBuilder.create(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ public class AndroidFileTemplateProvider implements FileTemplateGroupDescriptorF
|
||||
@NonNls public static final String ANDROID_MANIFEST_TEMPLATE = SdkConstants.FN_ANDROID_MANIFEST_XML;
|
||||
@NonNls public static final String VALUE_RESOURCE_FILE_TEMPLATE = "valueResourceFile.xml";
|
||||
@NonNls public static final String RESOURCE_FILE_TEMPLATE = "resourceFile.xml";
|
||||
@NonNls public static final String LAYOUT_RESOURCE_FILE_TEMPLATE = "layoutResourceFile.xml";
|
||||
@NonNls public static final String ACTIVITY = "Activity.java";
|
||||
@NonNls public static final String SERVICE = "Service.java";
|
||||
@NonNls public static final String BROADCAST_RECEIVER = "Broadcast Receiver.java";
|
||||
@@ -49,6 +50,7 @@ public class AndroidFileTemplateProvider implements FileTemplateGroupDescriptorF
|
||||
group.addTemplate(new FileTemplateDescriptor(ANDROID_MANIFEST_TEMPLATE, StdFileTypes.XML.getIcon()));
|
||||
group.addTemplate(new FileTemplateDescriptor(VALUE_RESOURCE_FILE_TEMPLATE, StdFileTypes.XML.getIcon()));
|
||||
group.addTemplate(new FileTemplateDescriptor(RESOURCE_FILE_TEMPLATE, StdFileTypes.XML.getIcon()));
|
||||
group.addTemplate(new FileTemplateDescriptor(LAYOUT_RESOURCE_FILE_TEMPLATE, StdFileTypes.XML.getIcon()));
|
||||
group.addTemplate(new FileTemplateDescriptor(ACTIVITY, StdFileTypes.JAVA.getIcon()));
|
||||
group.addTemplate(new FileTemplateDescriptor(SERVICE, StdFileTypes.JAVA.getIcon()));
|
||||
group.addTemplate(new FileTemplateDescriptor(BROADCAST_RECEIVER, StdFileTypes.JAVA.getIcon()));
|
||||
|
||||
+38
-28
@@ -102,7 +102,7 @@ public class CreateTypedResourceFileAction extends CreateElementActionBase {
|
||||
@Override
|
||||
protected PsiElement[] create(String newName, PsiDirectory directory) throws Exception {
|
||||
FileTemplateManager manager = FileTemplateManager.getInstance();
|
||||
String templateName = myValuesResourceFile ? AndroidFileTemplateProvider.VALUE_RESOURCE_FILE_TEMPLATE : AndroidFileTemplateProvider.RESOURCE_FILE_TEMPLATE;
|
||||
String templateName = getTemplateName();
|
||||
FileTemplate template = manager.getJ2eeTemplate(templateName);
|
||||
Properties properties = new Properties();
|
||||
if (!myValuesResourceFile) {
|
||||
@@ -135,35 +135,45 @@ public class CreateTypedResourceFileAction extends CreateElementActionBase {
|
||||
return new PsiElement[]{createdElement};
|
||||
}
|
||||
|
||||
/* private void invokeCompletion(Project project, final Editor editor, XmlFile file) {
|
||||
new CodeCompletionHandlerBase(CompletionType.BASIC).invokeCompletion(project, editor, file, 1);
|
||||
CompletionProgressIndicator indicator = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
|
||||
if (indicator != null) {
|
||||
final LookupImpl lookup = indicator.getLookup();
|
||||
lookup.setAdditionalPrefix(myDefaultRootTag);
|
||||
lookup.addLookupListener(new LookupAdapter() {
|
||||
boolean prefixCanceled;
|
||||
|
||||
@Override
|
||||
public void itemSelected(LookupEvent event) {
|
||||
TemplateManagerImpl.getTemplateState(editor).gotoEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void currentItemChanged(LookupEvent event) {
|
||||
if (!prefixCanceled) {
|
||||
prefixCanceled = true;
|
||||
lookup.setAdditionalPrefix("");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lookupCanceled(LookupEvent event) {
|
||||
}
|
||||
});
|
||||
private String getTemplateName() {
|
||||
if (myValuesResourceFile) {
|
||||
return AndroidFileTemplateProvider.VALUE_RESOURCE_FILE_TEMPLATE;
|
||||
}
|
||||
if ("layout".equals(myResourceType)) {
|
||||
return AndroidFileTemplateProvider.LAYOUT_RESOURCE_FILE_TEMPLATE;
|
||||
}
|
||||
return AndroidFileTemplateProvider.RESOURCE_FILE_TEMPLATE;
|
||||
}
|
||||
*/
|
||||
|
||||
/* private void invokeCompletion(Project project, final Editor editor, XmlFile file) {
|
||||
new CodeCompletionHandlerBase(CompletionType.BASIC).invokeCompletion(project, editor, file, 1);
|
||||
CompletionProgressIndicator indicator = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
|
||||
if (indicator != null) {
|
||||
final LookupImpl lookup = indicator.getLookup();
|
||||
lookup.setAdditionalPrefix(myDefaultRootTag);
|
||||
lookup.addLookupListener(new LookupAdapter() {
|
||||
boolean prefixCanceled;
|
||||
|
||||
@Override
|
||||
public void itemSelected(LookupEvent event) {
|
||||
TemplateManagerImpl.getTemplateState(editor).gotoEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void currentItemChanged(LookupEvent event) {
|
||||
if (!prefixCanceled) {
|
||||
prefixCanceled = true;
|
||||
lookup.setAdditionalPrefix("");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lookupCanceled(LookupEvent event) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
*/
|
||||
@Override
|
||||
protected boolean isAvailable(DataContext context) {
|
||||
if (!super.isAvailable(context)) return false;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<TextVi<caret>
|
||||
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<TextView
|
||||
@@ -153,9 +153,9 @@ public class AndroidLayoutDomTest extends AndroidDomTest {
|
||||
doTestCompletionVariants("tn3.xml", "View", "ViewAnimator", "ViewFlipper", "ViewStub", "ViewSwitcher");
|
||||
}
|
||||
|
||||
public void testTagNameCompletion4() throws Throwable {
|
||||
/*public void testTagNameCompletion4() throws Throwable {
|
||||
toTestCompletion("tn4.xml", "tn4_after.xml");
|
||||
}
|
||||
}*/
|
||||
|
||||
public void testTagNameCompletion5() throws Throwable {
|
||||
toTestCompletion("tn5.xml", "tn5_after.xml");
|
||||
@@ -197,6 +197,10 @@ public class AndroidLayoutDomTest extends AndroidDomTest {
|
||||
toTestCompletion("tableCell.xml", "tableCell_after.xml");
|
||||
}
|
||||
|
||||
public void testTextViewRootTag_IDEA_62889() throws Throwable {
|
||||
toTestCompletion("textViewRootTag.xml", "textViewRootTag_after.xml");
|
||||
}
|
||||
|
||||
public void testRequestFocus() throws Throwable {
|
||||
toTestCompletion(getTestName(true) + ".xml", getTestName(true) + "_after.xml");
|
||||
}
|
||||
|
||||
@@ -98,9 +98,9 @@ public class AndroidManifestDomTest extends AndroidDomTest {
|
||||
doTestHighlighting("unknownAttribute.xml");
|
||||
}
|
||||
|
||||
public void testNamespaceCompletion() throws Throwable {
|
||||
/*public void testNamespaceCompletion() throws Throwable {
|
||||
toTestCompletion("ns.xml", "ns_after.xml");
|
||||
}
|
||||
}*/
|
||||
|
||||
public void testInnerActivityHighlighting() throws Throwable {
|
||||
copyFileToProject("A.java", "src/p1/p2/A.java");
|
||||
|
||||
+1
-1
@@ -64,8 +64,8 @@ public class CvsRootOnFileSystem extends CvsRootProvider {
|
||||
File result = nearestRoot;
|
||||
if (result.getParentFile() == null) return result;
|
||||
while (cvsRoot.equals(getCvsRootFor(result.getParentFile()))) {
|
||||
if (result.getParentFile() == null) return result;
|
||||
result = result.getParentFile();
|
||||
if (result.getParentFile() == null) return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+4
@@ -70,4 +70,8 @@ public class SimpleRevision implements RevisionOrDate {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return myRevision;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -24,6 +24,7 @@ import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.ProblemHighlightType;
|
||||
import com.intellij.lang.annotation.Annotation;
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.lang.annotation.AnnotationSession;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
@@ -109,7 +110,7 @@ public class GroovyUnusedImportPass extends TextEditorHighlightingPass {
|
||||
}
|
||||
|
||||
public void doApplyInformationToEditor() {
|
||||
AnnotationHolder annotationHolder = new AnnotationHolderImpl();
|
||||
AnnotationHolder annotationHolder = new AnnotationHolderImpl(new AnnotationSession(myFile));
|
||||
List<HighlightInfo> infos = new ArrayList<HighlightInfo>(myUnusedImports.size());
|
||||
for (GrImportStatement unusedImport : myUnusedImports) {
|
||||
Annotation annotation = annotationHolder.createWarningAnnotation(unusedImport, GroovyInspectionBundle.message("unused.import"));
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.Notifications;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.event.DocumentAdapter;
|
||||
@@ -369,6 +370,10 @@ public class GroovyDslFileIndex extends ScalarIndexExtension<String> {
|
||||
final String exceptionText = writer.toString();
|
||||
LOG.info(exceptionText);
|
||||
|
||||
if (!ApplicationManagerEx.getApplicationEx().isInternal() && !ProjectRootManager.getInstance(project).getFileIndex().isInContent(vfile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().getMessageBus().syncPublisher(Notifications.TOPIC).notify(
|
||||
new Notification("Groovy DSL parsing", "DSL script execution error",
|
||||
"<p>" + e.getMessage() + "</p><p><a href=\"\">Click here to investigate.</a></p>", NotificationType.ERROR,
|
||||
|
||||
@@ -33,16 +33,22 @@ import com.intellij.psi.util.CachedValue;
|
||||
import com.intellij.psi.util.CachedValueProvider;
|
||||
import com.intellij.psi.util.CachedValuesManager;
|
||||
import com.intellij.psi.util.PsiModificationTracker;
|
||||
import com.intellij.reference.SoftReference;
|
||||
import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.containers.CollectionFactory;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.lang.UrlClassLoader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.extensions.GroovyScriptTypeDetector;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
/**
|
||||
* @author ilyas, peter
|
||||
@@ -51,7 +57,7 @@ public class AntTasksProvider {
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.gant.AntTasksProvider");
|
||||
public static final boolean antAvailable;
|
||||
private static final Key<CachedValue<Set<LightMethodBuilder>>> GANT_METHODS = Key.create("gantMethods");
|
||||
private static final Key<CachedValue<Map<String, Class>>> ANT_OBJECTS = Key.create("antObjects");
|
||||
private static final Object ourLock = new Object();
|
||||
|
||||
private AntTasksProvider() {
|
||||
}
|
||||
@@ -96,68 +102,94 @@ public class AntTasksProvider {
|
||||
}
|
||||
|
||||
private static Map<String, Class> getAntObjects(final GroovyFile groovyFile) {
|
||||
return CachedValuesManager
|
||||
.getManager(groovyFile.getProject()).getCachedValue(groovyFile, ANT_OBJECTS, new CachedValueProvider<Map<String, Class>>() {
|
||||
final Project project = groovyFile.getProject();
|
||||
|
||||
final Module module = ModuleUtil.findModuleForPsiElement(groovyFile);
|
||||
Set<VirtualFile> jars = new HashSet<VirtualFile>();
|
||||
if (module != null) {
|
||||
ContainerUtil.addAll(jars, OrderEnumerator.orderEntries(module).getAllLibrariesAndSdkClassesRoots());
|
||||
}
|
||||
|
||||
if (groovyFile.isScript() && GroovyScriptTypeDetector.getScriptType(groovyFile) instanceof GantScriptType) {
|
||||
jars.addAll(GantScriptType.additionalScopeFiles(groovyFile));
|
||||
}
|
||||
|
||||
final ArrayList<URL> urls = new ArrayList<URL>();
|
||||
for (VirtualFile jar : jars) {
|
||||
urls.add(VfsUtil.convertToURL(PathUtil.getLocalFile(jar).getUrl()));
|
||||
}
|
||||
|
||||
AntClassLoader loader;
|
||||
synchronized (ourLock) {
|
||||
final Map<List<URL>, SoftReference<AntClassLoader>> map = CachedValuesManager.getManager(project).getCachedValue(project, new CachedValueProvider<Map<List<URL>, SoftReference<AntClassLoader>>>() {
|
||||
@Override
|
||||
public Result<Map<String, Class>> compute() {
|
||||
final Module module = ModuleUtil.findModuleForPsiElement(groovyFile);
|
||||
Set<VirtualFile> jars = new HashSet<VirtualFile>();
|
||||
if (module != null) {
|
||||
ContainerUtil.addAll(jars, OrderEnumerator.orderEntries(module).getAllLibrariesAndSdkClassesRoots());
|
||||
}
|
||||
|
||||
if (groovyFile.isScript() && GroovyScriptTypeDetector.getScriptType(groovyFile) instanceof GantScriptType) {
|
||||
jars.addAll(GantScriptType.additionalScopeFiles(groovyFile));
|
||||
}
|
||||
|
||||
final ArrayList<URL> urls = new ArrayList<URL>();
|
||||
for (VirtualFile jar : jars) {
|
||||
urls.add(VfsUtil.convertToURL(PathUtil.getLocalFile(jar).getUrl()));
|
||||
}
|
||||
final ClassLoader loader = new UrlClassLoader(urls, null, false, false, true);
|
||||
Future<ReflectedProject> future = ApplicationManager.getApplication().executeOnPooledThread(new Callable<ReflectedProject>() {
|
||||
@Override
|
||||
public ReflectedProject call() throws Exception {
|
||||
try {
|
||||
return ReflectedProject.getProject(loader);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ReflectedProject antProject = null;
|
||||
while (true) {
|
||||
try {
|
||||
antProject = future.get(100, TimeUnit.MILLISECONDS);
|
||||
break;
|
||||
}
|
||||
catch (TimeoutException ignore) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
break;
|
||||
}
|
||||
ProgressManager.checkCanceled();
|
||||
}
|
||||
|
||||
final Map<String, Class> result = new HashMap<String, Class>();
|
||||
if (antProject != null) {
|
||||
final Map<String, Class> taskDefinitions = antProject.getTaskDefinitions();
|
||||
if (taskDefinitions != null) {
|
||||
result.putAll(taskDefinitions);
|
||||
}
|
||||
final Map<String, Class> dataTypeDefinitions = antProject.getDataTypeDefinitions();
|
||||
if (dataTypeDefinitions != null) {
|
||||
result.putAll(dataTypeDefinitions);
|
||||
}
|
||||
}
|
||||
return Result.create(result, ProjectRootManager.getInstance(groovyFile.getProject()));
|
||||
public Result<Map<List<URL>, SoftReference<AntClassLoader>>> compute() {
|
||||
final Map<List<URL>, SoftReference<AntClassLoader>> map = CollectionFactory.hashMap();
|
||||
final Result<Map<List<URL>, SoftReference<AntClassLoader>>> result = Result.create(map, ProjectRootManager.getInstance(project));
|
||||
result.setLockValue(true);
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
}, false);
|
||||
final SoftReference<AntClassLoader> reference = map.get(urls);
|
||||
loader = reference != null ? reference.get() : null;
|
||||
if (loader == null) {
|
||||
map.put(urls, new SoftReference<AntClassLoader>(loader = new AntClassLoader(urls)));
|
||||
}
|
||||
}
|
||||
|
||||
return loader.getAntObjects();
|
||||
}
|
||||
|
||||
private static class AntClassLoader extends UrlClassLoader {
|
||||
private final Future<Map<String, Class>> myFuture;
|
||||
|
||||
public AntClassLoader(ArrayList<URL> urls) {
|
||||
super(urls, null, false, false, true);
|
||||
myFuture = ApplicationManager.getApplication().executeOnPooledThread(new Callable<Map<String, Class>>() {
|
||||
@Override
|
||||
public Map<String, Class> call() throws Exception {
|
||||
try {
|
||||
final ReflectedProject antProject = ReflectedProject.getProject(AntClassLoader.this);
|
||||
final Map<String, Class> result = new HashMap<String, Class>();
|
||||
if (antProject != null) {
|
||||
final Map<String, Class> taskDefinitions = antProject.getTaskDefinitions();
|
||||
if (taskDefinitions != null) {
|
||||
result.putAll(taskDefinitions);
|
||||
}
|
||||
final Map<String, Class> dataTypeDefinitions = antProject.getDataTypeDefinitions();
|
||||
if (dataTypeDefinitions != null) {
|
||||
result.putAll(dataTypeDefinitions);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Map<String, Class> getAntObjects() {
|
||||
while (true) {
|
||||
try {
|
||||
final Map<String, Class> map = myFuture.get(100, TimeUnit.MILLISECONDS);
|
||||
if (map != null) {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
catch (TimeoutException ignore) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
break;
|
||||
}
|
||||
ProgressManager.checkCanceled();
|
||||
}
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.intellij.plugins.xpathView.util;
|
||||
|
||||
import com.intellij.lang.annotation.AnnotationSession;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -138,7 +139,7 @@ public class MyPsiUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String checkFile(PsiFile file) {
|
||||
public static String checkFile(final PsiFile file) {
|
||||
final String[] error = new String[1];
|
||||
file.accept(new PsiRecursiveElementVisitor() {
|
||||
public void visitErrorElement(PsiErrorElement element) {
|
||||
@@ -150,7 +151,7 @@ public class MyPsiUtil {
|
||||
final Annotator annotator = LanguageAnnotators.INSTANCE.forLanguage(file.getLanguage());
|
||||
file.accept(new PsiRecursiveElementVisitor() {
|
||||
public void visitElement(PsiElement element) {
|
||||
annotator.annotate(element, new AnnotationHolderImpl() {
|
||||
annotator.annotate(element, new AnnotationHolderImpl(new AnnotationSession(file)) {
|
||||
public Annotation createErrorAnnotation(@NotNull ASTNode astNode, String string) {
|
||||
error[0] = string;
|
||||
return super.createErrorAnnotation(astNode, string);
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
class UiControl {
|
||||
public static final Color COLOR = new Color(100, 120, 140);
|
||||
public static final Color COLOR = <spot>new Color(100, 120, 140)</spot>;
|
||||
}
|
||||
@@ -853,10 +853,6 @@
|
||||
implementationClass="com.intellij.openapi.roots.ui.configuration.libraryEditor.ClassesOrderRootTypeUIFactory"/>
|
||||
<OrderRootTypeUI key="SOURCES"
|
||||
implementationClass="com.intellij.openapi.roots.ui.configuration.libraryEditor.SourcesOrderRootTypeUIFactory"/>
|
||||
<!--
|
||||
<OrderRootTypeUI key="DOCUMENTATION"
|
||||
implementationClass="com.intellij.openapi.roots.libraries.doc.DocOrderRootTypeUIFactory"/>
|
||||
-->
|
||||
|
||||
<getDataRule key="analysisScope" implementationClass="com.intellij.analysis.AnalysisScopeRule"/>
|
||||
<getDataRule key="context.ProjectFileDirectory" implementationClass="com.intellij.ide.impl.dataRules.ProjectFileDirectoryRule"/>
|
||||
@@ -939,8 +935,6 @@
|
||||
|
||||
<orderRootType implementation="com.intellij.openapi.roots.AnnotationOrderRootType"/>
|
||||
<orderRootType implementation="com.intellij.openapi.roots.JavadocOrderRootType"/>
|
||||
|
||||
<!-- <orderRootType implementation="com.intellij.openapi.roots.libraries.doc.DocOrderRootType"/> -->
|
||||
|
||||
<highlightUsagesHandlerFactory implementation="com.intellij.codeInsight.highlighting.HighlightExceptionsHandlerFactory"/>
|
||||
<highlightUsagesHandlerFactory implementation="com.intellij.codeInsight.highlighting.HighlightSuppressedWarningsFactory"/>
|
||||
|
||||
+6
-20
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.intellij.util.xml.highlighting;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.AnnotationHolderImpl;
|
||||
import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.InspectionManager;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
@@ -26,31 +24,23 @@ import com.intellij.codeInspection.ProblemHighlightType;
|
||||
import com.intellij.lang.annotation.Annotation;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.editor.colors.CodeInsightColors;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.xml.util.XmlStringUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* User: Sergey.Vasiliev
|
||||
*/
|
||||
public class DomElementsHighlightingUtil {
|
||||
|
||||
private static final AnnotationHolderImpl EMPTY_ANNOTATION_HOLDER = new AnnotationHolderImpl() {
|
||||
public boolean add(final Annotation annotation) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
private DomElementsHighlightingUtil() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ProblemDescriptor createProblemDescriptors(final InspectionManager manager,
|
||||
final DomElementProblemDescriptor problemDescriptor) {
|
||||
public static ProblemDescriptor createProblemDescriptors(final InspectionManager manager, final DomElementProblemDescriptor problemDescriptor) {
|
||||
final ProblemHighlightType type = getProblemHighlightType(problemDescriptor);
|
||||
return createProblemDescriptors(problemDescriptor, new Function<Pair<TextRange, PsiElement>, ProblemDescriptor>() {
|
||||
public ProblemDescriptor fun(final Pair<TextRange, PsiElement> s) {
|
||||
@@ -82,12 +72,11 @@ public class DomElementsHighlightingUtil {
|
||||
String text = problemDescriptor.getDescriptionTemplate();
|
||||
if (StringUtil.isEmpty(text)) text = null;
|
||||
final HighlightSeverity severity = problemDescriptor.getHighlightSeverity();
|
||||
final AnnotationHolderImpl holder = EMPTY_ANNOTATION_HOLDER;
|
||||
|
||||
TextRange range = s.first;
|
||||
if (text == null) range = TextRange.from(range.getStartOffset(), 0);
|
||||
range = range.shiftRight(s.second.getTextRange().getStartOffset());
|
||||
final Annotation annotation = createAnnotation(severity, holder, range, text, s.second.getProject());
|
||||
final Annotation annotation = createAnnotation(severity, range, text);
|
||||
|
||||
if (problemDescriptor instanceof DomElementResolveProblemDescriptor) {
|
||||
annotation.setTextAttributes(CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES);
|
||||
@@ -102,13 +91,10 @@ public class DomElementsHighlightingUtil {
|
||||
}
|
||||
|
||||
private static Annotation createAnnotation(final HighlightSeverity severity,
|
||||
final AnnotationHolderImpl holder,
|
||||
final TextRange range,
|
||||
final String text, final Project project) {
|
||||
if (SeverityRegistrar.getInstance(project).compare(severity, HighlightSeverity.ERROR) >= 0) return holder.createErrorAnnotation(range, text);
|
||||
if (SeverityRegistrar.getInstance(project).compare(severity, HighlightSeverity.WARNING) >= 0) return holder.createWarningAnnotation(range, text);
|
||||
if (SeverityRegistrar.getInstance(project).compare(severity, HighlightSeverity.INFO) >= 0) return holder.createInformationAnnotation(range, text);
|
||||
return holder.createInfoAnnotation(range, text);
|
||||
final String text) {
|
||||
String tooltip = text == null ? null : "<html><body>" + XmlStringUtil.escapeString(text) + "</body></html>";
|
||||
return new Annotation(range.getStartOffset(), range.getEndOffset(), severity, text, tooltip);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -64,13 +63,14 @@ public class XmlSmartCompletionProvider {
|
||||
}
|
||||
|
||||
private static void addElementToResult(@NotNull XmlElementDescriptor descriptor, CompletionResultSet result) {
|
||||
LookupElementBuilder builder = createLookupElement(descriptor);
|
||||
result.addElement(builder.setInsertHandler(new InsertHandler<LookupElement>() {
|
||||
@Override
|
||||
public void handleInsert(InsertionContext context, LookupElement item) {
|
||||
XmlTagInsertHandler.INSTANCE.handleInsert(context, item);
|
||||
XmlTagInsertHandler insertHandler = XmlTagInsertHandler.INSTANCE;
|
||||
if (descriptor instanceof XmlElementDescriptorImpl) {
|
||||
String name = descriptor.getName();
|
||||
if (name != null) {
|
||||
insertHandler = new ExtendedTagInsertHandler(name, ((XmlElementDescriptorImpl)descriptor).getNamespace(), null);
|
||||
}
|
||||
}));
|
||||
}
|
||||
result.addElement(createLookupElement(descriptor).setInsertHandler(insertHandler));
|
||||
}
|
||||
|
||||
public static LookupElementBuilder createLookupElement(@NotNull XmlElementDescriptor descriptor) {
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
package com.intellij.xml.util;
|
||||
|
||||
import com.intellij.codeInsight.daemon.EmptyResolveMessageProvider;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.ElementManipulators;
|
||||
@@ -202,7 +204,12 @@ class AnchorReference implements PsiReference, EmptyResolveMessageProvider {
|
||||
final Map<String, XmlTag> idMap = getIdMap();
|
||||
if (idMap == null) return ArrayUtil.EMPTY_OBJECT_ARRAY;
|
||||
|
||||
return idMap.keySet().toArray(new Object[idMap.size()]);
|
||||
String[] variants = idMap.keySet().toArray(new String[idMap.size()]);
|
||||
LookupElement[] elements = new LookupElement[variants.length];
|
||||
for (int i = 0, variantsLength = variants.length; i < variantsLength; i++) {
|
||||
elements[i] = LookupElementBuilder.create(variants[i]).setCaseSensitive(true);
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user