• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

umbrello/umbrello

  • sources
  • kde-4.12
  • kdesdk
  • umbrello
  • umbrello
  • codegenerators
  • ruby
rubyclassifiercodedocument.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * This program is free software; you can redistribute it and/or modify *
3  * it under the terms of the GNU General Public License as published by *
4  * the Free Software Foundation; either version 2 of the License, or *
5  * (at your option) any later version. *
6  * *
7  * copyright (C) 2005 *
8  * Richard Dale <Richard_Dale@tipitina.demon.co.uk> *
9  * copyright (C) 2006-2013 *
10  * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
11  ***************************************************************************/
12 
13 // own header
14 #include "rubyclassifiercodedocument.h"
15 
16 // local includes
17 #include "codegen_utils.h"
18 #include "classifier.h"
19 #include "debug_utils.h"
20 #include "rubycodegenerator.h"
21 #include "rubycodecomment.h"
22 #include "rubyclassdeclarationblock.h"
23 #include "rubycodeclassfielddeclarationblock.h"
24 #include "rubycodeoperation.h"
25 #include "uml.h"
26 
27 // qt includes
28 #include <QRegExp>
29 
33 RubyClassifierCodeDocument::RubyClassifierCodeDocument(UMLClassifier * concept)
34  : ClassifierCodeDocument(concept)
35 {
36  init();
37 }
38 
42 RubyClassifierCodeDocument::~RubyClassifierCodeDocument()
43 {
44 }
45 
49 RubyCodeGenerationPolicy * RubyClassifierCodeDocument::getRubyPolicy()
50 {
51  CodeGenPolicyExt *pe = UMLApp::app()->policyExt();
52  RubyCodeGenerationPolicy * policy = dynamic_cast<RubyCodeGenerationPolicy*>(pe);
53  return policy;
54 }
55 
56 //**
57 // * Get the dialog widget which allows user interaction with the object parameters.
58 // * @return CodeDocumentDialog
59 // */
60 /*
61 CodeDocumentDialog RubyClassifierCodeDocument::getDialog()
62 {
63 }
64 */
65 
69 QString RubyClassifierCodeDocument::getPath()
70 {
71  QString path = getPackage();
72 
73  // Replace all white spaces with blanks
74  path = path.simplified();
75 
76  // Replace all blanks with underscore
77  path.replace(QRegExp(" "), "_");
78 
79  path.replace(QRegExp("\\."),"/");
80  path.replace(QRegExp("::"), "/");
81 
82  path = path.toLower();
83 
84  return path;
85 }
86 
87 QString RubyClassifierCodeDocument::getRubyClassName(const QString &name)
88 {
89  CodeGenerator *g = UMLApp::app()->generator();
90  return Codegen_Utils::capitalizeFirstLetter(g->cleanName(name));
91 }
92 
93 // Initialize this ruby classifier code document
94 void RubyClassifierCodeDocument::init()
95 {
96  setFileExtension(".rb");
97 
98  //initCodeClassFields(); // this is dubious because it calls down to
99  // CodeGenFactory::newCodeClassField(this)
100  // but "this" is still in construction at that time.
101 
102  classDeclCodeBlock = 0;
103  publicBlock = 0;
104  protectedBlock = 0;
105  privateBlock = 0;
106  pubConstructorBlock = 0;
107  protConstructorBlock = 0;
108  privConstructorBlock = 0;
109  pubOperationsBlock = 0;
110  privOperationsBlock = 0;
111  protOperationsBlock = 0;
112 
113  // this will call updateContent() as well as other things that sync our document.
114  synchronize();
115 }
116 
124 bool RubyClassifierCodeDocument::addCodeOperation(CodeOperation * op)
125 {
126  Uml::Visibility::Enum scope = op->getParentOperation()->visibility();
127  if(!op->getParentOperation()->isConstructorOperation())
128  {
129  switch (scope) {
130  default:
131  case Uml::Visibility::Public:
132  return pubOperationsBlock->addTextBlock(op);
133  break;
134  case Uml::Visibility::Protected:
135  return protOperationsBlock->addTextBlock(op);
136  break;
137  case Uml::Visibility::Private:
138  return privOperationsBlock->addTextBlock(op);
139  break;
140  }
141  } else {
142  switch (scope) {
143  default:
144  case Uml::Visibility::Public:
145  return pubConstructorBlock->addTextBlock(op);
146  break;
147  case Uml::Visibility::Protected:
148  return protConstructorBlock->addTextBlock(op);
149  break;
150  case Uml::Visibility::Private:
151  return privConstructorBlock->addTextBlock(op);
152  break;
153  }
154  }
155 }
156 
166 void RubyClassifierCodeDocument::loadChildTextBlocksFromNode(QDomElement & root)
167 {
168  QDomNode tnode = root.firstChild();
169  QDomElement telement = tnode.toElement();
170  bool loadCheckForChildrenOK = false;
171  while(!telement.isNull()) {
172  QString nodeName = telement.tagName();
173 
174  if(nodeName == "textblocks") {
175 
176  QDomNode node = telement.firstChild();
177  QDomElement element = node.toElement();
178 
179  // if there is nothing to begin with, then we don't worry about it
180  loadCheckForChildrenOK = element.isNull() ? true : false;
181 
182  while(!element.isNull()) {
183  QString name = element.tagName();
184 
185  if(name == "codecomment") {
186  CodeComment * block = new RubyCodeComment(this);
187  block->loadFromXMI(element);
188  if(!addTextBlock(block))
189  {
190  uError()<<"loadFromXMI : unable to add codeComment to :"<<this;
191  delete block;
192  } else
193  loadCheckForChildrenOK= true;
194  } else
195  if(name == "codeaccessormethod" ||
196  name == "ccfdeclarationcodeblock"
197  ) {
198  QString acctag = element.attribute("tag","");
199  // search for our method in the
200  TextBlock * tb = findCodeClassFieldTextBlockByTag(acctag);
201  if(!tb || !addTextBlock(tb))
202  {
203  uError()<<"loadFromXMI : unable to add codeclassfield child method to:"<<this;
204  // DON'T delete
205  } else
206  loadCheckForChildrenOK= true;
207 
208  } else
209  if(name == "codeblock") {
210  CodeBlock * block = newCodeBlock();
211  block->loadFromXMI(element);
212  if(!addTextBlock(block))
213  {
214  uError()<<"loadFromXMI : unable to add codeBlock to :"<<this;
215  delete block;
216  } else
217  loadCheckForChildrenOK= true;
218  } else
219  if(name == "codeblockwithcomments") {
220  CodeBlockWithComments * block = newCodeBlockWithComments();
221  block->loadFromXMI(element);
222  if(!addTextBlock(block))
223  {
224  uError()<<"loadFromXMI : unable to add codeBlockwithcomments to:"<<this;
225  delete block;
226  } else
227  loadCheckForChildrenOK= true;
228  } else
229  if(name == "header") {
230  // do nothing.. this is treated elsewhere
231  } else
232  if(name == "hierarchicalcodeblock") {
233  HierarchicalCodeBlock * block = newHierarchicalCodeBlock();
234  block->loadFromXMI(element);
235  if(!addTextBlock(block))
236  {
237  uError()<<"Unable to add hierarchicalcodeBlock to:"<<this;
238  delete block;
239  } else
240  loadCheckForChildrenOK= true;
241  } else
242  if(name == "codeoperation") {
243  // find the code operation by id
244  QString id = element.attribute("parent_id","-1");
245  UMLObject * obj = UMLApp::app()->document()->findObjectById(Uml::ID::fromString(id));
246  UMLOperation * op = dynamic_cast<UMLOperation*>(obj);
247  if(op) {
248  CodeOperation * block = new RubyCodeOperation(this, op);
249  block->loadFromXMI(element);
250  if(addTextBlock(block))
251  loadCheckForChildrenOK= true;
252  else
253  {
254  uError()<<"Unable to add codeoperation to:"<<this;
255  block->deleteLater();
256  }
257  } else
258  uError()<<"Unable to find operation create codeoperation for:"<<this;
259  } else
260  if(name == "rubyclassdeclarationblock")
261  {
262  RubyClassDeclarationBlock * block = getClassDecl();
263  block->loadFromXMI(element);
264  if(!addTextBlock(block))
265  {
266  uError()<<"Unable to add ruby code declaration block to:"<<this;
267  // DON'T delete.
268  // block->deleteLater();
269  } else
270  loadCheckForChildrenOK= true;
271  }
272  // This last item is only needed for extreme debugging conditions
273  // (E.g. making new codeclassdocument loader)
274  // else
275  // uDebug()<<" LoadFromXMI: Got strange tag in text block stack:"<<name<<", ignorning";
276 
277  node = element.nextSibling();
278  element = node.toElement();
279  }
280  break;
281  }
282 
283  tnode = telement.nextSibling();
284  telement = tnode.toElement();
285  }
286 
287  if(!loadCheckForChildrenOK)
288  {
289  CodeDocument * test = dynamic_cast<CodeDocument*>(this);
290  if(test)
291  {
292  uWarning()<<" loadChildBlocks : unable to initialize any child blocks in doc: "<<test->getFileName()<<" "<<this;
293  } else {
294  HierarchicalCodeBlock * hb = dynamic_cast<HierarchicalCodeBlock*>(this);
295  if(hb)
296  uWarning()<<" loadChildBlocks : unable to initialize any child blocks in Hblock: "<<hb->getTag()<<" "<<this;
297  else
298  uDebug()<<" loadChildBlocks : unable to initialize any child blocks in UNKNOWN OBJ:"<<this;
299  }
300  }
301 }
302 
303 RubyClassDeclarationBlock * RubyClassifierCodeDocument::getClassDecl()
304 {
305  if(!classDeclCodeBlock)
306  {
307  classDeclCodeBlock = new RubyClassDeclarationBlock (this);
308  classDeclCodeBlock->updateContent();
309  classDeclCodeBlock->setTag("ClassDeclBlock");
310  }
311  return classDeclCodeBlock;
312 }
313 
317 void RubyClassifierCodeDocument::resetTextBlocks()
318 {
319  // all special pointers to text blocks need to be zero'd out
320  operationsBlock = 0;
321  constructorBlock = 0;
322  classDeclCodeBlock = 0;
323 
324  // now do traditional release of text blocks.
325  ClassifierCodeDocument::resetTextBlocks();
326 }
327 
328 // This method will cause the class to rebuild its text representation.
329 // based on the parent classifier object.
330 // For any situation in which this is called, we are either building the code
331 // document up, or replacing/regenerating the existing auto-generated parts. As
332 // such, we will want to insert everything we resonablely will want
333 // during creation. We can set various parts of the document (esp. the
334 // comments) to appear or not, as needed.
335 void RubyClassifierCodeDocument::updateContent()
336 {
337  // Gather info on the various fields and parent objects of this class...
338  UMLClassifier * c = getParentClassifier();
339  RubyCodeGenerator * gen = dynamic_cast<RubyCodeGenerator*>(UMLApp::app()->generator());
340 
341  // first, set the global flag on whether or not to show classfield info
342  // This depends on whether or not we have attribute/association classes
343  const CodeClassFieldList * cfList = getCodeClassFieldList();
344  CodeClassFieldList::const_iterator it = cfList->begin();
345  CodeClassFieldList::const_iterator end = cfList->end();
346  for(; it != end; ++it) {
347  CodeClassField * field = *it;
348  if(field->parentIsAttribute())
349  field->setWriteOutMethods(gen->getAutoGenerateAttribAccessors());
350  else
351  field->setWriteOutMethods(gen->getAutoGenerateAssocAccessors());
352  }
353  // attribute-based ClassFields
354  // we do it this way to have the static fields sorted out from regular ones
355  CodeClassFieldList staticPublicAttribClassFields = getSpecificClassFields (CodeClassField::Attribute, true, Uml::Visibility::Public);
356  CodeClassFieldList publicAttribClassFields = getSpecificClassFields (CodeClassField::Attribute, false, Uml::Visibility::Public);
357  CodeClassFieldList staticProtectedAttribClassFields = getSpecificClassFields (CodeClassField::Attribute, true, Uml::Visibility::Protected);
358  CodeClassFieldList protectedAttribClassFields = getSpecificClassFields (CodeClassField::Attribute, false, Uml::Visibility::Protected);
359  CodeClassFieldList staticPrivateAttribClassFields = getSpecificClassFields (CodeClassField::Attribute, true, Uml::Visibility::Private);
360  CodeClassFieldList privateAttribClassFields = getSpecificClassFields (CodeClassField::Attribute, false, Uml::Visibility::Private);
361 
362  // association-based ClassFields
363  // don't care if they are static or not..all are lumped together
364  CodeClassFieldList publicPlainAssocClassFields = getSpecificClassFields (CodeClassField::PlainAssociation, Uml::Visibility::Public);
365  CodeClassFieldList publicAggregationClassFields = getSpecificClassFields (CodeClassField::Aggregation, Uml::Visibility::Public);
366  CodeClassFieldList publicCompositionClassFields = getSpecificClassFields (CodeClassField::Composition, Uml::Visibility::Public);
367 
368  CodeClassFieldList protPlainAssocClassFields = getSpecificClassFields (CodeClassField::PlainAssociation, Uml::Visibility::Protected);
369  CodeClassFieldList protAggregationClassFields = getSpecificClassFields (CodeClassField::Aggregation, Uml::Visibility::Protected);
370  CodeClassFieldList protCompositionClassFields = getSpecificClassFields (CodeClassField::Composition, Uml::Visibility::Protected);
371 
372  CodeClassFieldList privPlainAssocClassFields = getSpecificClassFields (CodeClassField::PlainAssociation, Uml::Visibility::Private);
373  CodeClassFieldList privAggregationClassFields = getSpecificClassFields (CodeClassField::Aggregation, Uml::Visibility::Private);
374  CodeClassFieldList privCompositionClassFields = getSpecificClassFields (CodeClassField::Composition, Uml::Visibility::Private);
375 
376  bool isInterface = parentIsInterface();
377  bool hasOperationMethods = false;
378  Q_ASSERT(c != NULL);
379  if (c) {
380  UMLOperationList list = c->getOpList();
381  hasOperationMethods = ! list.isEmpty();
382  }
383  CodeGenerationPolicy *pol = UMLApp::app()->commonPolicy();
384  QString endLine = pol->getNewLineEndingChars(); // a shortcut..so we don't have to call this all the time
385 
386  //
387  // START GENERATING CODE/TEXT BLOCKS and COMMENTS FOR THE DOCUMENT
388  //
389 
390 
391  // CLASS DECLARATION BLOCK
392  //
393 
394  // get the declaration block. If it is not already present, add it too
395  RubyClassDeclarationBlock * myClassDeclCodeBlock = getClassDecl();
396  addTextBlock(myClassDeclCodeBlock); // note: wont add if already present
397 
398  // declare public, protected and private methods, attributes (fields).
399  // set the start text ONLY if this is the first time we created the objects.
400  bool createdPublicBlock = publicBlock == 0 ? true : false;
401  publicBlock = myClassDeclCodeBlock->getHierarchicalCodeBlock("publicBlock","Public Items", 0);
402  if (createdPublicBlock)
403  publicBlock->setStartText("public");
404 
405  bool createdProtBlock = protectedBlock == 0 ? true : false;
406  protectedBlock = myClassDeclCodeBlock->getHierarchicalCodeBlock("protectedBlock","Protected Items", 0);
407  if(createdProtBlock)
408  protectedBlock->setStartText("protected");
409 
410  bool createdPrivBlock = privateBlock == 0 ? true : false;
411  privateBlock = myClassDeclCodeBlock->getHierarchicalCodeBlock("privateBlock","Private Items", 0);
412  if(createdPrivBlock)
413  privateBlock->setStartText("private");
414 
415  // NOW create document in sections..
416  // now we want to populate the body of our class
417  // our layout is the following general groupings of code blocks:
418 
419  // start ruby classifier document
420 
421  // header comment
422 
423  // class declaration
424 
425  // section:
426 
427  // section:
428  // - methods section comment
429 
430  // sub-section: constructor ops
431  // - constructor method section comment
432  // - constructor methods (0+ codeblocks)
433 
434  // sub-section: accessors
435  // - accessor method section comment
436  // - static accessor methods (0+ codeblocks)
437  // - non-static accessor methods (0+ codeblocks)
438 
439  // sub-section: non-constructor ops
440  // - operation method section comment
441  // - operations (0+ codeblocks)
442 
443  // end class declaration
444 
445  // end ruby classifier document
446 
447 
448  // Q: Why use the more complicated scheme of arranging code blocks within codeblocks?
449  // A: This will allow us later to preserve the format of our document so that if
450  // codeblocks are added, they may be easily added in the correct place, rather than at
451  // the end of the document, or by using a difficult algorithm to find the location of
452  // the last appropriate code block sibling (which may not exist.. for example user adds
453  // a constructor operation, but there currently are no constructor code blocks
454  // within the document).
455 
456 
457  //
458  // METHODS section
459  //
460 
461  // get/create the method codeblock
462  // public methods
463  HierarchicalCodeBlock * pubMethodsBlock = publicBlock->getHierarchicalCodeBlock("pubMethodsBlock", "", 1);
464  CodeComment * pubMethodsComment = pubMethodsBlock->getComment();
465  bool forceDoc = pol->getCodeVerboseDocumentComments();
466  // set conditions for showing this comment
467  if (!forceDoc && !hasClassFields() && !hasOperationMethods)
468  pubMethodsComment->setWriteOutText(false);
469  else
470  pubMethodsComment->setWriteOutText(true);
471 
472  // protected methods
473  HierarchicalCodeBlock * protMethodsBlock = protectedBlock->getHierarchicalCodeBlock("protMethodsBlock", "", 1);
474  CodeComment * protMethodsComment = protMethodsBlock->getComment();
475  // set conditions for showing this comment
476  if (!forceDoc && !hasClassFields() && !hasOperationMethods)
477  protMethodsComment->setWriteOutText(false);
478  else
479  protMethodsComment->setWriteOutText(true);
480 
481  // private methods
482  HierarchicalCodeBlock * privMethodsBlock = privateBlock->getHierarchicalCodeBlock("privMethodsBlock", "", 1);
483  CodeComment * privMethodsComment = privMethodsBlock->getComment();
484  // set conditions for showing this comment
485  if (!forceDoc && !hasClassFields() && !hasOperationMethods)
486  privMethodsComment->setWriteOutText(false);
487  else
488  privMethodsComment->setWriteOutText(true);
489 
490  // METHODS sub-section : constructor methods
491  //
492 
493  // public
494  pubConstructorBlock = pubMethodsBlock->getHierarchicalCodeBlock("constructionMethods", "Constructors", 1);
495  // special condiions for showing comment: only when autogenerateding empty constructors
496  // Although, we *should* check for other constructor methods too
497  CodeComment * pubConstComment = pubConstructorBlock->getComment();
498  if (!forceDoc && (isInterface || !pol->getAutoGenerateConstructors()))
499  pubConstComment->setWriteOutText(false);
500  else
501  pubConstComment->setWriteOutText(true);
502 
503  // protected
504  protConstructorBlock = protMethodsBlock->getHierarchicalCodeBlock("constructionMethods", "Constructors", 1);
505  // special condiions for showing comment: only when autogenerateding empty constructors
506  // Although, we *should* check for other constructor methods too
507  CodeComment * protConstComment = protConstructorBlock->getComment();
508  if (!forceDoc && (isInterface || !pol->getAutoGenerateConstructors()))
509  protConstComment->setWriteOutText(false);
510  else
511  protConstComment->setWriteOutText(true);
512 
513  // private
514  privConstructorBlock = privMethodsBlock->getHierarchicalCodeBlock("constructionMethods", "Constructors", 1);
515  // special condiions for showing comment: only when autogenerateding empty constructors
516  // Although, we *should* check for other constructor methods too
517  CodeComment * privConstComment = privConstructorBlock->getComment();
518  if (!forceDoc && (isInterface || !pol->getAutoGenerateConstructors()))
519  privConstComment->setWriteOutText(false);
520  else
521  privConstComment->setWriteOutText(true);
522 
523  // get/create the accessor codeblock
524  // public
525  HierarchicalCodeBlock * pubAccessorBlock = pubMethodsBlock->getHierarchicalCodeBlock("accessorMethods", "Accessor Methods", 1);
526  // set conditions for showing section comment
527  CodeComment * pubAccessComment = pubAccessorBlock->getComment();
528  if (!forceDoc && !hasClassFields())
529  pubAccessComment->setWriteOutText(false);
530  else
531  pubAccessComment->setWriteOutText(true);
532 
533  // protected
534  HierarchicalCodeBlock * protAccessorBlock = protMethodsBlock->getHierarchicalCodeBlock("accessorMethods", "Accessor Methods", 1);
535  // set conditions for showing section comment
536  CodeComment * protAccessComment = protAccessorBlock->getComment();
537  if (!forceDoc && !hasClassFields())
538  protAccessComment->setWriteOutText(false);
539  else
540  protAccessComment->setWriteOutText(true);
541 
542  // private
543  HierarchicalCodeBlock * privAccessorBlock = privMethodsBlock->getHierarchicalCodeBlock("accessorMethods", "Accessor Methods", 1);
544  // set conditions for showing section comment
545  CodeComment * privAccessComment = privAccessorBlock->getComment();
546  if (!forceDoc && !hasClassFields())
547  privAccessComment->setWriteOutText(false);
548  else
549  privAccessComment->setWriteOutText(true);
550 
551  // now, 2 sub-sub sections in accessor block
552  // add/update accessor methods for attributes
553  HierarchicalCodeBlock * pubStaticAccessors = pubAccessorBlock->getHierarchicalCodeBlock("pubStaticAccessorMethods", "", 1);
554  HierarchicalCodeBlock * pubRegularAccessors = pubAccessorBlock->getHierarchicalCodeBlock("pubRegularAccessorMethods", "", 1);
555  pubStaticAccessors->getComment()->setWriteOutText(false); // never write block comment
556  pubRegularAccessors->getComment()->setWriteOutText(false); // never write block comment
557 
558  HierarchicalCodeBlock * protStaticAccessors = protAccessorBlock->getHierarchicalCodeBlock("protStaticAccessorMethods", "", 1);
559  HierarchicalCodeBlock * protRegularAccessors = protAccessorBlock->getHierarchicalCodeBlock("protRegularAccessorMethods", "", 1);
560  protStaticAccessors->getComment()->setWriteOutText(false); // never write block comment
561  protRegularAccessors->getComment()->setWriteOutText(false); // never write block comment
562 
563  HierarchicalCodeBlock * privStaticAccessors = privAccessorBlock->getHierarchicalCodeBlock("privStaticAccessorMethods", "", 1);
564  HierarchicalCodeBlock * privRegularAccessors = privAccessorBlock->getHierarchicalCodeBlock("privRegularAccessorMethods", "", 1);
565  privStaticAccessors->getComment()->setWriteOutText(false); // never write block comment
566  privRegularAccessors->getComment()->setWriteOutText(false); // never write block comment
567  // now add in accessors as appropriate
568 
569  // public stuff
570  pubStaticAccessors->addCodeClassFieldMethods(staticPublicAttribClassFields);
571  pubRegularAccessors->addCodeClassFieldMethods(publicAttribClassFields);
572  pubRegularAccessors->addCodeClassFieldMethods(publicPlainAssocClassFields);
573  pubRegularAccessors->addCodeClassFieldMethods(publicAggregationClassFields);
574  pubRegularAccessors->addCodeClassFieldMethods(publicCompositionClassFields);
575 
576  // protected stuff
577  protStaticAccessors->addCodeClassFieldMethods(staticProtectedAttribClassFields);
578  protRegularAccessors->addCodeClassFieldMethods(protectedAttribClassFields);
579  protRegularAccessors->addCodeClassFieldMethods(protPlainAssocClassFields);
580  protRegularAccessors->addCodeClassFieldMethods(protAggregationClassFields);
581  protRegularAccessors->addCodeClassFieldMethods(protCompositionClassFields);
582 
583  // private stuff
584  privStaticAccessors->addCodeClassFieldMethods(staticPrivateAttribClassFields);
585  privRegularAccessors->addCodeClassFieldMethods(privateAttribClassFields);
586  privRegularAccessors->addCodeClassFieldMethods(privPlainAssocClassFields);
587  privRegularAccessors->addCodeClassFieldMethods(privAggregationClassFields);
588  privRegularAccessors->addCodeClassFieldMethods(privCompositionClassFields);
589 
590  // METHODS subsection : Operation methods (which aren't constructors)
591  //
592 
593  // setup/get/create the operations codeblock
594 
595  // public
596  pubOperationsBlock = pubMethodsBlock->getHierarchicalCodeBlock("operationMethods", "Operations", 1);
597  // set conditions for showing section comment
598  CodeComment * pubOcomment = pubOperationsBlock->getComment();
599  if (!forceDoc && !hasOperationMethods)
600  pubOcomment->setWriteOutText(false);
601  else
602  pubOcomment->setWriteOutText(true);
603 
604  //protected
605  protOperationsBlock = protMethodsBlock->getHierarchicalCodeBlock("operationMethods", "Operations", 1);
606  // set conditions for showing section comment
607  CodeComment * protOcomment = protOperationsBlock->getComment();
608  if (!forceDoc && !hasOperationMethods)
609  protOcomment->setWriteOutText(false);
610  else
611  protOcomment->setWriteOutText(true);
612 
613  //private
614  privOperationsBlock = privMethodsBlock->getHierarchicalCodeBlock("operationMethods", "Operations", 1);
615  // set conditions for showing section comment
616  CodeComment * privOcomment = privOperationsBlock->getComment();
617  if (!forceDoc && !hasOperationMethods)
618  privOcomment->setWriteOutText(false);
619  else
620  privOcomment->setWriteOutText(true);
621 }
622 
623 
624 #include "rubyclassifiercodedocument.moc"
RubyClassifierCodeDocument::getRubyClassName
QString getRubyClassName(const QString &name)
Definition: rubyclassifiercodedocument.cpp:87
CodeBlock::loadFromXMI
virtual void loadFromXMI(QDomElement &root)
Load params from the appropriate XMI element node.
Definition: codeblock.cpp:91
ClassifierCodeDocument::getSpecificClassFields
CodeClassFieldList getSpecificClassFields(CodeClassField::ClassFieldType cfType)
Get a list of codeclassifier objects held by this classifiercodedocument that meet the passed criteri...
Definition: classifiercodedocument.cpp:54
CodeClassField
class CodeClassField a special type of parameter.
Definition: codeclassfield.h:29
CodeDocument::newCodeBlockWithComments
virtual CodeBlockWithComments * newCodeBlockWithComments()
Create a new CodeBlockWithComments object belonging to this CodeDocument.
Definition: codedocument.cpp:465
CodeDocument::newCodeBlock
virtual CodeBlock * newCodeBlock()
Create a new CodeBlock object belonging to this CodeDocument.
Definition: codedocument.cpp:456
ClassifierCodeDocument::findCodeClassFieldTextBlockByTag
TextBlock * findCodeClassFieldTextBlockByTag(const QString &tag)
Find a specific textblock held by any code class field in this document by its tag.
Definition: classifiercodedocument.cpp:766
UMLClassifier
This class defines the non-graphical information required for a UML Classifier (ie a class or interfa...
Definition: classifier.h:39
CodeBlock
A "chunk" of code within the code document.
Definition: codeblock.h:20
CodeBlockWithComments::getComment
CodeComment * getComment() const
Get the Comment object.
Definition: codeblockwithcomments.cpp:46
UniqueID::gen
Uml::ID::Type gen()
MAIN FUNCTION: Return a new unique ID.
Definition: uniqueid.cpp:26
CodeClassField::Attribute
Definition: codeclassfield.h:34
ClassifierCodeDocument
class ClassifierCodeDocument A CodeDocument which represents a UMLClassifier (e.g.
Definition: classifiercodedocument.h:33
Uml::Visibility::Enum
Enum
Definition: basictypes.h:56
CodeComment::loadFromXMI
virtual void loadFromXMI(QDomElement &root)
Load params from the appropriate XMI element node.
Definition: codecomment.cpp:42
UMLObject::visibility
Uml::Visibility::Enum visibility() const
Returns the visibility of the object.
Definition: umlobject.cpp:435
RubyCodeGenerator::getAutoGenerateAssocAccessors
bool getAutoGenerateAssocAccessors()
A utility method to get the rubyCodeGenerationPolicy()->getAutoGenerateAssocAccessors() value...
Definition: rubycodegenerator.cpp:90
TextBlock::getTag
QString getTag() const
Get the tag of this text block.
Definition: textblock.cpp:110
CodeGenerationPolicy::getNewLineEndingChars
QString getNewLineEndingChars() const
Utility function to get the actual characters.
Definition: codegenerationpolicy.cpp:248
ClassifierCodeDocument::getCodeClassFieldList
CodeClassFieldList * getCodeClassFieldList()
Get the list of CodeClassField objects held by m_classfieldVector.
Definition: classifiercodedocument.cpp:262
rubycodecomment.h
RubyClassifierCodeDocument::addCodeOperation
bool addCodeOperation(CodeOperation *op)
Add a code operation to this ruby classifier code document.
Definition: rubyclassifiercodedocument.cpp:124
UMLApp::app
static UMLApp * app()
Get the last created instance of this class.
Definition: uml.cpp:206
RubyClassDeclarationBlock
Definition: rubyclassdeclarationblock.h:21
CodeGenerationPolicy
class CodeGenerationPolicy This class describes the code generation policy for this project...
Definition: codegenerationpolicy.h:29
CodeClassField::Composition
Definition: codeclassfield.h:34
CodeDocument::newHierarchicalCodeBlock
virtual HierarchicalCodeBlock * newHierarchicalCodeBlock()
Create a new HierarchicalCodeBlock object belonging to this CodeDocument.
Definition: codedocument.cpp:474
RubyClassifierCodeDocument::updateContent
void updateContent()
Update the content of this code document.
Definition: rubyclassifiercodedocument.cpp:335
RubyClassifierCodeDocument::resetTextBlocks
void resetTextBlocks()
Reset/clear our inventory of textblocks in this document.
Definition: rubyclassifiercodedocument.cpp:317
uWarning
#define uWarning()
Definition: debug_utils.h:97
ClassifierCodeDocument::getParentClassifier
UMLClassifier * getParentClassifier()
Get the value of m_parentclassifier.
Definition: classifiercodedocument.cpp:271
classifier.h
UMLApp::document
UMLDoc * document() const
Returns a pointer to the current document connected to the KMainWindow instance.
Definition: uml.cpp:872
RubyClassifierCodeDocument::getPath
QString getPath()
Overwritten by Ruby language implementation to get lowercase path.
Definition: rubyclassifiercodedocument.cpp:69
CodeGenObjectWithTextBlocks::addTextBlock
virtual bool addTextBlock(TextBlock *add_object)
Add a TextBlock object to the m_textblockVector List.
Definition: codegenobjectwithtextblocks.cpp:57
RubyClassDeclarationBlock::loadFromXMI
virtual void loadFromXMI(QDomElement &root)
load params from the appropriate XMI element node.
Definition: rubyclassdeclarationblock.cpp:44
debug_utils.h
RubyClassDeclarationBlock::updateContent
void updateContent()
Update the start/end text of this codeblock.
Definition: rubyclassdeclarationblock.cpp:52
RubyCodeOperation
Definition: rubycodeoperation.h:22
rubycodeclassfielddeclarationblock.h
rubyclassdeclarationblock.h
HierarchicalCodeBlock::addCodeClassFieldMethods
void addCodeClassFieldMethods(CodeClassFieldList &list)
Utility method to add accessormethods in this object.
Definition: hierarchicalcodeblock.cpp:215
RubyCodeGenerator::getAutoGenerateAttribAccessors
bool getAutoGenerateAttribAccessors()
A utility method to get the rubyCodeGenerationPolicy()->getAutoGenerateAttribAccessors() value...
Definition: rubycodegenerator.cpp:81
Uml::Visibility::Private
Definition: basictypes.h:58
UMLObject
This class is the non-graphical version of UMLWidget.
Definition: umlobject.h:41
UMLApp::policyExt
CodeGenPolicyExt * policyExt() const
Returns the CodeGenPolicyExt object.
Definition: uml.cpp:2148
RubyClassifierCodeDocument::getRubyPolicy
RubyCodeGenerationPolicy * getRubyPolicy()
Make it easier on ourselves.
Definition: rubyclassifiercodedocument.cpp:49
CodeGenerationPolicy::getCodeVerboseDocumentComments
bool getCodeVerboseDocumentComments() const
Get the value of m_codeVerboseDocumentComments Whether or not verbose code commenting for documentati...
Definition: codegenerationpolicy.cpp:147
CodeBlockWithComments
class CodeBlockWithComments A very common type of text block in any type of code. ...
Definition: codeblockwithcomments.h:24
Codegen_Utils::capitalizeFirstLetter
QString capitalizeFirstLetter(const QString &string)
Return the input string with the first letter capitalized.
Definition: codegen_utils.cpp:421
CodeClassField::PlainAssociation
Definition: codeclassfield.h:34
HierarchicalCodeBlock::loadFromXMI
virtual void loadFromXMI(QDomElement &root)
load params from the appropriate XMI element node.
Definition: hierarchicalcodeblock.cpp:269
CodeOperation
Definition: codeoperation.h:23
CodeOperation::loadFromXMI
virtual void loadFromXMI(QDomElement &root)
Load params from the appropriate XMI element node.
Definition: codeoperation.cpp:83
CodeClassField::parentIsAttribute
bool parentIsAttribute() const
Get the value of m_isAbstract.
Definition: codeclassfield.cpp:126
CodeDocument::resetTextBlocks
void resetTextBlocks()
Reset/clear our inventory of textblocks in this document.
Definition: codedocument.cpp:337
ClassifierCodeDocument::parentIsInterface
bool parentIsInterface()
Return if the parent classifier is an interface.
Definition: classifiercodedocument.cpp:413
TextBlock::setWriteOutText
void setWriteOutText(bool write)
Set the value of m_writeOutText Whether or not to include the text of this TextBlock into a file...
Definition: textblock.cpp:131
CodeDocument
A document containing the code for one file.
Definition: codedocument.h:32
CodeClassField::Aggregation
Definition: codeclassfield.h:34
CodeClassField::setWriteOutMethods
void setWriteOutMethods(bool val)
Determine if we will allow methods to be viewable.
Definition: codeclassfield.cpp:210
RubyCodeGenerator
Definition: rubycodegenerator.h:27
HierarchicalCodeBlock::addTextBlock
bool addTextBlock(TextBlock *add_object)
Add a TextBlock object to the m_textblockVector List.
Definition: hierarchicalcodeblock.cpp:93
RubyClassifierCodeDocument::~RubyClassifierCodeDocument
virtual ~RubyClassifierCodeDocument()
Empty Destructor.
Definition: rubyclassifiercodedocument.cpp:42
RubyCodeGenerationPolicy
Definition: rubycodegenerationpolicy.h:24
uDebug
#define uDebug()
Definition: debug_utils.h:95
rubycodeoperation.h
HierarchicalCodeBlock::setStartText
void setStartText(const QString &text)
Definition: hierarchicalcodeblock.cpp:199
RubyClassifierCodeDocument::forceDoc
bool forceDoc()
UMLApp::commonPolicy
CodeGenerationPolicy * commonPolicy() const
Returns the default code generation policy.
Definition: uml.cpp:2132
CodeGenerationPolicy::getAutoGenerateConstructors
bool getAutoGenerateConstructors()
Get the value of m_autoGenerateConstructors.
Definition: codegenerationpolicy.cpp:365
Uml::Visibility::Public
Definition: basictypes.h:57
CodeGenObjectWithTextBlocks::getHierarchicalCodeBlock
virtual HierarchicalCodeBlock * getHierarchicalCodeBlock(const QString &tag, const QString &comment, int indentLevel)
Will get a hierarchicalcodeblock from the document with given tag.
Definition: codegenobjectwithtextblocks.cpp:183
CodeOperation::getParentOperation
UMLOperation * getParentOperation()
Add a Parameter object to the m_parameterVector List.
Definition: codeoperation.cpp:64
UMLDoc::findObjectById
UMLObject * findObjectById(Uml::ID::Type id)
Used to find a reference to a UMLObject by its ID.
Definition: umldoc.cpp:766
HierarchicalCodeBlock
Definition: hierarchicalcodeblock.h:22
TextBlock
The fundemental unit of text within an output file containing code.
Definition: textblock.h:24
UMLOperation
This class represents an operation in the UML model.
Definition: operation.h:24
rubyclassifiercodedocument.h
RubyClassifierCodeDocument::RubyClassifierCodeDocument
RubyClassifierCodeDocument(UMLClassifier *classifier)
Constructor.
Definition: rubyclassifiercodedocument.cpp:33
CodeGenerator
This class collects together all of the code documents which form this project, and generates code fo...
Definition: codegenerator.h:68
RubyClassifierCodeDocument::loadChildTextBlocksFromNode
virtual void loadChildTextBlocksFromNode(QDomElement &root)
Need to overwrite this for ruby since we need to pick up the ruby class declaration block...
Definition: rubyclassifiercodedocument.cpp:166
uError
#define uError()
Definition: debug_utils.h:96
UMLClassifier::getOpList
UMLOperationList getOpList(bool includeInherited=false, UMLClassifierSet *alreadyTraversed=0)
Return a list of operations for the Classifier.
Definition: classifier.cpp:960
CodeGenerator::cleanName
static QString cleanName(const QString &name)
Replaces spaces with underscores and capitalises as defined in m_modname.
Definition: codegenerator.cpp:609
CodeGenPolicyExt
Base class for programming language specific code generation policy extensions.
Definition: codegenpolicyext.h:28
CodeClassFieldList
QList< CodeClassField * > CodeClassFieldList
Definition: codeclassfieldlist.h:17
UMLOperation::isConstructorOperation
bool isConstructorOperation()
Returns whether this operation is a constructor.
Definition: operation.cpp:352
Uml::ID::fromString
ID::Type fromString(const QString &id)
Definition: basictypes.cpp:1053
rubycodegenerator.h
UMLApp::generator
CodeGenerator * generator() const
Gets the appropriate CodeGenerator.
Definition: uml.cpp:2196
CodeComment
Text which will be comments.
Definition: codecomment.h:23
ClassifierCodeDocument::hasClassFields
bool hasClassFields()
Does this object have any classfields declared?
Definition: classifiercodedocument.cpp:147
CodeDocument::getFileName
QString getFileName() const
Get the value of m_filename.
Definition: codedocument.cpp:63
CodeDocument::setFileExtension
void setFileExtension(const QString &new_var)
Set the value of m_fileExtension.
Definition: codedocument.cpp:72
codegen_utils.h
CodeDocument::getPackage
QString getPackage() const
Get the value of the package of this code document.
Definition: codedocument.cpp:122
Uml::Visibility::Protected
Definition: basictypes.h:59
CodeBlockWithComments::loadFromXMI
virtual void loadFromXMI(QDomElement &root)
Load params from the appropriate XMI element node.
Definition: codeblockwithcomments.cpp:96
RubyCodeComment
class RubyCodeComment A Ruby code comment.
Definition: rubycodecomment.h:27
uml.h
QList
TextBlock::setTag
void setTag(const QString &value)
Set the tag of this text block.
Definition: textblock.cpp:121
ClassifierCodeDocument::synchronize
virtual void synchronize()
Cause this classifier code document to synchronize to current policy.
Definition: classifiercodedocument.cpp:475
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:06:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

umbrello/umbrello

Skip menu "umbrello/umbrello"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal