QString JavaCodeDocumentation::getNewEditorLine ( int amount )
{
    CodeGenerationPolicy *p = UMLApp::app()->getCommonPolicy();
    if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine)
        return getIndentationString(amount) + " * ";
    else
        return getIndentationString(amount) + "// ";
}
/**
 * @return      QString
 */
QString JavaCodeDocumentation::toString ( )
{

    QString output = "";

    // simple output method
    if(getWriteOutText())
    {
        bool useDoubleDashOutput = true;

        // need to figure out output type from java policy
        CodeGenerationPolicy *p = UMLApp::app()->getCommonPolicy();
        if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine)
            useDoubleDashOutput = false;

        QString indent = getIndentationString();
        QString endLine = getNewLineEndingChars();
        QString body = getText();
        if(useDoubleDashOutput)
        {
            if(!body.isEmpty())
                output.append(formatMultiLineText (body, indent +"// ", endLine));
        } else {
            output.append(indent+"/**"+endLine);
            output.append(formatMultiLineText (body, indent +" * ", endLine));
            output.append(indent+" */"+endLine);
        }
    }

    return output;
}
Example #3
0
QString DCodeDocumentation::toString() const
{
    QString output;

    // simple output method
    if(getWriteOutText())
    {
        bool useDoubleDashOutput = true;

        // need to figure out output type from d policy
        CodeGenerationPolicy * p = UMLApp::app()->commonPolicy();
        if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine)
            useDoubleDashOutput = false;

        QString indent = getIndentationString();
        QString endLine = getNewLineEndingChars();
        QString body = getText();

        if(useDoubleDashOutput)
        {
            if(!body.isEmpty()) {
                output += (formatMultiLineText (body, indent + QLatin1String("// "), endLine));
            }
        } else {
            output += indent + QLatin1String("/**") + endLine;
            output += formatMultiLineText (body, indent + QLatin1String(" * "), endLine);
            output += indent + QLatin1String(" */") + endLine;
        }
    }

    return output;
}
Example #4
0
void tab(QTextCursor &cursor, qompose::core::IndentationMode mode,
         std::size_t width)
{
	if(!cursor.hasSelection())
		cursor.insertText(getIndentationString(mode, width));
	else
		increaseSelectionIndent(cursor, mode, width);
}
Example #5
0
/**
 * Return the text in the right format. Returned string is empty
 * if m_writeOutText is false.
 * @return  QString
 */
QString TextBlock::toString() const
{
    // simple output method
    if (m_writeOutText && !m_text.isEmpty()) {
        QString endLine = UMLApp::app()->commonPolicy()->getNewLineEndingChars();
        return formatMultiLineText(m_text, getIndentationString(), endLine);
    }
    else {
        return QString();
    }
}
Example #6
0
// will remove indenation from this text block.
QString TextBlock::unformatText ( const QString & text, const QString & indent )
{
    QString output = text;
    QString myIndent = indent;
    if(myIndent.isEmpty())
        myIndent = getIndentationString();

    if(!output.isEmpty())
        output.remove(QRegExp('^'+myIndent));

    return output;
}
Example #7
0
/**
 * @return      QString
 */
QString CPPCodeComment::toString ( )
{

    QString output = "";

    // simple output method
    if(getWriteOutText())
    {
        QString indent = getIndentationString();
        QString endLine = getNewLineEndingChars();
        output.append(formatMultiLineText (getText()+endLine, indent +"// ", endLine));
    }

    return output;
}
Example #8
0
/**
 * UnFormat a long text string. Typically, this means removing
 * the indentaion (linePrefix) and/or newline chars from each line.
 * If an indentation is not specified, then the current indentation is used.
 * @param text     the original text for unformatting
 * @param indent   the indentation
 * @return         the unformatted text
 */
QString TextBlock::unformatText(const QString & text, const QString & indent)
{
    QString output = text;
    QString myIndent = indent;
    if (myIndent.isEmpty()) {
        myIndent = getIndentationString();
    }

    if (!output.isEmpty()) {
        // remove indenation from this text block.
        output.remove(QRegExp(QLatin1Char('^') + myIndent));
    }

    return output;
}
Example #9
0
void increaseSelectionIndent(QTextCursor &cursor,
                             qompose::core::IndentationMode mode,
                             std::size_t width)
{
	if(!cursor.hasSelection())
		return;
	CursorSelectionState state(cursor);

	// Do the indent.
	cursor.beginEditBlock();
	foreachBlock(cursor, state.startPosition,
	             static_cast<std::size_t>(state.blockCount),
	             [&mode, &width](QTextCursor &c) {
		             c.insertText(getIndentationString(mode, width));
		     });
	cursor.endEditBlock();

	setNormalizedSelection(cursor, state);
}
Example #10
0
QString DCodeComment::toString () const
{
    QString output;

    // simple output method
    if(getWriteOutText())
    {
        QString indent = getIndentationString();
        QString endLine = getNewLineEndingChars();
        QString body = getText();

        // check the need for multiline comments
        if (body.indexOf(QRegExp(endLine)) >= 0) {
            output += indent + QLatin1String("/**") + endLine;
            output += formatMultiLineText (body, indent + QLatin1String(" * "), endLine);
            output += indent + QLatin1String(" */") + endLine;
        } else {
            output += formatMultiLineText (body, indent + QLatin1String("// "), endLine);
        }
    }

    return output;
}
Example #11
0
QString CPPCodeComment::getNewEditorLine ( int amount ) {
    QString line = getIndentationString(amount) + "// ";
    return line;
}
Example #12
0
/**
 * Used by the CodeEditor. It provides it with an appropriate
 * starting string for a new line of text within the given textblock
 * (for example a string with the proper indentation).
 * If the indentation amount is '0' the current indentation string will
 * be used.
 * <p>
 * TODO: Can be refactored away and replaced with
 * <a href="#getIndentationString">getIndentationString</a>.
 * @param amount   the number of indent steps to use
 * @return         the new line
 */
QString TextBlock::getNewEditorLine(int amount)
{
    return getIndentationString(amount);
}
Example #13
0
// TODO: where is this used?
QString DCodeComment::getNewEditorLine (int amount)
{
    QString line = getIndentationString(amount) + QLatin1String("// ");
    return line;
}