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

kdevelop/kdevplatform/language/codegen

  • extragear
  • kdevelop
  • kdevelop
  • kdevplatform
  • language
  • codegen
documentchangeset.h
Go to the documentation of this file.
1 /*
2  Copyright 2008 David Nolden <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef KDEVPLATFORM_DOCUMENTCHANGESET_H
20 #define KDEVPLATFORM_DOCUMENTCHANGESET_H
21 
22 #include <language/languageexport.h>
23 
24 #include <serialization/indexedstring.h>
25 
26 #include <KTextEditor/Range>
27 
28 #include <QExplicitlySharedDataPointer>
29 #include <QUrl>
30 
31 namespace KDevelop {
32 class DocumentChangeSetPrivate;
33 
34 class KDEVPLATFORMLANGUAGE_EXPORT DocumentChange
35  : public QSharedData
36 {
37 public:
38 
39  DocumentChange(const IndexedString& document, const KTextEditor::Range& range, const QString& oldText,
40  const QString& newText) :
41  m_document(document)
42  , m_range(range)
43  , m_oldText(oldText)
44  , m_newText(newText)
45  , m_ignoreOldText(false)
46  {
47  //Clean the URL, so we don't get the same file be stored as a different one
48  QUrl url = m_document.toUrl();
49  m_document = IndexedString(url.adjusted(QUrl::NormalizePathSegments));
50  }
51 
52  IndexedString m_document;
53  KTextEditor::Range m_range;
54  QString m_oldText;
55  QString m_newText;
56  bool m_ignoreOldText; //Set this to disable the verification of m_oldText. This can be used to overwrite arbitrary text, but is dangerous!
57 };
58 
59 using DocumentChangePointer = QExplicitlySharedDataPointer<DocumentChange>;
60 
64 class KDEVPLATFORMLANGUAGE_EXPORT DocumentChangeSet
65 {
66 public:
67  DocumentChangeSet();
68  ~DocumentChangeSet();
69  DocumentChangeSet(const DocumentChangeSet& rhs);
70  DocumentChangeSet& operator=(const DocumentChangeSet& rhs);
71 
72  //Returns true on success
73  class ChangeResult
74  {
75 public:
76  explicit ChangeResult(const QString& failureReason,
77  const DocumentChangePointer& reasonChange = DocumentChangePointer())
78  : ChangeResult(failureReason, reasonChange, false) {}
79 
80  static ChangeResult successfulResult()
81  {
82  return ChangeResult({}, {}, true);
83  }
84 
85  operator bool() const
86  {
87  return m_success;
88  }
89 
91  QString m_failureReason;
93  DocumentChangePointer m_reasonChange;
94 
95  bool m_success;
96 
97 private:
98  explicit ChangeResult(const QString& failureReason, const DocumentChangePointer& reasonChange, bool success)
99  : m_failureReason(failureReason)
100  , m_reasonChange(reasonChange)
101  , m_success(success)
102  {}
103  };
104 
106  ChangeResult addChange(const DocumentChange& change);
107  ChangeResult addChange(const DocumentChangePointer& change);
108 
110  ChangeResult addDocumentRenameChange(const IndexedString& oldFile, const IndexedString& newname);
111 
112  enum ReplacementPolicy {
113  IgnoreFailedChange,
114  WarnOnFailedChange,
115  StopOnFailedChange
117  };
118 
120  void setReplacementPolicy(ReplacementPolicy policy);
121 
122  enum FormatPolicy {
123  NoAutoFormat,
124  AutoFormatChanges,
125  AutoFormatChangesKeepIndentation
126  };
127 
129  void setFormatPolicy(FormatPolicy policy);
130 
131  enum DUChainUpdateHandling {
132  NoUpdate,
133  SimpleUpdate
134  //FullUpdate ///All documents in all open projects that recursively import any of the changed documents will be updated
135  };
136 
138  void setUpdateHandling(DUChainUpdateHandling policy);
139 
140  enum ActivationPolicy {
141  Activate,
142  DoNotActivate
143  };
144 
146  void setActivationPolicy(ActivationPolicy policy);
147 
149  ChangeResult applyAllChanges();
150 
151 private:
152  const QScopedPointer<class DocumentChangeSetPrivate> d_ptr;
153  Q_DECLARE_PRIVATE(DocumentChangeSet)
154 };
155 }
156 
157 #endif
KDevelop::DocumentChange::DocumentChange
DocumentChange(const IndexedString &document, const KTextEditor::Range &range, const QString &oldText, const QString &newText)
Definition: documentchangeset.h:39
KDevelop::DocumentChangeSet::Activate
Definition: documentchangeset.h:141
KDevelop::DocumentChangeSet::WarnOnFailedChange
If this is given, all changes that could not be applied are simply ignored.
Definition: documentchangeset.h:114
KDevelop::DocumentChange::m_range
KTextEditor::Range m_range
Definition: documentchangeset.h:53
KDevelop::DocumentChangeSet::ChangeResult::m_failureReason
QString m_failureReason
Reason why the change failed.
Definition: documentchangeset.h:91
KDevelop::DocumentChangeSet::ChangeResult::m_success
bool m_success
Definition: documentchangeset.h:95
KDevelop::DocumentChangeSet::ReplacementPolicy
ReplacementPolicy
Definition: documentchangeset.h:112
KDevelop::DocumentChangeSet::ChangeResult::m_reasonChange
DocumentChangePointer m_reasonChange
Specific change that caused the problem (might be 0)
Definition: documentchangeset.h:93
KDevelop::DocumentChangeSet
Object representing an arbitrary set of changes to an arbitrary set of files that can be applied atom...
Definition: documentchangeset.h:64
KDevelop::DocumentChangeSet::IgnoreFailedChange
Definition: documentchangeset.h:113
KDevelop::DocumentChangeSet::ChangeResult::successfulResult
static ChangeResult successfulResult()
Definition: documentchangeset.h:80
KDevelop::DocumentChange::m_newText
QString m_newText
Definition: documentchangeset.h:55
QSharedData
KDevelop::DocumentChangeSet::ChangeResult
Definition: documentchangeset.h:73
KDevelop::DocumentChange
Definition: documentchangeset.h:34
QScopedPointer< class DocumentChangeSetPrivate >
QString
KDevelop::DocumentChangeSet::DUChainUpdateHandling
DUChainUpdateHandling
Definition: documentchangeset.h:131
KDevelop::DocumentChangeSet::NoAutoFormat
Definition: documentchangeset.h:123
KDevelop::DocumentChange::m_ignoreOldText
bool m_ignoreOldText
Definition: documentchangeset.h:56
QUrl
KDevelop::DocumentChange::m_document
IndexedString m_document
Definition: documentchangeset.h:52
KDevelop::DocumentChangeSet::ActivationPolicy
ActivationPolicy
Definition: documentchangeset.h:140
KDevelop::DocumentChangePointer
QExplicitlySharedDataPointer< DocumentChange > DocumentChangePointer
Definition: documentchangeset.h:59
KDevelop::DocumentChangeSet::AutoFormatChanges
If this option is given, no automatic formatting is applied.
Definition: documentchangeset.h:124
KDevelop::DocumentChangeSet::FormatPolicy
FormatPolicy
Definition: documentchangeset.h:122
KDevelop::DocumentChangeSet::ChangeResult::ChangeResult
ChangeResult(const QString &failureReason, const DocumentChangePointer &reasonChange=DocumentChangePointer())
Definition: documentchangeset.h:76
KDevelop::DocumentChangeSet::NoUpdate
Definition: documentchangeset.h:132
QExplicitlySharedDataPointer< DocumentChange >
KDevelop::DocumentChange::m_oldText
QString m_oldText
Definition: documentchangeset.h:54
This file is part of the KDE documentation.
Documentation copyright © 1996-2019 The KDE developers.
Generated on Fri Dec 13 2019 03:34:46 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kdevelop/kdevplatform/language/codegen

Skip menu "kdevelop/kdevplatform/language/codegen"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdevelop API Reference

Skip menu "kdevelop API Reference"
  •   kdevplatform
  •     debugger
  •     documentation
  •     interfaces
  •     language
  •       assistant
  •       backgroundparser
  •       checks
  •       classmodel
  •       codecompletion
  •       codegen
  •       duchain
  •       editor
  •       highlighting
  •       interfaces
  •       util
  •     outputview
  •     project
  •     serialization
  •     shell
  •     sublime
  •     tests
  •     util
  •     vcs

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