List of usage examples for org.eclipse.jdt.core.jdom IDOMNode TYPE
int TYPE
To view the source code for org.eclipse.jdt.core.jdom IDOMNode TYPE.
Click Source Link
From source file:com.iw.plugins.spindle.wizards.project.ApplicationWizardPage.java
License:Mozilla Public License
protected void populateMethodSource(IType servletType, IProgressMonitor monitor) throws JavaModelException { String methodName = MessageUtil.getString("Tapestry.servlet.getAppMethodName"); ICompilationUnit parentCU = servletType.getCompilationUnit(); String gensource = parentCU.getSource(); DOMFactory domFactory = new DOMFactory(); IDOMCompilationUnit unit = domFactory.createCompilationUnit(gensource, servletType.getElementName()); IDOMNode current = unit.getFirstChild(); while (current.getNodeType() != IDOMNode.TYPE) { current = current.getNextNode(); }/* w w w . jav a2s. co m*/ IDOMNode theType = current; IDOMMethod method = findMethod(theType, methodName); if (method == null) { method = domFactory.createMethod("protected String getApplicationSpecificationPath() {}"); theType.addChild(method); } method.setBody(getAppMethodBody()); String newContents = Utils.formatJavaCode(unit.getContents(), 0, StubUtility.getLineDelimiterUsed(parentCU)); parentCU.getBuffer().setContents(newContents); parentCU.save(monitor, true); }
From source file:org.eclipse.emf.codegen.jet.JETSkeleton.java
License:Open Source License
public void setConstants(List<String> constants) { for (IDOMNode node = compilationUnit.getFirstChild(); node != null; node = node.getNextNode()) { if (node.getNodeType() == IDOMNode.TYPE) { String name = node.getName(); IDOMNode insertionNode = node.getFirstChild(); insertionNode.insertSibling(jdomFactory.createField(STATIC_NL_DECLARATION)); insertionNode.insertSibling(jdomFactory.createMethod( CREATE_METHOD_DECLARATION_HEAD + name + CREATE_METHOD_DECLARATION_MIDDLE + name + CREATE_METHOD_DECLARATION_MIDDLE2 + name + CREATE_METHOD_DECLARATION_TAIL)); insertionNode.insertSibling( jdomFactory.createField(NL_DECLARATION + getNLString() + NL_DECLARATION_TAIL)); for (Iterator<String> i = constants.iterator(); i.hasNext();) { String constant = " " + i.next() + NL; if (!i.hasNext()) { constant += NL;//from ww w.j a va 2 s .c om } insertionNode.insertSibling(jdomFactory.createField(constant)); } break; } } }
From source file:org.eclipse.emf.codegen.jet.JETSkeleton.java
License:Open Source License
public void addImports(String importList) { for (IDOMNode node = compilationUnit.getFirstChild(); node != null; node = node.getNextNode()) { if (node.getNodeType() == IDOMNode.TYPE) { for (StringTokenizer stringTokenizer = new StringTokenizer(importList, " \t\n\r"); stringTokenizer .hasMoreTokens();) { String token = stringTokenizer.nextToken(); String newImport = "import " + token + ";" + NL; if (!stringTokenizer.hasMoreTokens()) { newImport += NL;//from w w w . j a v a2s . co m } IDOMImport imports = jdomFactory.createImport(newImport); if (imports != null) { node.insertSibling(imports); } } return; } } }
From source file:org.eclipse.emf.codegen.jet.JETSkeleton.java
License:Open Source License
public String getClassName() { for (IDOMNode node = compilationUnit.getFirstChild(); node != null; node = node.getNextNode()) { if (node.getNodeType() == IDOMNode.TYPE) { return node.getName(); }/*from w w w.ja v a 2 s . c o m*/ } return null; }
From source file:org.eclipse.emf.codegen.jet.JETSkeleton.java
License:Open Source License
public void setClassName(String className) { for (IDOMNode node = compilationUnit.getFirstChild(); node != null; node = node.getNextNode()) { if (node.getNodeType() == IDOMNode.TYPE) { node.setName(className);//from ww w . jav a 2s.c o m } } }
From source file:org.eclipse.emf.codegen.jet.JETSkeleton.java
License:Open Source License
protected IDOMMethod getLastMethod() { IDOMMethod method = null;/* ww w.j a v a 2 s.c om*/ for (IDOMNode node = compilationUnit.getFirstChild(); node != null; node = node.getNextNode()) { if (node.getNodeType() == IDOMNode.TYPE) { for (IDOMNode child = node.getFirstChild(); child != null; child = child.getNextNode()) { if (child.getNodeType() == IDOMNode.METHOD) { method = (IDOMMethod) child; } } } } return method; }
From source file:org.eclipse.emf.codegen.jmerge.JMerger.java
License:Open Source License
protected void pullTargetCompilationUnit() { if (targetCompilationUnit == null) { setTargetCompilationUnit((IDOMCompilationUnit) insertClone(sourceCompilationUnit)); } else {/* ww w .j av a 2 s .co m*/ map(sourceCompilationUnit, targetCompilationUnit); applyPullRules(sourceCompilationUnit, targetCompilationUnit); /* // PULL Header // String sourceHeader = sourceCompilationUnit.getHeader(); if (sourceHeader != null) { targetCompilationUnit.setHeader(sourceHeader); } */ for (IDOMNode child = targetCompilationUnit.getFirstChild(); child != null; child = child .getNextNode()) { switch (child.getNodeType()) { case IDOMNode.PACKAGE: { pullTargetPackage((IDOMPackage) child); break; } case IDOMNode.IMPORT: { pullTargetImport((IDOMImport) child); break; } case IDOMNode.TYPE: { IDOMType type = (IDOMType) child; isBlocked = jControlModel.getBlockPattern() != null && type.getComment() != null && jControlModel.getBlockPattern().matcher(type.getComment()).find(); if (!isBlocked) { pullTargetType(type); } break; } } } } }
From source file:org.eclipse.emf.codegen.jmerge.JMerger.java
License:Open Source License
protected void pullTargetType(IDOMType targetType) { IDOMType sourceType = (IDOMType) sourcePatternDictionary.getTypeMap() .get(targetPatternDictionary.getQualifiedName(targetType)); map(sourceType, targetType);//w w w . ja va 2 s. c om if (sourceType != null) { applyPullRules(sourceType, targetType); /* // PULL: Comment // String sourceComment = sourceType.getComment(); if (sourceComment != null) { targetType.setComment(sourceComment); } */ /* // PULL: Flags // int sourceFlags = sourceType.getFlags(); targetType.setFlags(sourceFlags); // PULL: Superclass // targetType.setSuperclass(sourceType.getSuperclass()); // PULL: SuperInterfaces // ArrayList additionalSuperInterfaces = new ArrayList(); String [] sourceSuperInterfaces = sourceType.getSuperInterfaces(); if (sourceSuperInterfaces != null) { additionalSuperInterfaces.addAll(Arrays.asList(sourceSuperInterfaces)); String [] targetTypeSuperInterfaces = targetType.getSuperInterfaces(); if (targetTypeSuperInterfaces != null) { additionalSuperInterfaces.removeAll(Arrays.asList(targetType.getSuperInterfaces())); } } for (Iterator i = additionalSuperInterfaces.iterator(); i.hasNext(); ) { String superInterface = (String)i.next(); targetType.addSuperInterface(superInterface); } */ } for (IDOMNode child = targetType.getFirstChild(); child != null; child = child.getNextNode()) { switch (child.getNodeType()) { case IDOMNode.INITIALIZER: { pullTargetInitializer((IDOMInitializer) child); break; } case IDOMNode.FIELD: { pullTargetField((IDOMField) child); break; } case IDOMNode.METHOD: { pullTargetMethod((IDOMMethod) child); break; } case IDOMNode.TYPE: { pullTargetType((IDOMType) child); break; } } } }
From source file:org.eclipse.emf.codegen.jmerge.JMerger.java
License:Open Source License
protected void pushSourceCompilationUnit() { for (IDOMNode child = sourceCompilationUnit.getFirstChild(); child != null; child = child.getNextNode()) { switch (child.getNodeType()) { case IDOMNode.PACKAGE: { pushSourcePackage((IDOMPackage) child); break; }/*from w w w. j a va 2 s. co m*/ case IDOMNode.IMPORT: { pushSourceImport((IDOMImport) child); break; } case IDOMNode.TYPE: { pushSourceType((IDOMType) child); break; } } } }
From source file:org.eclipse.emf.codegen.jmerge.JMerger.java
License:Open Source License
protected void pushSourceType(IDOMType sourceType) { if (!sourceToTargetMap.containsKey(sourceType)) { insertClone(sourceType);/* w w w .j a v a2 s . c o m*/ } else { for (IDOMNode child = sourceType.getFirstChild(); child != null; child = child.getNextNode()) { switch (child.getNodeType()) { case IDOMNode.INITIALIZER: { pushSourceInitializer((IDOMInitializer) child); break; } case IDOMNode.FIELD: { pushSourceField((IDOMField) child); break; } case IDOMNode.METHOD: { pushSourceMethod((IDOMMethod) child); break; } case IDOMNode.TYPE: { pushSourceType((IDOMType) child); break; } } } } }