mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
remove duplicate reference for url
This commit is contained in:
@@ -26,6 +26,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author Eugene.Kudelevsky
|
||||
*/
|
||||
public class WebReference extends PsiReferenceBase<PsiElement> {
|
||||
public WebReference(@NotNull PsiElement element) {
|
||||
super(element, true);
|
||||
}
|
||||
|
||||
public WebReference(@NotNull PsiElement element, @NotNull TextRange textRange) {
|
||||
super(element, textRange, true);
|
||||
}
|
||||
@@ -35,6 +39,10 @@ public class WebReference extends PsiReferenceBase<PsiElement> {
|
||||
return new MyFakePsiElement();
|
||||
}
|
||||
|
||||
protected String getUrl() {
|
||||
return getValue();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Object[] getVariants() {
|
||||
@@ -43,25 +51,31 @@ public class WebReference extends PsiReferenceBase<PsiElement> {
|
||||
|
||||
class MyFakePsiElement extends FakePsiElement {
|
||||
@Override
|
||||
public PsiElement getParent() {
|
||||
return myElement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void navigate(boolean requestFocus) {
|
||||
BrowserUtil.browse(getValue());
|
||||
public PsiElement getParent() {
|
||||
return myElement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return getValue();
|
||||
}
|
||||
public void navigate(boolean requestFocus) {
|
||||
BrowserUtil.browse(getUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextRange getTextRange() {
|
||||
final TextRange rangeInElement = getRangeInElement();
|
||||
final TextRange elementRange = myElement.getTextRange();
|
||||
return elementRange != null ? rangeInElement.shiftRight(elementRange.getStartOffset()) : rangeInElement;
|
||||
}
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return getUrl();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextRange getTextRange() {
|
||||
final TextRange rangeInElement = getRangeInElement();
|
||||
final TextRange elementRange = myElement.getTextRange();
|
||||
return elementRange != null ? rangeInElement.shiftRight(elementRange.getStartOffset()) : rangeInElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,59 +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.psi.impl;
|
||||
|
||||
import com.intellij.ide.BrowserUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReferenceBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class UrlPsiReference extends PsiReferenceBase<PsiElement> {
|
||||
public UrlPsiReference(PsiElement element) {
|
||||
super(element);
|
||||
}
|
||||
|
||||
protected String getUrl() {
|
||||
return getValue();
|
||||
}
|
||||
|
||||
public PsiElement resolve() {
|
||||
return new FakePsiElement() {
|
||||
public PsiElement getParent() {
|
||||
return getElement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void navigate(boolean requestFocus) {
|
||||
BrowserUtil.browse(getUrl());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Object[] getVariants() {
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSoft() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -15,10 +15,10 @@
|
||||
*/
|
||||
package org.jetbrains.idea.maven.dom.converters;
|
||||
|
||||
import com.intellij.openapi.paths.WebReference;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.impl.UrlPsiReference;
|
||||
import com.intellij.util.xml.ConvertContext;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -35,6 +35,6 @@ public class MavenUrlConverter extends MavenReferenceConverter<String> {
|
||||
}
|
||||
|
||||
protected PsiReference createReference(PsiElement element, String text, TextRange range) {
|
||||
return new UrlPsiReference(element);
|
||||
return new WebReference(element, range);
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -18,10 +18,10 @@ package org.jetbrains.idea.maven.dom.converters.repositories;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.paths.WebReference;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.impl.UrlPsiReference;
|
||||
import com.intellij.util.xml.ConvertContext;
|
||||
import com.intellij.util.xml.GenericDomValue;
|
||||
import com.intellij.util.xml.ResolvingConverter;
|
||||
@@ -76,8 +76,7 @@ public abstract class MavenRepositoryConverter extends ResolvingConverter<String
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiReference[] createReferences(GenericDomValue value, final PsiElement element, final ConvertContext context) {
|
||||
return new PsiReference[]{new UrlPsiReference(element) {
|
||||
|
||||
return new PsiReference[]{new WebReference(element) {
|
||||
@NotNull
|
||||
@Override
|
||||
public Object[] getVariants() {
|
||||
|
||||
@@ -18,12 +18,12 @@ package com.intellij.xml.util;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.encoding.XmlEncodingReferenceProvider;
|
||||
import com.intellij.html.impl.providers.MicrodataReferenceProvider;
|
||||
import com.intellij.html.impl.util.MicrodataUtil;
|
||||
import com.intellij.openapi.paths.WebReference;
|
||||
import com.intellij.patterns.PlatformPatterns;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.filters.*;
|
||||
import com.intellij.psi.filters.position.NamespaceFilter;
|
||||
import com.intellij.psi.filters.position.ParentElementFilter;
|
||||
import com.intellij.psi.impl.UrlPsiReference;
|
||||
import com.intellij.psi.impl.source.resolve.reference.impl.providers.*;
|
||||
import com.intellij.psi.xml.*;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
@@ -116,7 +116,7 @@ public class XmlReferenceContributor extends PsiReferenceContributor {
|
||||
@Override
|
||||
public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
|
||||
@NotNull ProcessingContext context) {
|
||||
return new PsiReference[] { new UrlPsiReference(element) };
|
||||
return new PsiReference[] { new WebReference(element) };
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user