update copyright
[fedora-idea.git] / java / java-impl / src / com / intellij / codeInsight / hint / JavaImplementationTextSelectioner.java
blob8e5800d295c60657c98ec5bb041263a6bab64198
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * User: anna
19 * Date: 01-Feb-2008
21 package com.intellij.codeInsight.hint;
23 import com.intellij.openapi.diagnostic.Logger;
24 import com.intellij.psi.PsiDocCommentOwner;
25 import com.intellij.psi.PsiElement;
26 import com.intellij.psi.PsiWhiteSpace;
27 import com.intellij.psi.javadoc.PsiDocComment;
28 import org.jetbrains.annotations.NotNull;
30 public class JavaImplementationTextSelectioner implements ImplementationTextSelectioner {
31 private static final Logger LOG = Logger.getInstance("#" + JavaImplementationTextSelectioner.class.getName());
33 public int getTextStartOffset(@NotNull final PsiElement parent) {
34 PsiElement element = parent;
35 if (element instanceof PsiDocCommentOwner) {
36 PsiDocComment comment = ((PsiDocCommentOwner)element).getDocComment();
37 if (comment != null) {
38 element = comment.getNextSibling();
39 while (element instanceof PsiWhiteSpace) {
40 element = element.getNextSibling();
45 if (element != null) {
46 return element.getTextRange().getStartOffset();
48 else {
49 LOG.assertTrue(false, "Element should not be null: " + parent.getText());
50 return parent.getTextRange().getStartOffset();
54 public int getTextEndOffset(@NotNull PsiElement element) {
55 return element.getTextRange().getEndOffset();