mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
bunch of dead code
This commit is contained in:
@@ -1,45 +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.pom.references;
|
||||
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.pom.PomTarget;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class PomPolyVariantReferenceBase extends PomReference {
|
||||
protected PomPolyVariantReferenceBase(PsiElement element, TextRange rangeInElement) {
|
||||
super(element, rangeInElement);
|
||||
}
|
||||
|
||||
public PomTarget resolve() {
|
||||
final PomTarget[] targets = multiResolve();
|
||||
if (targets.length == 1) {
|
||||
return targets[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isReferenceTo(@NotNull PomTarget candidate) {
|
||||
for (final PomTarget target : multiResolve()) {
|
||||
if (target.equals(candidate)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,87 +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.pom.references;
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionParameters;
|
||||
import com.intellij.codeInsight.completion.CompletionResultSet;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.pom.PomNamedTarget;
|
||||
import com.intellij.pom.PomTarget;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public abstract class PomReference {
|
||||
public static final PomReference[] EMPTY_ARRAY = new PomReference[0];
|
||||
|
||||
private final PsiElement myElement;
|
||||
private final TextRange myRangeInElement;
|
||||
|
||||
protected PomReference(PsiElement element, TextRange rangeInElement) {
|
||||
myElement = element;
|
||||
myRangeInElement = rangeInElement;
|
||||
}
|
||||
|
||||
protected PomReference(PsiElement element) {
|
||||
this(element, PomReferenceUtil.getDefaultRangeInElement(element));
|
||||
}
|
||||
|
||||
public final PsiElement getElement() {
|
||||
return myElement;
|
||||
}
|
||||
|
||||
public final TextRange getRangeInElement() {
|
||||
return myRangeInElement;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract PomTarget resolve();
|
||||
|
||||
@NotNull
|
||||
public abstract PomTarget[] multiResolve();
|
||||
|
||||
public abstract boolean isReferenceTo(@NotNull PomTarget target);
|
||||
|
||||
public void bindToElement(@NotNull PomTarget target) {
|
||||
if (target instanceof PomNamedTarget) {
|
||||
final PomNamedTarget namedTarget = (PomNamedTarget)target;
|
||||
PomReferenceUtil.changeContent(this, namedTarget.getName());
|
||||
}
|
||||
throw new UnsupportedOperationException("Cannot bind reference " + this + " to unnamed target " + target);
|
||||
}
|
||||
|
||||
public void processVariants(@NotNull CompletionResultSet result, @NotNull CompletionParameters parameters) {
|
||||
final LookupElement[] elements = ApplicationManager.getApplication().runReadAction(new Computable<LookupElement[]>() {
|
||||
public LookupElement[] compute() {
|
||||
return getVariants();
|
||||
}
|
||||
});
|
||||
for (final LookupElement element : elements) {
|
||||
result.addElement(element);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public LookupElement[] getVariants() {
|
||||
return LookupElement.EMPTY_ARRAY;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +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.pom.references;
|
||||
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.pom.PomTarget;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class PomReferenceBase extends PomReference {
|
||||
protected PomReferenceBase(PsiElement element, TextRange rangeInElement) {
|
||||
super(element, rangeInElement);
|
||||
}
|
||||
|
||||
protected PomReferenceBase(PsiElement element) {
|
||||
super(element);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PomTarget[] multiResolve() {
|
||||
final PomTarget target = resolve();
|
||||
if (target == null) {
|
||||
return PomTarget.EMPTY_ARRAY;
|
||||
}
|
||||
return new PomTarget[]{target};
|
||||
}
|
||||
|
||||
public boolean isReferenceTo(@NotNull PomTarget candidate) {
|
||||
return candidate.equals(resolve());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +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.pom.references;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public abstract class PomReferenceProvider<T extends PsiElement> {
|
||||
|
||||
@NotNull
|
||||
public abstract PomReference[] getReferencesByElement(@NotNull T element, @NotNull final ProcessingContext context);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,65 +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.pom.references;
|
||||
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.ElementManipulator;
|
||||
import com.intellij.psi.ElementManipulators;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.DelegatePsiTarget;
|
||||
import com.intellij.psi.meta.PsiMetaOwner;
|
||||
import com.intellij.psi.meta.PsiMetaData;
|
||||
import com.intellij.psi.meta.PsiMetaDataTarget;
|
||||
import com.intellij.pom.PomTarget;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class PomReferenceUtil {
|
||||
|
||||
public static String getReferenceText(PomReference reference) {
|
||||
return reference.getRangeInElement().substring(reference.getElement().getText());
|
||||
}
|
||||
|
||||
public static TextRange getDefaultRangeInElement(PsiElement element) {
|
||||
final ElementManipulator<PsiElement> manipulator = ElementManipulators.getManipulator(element);
|
||||
assert manipulator != null: "Cannot find manipulator for " + element;
|
||||
return manipulator.getRangeInElement(element);
|
||||
}
|
||||
|
||||
public static void changeContent(PomReference reference, String newContent) {
|
||||
final ElementManipulator<PsiElement> manipulator = ElementManipulators.getManipulator(reference.getElement());
|
||||
assert manipulator != null: "Cannot find manipulator for " + reference.getElement();
|
||||
manipulator.handleContentChange(reference.getElement(), reference.getRangeInElement(), newContent);
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public static PomTarget convertPsi2Target(@NotNull PsiElement element) {
|
||||
if (element instanceof PsiMetaOwner) {
|
||||
final PsiMetaOwner metaOwner = (PsiMetaOwner)element;
|
||||
final PsiMetaData psiMetaData = metaOwner.getMetaData();
|
||||
if (psiMetaData != null) {
|
||||
return new PsiMetaDataTarget(psiMetaData);
|
||||
}
|
||||
}
|
||||
if (element instanceof PomTarget) {
|
||||
return (PomTarget)element;
|
||||
}
|
||||
return new DelegatePsiTarget(element);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.patterns.ElementPattern;
|
||||
import com.intellij.pom.references.PomReferenceProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -50,11 +49,4 @@ public abstract class PsiReferenceRegistrar {
|
||||
* @param priority @see DEFAULT_PRIORITY, HIGHER_PRIORITY, LOWER_PRIORITY
|
||||
*/
|
||||
public abstract <T extends PsiElement> void registerReferenceProvider(@NotNull ElementPattern<T> pattern, @NotNull PsiReferenceProvider provider, double priority);
|
||||
|
||||
public <T extends PsiElement> void registerReferenceProvider(@NotNull ElementPattern<T> pattern, @NotNull PomReferenceProvider<T> provider) {
|
||||
registerReferenceProvider(pattern, provider, DEFAULT_PRIORITY);
|
||||
}
|
||||
|
||||
public abstract <T extends PsiElement> void registerReferenceProvider(@NotNull ElementPattern<T> pattern, @NotNull PomReferenceProvider<T> provider, double priority);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,109 +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.pom.references;
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionData;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.pom.PomTarget;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class PomPsiReference extends PomReference {
|
||||
private final PsiReference myDelegate;
|
||||
|
||||
public PomPsiReference(PsiReference delegate) {
|
||||
super(delegate.getElement(), delegate.getRangeInElement());
|
||||
myDelegate = delegate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PomTarget resolve() {
|
||||
final PsiElement element = myDelegate.resolve();
|
||||
return element == null ? null : PomReferenceUtil.convertPsi2Target(element);
|
||||
}
|
||||
|
||||
public PsiReference getDelegate() {
|
||||
return myDelegate;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PomTarget[] multiResolve() {
|
||||
if (myDelegate instanceof PsiPolyVariantReference) {
|
||||
final PsiPolyVariantReference reference = (PsiPolyVariantReference)myDelegate;
|
||||
final List<PomTarget> list =
|
||||
ContainerUtil.mapNotNull(reference.multiResolve(false), new NullableFunction<ResolveResult, PomTarget>() {
|
||||
public PomTarget fun(ResolveResult resolveResult) {
|
||||
final PsiElement element = resolveResult.getElement();
|
||||
if (element == null) {
|
||||
return null;
|
||||
}
|
||||
return PomReferenceUtil.convertPsi2Target(element);
|
||||
}
|
||||
});
|
||||
return list.toArray(new PomTarget[list.size()]);
|
||||
}
|
||||
|
||||
final PomTarget target = resolve();
|
||||
return target == null ? PomTarget.EMPTY_ARRAY : new PomTarget[]{target};
|
||||
}
|
||||
|
||||
public void bindToElement(@NotNull PomTarget target) throws IncorrectOperationException {
|
||||
myDelegate.bindToElement(((PsiTarget) target).getNavigationElement());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReferenceTo(@NotNull PomTarget target) {
|
||||
return myDelegate.isReferenceTo(((PsiTarget) target).getNavigationElement());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public LookupElement[] getVariants() {
|
||||
return ContainerUtil.map2Array(myDelegate.getVariants(), LookupElement.class, new Function<Object, LookupElement>() {
|
||||
public LookupElement fun(Object o) {
|
||||
return CompletionData.objectToLookupItem(o);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
PomPsiReference that = (PomPsiReference)o;
|
||||
|
||||
if (!myDelegate.equals(that.myDelegate)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return myDelegate.hashCode();
|
||||
}
|
||||
}
|
||||
-6
@@ -17,7 +17,6 @@ package com.intellij.psi.impl.source.resolve.reference;
|
||||
|
||||
import com.intellij.openapi.util.Trinity;
|
||||
import com.intellij.patterns.*;
|
||||
import com.intellij.pom.references.PomReferenceProvider;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReferenceProvider;
|
||||
import com.intellij.psi.PsiReferenceRegistrar;
|
||||
@@ -75,11 +74,6 @@ public class PsiReferenceRegistrarImpl extends PsiReferenceRegistrar {
|
||||
registerReferenceProvider(PlatformPatterns.psiElement(scope).and(new FilterPattern(elementFilter)), provider, priority);
|
||||
}
|
||||
|
||||
public <T extends PsiElement> void registerReferenceProvider(@NotNull ElementPattern<T> pattern,
|
||||
@NotNull PomReferenceProvider<T> provider,
|
||||
double priority) {
|
||||
}
|
||||
|
||||
public <T extends PsiElement> void registerReferenceProvider(@NotNull ElementPattern<T> pattern,
|
||||
@NotNull PsiReferenceProvider provider,
|
||||
double priority) {
|
||||
|
||||
Reference in New Issue
Block a user