OffsetsInFile (PsiFile originalFile, OffsetsInFile hostCopyOffsets) { CompletionAssertions.assertHostInfo(hostCopyOffsets.getFile(), hostCopyOffsets.getOffsets()); int hostStartOffset = hostCopyOffsets.getOffsets().getOffset(CompletionInitializationContext.START_OFFSET); OffsetsInFile translatedOffsets = hostCopyOffsets.toInjectedIfAny(hostStartOffset); if (translatedOffsets != hostCopyOffsets) { PsiFile injected = translatedOffsets.getFile(); if (originalFile != injected && injected instanceof PsiFileImpl && InjectedLanguageManager.getInstance(originalFile.getProject()).isInjectedFragment(originalFile)) { setOriginalFile((PsiFileImpl)injected, originalFile); } VirtualFile virtualFile = injected.getVirtualFile(); DocumentWindow documentWindow = null; if (virtualFile instanceof VirtualFileWindow) { documentWindow = ((VirtualFileWindow)virtualFile).getDocumentWindow(); } CompletionAssertions.assertInjectedOffsets(hostStartOffset, injected, documentWindow); if (injected.getTextRange().contains(translatedOffsets.getOffsets().getOffset(CompletionInitializationContext.START_OFFSET))) { return translatedOffsets; } } return hostCopyOffsets; }