dltk & php

本文深入探讨了PHP的代码补全机制,包括Eclipse插件dltk的完成建议实现,以及如何通过配置控制补全顺序。同时,文章介绍了PHP的调试技术,如表达式评估和变量查看。此外,还分析了静态类变量在调试时的显示问题,并揭示了Java断点命中计数的工作原理。最后,讨论了PHP编辑器中代码助手在HTML内容中的行为以及WTP编辑器的基础架构。
摘要由CSDN通过智能技术生成

dltk code Completion

org.eclipse.dltk.ui.text.completion.ScriptCompletionProposalComputer#computeCompletionProposals

the Language specific proposals is on top of Template proposals

 

if want to change the proposals' older,could store the configure the older in the preference page and

store it(format like "computeScriptCompletionProposals,computeTemplateCompletionProposals,other"),and ScriptCompletionProposalComputer's subclass override computeCompletionProposals,split the stored value then iterate them and then judge it use if ,finally call the corresponding method,so the older is under control.

 


code completion contexts : CompletionContextResolver.java    /org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/contexts

 


php completion engine    PHPCompletionEngine.java    /org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist

php evaluate expression    PHPWatchExpressionDelegate.java    /org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/watch


php text hover    PHPDebugTextHover.java    /org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/hovers

 

 

 

 

Bug 207699
Static class variables do not show up in the Variables view when debugging in the PHP Debug perspective

because the value is got from PHPValue#getVariables,requestVariables,actually the RemoteDebugger send a
GetVariableValueRequest
response = (GetVariableValueResponse) connection
                    .sendRequest(request);
...
return response.getVarResult();

and then ExpressionsValueDeserializer#deserializer use VariableReader to deserialize the value

it seems there is no method to get a static variable's value



java hit count store the hitcount number in BreakpointRequestImpl(EventRequestImpl).fCountFilters,
and then write to JDWP bytestream(outData)
JavaBreakpoint#configureRequestHitCount
    protected void configureRequestHitCount(EventRequest request) throws CoreException {
        int hitCount= getHitCount();
        if (hitCount > 0) {
            request.addCountFilter(hitCount);//store to EventRequestImpl.fCountFilters
            request.putProperty(HIT_COUNT, new Integer(hitCount));
        }
    }
   
writeInt(((Integer)fCountFilters.get(i)).intValue(), "count filter", outData);

so if want to add hit count support to pdt,it must be supported by the debugger

link with debug view is completed through PHPThread#setBreakpoints which is called by
PHPDebugTarget#breakpointHit.

the php debug is through the ui ,then new request for the special action then receive response.
when start a php debug,pdt will add all breakpoints to the remote debugger(AddBreakpointRequest)


get content type for a text viewer and the text offset
            IDocument document= viewer.getDocument();
            String type= TextUtilities.getContentType(document, getDocumentPartitioning(), offset, true);

php code assist works in the html contest,this is for PHPStructuredTextViewerConfiguration#getContentAssistProcessors


type <input type="hi in php file entry "ctrl" + "space" will not show "hidden".
this because php PHPTokenizer(about line 1944)

// JSP attribute value start - complex single quoted
                assembleEmbeddedContainer(XML_TAG_ATTRIBUTE_VALUE_SQUOTE,
                        XML_TAG_ATTRIBUTE_VALUE_SQUOTE);

this make XML_TAG_ATTRIBUTE_VALUE_SQUOTE ContextRegionContainer type not AttributeValueRegion type.

and then in HTMLContentAssistProcessor#addAttributeValueProposals method (line 343)

// d210858, if the region's a container, don't suggest the
// enumerated values as they probably won't help
boolean existingComplicatedValue = (contentAssistRequest.getRegion() != null) && (contentAssistRequest.getRegion() instanceof ITextRegionContainer);
if (!existingComplicatedValue) {
...
}

so the "hidden" string not popup when entry "ctrl" + "space"


editor base wtp,its code assist is computed in CompoundContentAssistProcessor#computeCompletionProposals
here has some relation with StructuredTextViewerConfigurationHTML#getContentAssistProcessors,subclass
reimplement this method to deal with the partition types that it is interested in.




    <!-- PHP Model Handler -->
    <extension
        point="org.eclipse.wst.sse.core.modelHandler">
        <modelHandler
            default="yes"
            class="org.eclipse.php.internal.core.documentModel.handler.PHPModelHandler"
            associatedContentTypeId="org.eclipse.php.core.phpsource"
            id="org.eclipse.php.core.documentModel.handler">
        </modelHandler>
    </extension>
   
    org.eclipse.php.internal.core.documentModel.handler.PHPModelHandler
   
    public IDocumentLoader getDocumentLoader() {
        return new PHPDocumentLoader();
    }
   
    in PHPDocumentLoader
   
    protected IEncodedDocument newEncodedDocument() {
        IEncodedDocument doc = super.newEncodedDocument();
        assert doc instanceof BasicStructuredDocument;
        ((BasicStructuredDocument) doc)
                .setReParser(new PhpStructuredDocumentReParser());

        // doc.setPreferredLineDelimiter( "\n" );
        return doc;
    }

    public RegionParser getParser() {
        PhpSourceParser parser = new PhpSourceParser();
        // for the "static HTML" case, we need to initialize
        // Blocktags here.
        addHTMLishTag(parser, "script"); //$NON-NLS-1$
        addHTMLishTag(parser, "style"); //$NON-NLS-1$
        return parser;
    }

when change something in php editor will call PhpStructuredDocumentReParser#reparse,
then PhpSourceParser#parseNodes,then PHPTokenizer#getNextToken
then ContextRegionContainer...will be instanced


ScriptCompletionProcessor


PHPStructuredEditor#

        resAction = new TextOperationAction(
                DLTKEditorMessages.getBundleForConstructedKeys(),
                "ShowOutline.", this, PHPStructuredTextViewer.SHOW_OUTLINE, true); //$NON-NLS-1$
        resAction
                .setActionDefinitionId(IScriptEditorActionDefinitionIds.SHOW_OUTLINE); //$NON-NLS-1$
        setAction(IScriptEditorActionDefinitionIds.SHOW_OUTLINE, resAction);
       
PHPStructuredTextViewer#configure

        fOutlinePresenter = phpConfiguration.getOutlinePresenter(this);
        if (fOutlinePresenter != null) {
            fOutlinePresenter.install(this);
        }
       
       
PHPStructuredTextViewer#doOperation

        case SHOW_OUTLINE:
            if (fOutlinePresenter != null) {
                fOutlinePresenter.showInformation();
            }
            return;
           
PHPStructuredTextViewerConfiguration#getOutlinePresenter

 

 

 

 

refactor is in DeltaProcessor#updateModel,ModelUpdater#traverseDelta,SourceModule#close

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值