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:
Generated
+1
-1
@@ -27,7 +27,7 @@
|
||||
<component name="ProjectKey">
|
||||
<option name="state" value="$PROJECT_DIR$/.idea/misc.xml" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_5" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA jdk" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA jdk" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="SvnBranchConfigurationManager">
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.OrderedSet;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
|
||||
@@ -85,116 +86,103 @@ public class ModuleChunkClasspath extends Path {
|
||||
processedModules.add(module);
|
||||
final ProjectEx project = (ProjectEx)chunk.getProject();
|
||||
final File baseDir = BuildProperties.getProjectBaseDir(project);
|
||||
for (final OrderEntry orderEntry : ModuleRootManager.getInstance(module).getOrderEntries()) {
|
||||
if (!orderEntry.isValid()) {
|
||||
continue;
|
||||
}
|
||||
if (orderEntry instanceof ExportableOrderEntry) {
|
||||
ExportableOrderEntry e = (ExportableOrderEntry)orderEntry;
|
||||
switch (e.getScope()) {
|
||||
case COMPILE:
|
||||
break;
|
||||
case PROVIDED:
|
||||
if (generateRuntimeClasspath && !generateTestClasspath) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case RUNTIME:
|
||||
if (!generateRuntimeClasspath) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case TEST:
|
||||
if (!generateTestClasspath) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!generateRuntimeClasspath) {
|
||||
// needed for compilation classpath only
|
||||
if ((orderEntry instanceof ModuleSourceOrderEntry)) {
|
||||
// this is the entry for outpath of the currently processed module
|
||||
if (!generateTestClasspath && (dependencyLevel == 0 || chunk.contains(module))) {
|
||||
// the root module is never included
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
final boolean isExported = (orderEntry instanceof ExportableOrderEntry) && ((ExportableOrderEntry)orderEntry).isExported();
|
||||
if (dependencyLevel > 0 && !isExported) {
|
||||
if (!(orderEntry instanceof ModuleOrderEntry)) {
|
||||
// non-exported dependencies are excluded and not processed
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (orderEntry instanceof JdkOrderEntry) {
|
||||
if (genOptions.forceTargetJdk && !generateRuntimeClasspath) {
|
||||
pathItems
|
||||
.add(new PathRefItem(BuildProperties.propertyRef(BuildProperties.getModuleChunkJdkClasspathProperty(chunk.getName()))));
|
||||
}
|
||||
}
|
||||
else if (orderEntry instanceof ModuleOrderEntry) {
|
||||
final ModuleOrderEntry moduleOrderEntry = (ModuleOrderEntry)orderEntry;
|
||||
final Module dependentModule = moduleOrderEntry.getModule();
|
||||
if (!chunk.contains(dependentModule)) {
|
||||
if (generateRuntimeClasspath && !genOptions.inlineRuntimeClasspath) {
|
||||
// in case of runtime classpath, just an referenced to corresponding classpath is created
|
||||
final ModuleChunk depChunk = genOptions.getChunkByModule(dependentModule);
|
||||
if (!processedChunks.contains(depChunk)) {
|
||||
// chunk references are included in the runtime classpath only once
|
||||
processedChunks.add(depChunk);
|
||||
String property = generateTestClasspath ? BuildProperties.getTestRuntimeClasspathProperty(depChunk.getName())
|
||||
: BuildProperties.getRuntimeClasspathProperty(depChunk.getName());
|
||||
pathItems.add(new PathRefItem(property));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// in case of compile classpath or inlined runtime classpath,
|
||||
// the referenced module is processed recursively
|
||||
processModule(dependentModule, dependencyLevel + 1, moduleOrderEntry.isExported());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (orderEntry instanceof LibraryOrderEntry) {
|
||||
final LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry)orderEntry;
|
||||
final String libraryName = libraryOrderEntry.getLibraryName();
|
||||
if (((LibraryOrderEntry)orderEntry).isModuleLevel()) {
|
||||
CompositeGenerator gen = new CompositeGenerator();
|
||||
gen.setHasLeadingNewline(false);
|
||||
LibraryDefinitionsGeneratorFactory.genLibraryContent(project, genOptions, libraryOrderEntry.getLibrary(), baseDir, gen);
|
||||
pathItems.add(new GeneratorItem(libraryName, gen));
|
||||
}
|
||||
else {
|
||||
pathItems.add(new PathRefItem(BuildProperties.getLibraryPathId(libraryName)));
|
||||
}
|
||||
}
|
||||
else if (orderEntry instanceof ModuleSourceOrderEntry) {
|
||||
// Module source entry?
|
||||
for (String url : getCompilationClasses(orderEntry, ((GenerationOptionsImpl)genOptions), generateRuntimeClasspath,
|
||||
generateTestClasspath, dependencyLevel == 0)) {
|
||||
if (url.endsWith(JarFileSystem.JAR_SEPARATOR)) {
|
||||
url = url.substring(0, url.length() - JarFileSystem.JAR_SEPARATOR.length());
|
||||
}
|
||||
final String propertyRef = genOptions.getPropertyRefForUrl(url);
|
||||
if (propertyRef != null) {
|
||||
pathItems.add(new PathElementItem(propertyRef));
|
||||
}
|
||||
else {
|
||||
final String path = VirtualFileManager.extractPath(url);
|
||||
pathItems.add(new PathElementItem(
|
||||
GenerationUtils.toRelativePath(path, chunk.getBaseDir(), moduleChunkBasedirProperty, genOptions)));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Unknown order entry type. If it is actually encountered, extension point should be implemented
|
||||
pathItems.add(new GeneratorItem(orderEntry.getClass().getName(),
|
||||
new Comment("Unknown OrderEntryType: " + orderEntry.getClass().getName())));
|
||||
OrderEnumerator enumerator = ModuleRootManager.getInstance(module).orderEntries();
|
||||
if (generateRuntimeClasspath) {
|
||||
enumerator = enumerator.runtimeOnly();
|
||||
}
|
||||
else {
|
||||
enumerator = enumerator.compileOnly();
|
||||
if (!generateTestClasspath && (dependencyLevel == 0 || chunk.contains(module))) {
|
||||
// this is the entry for outpath of the currently processed module
|
||||
// the root module is never included
|
||||
enumerator = enumerator.withoutModuleSourceEntries();
|
||||
}
|
||||
}
|
||||
if (!generateTestClasspath) {
|
||||
enumerator = enumerator.productionOnly();
|
||||
}
|
||||
enumerator.forEach(new Processor<OrderEntry>() {
|
||||
@Override
|
||||
public boolean process(OrderEntry orderEntry) {
|
||||
if (!orderEntry.isValid()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!generateRuntimeClasspath && !(orderEntry instanceof ModuleOrderEntry)) {
|
||||
// needed for compilation classpath only
|
||||
final boolean isExported = (orderEntry instanceof ExportableOrderEntry) && ((ExportableOrderEntry)orderEntry).isExported();
|
||||
if (dependencyLevel > 0 && !isExported) {
|
||||
// non-exported dependencies are excluded and not processed
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (orderEntry instanceof JdkOrderEntry) {
|
||||
if (genOptions.forceTargetJdk && !generateRuntimeClasspath) {
|
||||
pathItems.add(new PathRefItem(BuildProperties.propertyRef(BuildProperties.getModuleChunkJdkClasspathProperty(chunk.getName()))));
|
||||
}
|
||||
}
|
||||
else if (orderEntry instanceof ModuleOrderEntry) {
|
||||
final ModuleOrderEntry moduleOrderEntry = (ModuleOrderEntry)orderEntry;
|
||||
final Module dependentModule = moduleOrderEntry.getModule();
|
||||
if (!chunk.contains(dependentModule)) {
|
||||
if (generateRuntimeClasspath && !genOptions.inlineRuntimeClasspath) {
|
||||
// in case of runtime classpath, just an referenced to corresponding classpath is created
|
||||
final ModuleChunk depChunk = genOptions.getChunkByModule(dependentModule);
|
||||
if (!processedChunks.contains(depChunk)) {
|
||||
// chunk references are included in the runtime classpath only once
|
||||
processedChunks.add(depChunk);
|
||||
String property = generateTestClasspath ? BuildProperties.getTestRuntimeClasspathProperty(depChunk.getName())
|
||||
: BuildProperties.getRuntimeClasspathProperty(depChunk.getName());
|
||||
pathItems.add(new PathRefItem(property));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// in case of compile classpath or inlined runtime classpath,
|
||||
// the referenced module is processed recursively
|
||||
processModule(dependentModule, dependencyLevel + 1, moduleOrderEntry.isExported());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (orderEntry instanceof LibraryOrderEntry) {
|
||||
final LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry)orderEntry;
|
||||
final String libraryName = libraryOrderEntry.getLibraryName();
|
||||
if (((LibraryOrderEntry)orderEntry).isModuleLevel()) {
|
||||
CompositeGenerator gen = new CompositeGenerator();
|
||||
gen.setHasLeadingNewline(false);
|
||||
LibraryDefinitionsGeneratorFactory.genLibraryContent(project, genOptions, libraryOrderEntry.getLibrary(), baseDir, gen);
|
||||
pathItems.add(new GeneratorItem(libraryName, gen));
|
||||
}
|
||||
else {
|
||||
pathItems.add(new PathRefItem(BuildProperties.getLibraryPathId(libraryName)));
|
||||
}
|
||||
}
|
||||
else if (orderEntry instanceof ModuleSourceOrderEntry) {
|
||||
// Module source entry?
|
||||
for (String url : getCompilationClasses(module, ((GenerationOptionsImpl)genOptions), generateRuntimeClasspath,
|
||||
generateTestClasspath, dependencyLevel == 0)) {
|
||||
if (url.endsWith(JarFileSystem.JAR_SEPARATOR)) {
|
||||
url = url.substring(0, url.length() - JarFileSystem.JAR_SEPARATOR.length());
|
||||
}
|
||||
final String propertyRef = genOptions.getPropertyRefForUrl(url);
|
||||
if (propertyRef != null) {
|
||||
pathItems.add(new PathElementItem(propertyRef));
|
||||
}
|
||||
else {
|
||||
final String path = VirtualFileManager.extractPath(url);
|
||||
pathItems.add(new PathElementItem(
|
||||
GenerationUtils.toRelativePath(path, chunk.getBaseDir(), moduleChunkBasedirProperty, genOptions)));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Unknown order entry type. If it is actually encountered, extension point should be implemented
|
||||
pathItems.add(new GeneratorItem(orderEntry.getClass().getName(),
|
||||
new Comment("Unknown OrderEntryType: " + orderEntry.getClass().getName())));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}.processModule(module, 0, false);
|
||||
}
|
||||
@@ -225,24 +213,26 @@ public class ModuleChunkClasspath extends Path {
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] getCompilationClasses(final OrderEntry orderEntry,
|
||||
private static String[] getCompilationClasses(final Module module,
|
||||
final GenerationOptionsImpl options,
|
||||
final boolean forRuntime,
|
||||
final boolean forTest,
|
||||
final boolean firstLevel) {
|
||||
final CompilerModuleExtension extension = CompilerModuleExtension.getInstance(module);
|
||||
if (extension == null) return ArrayUtil.EMPTY_STRING_ARRAY;
|
||||
|
||||
if (!forRuntime) {
|
||||
if (forTest) {
|
||||
return orderEntry.getUrls(firstLevel ? OrderRootType.PRODUCTION_COMPILATION_CLASSES : OrderRootType.COMPILATION_CLASSES);
|
||||
return extension.getOutputRootUrls(!firstLevel);
|
||||
}
|
||||
else {
|
||||
return firstLevel ? new String[0] : orderEntry.getUrls(OrderRootType.PRODUCTION_COMPILATION_CLASSES);
|
||||
return firstLevel ? ArrayUtil.EMPTY_STRING_ARRAY : extension.getOutputRootUrls(false);
|
||||
}
|
||||
}
|
||||
final Set<String> jdkUrls = options.getAllJdkUrls();
|
||||
|
||||
final OrderedSet<String> urls = new OrderedSet<String>();
|
||||
urls.addAll(Arrays.asList(orderEntry.getUrls(forTest ? OrderRootType.COMPILATION_CLASSES
|
||||
: OrderRootType.PRODUCTION_COMPILATION_CLASSES)));
|
||||
urls.addAll(Arrays.asList(extension.getOutputRootUrls(forTest)));
|
||||
urls.removeAll(jdkUrls);
|
||||
return ArrayUtil.toStringArray(urls);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,10 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.OrderEnumerator;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -39,8 +42,7 @@ import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.StringBuilderSpinAllocator;
|
||||
import com.intellij.util.PathsList;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -385,35 +387,9 @@ public class RmicCompiler implements ClassPostProcessingCompiler{
|
||||
}
|
||||
|
||||
private static String getCompilationClasspath(Module module) {
|
||||
final StringBuilder classpathBuffer = StringBuilderSpinAllocator.alloc();
|
||||
try {
|
||||
final OrderEntry[] orderEntries = ModuleRootManager.getInstance(module).getOrderEntries();
|
||||
final Set<VirtualFile> processedFiles = new HashSet<VirtualFile>();
|
||||
for (final OrderEntry orderEntry : orderEntries) {
|
||||
if (orderEntry instanceof JdkOrderEntry) {
|
||||
continue;
|
||||
}
|
||||
final VirtualFile[] files = orderEntry.getFiles(OrderRootType.COMPILATION_CLASSES);
|
||||
for (VirtualFile file : files) {
|
||||
if (processedFiles.contains(file)) {
|
||||
continue;
|
||||
}
|
||||
processedFiles.add(file);
|
||||
final String path = PathUtil.getLocalPath(file);
|
||||
if (path == null) {
|
||||
continue;
|
||||
}
|
||||
if (classpathBuffer.length() > 0) {
|
||||
classpathBuffer.append(File.pathSeparatorChar);
|
||||
}
|
||||
classpathBuffer.append(path);
|
||||
}
|
||||
}
|
||||
return classpathBuffer.toString();
|
||||
}
|
||||
finally {
|
||||
StringBuilderSpinAllocator.dispose(classpathBuffer);
|
||||
}
|
||||
final OrderEnumerator enumerator = ModuleRootManager.getInstance(module).orderEntries().withoutSdk().compileOnly().recursively().exportedOnly();
|
||||
final PathsList pathsList = enumerator.getPathsList();
|
||||
return pathsList.getPathsString();
|
||||
}
|
||||
|
||||
private static final class RemoteClassValidityState implements ValidityState {
|
||||
|
||||
+34
-24
@@ -299,40 +299,50 @@ public class CompilerModuleExtensionImpl extends CompilerModuleExtension {
|
||||
if (OrderRootType.CLASSES_AND_OUTPUT.equals(type) ||
|
||||
OrderRootType.COMPILATION_CLASSES.equals(type) ||
|
||||
OrderRootType.PRODUCTION_COMPILATION_CLASSES.equals(type)) {
|
||||
final ArrayList<VirtualFile> result = new ArrayList<VirtualFile>();
|
||||
|
||||
final VirtualFile outputPathForTests = OrderRootType.PRODUCTION_COMPILATION_CLASSES.equals(type) ? null : getCompilerOutputPathForTests();
|
||||
if (outputPathForTests != null) {
|
||||
result.add(outputPathForTests);
|
||||
}
|
||||
|
||||
VirtualFile outputRoot = getCompilerOutputPath();
|
||||
if (outputRoot != null && !outputRoot.equals(outputPathForTests)) {
|
||||
result.add(outputRoot);
|
||||
}
|
||||
return VfsUtil.toVirtualFileArray(result);
|
||||
return getOutputRoots(!OrderRootType.PRODUCTION_COMPILATION_CLASSES.equals(type));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFile[] getOutputRoots(final boolean includeTests) {
|
||||
final ArrayList<VirtualFile> result = new ArrayList<VirtualFile>();
|
||||
|
||||
final VirtualFile outputPathForTests = includeTests ? getCompilerOutputPathForTests() : null;
|
||||
if (outputPathForTests != null) {
|
||||
result.add(outputPathForTests);
|
||||
}
|
||||
|
||||
VirtualFile outputRoot = getCompilerOutputPath();
|
||||
if (outputRoot != null && !outputRoot.equals(outputPathForTests)) {
|
||||
result.add(outputRoot);
|
||||
}
|
||||
return VfsUtil.toVirtualFileArray(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getRootUrls(final OrderRootType type) {
|
||||
if (OrderRootType.CLASSES_AND_OUTPUT.equals(type) ||
|
||||
OrderRootType.COMPILATION_CLASSES.equals(type) ||
|
||||
OrderRootType.PRODUCTION_COMPILATION_CLASSES.equals(type)) {
|
||||
final List<String> result = new ArrayList<String>();
|
||||
|
||||
final String outputPathForTests = OrderRootType.PRODUCTION_COMPILATION_CLASSES.equals(type) ? null : getCompilerOutputUrlForTests();
|
||||
if (outputPathForTests != null) {
|
||||
result.add(outputPathForTests);
|
||||
}
|
||||
|
||||
String outputRoot = getCompilerOutputUrl();
|
||||
if (outputRoot != null && !outputRoot.equals(outputPathForTests)) {
|
||||
result.add(outputRoot);
|
||||
}
|
||||
return ArrayUtil.toStringArray(result);
|
||||
return getOutputRootUrls(!OrderRootType.PRODUCTION_COMPILATION_CLASSES.equals(type));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutputRootUrls(final boolean includeTests) {
|
||||
final List<String> result = new ArrayList<String>();
|
||||
|
||||
final String outputPathForTests = includeTests ? getCompilerOutputUrlForTests() : null;
|
||||
if (outputPathForTests != null) {
|
||||
result.add(outputPathForTests);
|
||||
}
|
||||
|
||||
String outputRoot = getCompilerOutputUrl();
|
||||
if (outputRoot != null && !outputRoot.equals(outputPathForTests)) {
|
||||
result.add(outputRoot);
|
||||
}
|
||||
return ArrayUtil.toStringArray(result);
|
||||
}
|
||||
}
|
||||
@@ -592,6 +592,19 @@ public class DeclarationParsing extends Parsing {
|
||||
return pair;
|
||||
}
|
||||
|
||||
public TreeElement parseAnnotationMemberValue(PsiManager manager, CharSequence text) {
|
||||
Lexer originalLexer = new JavaLexer(myContext.getLanguageLevel());
|
||||
FilterLexer lexer = new FilterLexer(originalLexer, new FilterLexer.SetFilter(StdTokenSets.WHITE_SPACE_OR_COMMENT_BIT_SET));
|
||||
lexer.start(text);
|
||||
final TreeElement result = parseAnnotationMemberValue(lexer);
|
||||
|
||||
final FileElement dummyRoot = DummyHolderFactory.createHolder(manager, null, myContext.getCharTable()).getTreeElement();
|
||||
dummyRoot.rawAddChildren(result);
|
||||
ParseUtil.insertMissingTokens(dummyRoot, originalLexer, 0, text.length(), -1, WhiteSpaceAndCommentsProcessor.INSTANCE, myContext);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private TreeElement parseAnnotationMemberValue(Lexer lexer) {
|
||||
TreeElement result;
|
||||
if (lexer.getTokenType() == JavaTokenType.AT) {
|
||||
|
||||
+2
-1
@@ -76,6 +76,7 @@ public abstract class JavaExtractSuperBaseDialog extends ExtractSuperBaseDialog<
|
||||
return directories[0];
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void preparePackage() throws OperationFailedException {
|
||||
final PsiPackage aPackage = JavaPsiFacade.getInstance(myProject).findPackage(getTargetPackageName());
|
||||
@@ -108,4 +109,4 @@ public abstract class JavaExtractSuperBaseDialog extends ExtractSuperBaseDialog<
|
||||
? null
|
||||
: RefactoringMessageUtil.getIncorrectIdentifierMessage(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-8
@@ -14,18 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: mike
|
||||
* Date: Aug 22, 2002
|
||||
* Time: 2:58:42 PM
|
||||
* To change template for new class use
|
||||
* Code Style | Class Templates options (Tools | IDE Options).
|
||||
*/
|
||||
package com.intellij.codeInsight.intention;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingProjectManager;
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestUtil;
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
|
||||
|
||||
@@ -38,6 +31,7 @@ public class ConvertToBasicLatinTest extends JavaCodeInsightFixtureTestCase {
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myIntention = CodeInsightBundle.message("intention.convert.to.basic.latin");
|
||||
EncodingProjectManager.getInstance().setDefaultCharsetName("UTF-8");
|
||||
}
|
||||
|
||||
public void testConvertCharLiteral() throws Exception {
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl;
|
||||
import com.intellij.util.PathsList;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -38,10 +39,10 @@ public class DependencyScopeTest extends ModuleTestCase {
|
||||
assertFalse(moduleA.getModuleWithDependenciesAndLibrariesScope(false).contains(classB));
|
||||
assertFalse(moduleA.getModuleWithDependenciesAndLibrariesScope(false).isSearchInModuleContent(moduleB));
|
||||
|
||||
final VirtualFile[] compilationClasspath = ModuleRootManager.getInstance(moduleA).getFiles(OrderRootType.COMPILATION_CLASSES);
|
||||
assertEquals(1, compilationClasspath.length);
|
||||
final VirtualFile[] productionCompilationClasspath = ModuleRootManager.getInstance(moduleA).getFiles(OrderRootType.PRODUCTION_COMPILATION_CLASSES);
|
||||
assertEquals(0, productionCompilationClasspath.length);
|
||||
final Collection<VirtualFile> compilationClasspath = getCompilationClasspath(moduleA);
|
||||
assertEquals(1, compilationClasspath.size());
|
||||
final Collection<VirtualFile> productionCompilationClasspath = getProductionCompileClasspath(moduleA);
|
||||
assertEmpty(productionCompilationClasspath);
|
||||
|
||||
final PathsList pathsList = OrderEnumerator.orderEntries(moduleA).recursively().getPathsList();
|
||||
assertEquals(1, pathsList.getPathList().size());
|
||||
@@ -77,35 +78,34 @@ public class DependencyScopeTest extends ModuleTestCase {
|
||||
assertTrue(m.getModuleWithDependenciesAndLibrariesScope(true).contains(libraryClass));
|
||||
assertFalse(m.getModuleWithDependenciesAndLibrariesScope(false).contains(libraryClass));
|
||||
|
||||
final VirtualFile[] compilationClasspath = ModuleRootManager.getInstance(m).getFiles(OrderRootType.COMPILATION_CLASSES);
|
||||
assertEquals(1, compilationClasspath.length);
|
||||
final VirtualFile[] productionCompilationClasspath = ModuleRootManager.getInstance(m).getFiles(OrderRootType.PRODUCTION_COMPILATION_CLASSES);
|
||||
assertEquals(0, productionCompilationClasspath.length);
|
||||
final Collection<VirtualFile> compilationClasspath = getCompilationClasspath(m);
|
||||
assertEquals(1, compilationClasspath.size());
|
||||
final Collection<VirtualFile> productionCompilationClasspath = getProductionCompileClasspath(m);
|
||||
assertEmpty(productionCompilationClasspath);
|
||||
}
|
||||
|
||||
public void testRuntimeModuleDependency() throws IOException {
|
||||
Module moduleA = createModule("a.iml", StdModuleTypes.JAVA);
|
||||
addDependentModule(moduleA, DependencyScope.RUNTIME);
|
||||
final VirtualFile[] runtimeClasspath = ModuleRootManager.getInstance(moduleA).getFiles(OrderRootType.CLASSES_AND_OUTPUT);
|
||||
assertEquals(1, runtimeClasspath.length);
|
||||
final VirtualFile[] compilationClasspath = ModuleRootManager.getInstance(moduleA).getFiles(OrderRootType.COMPILATION_CLASSES);
|
||||
assertEquals(1, compilationClasspath.length);
|
||||
VirtualFile[] production = ModuleRootManager.getInstance(moduleA).getFiles(OrderRootType.PRODUCTION_COMPILATION_CLASSES);
|
||||
assertEquals(0, production.length);
|
||||
final Collection<VirtualFile> runtimeClasspath = getRuntimeClasspath(moduleA);
|
||||
assertEquals(1, runtimeClasspath.size());
|
||||
final Collection<VirtualFile> compilationClasspath = getCompilationClasspath(moduleA);
|
||||
assertEquals(1, compilationClasspath.size());
|
||||
Collection<VirtualFile> production = getProductionCompileClasspath(moduleA);
|
||||
assertEmpty(production);
|
||||
}
|
||||
|
||||
public void testRuntimeLibraryDependency() throws IOException {
|
||||
Module m = createModule("a.iml", StdModuleTypes.JAVA);
|
||||
VirtualFile libraryRoot = addLibrary(m, DependencyScope.RUNTIME);
|
||||
|
||||
final VirtualFile[] runtimeClasspath = ModuleRootManager.getInstance(m).getFiles(OrderRootType.CLASSES_AND_OUTPUT);
|
||||
assertEquals(1, runtimeClasspath.length);
|
||||
assertEquals(libraryRoot, runtimeClasspath [0]);
|
||||
final Collection<VirtualFile> runtimeClasspath = getRuntimeClasspath(m);
|
||||
assertOrderedEquals(runtimeClasspath, libraryRoot);
|
||||
|
||||
final VirtualFile[] compilationClasspath = ModuleRootManager.getInstance(m).getFiles(OrderRootType.COMPILATION_CLASSES);
|
||||
assertEquals(1, compilationClasspath.length);
|
||||
VirtualFile[] production = ModuleRootManager.getInstance(m).getFiles(OrderRootType.PRODUCTION_COMPILATION_CLASSES);
|
||||
assertEquals(0, production.length);
|
||||
final Collection<VirtualFile> compilationClasspath = getCompilationClasspath(m);
|
||||
assertEquals(1, compilationClasspath.size());
|
||||
Collection<VirtualFile> production = getProductionCompileClasspath(m);
|
||||
assertEmpty(production);
|
||||
|
||||
VirtualFile libraryClass = myFixture.createFile("lib/Test.java", "public class Test { }");
|
||||
assertTrue(m.getModuleWithDependenciesAndLibrariesScope(true).contains(libraryClass));
|
||||
@@ -115,28 +115,39 @@ public class DependencyScopeTest extends ModuleTestCase {
|
||||
public void testProvidedModuleDependency() throws IOException {
|
||||
Module moduleA = createModule("a.iml", StdModuleTypes.JAVA);
|
||||
addDependentModule(moduleA, DependencyScope.PROVIDED);
|
||||
final VirtualFile[] runtimeClasspath = ModuleRootManager.getInstance(moduleA).getFiles(OrderRootType.CLASSES_AND_OUTPUT);
|
||||
assertEquals(0, runtimeClasspath.length);
|
||||
final VirtualFile[] compilationClasspath = ModuleRootManager.getInstance(moduleA).getFiles(OrderRootType.COMPILATION_CLASSES);
|
||||
assertEquals(1, compilationClasspath.length);
|
||||
Collection<VirtualFile> runtimeClasspath = getRuntimeClasspath(moduleA);
|
||||
assertEmpty(runtimeClasspath);
|
||||
final Collection<VirtualFile> compilationClasspath = getCompilationClasspath(moduleA);
|
||||
assertEquals(1, compilationClasspath.size());
|
||||
}
|
||||
|
||||
public void testProvidedLibraryDependency() throws IOException {
|
||||
Module m = createModule("a.iml", StdModuleTypes.JAVA);
|
||||
VirtualFile libraryRoot = addLibrary(m, DependencyScope.PROVIDED);
|
||||
|
||||
final VirtualFile[] runtimeClasspath = ModuleRootManager.getInstance(m).getFiles(OrderRootType.CLASSES_AND_OUTPUT);
|
||||
assertEquals(0, runtimeClasspath.length);
|
||||
final Collection<VirtualFile> runtimeClasspath = getRuntimeClasspath(m);
|
||||
assertEmpty(runtimeClasspath);
|
||||
|
||||
final VirtualFile[] compilationClasspath = ModuleRootManager.getInstance(m).getFiles(OrderRootType.COMPILATION_CLASSES);
|
||||
assertEquals(1, compilationClasspath.length);
|
||||
assertEquals(libraryRoot, compilationClasspath [0]);
|
||||
final Collection<VirtualFile> compilationClasspath = getCompilationClasspath(m);
|
||||
assertOrderedEquals(compilationClasspath, libraryRoot);
|
||||
|
||||
VirtualFile libraryClass = myFixture.createFile("lib/Test.java", "public class Test { }");
|
||||
assertTrue(m.getModuleWithDependenciesAndLibrariesScope(true).contains(libraryClass));
|
||||
assertTrue(m.getModuleWithDependenciesAndLibrariesScope(false).contains(libraryClass));
|
||||
}
|
||||
|
||||
private static Collection<VirtualFile> getRuntimeClasspath(Module m) {
|
||||
return ModuleRootManager.getInstance(m).orderEntries().productionOnly().runtimeOnly().recursively().getClassesRoots();
|
||||
}
|
||||
|
||||
private static Collection<VirtualFile> getProductionCompileClasspath(Module moduleA) {
|
||||
return ModuleRootManager.getInstance(moduleA).orderEntries().productionOnly().compileOnly().recursively().exportedOnly().getClassesRoots();
|
||||
}
|
||||
|
||||
private static Collection<VirtualFile> getCompilationClasspath(Module m) {
|
||||
return ModuleRootManager.getInstance(m).orderEntries().recursively().exportedOnly().getClassesRoots();
|
||||
}
|
||||
|
||||
private VirtualFile addLibrary(Module m, final DependencyScope scope) {
|
||||
VirtualFile libraryRoot = myFixture.findOrCreateDir("lib");
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ public class OrderEntriesTest extends ModuleRootManagerTestCase {
|
||||
return base.recursively().exportedOnly().getPathsList();
|
||||
}
|
||||
if (type == OrderRootType.PRODUCTION_COMPILATION_CLASSES) {
|
||||
return base.productionOnly().recursively().exportedOnly().getPathsList();
|
||||
return base.productionOnly().compileOnly().recursively().exportedOnly().getPathsList();
|
||||
}
|
||||
if (type == OrderRootType.CLASSES) {
|
||||
return base.withoutModuleSourceEntries().recursively().exportedOnly().getPathsList();
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.OrderEnumerator;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -138,37 +138,41 @@ public abstract class JspSpiUtil {
|
||||
}
|
||||
|
||||
public static List<URL> buildUrls(@Nullable final VirtualFile virtualFile, @Nullable final Module module) {
|
||||
return buildUrls(virtualFile, module, OrderRootType.CLASSES_AND_OUTPUT);
|
||||
return buildUrls(virtualFile, module, true);
|
||||
}
|
||||
|
||||
public static List<URL> buildUrls(@Nullable final VirtualFile virtualFile, @Nullable final Module module, OrderRootType rootType) {
|
||||
public static List<URL> buildUrls(@Nullable final VirtualFile virtualFile, @Nullable final Module module, boolean includeModuleOutput) {
|
||||
final List<URL> urls = new ArrayList<URL>();
|
||||
processClassPathItems(virtualFile, module, new Consumer<VirtualFile>() {
|
||||
public void consume(final VirtualFile file) {
|
||||
addUrl(urls, file);
|
||||
}
|
||||
}, rootType);
|
||||
}, includeModuleOutput);
|
||||
return urls;
|
||||
}
|
||||
|
||||
public static void processClassPathItems(final VirtualFile virtualFile, final Module module, final Consumer<VirtualFile> consumer) {
|
||||
processClassPathItems(virtualFile, module, consumer, OrderRootType.CLASSES_AND_OUTPUT);
|
||||
processClassPathItems(virtualFile, module, consumer, true);
|
||||
}
|
||||
|
||||
public static void processClassPathItems(final VirtualFile virtualFile, final Module module, final Consumer<VirtualFile> consumer,
|
||||
OrderRootType rootType) {
|
||||
boolean includeModuleOutput) {
|
||||
if (isJarFile(virtualFile)){
|
||||
consumer.consume(virtualFile);
|
||||
}
|
||||
|
||||
if (module != null) {
|
||||
for (VirtualFile file1 : ModuleRootManager.getInstance(module).getFiles(rootType)) {
|
||||
OrderEnumerator enumerator = ModuleRootManager.getInstance(module).orderEntries().recursively();
|
||||
if (!includeModuleOutput) {
|
||||
enumerator = enumerator.withoutModuleSourceEntries();
|
||||
}
|
||||
for (VirtualFile root : enumerator.getClassesRoots()) {
|
||||
final VirtualFile file;
|
||||
if (file1.getFileSystem().getProtocol().equals(JarFileSystem.PROTOCOL)) {
|
||||
file = JarFileSystem.getInstance().getVirtualFileForJar(file1);
|
||||
if (root.getFileSystem().getProtocol().equals(JarFileSystem.PROTOCOL)) {
|
||||
file = JarFileSystem.getInstance().getVirtualFileForJar(root);
|
||||
}
|
||||
else {
|
||||
file = file1;
|
||||
file = root;
|
||||
}
|
||||
consumer.consume(file);
|
||||
}
|
||||
|
||||
@@ -97,4 +97,8 @@ public abstract class CompilerModuleExtension extends ModuleExtension {
|
||||
public abstract void setExcludeOutput(boolean exclude);
|
||||
|
||||
public abstract boolean isExcludeOutput();
|
||||
|
||||
public abstract VirtualFile[] getOutputRoots(boolean includeTests);
|
||||
|
||||
public abstract String[] getOutputRootUrls(boolean includeTests);
|
||||
}
|
||||
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package com.intellij.formatting;
|
||||
|
||||
import com.intellij.formatting.templateLanguages.DataLanguageBlockWrapper;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.formatter.common.AbstractBlock;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.List;
|
||||
|
||||
@@ -32,7 +32,8 @@ public class CommonShortcuts {
|
||||
SystemInfo.isMac
|
||||
? KeyEvent.META_DOWN_MASK
|
||||
: KeyEvent.CTRL_DOWN_MASK));
|
||||
public static final ShortcutSet INSERT = new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0));
|
||||
public static final ShortcutSet INSERT = new CustomShortcutSet(SystemInfo.isMac ? KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK)
|
||||
: KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0));
|
||||
public static final ShortcutSet DELETE = new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
|
||||
public static final ShortcutSet ESCAPE = new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));
|
||||
|
||||
|
||||
@@ -455,19 +455,27 @@ public class ThreeComponentsSplitter extends JPanel {
|
||||
}
|
||||
|
||||
private boolean isInside(Point p) {
|
||||
if (!isVisible()) return false;
|
||||
|
||||
if (myVerticalSplit) {
|
||||
if (getHeight() > 0) {
|
||||
return p.y >= 0 && p.y < getHeight();
|
||||
} else {
|
||||
return p.y >= -myDividerZone / 2 && p.y <= myDividerZone / 2;
|
||||
if (p.x >= 0 && p.x < getWidth()) {
|
||||
if (getHeight() > 0) {
|
||||
return p.y >= 0 && p.y < getHeight();
|
||||
} else {
|
||||
return p.y >= -myDividerZone / 2 && p.y <= myDividerZone / 2;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (getWidth() > 0) {
|
||||
return p.x >= 0 && p.x < getWidth();
|
||||
} else {
|
||||
return p.x >= -myDividerZone / 2 && p.x <= myDividerZone / 2;
|
||||
if (p.y >= 0 && p.y < getHeight()) {
|
||||
if (getWidth() > 0) {
|
||||
return p.x >= 0 && p.x < getWidth();
|
||||
} else {
|
||||
return p.x >= -myDividerZone / 2 && p.x <= myDividerZone / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.ui.components;
|
||||
import com.intellij.util.ui.ButtonlessScrollBarUI;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.plaf.ScrollPaneUI;
|
||||
import java.awt.*;
|
||||
|
||||
@@ -46,6 +47,9 @@ public class JBScrollPane extends JScrollPane {
|
||||
*/
|
||||
public void setUI(ScrollPaneUI ui) {
|
||||
super.setUI(ui);
|
||||
|
||||
setViewportBorder(new EmptyBorder(1, 1, 1, 1));
|
||||
|
||||
// We need to set color of viewport later because UIManager
|
||||
// updates UI of scroll pane and only after that updates UI
|
||||
// of its children. To be the last in this sequence we need
|
||||
|
||||
@@ -45,7 +45,7 @@ public class TabsBorder {
|
||||
|
||||
myEffectiveBorder = null;
|
||||
|
||||
myTabs.revalidateAndRepaint(false);
|
||||
myTabs.relayout(true, false);
|
||||
|
||||
return myTabs;
|
||||
}
|
||||
@@ -77,7 +77,6 @@ public class TabsBorder {
|
||||
myPosition == JBTabsPosition.bottom ? myTabBorderSize : myBorderSize.bottom,
|
||||
myPosition == JBTabsPosition.right ? myTabBorderSize : myBorderSize.right
|
||||
);
|
||||
|
||||
return (Insets)myEffectiveBorder.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.ui.tabs.impl.singleRow;
|
||||
|
||||
import com.intellij.ui.tabs.TabInfo;
|
||||
import com.intellij.ui.tabs.impl.*;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
@@ -128,6 +128,8 @@ public class TableLayout extends TabLayout {
|
||||
toAjust = true;
|
||||
}
|
||||
|
||||
toAjust |= myTabs.myForcedRelayout;
|
||||
|
||||
for (int i = 0; i < eachRow.myColumns.size(); i++) {
|
||||
TabInfo tabInfo = eachRow.myColumns.get(i);
|
||||
final TabLabel label = myTabs.myInfo2Label.get(tabInfo);
|
||||
|
||||
@@ -136,9 +136,14 @@ public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEvent
|
||||
if (target != null) {
|
||||
if (myLastCursorComponent != target) {
|
||||
myLastCursorComponent = target;
|
||||
myLastOriginalCursor = target.getCursor();
|
||||
if (target.isCursorSet()) {
|
||||
myLastOriginalCursor = target.getCursor();
|
||||
}
|
||||
}
|
||||
|
||||
if (cursor != null && !cursor.equals(target.getCursor())) {
|
||||
target.setCursor(cursor);
|
||||
}
|
||||
target.setCursor(cursor);
|
||||
}
|
||||
|
||||
getRootPane().setCursor(cursor);
|
||||
|
||||
@@ -463,7 +463,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
}
|
||||
|
||||
if (insets.bottom > 0) {
|
||||
UIUtil.drawLine(g, x + 1, y + height - 1, x + width - 1, y + height - 1);
|
||||
UIUtil.drawLine(g, x, y + height - 1, x + width - 1, y + height - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1030,7 +1030,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
assertInitialized();
|
||||
try {
|
||||
final OutputStream outputStream = copy.getOutputStream(null, 0, 0);
|
||||
outputStream.write(loader.newFileText.getBytes());
|
||||
outputStream.write(loader.newFileText.getBytes(copy.getCharset()));
|
||||
outputStream.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
@@ -22,12 +22,13 @@ import com.intellij.spellchecker.inspections.CommentSplitter;
|
||||
import com.intellij.spellchecker.inspections.SplitterFactory;
|
||||
import com.intellij.spellchecker.tokenizer.Token;
|
||||
import com.intellij.spellchecker.tokenizer.Tokenizer;
|
||||
import com.intellij.util.containers.hash.HashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
@@ -36,8 +37,13 @@ import java.util.List;
|
||||
*/
|
||||
public class DocCommentTokenizer extends Tokenizer<PsiDocComment> {
|
||||
|
||||
|
||||
private final String[] excludedTags = new String[]{"author", "link"};
|
||||
private static final Set<String> excludedTags = new HashSet<String>();
|
||||
{
|
||||
excludedTags.add("author");
|
||||
excludedTags.add("see");
|
||||
excludedTags.add("by");
|
||||
excludedTags.add("link");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -48,7 +54,7 @@ public class DocCommentTokenizer extends Tokenizer<PsiDocComment> {
|
||||
for (PsiElement el : comment.getChildren()) {
|
||||
if (el instanceof PsiDocTag) {
|
||||
PsiDocTag tag = (PsiDocTag)el;
|
||||
if (!Arrays.asList(excludedTags).contains(tag.getName())) {
|
||||
if (!excludedTags.contains(tag.getName())) {
|
||||
for (PsiElement data : tag.getDataElements()) {
|
||||
result.add(new Token<PsiElement>(data, splitter));
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ import com.intellij.psi.PsiLiteralExpression;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiNamedElement;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.spellchecker.tokenizer.Tokenizer;
|
||||
import com.intellij.spellchecker.tokenizer.SpellcheckingStrategy;
|
||||
import com.intellij.spellchecker.tokenizer.Tokenizer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.spellchecker;
|
||||
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiTypeElement;
|
||||
@@ -49,6 +50,16 @@ public class PsiTypeTokenizer extends Tokenizer<PsiTypeElement> {
|
||||
|
||||
final boolean isInSource = (virtualFile != null) && fileIndex.isInContent(virtualFile);
|
||||
|
||||
return !isInSource ? null : new Token[]{new Token<PsiTypeElement>(element, element.getText(), true, SplitterFactory.getInstance().getIdentifierSplitter())};
|
||||
return !isInSource
|
||||
? null
|
||||
: new Token[]{
|
||||
new Token<PsiTypeElement>(element, element.getText(), true, 0, getRangeToCheck(element.getText(), psiClass.getName()),
|
||||
SplitterFactory.getInstance().getIdentifierSplitter())};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private TextRange getRangeToCheck(@NotNull String text, @NotNull String name) {
|
||||
final int i = text.indexOf(name);
|
||||
return new TextRange(i, i + name.length());
|
||||
}
|
||||
}
|
||||
+21
-42
@@ -16,66 +16,45 @@
|
||||
package com.intellij.psi.impl.search;
|
||||
|
||||
import com.intellij.lang.properties.psi.Property;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.QueryExecutorBase;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.ReferenceRange;
|
||||
import com.intellij.psi.search.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.search.UsageSearchContext;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.QueryExecutor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public class PropertyReferenceViaLastWordSearcher implements QueryExecutor<PsiReference, ReferencesSearch.SearchParameters> {
|
||||
public class PropertyReferenceViaLastWordSearcher extends QueryExecutorBase<PsiReference, ReferencesSearch.SearchParameters> {
|
||||
public PropertyReferenceViaLastWordSearcher() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
// add to the search results occurences in JSPs of the last word in the property name, since this stuff is possible:
|
||||
// <bla:bla ref.key="lastWord> (can reference to xxx.lastWord property)
|
||||
|
||||
public boolean execute(final ReferencesSearch.SearchParameters queryParameters, final Processor<PsiReference> consumer) {
|
||||
@Override
|
||||
public void processQuery(ReferencesSearch.SearchParameters queryParameters, Processor<PsiReference> consumer) {
|
||||
final PsiElement refElement = queryParameters.getElementToSearch();
|
||||
if (refElement instanceof Property) {
|
||||
final String name = ((Property)refElement).getName();
|
||||
if (name == null) return true;
|
||||
final List<String> words = StringUtil.getWordsIn(name);
|
||||
if (words.isEmpty()) return true;
|
||||
final String lastWord = words.get(words.size() - 1);
|
||||
if (!(refElement instanceof Property)) return;
|
||||
|
||||
SearchScope searchScope = ApplicationManager.getApplication().runReadAction(new Computable<SearchScope>() {
|
||||
public SearchScope compute() {
|
||||
return queryParameters.getEffectiveSearchScope();
|
||||
}
|
||||
});
|
||||
if (searchScope instanceof GlobalSearchScope) {
|
||||
searchScope = GlobalSearchScope.getScopeRestrictedByFileTypes((GlobalSearchScope)searchScope, StdFileTypes.JSP, StdFileTypes.JSPX);
|
||||
}
|
||||
final PsiSearchHelper helper = PsiManager.getInstance(refElement.getProject()).getSearchHelper();
|
||||
final TextOccurenceProcessor processor = new TextOccurenceProcessor() {
|
||||
public boolean execute(PsiElement element, int offsetInElement) {
|
||||
ProgressManager.checkCanceled();
|
||||
final PsiReference[] refs = element.getReferences();
|
||||
for (PsiReference ref : refs) {
|
||||
if (ReferenceRange.containsOffsetInElement(ref, offsetInElement) && ref.isReferenceTo(refElement)) {
|
||||
return consumer.process(ref);
|
||||
}
|
||||
ProgressManager.checkCanceled();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
final String name = ((Property)refElement).getName();
|
||||
if (name == null) return;
|
||||
final List<String> words = StringUtil.getWordsIn(name);
|
||||
if (words.isEmpty()) return;
|
||||
final String lastWord = words.get(words.size() - 1);
|
||||
|
||||
if (!helper.processElementsWithWord(processor, searchScope, lastWord, UsageSearchContext.IN_FOREIGN_LANGUAGES, false)) {
|
||||
return false;
|
||||
}
|
||||
SearchScope searchScope = queryParameters.getEffectiveSearchScope();
|
||||
if (searchScope instanceof GlobalSearchScope) {
|
||||
searchScope = GlobalSearchScope.getScopeRestrictedByFileTypes((GlobalSearchScope)searchScope, StdFileTypes.JSP, StdFileTypes.JSPX);
|
||||
}
|
||||
|
||||
return true;
|
||||
queryParameters.getOptimizer().searchWord(lastWord, searchScope, UsageSearchContext.IN_FOREIGN_LANGUAGES, false, refElement);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,8 @@ spellchecking
|
||||
Holdability
|
||||
permalink
|
||||
serializable
|
||||
mutex, mutexes
|
||||
mutex
|
||||
mutexes
|
||||
arity
|
||||
unhandled
|
||||
trinary
|
||||
@@ -108,5 +109,188 @@ utf
|
||||
stylesheet
|
||||
charset
|
||||
vertices
|
||||
println
|
||||
encoded
|
||||
commandline
|
||||
cmdline
|
||||
Petersburg
|
||||
tokenize
|
||||
vararg
|
||||
sqlerror
|
||||
pctused
|
||||
maxtrans
|
||||
nvarchar
|
||||
localtimestamp
|
||||
linestring
|
||||
autoextend
|
||||
inout
|
||||
freepools
|
||||
multipoint
|
||||
unpivot
|
||||
servererror
|
||||
xmlschemas
|
||||
middleint
|
||||
infile
|
||||
multiset
|
||||
rowdependencies
|
||||
systimestamp
|
||||
outfile
|
||||
likec
|
||||
maxvalue
|
||||
instantiable
|
||||
timestamp
|
||||
mediumtext
|
||||
x509
|
||||
anyschema
|
||||
desc
|
||||
plsql
|
||||
ccflags
|
||||
asensitive
|
||||
geometrycollection
|
||||
varchar
|
||||
xmlschema
|
||||
dumpfile
|
||||
tinytext
|
||||
rtree
|
||||
zerofill
|
||||
btree
|
||||
norely
|
||||
binlog
|
||||
float4
|
||||
float8
|
||||
schemas
|
||||
innodb
|
||||
novalidate
|
||||
longtext
|
||||
datafiles
|
||||
resetlogs
|
||||
substring
|
||||
nullif
|
||||
datetime
|
||||
locator
|
||||
charset
|
||||
noarchivelog
|
||||
norowdependencies
|
||||
bool
|
||||
nocopy
|
||||
archivelog
|
||||
processlist
|
||||
mediumint
|
||||
pipelined
|
||||
serializable
|
||||
ndbcluster
|
||||
temptable
|
||||
expr
|
||||
keepduplicates
|
||||
uninstall
|
||||
sqlwarning
|
||||
nomonitoring
|
||||
maxdatafiles
|
||||
filesystem
|
||||
maxx
|
||||
pctfree
|
||||
notnull
|
||||
maxlogfiles
|
||||
fulltext
|
||||
reindex
|
||||
pctversion
|
||||
clob
|
||||
nocycle
|
||||
maxloghistory
|
||||
bigfile
|
||||
bigint
|
||||
nonschema
|
||||
nomaxvalue
|
||||
nominvalue
|
||||
varray
|
||||
isnull
|
||||
sysdate
|
||||
multipolygon
|
||||
sqlcode
|
||||
xmltype
|
||||
pctthreshold
|
||||
datafile
|
||||
plsql
|
||||
minvalue
|
||||
noresetlogs
|
||||
checksum
|
||||
prebuilt
|
||||
authid
|
||||
nologging
|
||||
nocache
|
||||
plsql
|
||||
bfile
|
||||
timestamp
|
||||
undofile
|
||||
elsif
|
||||
nocompress
|
||||
deallocate
|
||||
varcharacter
|
||||
nodegroup
|
||||
smallint
|
||||
rlike
|
||||
varchar
|
||||
nomapping
|
||||
varbinary
|
||||
basicfile
|
||||
noaudit
|
||||
autocommit
|
||||
deferrable
|
||||
indextype
|
||||
nchar
|
||||
urowid
|
||||
evex
|
||||
rollup
|
||||
minextents
|
||||
online
|
||||
sqlstate
|
||||
deduplicate
|
||||
controlfile
|
||||
logoff
|
||||
noparallel
|
||||
subpartition
|
||||
sqlexception
|
||||
nosort
|
||||
maxsize
|
||||
maxinstances
|
||||
capath
|
||||
freelist
|
||||
nclob
|
||||
maxextents
|
||||
binlog
|
||||
plugins
|
||||
mediumblob
|
||||
pragma
|
||||
logon
|
||||
plsql
|
||||
miny
|
||||
localtime
|
||||
mlslabel
|
||||
noorder
|
||||
tinyint
|
||||
initrans
|
||||
maxlogmembers
|
||||
tinyblob
|
||||
plsql
|
||||
securefile
|
||||
soname
|
||||
oidindex
|
||||
smallfile
|
||||
stmt
|
||||
tablespace
|
||||
distinctrow
|
||||
nowait
|
||||
logfile
|
||||
pctincrease
|
||||
savepoint
|
||||
freelists
|
||||
autoincrement
|
||||
longblob
|
||||
autoextend
|
||||
multilinestring
|
||||
noreverse
|
||||
calc
|
||||
subpartitions
|
||||
startup
|
||||
elseif
|
||||
configurator
|
||||
django
|
||||
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
*/
|
||||
package com.intellij.spellchecker.tokenizer;
|
||||
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.spellchecker.inspections.CheckArea;
|
||||
import com.intellij.spellchecker.inspections.Splitter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
@@ -25,18 +27,24 @@ import java.util.List;
|
||||
|
||||
public class Token<T extends PsiElement> {
|
||||
|
||||
private String text;
|
||||
private String description;
|
||||
private T element;
|
||||
private boolean useRename;
|
||||
private final String text;
|
||||
private final String description;
|
||||
private final boolean useRename;
|
||||
private int offset;
|
||||
|
||||
|
||||
private final T element;
|
||||
private final Splitter splitter;
|
||||
|
||||
private TextRange range;
|
||||
|
||||
public Token(T element, String text, boolean useRename, Splitter splitter) {
|
||||
this.element = element;
|
||||
this.text = text;
|
||||
this.useRename = useRename;
|
||||
this.splitter = splitter;
|
||||
this.offset = 0;
|
||||
this.description = null;
|
||||
}
|
||||
|
||||
public Token(T element, String text, boolean useRename, int offset, Splitter splitter) {
|
||||
@@ -52,6 +60,11 @@ public class Token<T extends PsiElement> {
|
||||
this(element, element.getText(), useRename, splitter);
|
||||
}
|
||||
|
||||
public Token(T element, String text, boolean useRename, int offset, TextRange textRange, Splitter splitter) {
|
||||
this(element, text, useRename, offset, splitter);
|
||||
this.range = textRange;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
@@ -72,12 +85,21 @@ public class Token<T extends PsiElement> {
|
||||
return offset;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public TextRange getRange() {
|
||||
if (range==null){
|
||||
range = new TextRange(0,(text!=null?text.length():0));
|
||||
}
|
||||
return range;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<CheckArea> getAreas() {
|
||||
if (splitter == null || text == null) {
|
||||
return null;
|
||||
}
|
||||
return splitter.split(text);
|
||||
return splitter.split(text, getRange());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
public class GenericTest {
|
||||
/**
|
||||
@see com.intellij.openapi
|
||||
*/
|
||||
public void a( GenTest<?> obj ) {
|
||||
|
||||
}
|
||||
|
||||
public void b( AnotherGenTest<?> obj ) {
|
||||
|
||||
}
|
||||
|
||||
public void c( Predicate<?> obj ) {
|
||||
|
||||
}
|
||||
|
||||
public void d( AnotherPredicate<?> obj ) {
|
||||
|
||||
}
|
||||
|
||||
public class GenTest<T> {
|
||||
|
||||
}
|
||||
|
||||
public class AnotherGenTest<T> {
|
||||
|
||||
}
|
||||
|
||||
public interface Predicate<T> {
|
||||
|
||||
}
|
||||
|
||||
public interface AnotherPredicate<T> {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
public class Generic<TYPO descr="Typo: In word 'Testt'">Testt</TYPO> {
|
||||
|
||||
public void a( Gen<TYPO descr="Typo: In word 'Testt'">Testt</TYPO><?> obj ) {
|
||||
|
||||
}
|
||||
|
||||
public void b( AnotherGen<TYPO descr="Typo: In word 'Testt'">Testt</TYPO><?> obj ) {
|
||||
|
||||
}
|
||||
|
||||
public void c( <TYPO descr="Typo: In word 'Predicatte'">Predicatte</TYPO><?> obj ) {
|
||||
|
||||
}
|
||||
|
||||
public void d( Another<TYPO descr="Typo: In word 'Predicatte'">Predicatte</TYPO><?> obj ) {
|
||||
|
||||
}
|
||||
|
||||
public class Gen<TYPO descr="Typo: In word 'Testt'">Testt</TYPO><T> {
|
||||
|
||||
}
|
||||
|
||||
public class AnotherGen<TYPO descr="Typo: In word 'Testt'">Testt</TYPO><T> {
|
||||
|
||||
}
|
||||
|
||||
public interface <TYPO descr="Typo: In word 'Predicatte'">Predicatte</TYPO><T> {
|
||||
|
||||
}
|
||||
|
||||
public interface Another<TYPO descr="Typo: In word 'Predicatte'">Predicatte</TYPO><T> {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.spellchecker.inspection;
|
||||
|
||||
import com.intellij.spellchecker.inspections.SpellCheckerInspectionToolProvider;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: Ekaterina Shliakhovetskaja
|
||||
*/
|
||||
public class JavaSpellcheckingTest extends SpellcheckerInspectionTestCase {
|
||||
|
||||
|
||||
protected String getBasePath() {
|
||||
return getSpellcheckerTestDataPath() + "/inspection/java";
|
||||
}
|
||||
|
||||
public void testCorrectJava() throws Throwable {
|
||||
doTest("GenericTest.java", SpellCheckerInspectionToolProvider.getInspectionTools());
|
||||
}
|
||||
|
||||
public void testTypoInJava() throws Throwable {
|
||||
doTest("GenericTestt.java", SpellCheckerInspectionToolProvider.getInspectionTools());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -97,7 +97,7 @@ public class XsltNamespaceContext implements NamespaceContext {
|
||||
final XmlAttribute attribute = parent.getAttribute(name, null);
|
||||
if (attribute != null) {
|
||||
final TextRange textRange = TextRange.from("xmlns:".length(), prefix.length());
|
||||
return new SchemaPrefix(attribute, textRange, prefix) {
|
||||
return new SchemaPrefix(attribute, textRange, prefix, attribute) {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof SchemaPrefix) {
|
||||
|
||||
+2
-2
@@ -52,7 +52,7 @@ public final class XsltImplicitUsagesProvider implements ImplicitUsageProvider {
|
||||
// BTW: Almost the same logic applies to other XML dialects (RELAX-NG).
|
||||
// Pull this class into the platform?
|
||||
final String prefix = attr.getLocalName();
|
||||
final SchemaPrefix target = new SchemaPrefix(attr, TextRange.from("xmlns:".length(), prefix.length()), prefix);
|
||||
final SchemaPrefix target = new SchemaPrefix(attr, TextRange.from("xmlns:".length(), prefix.length()), prefix, attr);
|
||||
final Query<PsiReference> q = ReferencesSearch.search(target, new LocalSearchScope(attr.getParent()));
|
||||
return !q.forEach(new Processor<PsiReference>() {
|
||||
public boolean process(PsiReference psiReference) {
|
||||
@@ -71,4 +71,4 @@ public final class XsltImplicitUsagesProvider implements ImplicitUsageProvider {
|
||||
public boolean isImplicitWrite(PsiElement element) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.intellij.psi.xml.XmlTag;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public abstract class AbstractSyntheticBlock implements Block{
|
||||
public abstract class AbstractSyntheticBlock implements Block {
|
||||
protected final Indent myIndent;
|
||||
protected final XmlFormattingPolicy myXmlFormattingPolicy;
|
||||
protected final ASTNode myEndTreeNode;
|
||||
@@ -41,7 +41,15 @@ public abstract class AbstractSyntheticBlock implements Block{
|
||||
myStartTreeNode = getFirstNode(subBlocks);
|
||||
myIndent = indent;
|
||||
myXmlFormattingPolicy = policy;
|
||||
myTag = ((AbstractXmlBlock)parent).getTag();
|
||||
if (parent instanceof AbstractXmlBlock) {
|
||||
myTag = ((AbstractXmlBlock)parent).getTag();
|
||||
}
|
||||
else if (parent instanceof AbstractSyntheticBlock) {
|
||||
myTag = ((AbstractSyntheticBlock)parent).getTag();
|
||||
} else {
|
||||
throw new IllegalStateException("Parent should be AbstractXmlBlock or AbstractSyntheticBlock, but it is " + parent.getClass());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.formatter.xml.AbstractSyntheticBlock");
|
||||
@@ -51,7 +59,8 @@ public abstract class AbstractSyntheticBlock implements Block{
|
||||
final Block firstBlock = subBlocks.get(0);
|
||||
if (firstBlock instanceof AbstractBlock) {
|
||||
return ((AbstractBlock)firstBlock).getNode();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return getFirstNode(firstBlock.getSubBlocks());
|
||||
}
|
||||
}
|
||||
@@ -61,7 +70,8 @@ public abstract class AbstractSyntheticBlock implements Block{
|
||||
final Block lastBlock = subBlocks.get(subBlocks.size() - 1);
|
||||
if (lastBlock instanceof AbstractBlock) {
|
||||
return ((AbstractBlock)lastBlock).getNode();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return getLastNode(lastBlock.getSubBlocks());
|
||||
}
|
||||
}
|
||||
@@ -90,7 +100,8 @@ public abstract class AbstractSyntheticBlock implements Block{
|
||||
}
|
||||
|
||||
public boolean endsWithText() {
|
||||
return myEndTreeNode.getElementType() == XmlElementType.XML_TEXT || myEndTreeNode.getElementType() == XmlElementType.XML_DATA_CHARACTERS;
|
||||
return myEndTreeNode.getElementType() == XmlElementType.XML_TEXT ||
|
||||
myEndTreeNode.getElementType() == XmlElementType.XML_DATA_CHARACTERS;
|
||||
}
|
||||
|
||||
public boolean isTagDescription() {
|
||||
@@ -99,11 +110,13 @@ public abstract class AbstractSyntheticBlock implements Block{
|
||||
}
|
||||
|
||||
private static boolean isTagDescription(final ASTNode startTreeNode) {
|
||||
return startTreeNode.getElementType() == XmlElementType.XML_START_TAG_START || startTreeNode.getElementType() == XmlElementType.XML_END_TAG_START;
|
||||
return startTreeNode.getElementType() == XmlElementType.XML_START_TAG_START ||
|
||||
startTreeNode.getElementType() == XmlElementType.XML_END_TAG_START;
|
||||
}
|
||||
|
||||
public boolean startsWithText() {
|
||||
return myStartTreeNode.getElementType() == XmlElementType.XML_TEXT || myStartTreeNode.getElementType() == XmlElementType.XML_DATA_CHARACTERS;
|
||||
return myStartTreeNode.getElementType() == XmlElementType.XML_TEXT ||
|
||||
myStartTreeNode.getElementType() == XmlElementType.XML_DATA_CHARACTERS;
|
||||
}
|
||||
|
||||
public boolean endsWithTextElement() {
|
||||
@@ -136,7 +149,7 @@ public abstract class AbstractSyntheticBlock implements Block{
|
||||
|
||||
protected static TextRange calculateTextRange(final List<Block> subBlocks) {
|
||||
return new TextRange(subBlocks.get(0).getTextRange().getStartOffset(),
|
||||
subBlocks.get(subBlocks.size()- 1).getTextRange().getEndOffset());
|
||||
subBlocks.get(subBlocks.size() - 1).getTextRange().getEndOffset());
|
||||
}
|
||||
|
||||
public boolean isIncomplete() {
|
||||
@@ -148,14 +161,14 @@ public abstract class AbstractSyntheticBlock implements Block{
|
||||
}
|
||||
|
||||
public XmlTag getStartTag() {
|
||||
return (XmlTag)myStartTreeNode.getPsi();
|
||||
return (XmlTag)myStartTreeNode.getPsi();
|
||||
}
|
||||
|
||||
|
||||
public boolean endsWithTag() {
|
||||
return isXmlTag(myEndTreeNode);
|
||||
}
|
||||
|
||||
|
||||
public boolean isJspTextBlock() {
|
||||
return false;
|
||||
}
|
||||
@@ -166,6 +179,7 @@ public abstract class AbstractSyntheticBlock implements Block{
|
||||
|
||||
/**
|
||||
* Checks if the block contains a single node which belongs to the outer (template) language.
|
||||
*
|
||||
* @return True if it does, False otherwise.
|
||||
*/
|
||||
public boolean isOuterLanguageBlock() {
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.psi.impl.source.xml;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.impl.RenameableFakePsiElement;
|
||||
import com.intellij.psi.xml.XmlAttribute;
|
||||
import com.intellij.psi.xml.XmlElement;
|
||||
import com.intellij.util.Icons;
|
||||
|
||||
@@ -26,47 +27,53 @@ import javax.swing.*;
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class SchemaPrefix extends RenameableFakePsiElement {
|
||||
private final XmlElement myParent;
|
||||
private final TextRange myRange;
|
||||
private final String myName;
|
||||
public class SchemaPrefix extends RenameableFakePsiElement {
|
||||
private final XmlElement myParent;
|
||||
private final TextRange myRange;
|
||||
private final String myName;
|
||||
private final XmlAttribute myDeclaration;
|
||||
|
||||
public SchemaPrefix(final XmlElement parent, TextRange range, String name) {
|
||||
super(parent);
|
||||
myParent = parent;
|
||||
myRange = range;
|
||||
myName = name;
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return "XML Namespace Prefix";
|
||||
}
|
||||
|
||||
public Icon getIcon() {
|
||||
return Icons.VARIABLE_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTextOffset() {
|
||||
return myParent.getTextRange().getStartOffset() + myRange.getStartOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTextLength() {
|
||||
return myName.length();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
public PsiElement getParent() {
|
||||
return myParent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextRange getTextRange() {
|
||||
return TextRange.from(getTextOffset(), getTextLength());
|
||||
}
|
||||
public SchemaPrefix(final XmlElement parent, TextRange range, String name, XmlAttribute nsDeclaration) {
|
||||
super(parent);
|
||||
myParent = parent;
|
||||
myRange = range;
|
||||
myName = name;
|
||||
myDeclaration = nsDeclaration;
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return "XML Namespace Prefix";
|
||||
}
|
||||
|
||||
public Icon getIcon() {
|
||||
return Icons.VARIABLE_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTextOffset() {
|
||||
return myParent.getTextRange().getStartOffset() + myRange.getStartOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTextLength() {
|
||||
return myName.length();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
public PsiElement getParent() {
|
||||
return myParent;
|
||||
}
|
||||
|
||||
public XmlAttribute getDeclaration() {
|
||||
return myDeclaration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextRange getTextRange() {
|
||||
return TextRange.from(getTextOffset(), getTextLength());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,20 +33,23 @@ public class SchemaPrefixReference extends PsiReferenceBase<XmlElement> {
|
||||
private final SchemaPrefix myPrefix;
|
||||
private final PsiElement myElement;
|
||||
private final String myName;
|
||||
private XmlElement myDeclaration = null;
|
||||
|
||||
public SchemaPrefixReference(XmlElement element, TextRange range, String name) {
|
||||
super(element, range, true);
|
||||
myElement = element;
|
||||
myName = name;
|
||||
if (myElement instanceof XmlAttribute && ((XmlAttribute)myElement).isNamespaceDeclaration()) {
|
||||
myPrefix = new SchemaPrefix(element, range, name);
|
||||
myPrefix = new SchemaPrefix(element, range, name, (XmlAttribute)element);
|
||||
myDeclaration = element;
|
||||
} else {
|
||||
final PsiElement declaration = XmlUtil.findNamespaceDeclaration(element.getContainingFile(), name);
|
||||
final PsiElement declaration = XmlUtil.findNamespaceDeclaration(element, name);
|
||||
if (declaration instanceof XmlAttribute) {
|
||||
final XmlAttribute attribute = (XmlAttribute)declaration;
|
||||
final String prefix = attribute.getNamespacePrefix();
|
||||
final TextRange textRange = TextRange.from(prefix.length() + 1, name.length());
|
||||
myPrefix = new SchemaPrefix(attribute, textRange, name);
|
||||
myPrefix = new SchemaPrefix(attribute, textRange, name, (XmlAttribute)declaration);
|
||||
myDeclaration = (XmlElement)declaration;
|
||||
} else {
|
||||
myPrefix = null;
|
||||
}
|
||||
@@ -66,6 +69,7 @@ public class SchemaPrefixReference extends PsiReferenceBase<XmlElement> {
|
||||
public boolean isReferenceTo(PsiElement element) {
|
||||
return element instanceof SchemaPrefix
|
||||
&& element.getContainingFile() == myElement.getContainingFile()
|
||||
&& ((SchemaPrefix)element).getDeclaration() == myDeclaration
|
||||
&& myName.equals(((SchemaPrefix)element).getName())
|
||||
&& myName.length() > 0;
|
||||
}
|
||||
|
||||
@@ -530,18 +530,21 @@ public class XmlUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement findNamespaceDeclaration(PsiFile xmlFile, String nsName) {
|
||||
if (xmlFile instanceof XmlFile) {
|
||||
final XmlDocument document = ((XmlFile)xmlFile).getDocument();
|
||||
if (document != null) {
|
||||
final XmlTag rootTag = document.getRootTag();
|
||||
if (rootTag != null) {
|
||||
for (XmlAttribute attribute : rootTag.getAttributes()) {
|
||||
if (attribute.isNamespaceDeclaration() && attribute.getLocalName().equals(nsName)) {
|
||||
return attribute;
|
||||
}
|
||||
public static PsiElement findNamespaceDeclaration(XmlElement xmlElement, String nsName) {
|
||||
while (! (xmlElement instanceof XmlTag) && xmlElement != null) {
|
||||
final PsiElement parent = xmlElement.getParent();
|
||||
if (!(parent instanceof XmlElement)) return null;
|
||||
xmlElement = (XmlElement)parent;
|
||||
}
|
||||
if (xmlElement != null) {
|
||||
XmlTag tag = (XmlTag)xmlElement;
|
||||
while (tag != null) {
|
||||
for (XmlAttribute attribute : tag.getAttributes()) {
|
||||
if (attribute.isNamespaceDeclaration() && attribute.getLocalName().equals(nsName)) {
|
||||
return attribute;
|
||||
}
|
||||
}
|
||||
tag = tag.getParentTag();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user