2011-05-04 16 views
8

जैसा कि मैं धीरे-धीरे .NET से जावा में अपने संक्रमण में क्रॉल करता हूं, मुझे ग्रहण आईडीई के बारे में अधिक से अधिक रोचक चीज़ें मिलती हैं। मैंने हाल ही में अपने टेम्पलेट्स पर ठोकर खाई और मैं इसे प्यार कर रहा हूं। जो मुझे एक प्रश्न पर लाता है: क्या मैं एक टेम्पलेट को टेम्पलेट के भीतर से कॉल कर सकता हूं? बेशक यह केवल एक प्रतिलिपि और पेस्ट मामला होगा, लेकिन मुझे आश्चर्य है कि यह किया जा सकता है।टेम्पलेट के भीतर टेम्पलेट का उपयोग करना - ग्रहण

+1

क्या आप यह स्पष्ट कर सकते हैं कि आप क्या करने की कोशिश कर रहे हैं? ग्रहण में किसी अन्य टेम्पलेट के अंदर टेम्पलेट का विस्तार करने के लिए तंत्र नहीं है, लेकिन यदि आपको आवश्यकता हो तो आप कॉपी और पेस्ट कर सकते हैं। –

+0

@Pakka, मैं डिफ़ॉल्ट "नई जावा फ़ाइलें" टेम्पलेट देख रहा हूं और यह चार अद्वितीय उप-टेम्पलेट्स का उपयोग करता है। यह वास्तव में एक बड़ा सौदा नहीं है। बस सुनिश्चित करें कि आपके टेम्पलेट्स का सेट एक निर्देशित विश्वकोश ग्राफ बनाता है और आपके पास रिकर्सिव टेम्पलेट समस्याएं नहीं होंगी। –

उत्तर

4

हां, वास्तव में, आप डिफ़ॉल्ट सेट में एक उदाहरण सही कर सकते हैं।

यदि आप अपनी प्राथमिकताओं -> जावा -> कोड शैली -> कोड टेम्पलेट्स पर जाते हैं, तो आप प्रदान किए जा सकने वाले जावा टेम्पलेट्स के सभी निर्यात कर सकते हैं।

<template 
    autoinsert="true" 
    context="filecomment_context" 
    deleted="false" 
    description="Comment for created Java files" 
    enabled="true" 
    id="org.eclipse.jdt.ui.text.codetemplates.filecomment" 
    name="filecomment"> 
    /** * */ 
</template> 

और आगे नीचे एक सा, नए प्रकार जो कि फ़ाइल टेम्पलेट का उपयोग करता है:

<template 
    autoinsert="true" 
    context="newtype_context" 
    deleted="false" 
    description="Newly created files" 
    enabled="true" 
    id="org.eclipse.jdt.ui.text.codetemplates.newtype" 
    name="newtype"> 
    ${filecomment} ${package_declaration} ${typecomment} ${type_declaration} 
</template> 
वहाँ में आप निम्नलिखित फ़ाइल टेम्पलेट (पठनीयता के लिए प्रारूपित) देखेंगे

इसलिए, यदि आप टेम्पलेट को दूसरे का उपयोग करना चाहते हैं, तो मूल रूप आपके उप-टेम्पलेट की आईडी को डॉलर साइन उपसर्ग के साथ संदर्भित करना है। उदाहरण के लिए:

<template 
    autoinsert="true" 
    context="BobOuter_context" 
    deleted="false" 
    description="Bob example outer template" 
    enabled="true" 
    id="bob.example.outertemplate" 
    name="BobOuter"> 
    BobOuterBegins Insert inner template ${bob.example.innertemplate} BobOuterEnds 
</template> 

<template 
    autoinsert="true" 
    context="BobInner_context" 
    deleted="false" 
    description="Bob example inner template" 
    enabled="true" 
    id="bob.example.innertemplate" 
    name="BobInner"> 
    BobInnerBegins Super awesome content goes here BobInnerEnds 
</template> 
+0

क्या इसे सीधे अंतर्निहित टेम्पलेट संपादक में पूरा करना संभव है? – faintsignal

संबंधित मुद्दे