com.jetbrains.php.completion.insert.PhpReferenceInsertHandler Java Examples

The following examples show how to use com.jetbrains.php.completion.insert.PhpReferenceInsertHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ToolboxJsonCompletionContributor.java    From idea-php-toolbox with MIT License 5 votes vote down vote up
public void handleInsert(@NotNull InsertionContext context, @NotNull LookupElement lookupElement) {

            // reuse core class + namespace insertHandler
            PhpReferenceInsertHandler.getInstance().handleInsert(context, lookupElement);

            // phpstorm8: remove leading backslash on PhpReferenceInsertHandler
            String backslash = context.getDocument().getText(new TextRange(context.getStartOffset(), context.getStartOffset() + 1));
            if("\\".equals(backslash)) {
                context.getDocument().deleteString(context.getStartOffset(), context.getStartOffset() + 1);
            }
        }
 
Example #2
Source File: ToolboxJsonCompletionContributor.java    From idea-php-toolbox with MIT License 5 votes vote down vote up
public void handleInsert(@NotNull InsertionContext context, @NotNull LookupElement lookupElement) {

            // reuse core class + namespace insertHandler
            PhpReferenceInsertHandler.getInstance().handleInsert(context, lookupElement);

            // phpstorm8: remove leading backslash on PhpReferenceInsertHandler
            String backslash = context.getDocument().getText(new TextRange(context.getStartOffset(), context.getStartOffset() + 1));
            if("\\".equals(backslash)) {
                context.getDocument().deleteString(context.getStartOffset(), context.getStartOffset() + 1);
            }
        }
 
Example #3
Source File: ClassConstantInsertHandler.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Override
public void handleInsert(InsertionContext context, LookupElement lookupElement) {

    if(!(lookupElement instanceof ClassConstantLookupElementInterface) || !(lookupElement.getObject() instanceof PhpClass)) {
        return;
    }

    PhpReferenceInsertHandler.getInstance().handleInsert(context, lookupElement);
    PhpInsertHandlerUtil.insertStringAtCaret(context.getEditor(), "::class");
}
 
Example #4
Source File: PhpClassCompletionProvider.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
private static MyPhpLookupElement wrapInsertHandler(MyPhpLookupElement lookupElement, boolean withLeadBackslash) {

        if(withLeadBackslash) {
            return lookupElement.withInsertHandler(PhpReferenceInsertHandler.getInstance());
        }

        return lookupElement.withInsertHandler(PhpReferenceTrimBackslashInsertHandler.getInstance());
    }
 
Example #5
Source File: PhpReferenceTrimBackslashInsertHandler.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void handleInsert(@NotNull InsertionContext context, @NotNull LookupElement lookupElement) {

        // reuse core class + namespace insertHandler
        PhpReferenceInsertHandler.getInstance().handleInsert(context, lookupElement);

        // phpstorm8: remove leading backslash on PhpReferenceInsertHandler
        String backslash = context.getDocument().getText(new TextRange(context.getStartOffset(), context.getStartOffset() + 1));
        if("\\".equals(backslash)) {
            context.getDocument().deleteString(context.getStartOffset(), context.getStartOffset() + 1);
        }

    }