qtcreator-plugin-go-3.5.0+15.10.20150812.1/0000755000015300001610000000000012562573550020123 5ustar pbuserpbgroup00000000000000qtcreator-plugin-go-3.5.0+15.10.20150812.1/share/0000755000015300001610000000000012562573550021225 5ustar pbuserpbgroup00000000000000qtcreator-plugin-go-3.5.0+15.10.20150812.1/share/qtcreator/0000755000015300001610000000000012562573550023231 5ustar pbuserpbgroup00000000000000qtcreator-plugin-go-3.5.0+15.10.20150812.1/share/qtcreator/templates/0000755000015300001610000000000012562573550025227 5ustar pbuserpbgroup00000000000000qtcreator-plugin-go-3.5.0+15.10.20150812.1/share/qtcreator/templates/wizards/0000755000015300001610000000000012562573550026712 5ustar pbuserpbgroup00000000000000qtcreator-plugin-go-3.5.0+15.10.20150812.1/share/qtcreator/templates/wizards/plaingo/0000755000015300001610000000000012562573550030343 5ustar pbuserpbgroup00000000000000qtcreator-plugin-go-3.5.0+15.10.20150812.1/share/qtcreator/templates/wizards/plaingo/gopher.png0000644000015300001610000000363212562573357032346 0ustar pbuserpbgroup00000000000000PNG  IHDR ,bKGD pHYs B(xtIMEVaq'IDATX͘kpW+d[#~(vIbq4n@̔:aS  (0$M - IiS7;ISQX؎l)ŖXI|06j {~眻Wϔvb~uOըrJD4RDS T(<m~g{ ]h4t,R'lmJXA ^uT?;rpHghFeU}z3 Y^wRi{< 1~B,ǃ)@,hx4F Cn `{t㏬z W.wrX[d am{/-!JNcرy#hqhj697|(Q1eӷa&m~4l+"Rp~-ZS\riC׎?;F<24 IUe؟Ăm`$%4*SP$Aq(4 dh2s_I-&;wD{{ 2(8R)J}n@n^2}(Ot)<Ȅ;v HIIAIIɒ99hZh4˓dOK':^7L皟e=-/<ܓxQHII Lxpvp*)qqH$  hX ZyIٷO+VgF6z'ԴtE<#`W&)ń|qryOßF@g;Yy|I,I5Wc0q4I:50; NL2h"bRxQp HQd(eBy90.m(.F5zG%CMe.Όc?q%GB(^u갫 GAz R>y!#Q q=h/6?b԰8M0Gł.H^ySK_B!&n?493p&\ Vh4 o>~%H*"W 6< Zf#B4|p$!xĒ^C@~~}FTbs_HUBBO ԗK˾woy`7X \s`T)8c51]{7|O-kA>xV~o|2yR#7}qGoש2HS#H3a3ohq]ZUb&Y#cĊ+] y< JW1́aVǞSW~#ijN[H(3,.& ;Sn }F7䥩O}\L*Z/הSGj~#U1yEr;w&LsWuCNj|må3W{ud9IENDB`qtcreator-plugin-go-3.5.0+15.10.20150812.1/share/qtcreator/templates/wizards/plaingo/wizard.xml0000644000015300001610000000154712562573357032401 0ustar pbuserpbgroup00000000000000 gopher.png Creates a plain Go project using the Qt library. QML Go Project Applications qtcreator-plugin-go-3.5.0+15.10.20150812.1/share/qtcreator/templates/wizards/plaingo/particle.png0000644000015300001610000000153512562573357032665 0ustar pbuserpbgroup00000000000000PNG  IHDR szztEXtSoftwareAdobe ImageReadyqe<IDATxڔWM0 Mta~pX6&閑d~v'HChcW&:/1F935jh3`^\Ť8 =WibϳY?QmXl޶IAGG- F{6\H"BĢ8H1}!G\ `"о]T&0#x<eJp*:3gr͙͋ F`ydt2(F{ޛ"0xT~b,9Q(3V+@FxIS/:j;採zhDS][c*&# st30UWym$Ue/TP·ѹNU[3vm`{9'FpC^q W7~\;T1}6k4'@}&/e'M~XU3`r mis`: f`hcPE% SO?V3>Lf\S1ThgzG*oꀚB:ڗaSd3<!3tp; &׭JXhDa ؎L4N#y/dbVg' G:{-PxG'8Sy /p2ţ-j^LȊϺMikI>|L{A .&}mN (FfC&x#nK8XoGhG)@շ`ɄIENDB`qtcreator-plugin-go-3.5.0+15.10.20150812.1/share/qtcreator/templates/wizards/plaingo/main.go0000644000015300001610000000303312562573357031622 0ustar pbuserpbgroup00000000000000package main import ( "gopkg.in/qml.v0" "math/rand" "time" ) func main() { qml.Init(nil) engine := qml.NewEngine() component, err := engine.LoadFile("share/%ProjectName%/main.qml") if err != nil { panic(err) } ctrl := Control{Message: "Hello from Go!"} context := engine.Context() context.SetVar("ctrl", &ctrl) window := component.CreateWindow(nil) ctrl.Root = window.Root() rand.Seed(time.Now().Unix()) window.Show() window.Wait() } type Control struct { Root qml.Object Message string } func (ctrl *Control) TextReleased(text qml.Object) { x := text.Int("x") y := text.Int("y") width := text.Int("width") height := text.Int("height") ctrl.Emit(x+15, y+height/2) ctrl.Emit(x+width/2, 1.0*y+height/2) ctrl.Emit(x+width-15, 1.0*y+height/2) go func() { time.Sleep(500 * time.Millisecond) messages := []string{"Hello", "Hello", "Hacks"} ctrl.Message = messages[rand.Intn(len(messages))] + " from Go!" qml.Changed(ctrl, &ctrl.Message) }() } func (ctrl *Control) Emit(x, y int) { component := ctrl.Root.Object("emitterComponent") for i := 0; i < 8; i++ { emitter := component.Create(nil) emitter.Set("x", x) emitter.Set("y", y) emitter.Set("targetX", rand.Intn(240)-120+x) emitter.Set("targetY", rand.Intn(240)-120+y) emitter.Set("life", rand.Intn(2400)+200) emitter.Set("emitRate", rand.Intn(32)+32) emitter.ObjectByName("xAnim").Call("start") emitter.ObjectByName("yAnim").Call("start") emitter.Set("enabled", true) } } func (ctrl *Control) Done(emitter qml.Object) { emitter.Destroy() } qtcreator-plugin-go-3.5.0+15.10.20150812.1/share/qtcreator/templates/wizards/plaingo/main.qml0000644000015300001610000000303212562573357032005 0ustar pbuserpbgroup00000000000000import QtQuick 2.0 import QtQuick.Particles 2.0 import QtGraphicalEffects 1.0; Rectangle { id: root width: 640 height: 480 gradient: Gradient { GradientStop { position: 0.0; color: "#3a2c32"; } GradientStop { position: 0.8; color: "#875864"; } GradientStop { position: 1.0; color: "#9b616c"; } } Text { text: ctrl.message Component.onCompleted: { x = parent.width/2 - width/2 y = parent.height/2 - height/2 } color: "white" font.bold: true font.pointSize: 20 MouseArea { id: mouseArea anchors.fill: parent drag.target: parent onReleased: ctrl.textReleased(parent) } } ParticleSystem { id: sys } ImageParticle { system: sys source: "png/particle.png" color: "white" colorVariation: 1.0 alpha: 0.1 } property var emitterComponent: Component { id: emitterComponent Emitter { id: container system: sys Emitter { system: sys emitRate: 128 lifeSpan: 600 size: 16 endSize: 8 velocity: AngleDirection { angleVariation:360; magnitude: 60 } } property int life: 2600 property real targetX: 0 property real targetY: 0 emitRate: 128 lifeSpan: 600 size: 24 endSize: 8 NumberAnimation on x { objectName: "xAnim" id: xAnim; to: targetX duration: life running: false } NumberAnimation on y { objectName: "yAnim" id: yAnim; to: targetY duration: life running: false } Timer { interval: life running: true onTriggered: ctrl.done(container) } } } } ././@LongLink0000000000000000000000000000014700000000000011217 Lustar 00000000000000qtcreator-plugin-go-3.5.0+15.10.20150812.1/share/qtcreator/templates/wizards/plaingo/project.goprojectqtcreator-plugin-go-3.5.0+15.10.20150812.1/share/qtcreator/templates/wizards/plaingo/project.goproje0000644000015300001610000000103112562573357033400 0ustar pbuserpbgroup00000000000000/* File generated by Qt Creator (with Ubuntu Plugin), version 3.0.1 */ import GoProject 1.1 GoProject { Application { name: "%ProjectName%" GoFiles { } /* Include .qml, .js, and image files from main directory and subdirectories */ QmlFiles { directory:"share/%ProjectName%" } JavaScriptFiles { directory:"share/%ProjectName%" } } Package { name: "gopkg.in/qml.v0" Files { filter: "*.*" } } } qtcreator-plugin-go-3.5.0+15.10.20150812.1/LICENSE.LGPL0000644000015300001610000006350212562573357021700 0ustar pbuserpbgroup00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! qtcreator-plugin-go-3.5.0+15.10.20150812.1/qtcreator-plugin-go.pro0000644000015300001610000000005012562573357024550 0ustar pbuserpbgroup00000000000000TEMPLATE = subdirs SUBDIRS = src/golang qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/0000755000015300001610000000000012562573550020712 5ustar pbuserpbgroup00000000000000qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/plugin.pri0000644000015300001610000000174112562573362022730 0ustar pbuserpbgroup00000000000000PROVIDER = Canonical ## Where the Qt Creator headers are located at QTCREATOR_SOURCES = $$(QTC_SOURCE) isEmpty(QTCREATOR_SOURCES):QTCREATOR_SOURCES=/usr/src/qtcreator ## Where our plugin will be compiled to IDE_BUILD_TREE = $$(QTC_BUILD) isEmpty(IDE_BUILD_TREE):IDE_BUILD_TREE=../../builddir UBUNTU_LOCAL_BUILD = $$(UBUNTU_QTC_PLUGIN_LOCALBUILD) !isEmpty(UBUNTU_LOCAL_BUILD) { message("!!!!!!!!!!BUILDING LOCAL VERSION OF PLUGIN !!!!!!!!!!!!!!!!!!!") USE_USER_DESTDIR = yes PATHSTR = '\\"$${PWD}/../share/qtcreator\\"' DEFINES += UBUNTU_RESOURCE_PATH_LOCAL=\"$${PATHSTR}\" UBUNTU_BUILD_LOCAL } include($$QTCREATOR_SOURCES/src/qtcreatorplugin.pri) INCLUDEPATH += $$QTCREATOR_SOURCES/src/ ## make sure the QtProject libs are available when building locally !isEmpty(UBUNTU_LOCAL_BUILD) { LIBS += -L$$DESTDIRBASE/QtProject/$$DESTDIRAPPNAME/plugins/$$QTCREATOR_VERSION/QtProject } LIBS += -L$$[QT_INSTALL_LIBS]/qtcreator LIBS += -L$$[QT_INSTALL_LIBS]/qtcreator/plugins qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/0000755000015300001610000000000012562573550022161 5ustar pbuserpbgroup00000000000000qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/goprojectmanager.h0000644000015300001610000000443212562573362025665 0ustar pbuserpbgroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Author: Juhapekka Piiroinen */ #ifndef GOPROJECTMANAGER_H #define GOPROJECTMANAGER_H #include #include "golangconstants.h" #include "goproject.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace GoLang { class GoProject; namespace Internal { class Manager : public ProjectExplorer::IProjectManager { Q_OBJECT public: Manager(); virtual QString mimeType() const override; ProjectExplorer::Project* openProject(const QString &filePath, QString *errorString) override; void registerProject(GoProject *project); void unregisterProject(GoProject *project); Q_INVOKABLE void *createKitMatcher () const; protected slots: void onProjectAdded(ProjectExplorer::Project*); private: QList m_projects; }; } // Internal } // GoLang #endif // GOPROJECTMANAGER_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/goprojectnode.cpp0000644000015300001610000001430412562573362025532 0ustar pbuserpbgroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Author: Juhapekka Piiroinen */ #include "goprojectnode.h" #include "goprojectitem.h" #include "filefilteritems.h" using namespace GoLang::Internal; GoProjectNode::GoProjectNode(GoProject *project, Core::IDocument *projectFile) : ProjectExplorer::ProjectNode(projectFile->filePath()), m_project(project), m_projectFile(projectFile) { setDisplayName(projectFile->filePath().toFileInfo().completeBaseName()); refresh(); } Core::IDocument *GoProjectNode::projectFile() const { return m_projectFile; } QString GoProjectNode::projectFilePath() const { return m_projectFile->filePath().toString(); } void GoProjectNode::refresh() { using namespace ProjectExplorer; this->removeFileNodes(fileNodes()); this->removeFolderNodes(subFolderNodes()); QPointer proItem = m_project->m_projectItem; if(proItem) { FileNode *projectFilesNode = new FileNode(Utils::FileName::fromString(m_project->filesFileName()), ProjectFileType, /* generated = */ false); this->addFileNodes(QList() << projectFilesNode); foreach(GoBaseTargetItem* item, proItem->commands()) { QStringList files = item->files(); files.removeAll(m_project->filesFileName()); QHash filesInDirectory; foreach (const QString &fileName, files) { QFileInfo fileInfo(fileName); QString absoluteFilePath; QString relativeDirectory; if (fileInfo.isAbsolute()) { absoluteFilePath = fileInfo.filePath(); relativeDirectory = m_project->projectDir().relativeFilePath(fileInfo.path()); } else { absoluteFilePath = m_project->projectDir().absoluteFilePath(fileInfo.filePath()); relativeDirectory = fileInfo.path(); if (relativeDirectory == QLatin1String(".")) relativeDirectory.clear(); } filesInDirectory[relativeDirectory].append(absoluteFilePath); } VirtualFolderNode* vFolder = new VirtualFolderNode(Utils::FileName::fromString(item->name()),1); this->addFolderNodes(QList() << vFolder); const QHash::ConstIterator cend = filesInDirectory.constEnd(); for (QHash::ConstIterator it = filesInDirectory.constBegin(); it != cend; ++it) { FolderNode *folder = findOrCreateFolderByName(it.key(),vFolder); QList fileNodes; foreach (const QString &file, it.value()) { FileType fileType = SourceType; // ### FIXME FileNode *fileNode = new FileNode(Utils::FileName::fromString(file), fileType, false); fileNodes.append(fileNode); } folder->addFileNodes(fileNodes); } m_folderByName.clear(); } } //QStringList files = m_project->files(Project::AllFiles); //files.removeAll(m_project->filesFileName()); m_folderByName.clear(); } ProjectExplorer::FolderNode *GoProjectNode::findOrCreateFolderByName(const QStringList &components, int end, ProjectExplorer::VirtualFolderNode *virtualRoot) { if (! end) return 0; QString baseDir = path().toFileInfo().path(); QString folderName; for (int i = 0; i < end; ++i) { folderName.append(components.at(i)); folderName += QLatin1Char('/'); } const QString component = components.at(end - 1); if (component.isEmpty()) return virtualRoot; else if (FolderNode *folder = m_folderByName.value(folderName)) return folder; FolderNode *folder = new FolderNode(Utils::FileName::fromString(baseDir + QLatin1Char('/') + folderName)); folder->setDisplayName(component); m_folderByName.insert(folderName, folder); FolderNode *parent = findOrCreateFolderByName(components, end - 1, virtualRoot); if (! parent) parent = virtualRoot; parent->addFolderNodes(QList() << folder); return folder; } ProjectExplorer::FolderNode *GoProjectNode::findOrCreateFolderByName(const QString &filePath, ProjectExplorer::VirtualFolderNode *parent) { QStringList components = filePath.split(QLatin1Char('/')); return findOrCreateFolderByName(components, components.length(),parent); } QList GoProjectNode::supportedActions(Node *node) const { Q_UNUSED(node); QList actions; actions.append(ProjectExplorer::AddNewFile); actions.append(ProjectExplorer::EraseFile); actions.append(ProjectExplorer::Rename); return actions; } bool GoProjectNode::canAddSubProject(const QString &proFilePath) const { Q_UNUSED(proFilePath) return false; } bool GoProjectNode::addSubProjects(const QStringList &proFilePaths) { Q_UNUSED(proFilePaths) return false; } bool GoProjectNode::removeSubProjects(const QStringList &proFilePaths) { Q_UNUSED(proFilePaths) return false; } bool GoProjectNode::addFiles(const QStringList &, QStringList *) { return false; } bool GoProjectNode::removeFiles(const QStringList &, QStringList *) { return false; } bool GoProjectNode::deleteFiles(const QStringList &) { return true; } bool GoProjectNode::renameFile(const QString &, const QString &) { return true; } qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/gokitinformation.h0000644000015300001610000000537412562573362025727 0ustar pbuserpbgroup00000000000000#ifndef GOLANG_GOKITINFORMATION_H #define GOLANG_GOKITINFORMATION_H #include #include #include #include namespace GoLang { class ToolChain; class GoKitMatcher : public ProjectExplorer::KitMatcher { public: GoKitMatcher(); static bool matches(); }; class GoToolChainKitInformation : public ProjectExplorer::KitInformation { Q_OBJECT public: GoToolChainKitInformation(); // KitInformation interface virtual QVariant defaultValue(ProjectExplorer::Kit *) const override; virtual QList validate(const ProjectExplorer::Kit *kit) const override; virtual void fix(ProjectExplorer::Kit *) override; virtual void setup(ProjectExplorer::Kit *) override; virtual ItemList toUserOutput(const ProjectExplorer::Kit *) const override; virtual ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *) const override; virtual void addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const override; virtual ProjectExplorer::IOutputParser *createOutputParser(const ProjectExplorer::Kit *k) const override; virtual QString displayNamePostfix(const ProjectExplorer::Kit *k) const override; static Core::Id id(); static ToolChain *toolChain(const ProjectExplorer::Kit *k); static void setToolChain(ProjectExplorer::Kit *k, ToolChain *tc); static ProjectExplorer::KitMatcher kitMatcher (); protected slots: void kitsWereLoaded(); void toolChainUpdated(GoLang::ToolChain *tc); void toolChainRemoved(GoLang::ToolChain *tc); }; namespace Internal { // -------------------------------------------------------------------------- // ToolChainInformationConfigWidget: // -------------------------------------------------------------------------- class ToolChainInformationConfigWidget : public ProjectExplorer::KitConfigWidget { Q_OBJECT public: ToolChainInformationConfigWidget(ProjectExplorer::Kit *k, const ProjectExplorer::KitInformation *ki); ~ToolChainInformationConfigWidget(); QString displayName() const override; void refresh() override; void makeReadOnly() override; QWidget *mainWidget() const override; QWidget *buttonWidget() const override; QString toolTip() const override; private slots: void toolChainAdded(GoLang::ToolChain *tc); void toolChainRemoved(GoLang::ToolChain *tc); void toolChainUpdated(GoLang::ToolChain *tc); void manageToolChains(); void currentToolChainChanged(int idx); private: void updateComboBox(); int indexOf(const ToolChain *tc); QComboBox *m_comboBox; QPushButton *m_manageButton; }; } // namespace Internal } // namespace GoLang #endif // GOLANG_GOKITINFORMATION_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/golang_dependencies.pri0000644000015300001610000000022612562573357026657 0ustar pbuserpbgroup00000000000000QTC_PLUGIN_NAME = GoLang QTC_LIB_DEPENDS += \ utils QTC_PLUGIN_DEPENDS += \ coreplugin \ projectexplorer \ qmljstools \ qtsupport qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/toolchainconfigwidget.h0000644000015300001610000000512412562573357026713 0ustar pbuserpbgroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef GOLANG_INTERNAL_TOOLCHAINCONFIGWIDGET_H #define GOLANG_INTERNAL_TOOLCHAINCONFIGWIDGET_H #include QT_BEGIN_NAMESPACE class QFormLayout; class QGridLayout; class QLineEdit; class QLabel; QT_END_NAMESPACE namespace GoLang { class ToolChain; // -------------------------------------------------------------------------- // ToolChainConfigWidget // -------------------------------------------------------------------------- class ToolChainConfigWidget : public QWidget { Q_OBJECT public: ToolChainConfigWidget(GoLang::ToolChain *); GoLang::ToolChain *toolChain() const; void apply(); void discard(); bool isDirty() const; void makeReadOnly(); signals: void dirty(); protected slots: void setErrorMessage(const QString &); void clearErrorMessage(); protected: virtual void applyImpl() ; virtual void discardImpl(); virtual bool isDirtyImpl() const; virtual void makeReadOnlyImpl(); void addErrorLabel(); QFormLayout *m_mainLayout; QLineEdit *m_nameLineEdit; private: ToolChain *m_toolChain; QLabel *m_errorLabel; }; } // namespace GoLang #endif // GOLANG_INTERNAL_TOOLCHAINCONFIGWIDGET_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/gobuildconfiguration.cpp0000644000015300001610000005665712562573362027126 0ustar pbuserpbgroup00000000000000#include "gobuildconfiguration.h" #include "golangconstants.h" #include "gotoolchain.h" #include "gokitinformation.h" #include "goproject.h" #include "goprojectitem.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace GoLang { const char GO_BUILDSTEP_ISCLEAN_KEYC[] = "GoLang.GoBuildStep.IsCleanStep"; namespace { //forked from projectexplorer because AnsiParser is not exported enum AnsiState { PLAIN, ANSI_START, ANSI_CSI, ANSI_SEQUENCE, ANSI_WAITING_FOR_ST, ANSI_ST_STARTED }; QString filterLine(const QString &line) { QString result; result.reserve(line.count()); static AnsiState state = PLAIN; foreach (const QChar c, line) { unsigned int val = c.unicode(); switch (state) { case PLAIN: if (val == 27) // 'ESC' state = ANSI_START; else if (val == 155) // equivalent to 'ESC'-'[' state = ANSI_CSI; else result.append(c); break; case ANSI_START: if (val == 91) // [ state = ANSI_CSI; else if (val == 80 || val == 93 || val == 94 || val == 95) // 'P', ']', '^' and '_' state = ANSI_WAITING_FOR_ST; else if (val >= 64 && val <= 95) state = PLAIN; else state = ANSI_SEQUENCE; break; case ANSI_CSI: if (val >= 64 && val <= 126) // Anything between '@' and '~' state = PLAIN; break; case ANSI_SEQUENCE: if (val >= 64 && val <= 95) // Anything between '@' and '_' state = PLAIN; break; case ANSI_WAITING_FOR_ST: if (val == 7) // 'BEL' state = PLAIN; if (val == 27) // 'ESC' state = ANSI_ST_STARTED; break; case ANSI_ST_STARTED: if (val == 92) // '\' state = PLAIN; else state = ANSI_WAITING_FOR_ST; break; } } return result; } } GoBuildConfiguration::GoBuildConfiguration(ProjectExplorer::Target *target) : ProjectExplorer::BuildConfiguration(target,Constants::GO_BUILDCONFIGURATION_ID) { } GoBuildConfiguration::GoBuildConfiguration(ProjectExplorer::Target *target, GoBuildConfiguration *other) : ProjectExplorer::BuildConfiguration(target,other) { } ProjectExplorer::NamedWidget *GoBuildConfiguration::createConfigWidget() { return new ProjectExplorer::NamedWidget(); } QList GoBuildConfiguration::createSubConfigWidgets() { return BuildConfiguration::createSubConfigWidgets(); } bool GoBuildConfiguration::isEnabled() const { return true; } QString GoBuildConfiguration::disabledReason() const { return QString(); } ProjectExplorer::BuildConfiguration::BuildType GoBuildConfiguration::buildType() const { return ProjectExplorer::BuildConfiguration::Debug; } void GoBuildConfiguration::setBuildDirectory(const Utils::FileName &dir) { ProjectExplorer::BuildConfiguration::setBuildDirectory(dir); } bool GoBuildConfiguration::fromMap(const QVariantMap &map) { if(!ProjectExplorer::BuildConfiguration::fromMap(map)) return false; return true; } QVariantMap GoBuildConfiguration::toMap() const { QVariantMap map = ProjectExplorer::BuildConfiguration::toMap(); if(map.isEmpty()) return map; return map; } /*! * \class GoBuildConfigurationFactory * Factory class to create GoBuildConfiguration * instances. */ GoBuildConfigurationFactory::GoBuildConfigurationFactory(QObject *parent) : ProjectExplorer::IBuildConfigurationFactory(parent) { } GoBuildConfigurationFactory::~GoBuildConfigurationFactory() { } int GoBuildConfigurationFactory::priority(const ProjectExplorer::Target *parent) const { if(canHandle(parent)) return 1; return -1; } QList GoBuildConfigurationFactory::availableBuilds(const ProjectExplorer::Kit *kit, const QString &projectFilePath) const { QList result; QFileInfo projFileInfo(projectFilePath); ProjectExplorer::BuildInfo *goBuild = new ProjectExplorer::BuildInfo(this); goBuild->displayName = tr("Default"); goBuild->buildDirectory = Utils::FileName::fromString(projFileInfo.absolutePath()); goBuild->kitId = kit->id(); goBuild->typeName = QStringLiteral("Default"); result << goBuild; return result; } QList GoBuildConfigurationFactory::availableBuilds(const ProjectExplorer::Target *parent) const { QList result; if(!canHandle(parent)) return result; return availableBuilds(parent->kit(),parent->project()->projectFilePath().toString()); } int GoBuildConfigurationFactory::priority(const ProjectExplorer::Kit *k, const QString &projectPath) const { if(!k) return -1; GoLang::ToolChain* tc = GoToolChainKitInformation::toolChain(k); if(!tc) return -1; return (Utils::MimeDatabase().mimeTypeForFile(QFileInfo(projectPath)).matchesName(QLatin1String(Constants::GO_PROJECT_MIMETYPE))) ? 10 : -1; } QList GoBuildConfigurationFactory::availableSetups(const ProjectExplorer::Kit *k, const QString &projectPath) const { if(!GoToolChainKitInformation::toolChain(k)) return QList(); if(!Utils::MimeDatabase().mimeTypeForFile(QFileInfo(projectPath)).matchesName(QLatin1String(Constants::GO_PROJECT_MIMETYPE))) return QList(); return availableBuilds(k,projectPath); } GoBuildConfiguration *GoBuildConfigurationFactory::create(ProjectExplorer::Target *parent, const ProjectExplorer::BuildInfo *info) const { QTC_ASSERT(info->factory() == this, return 0); QTC_ASSERT(info->kitId == parent->kit()->id(), return 0); QTC_ASSERT(!info->displayName.isEmpty(), return 0); QTC_ASSERT(canHandle(parent),return 0); ProjectExplorer::BuildInfo copy(*info); GoProject *project = static_cast(parent->project()); if (copy.buildDirectory.isEmpty()) copy.buildDirectory = project->projectDirectory(); GoBuildConfiguration *bc = new GoBuildConfiguration(parent); bc->setDisplayName(copy.displayName); bc->setDefaultDisplayName(copy.displayName); ProjectExplorer::BuildStepList *buildSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); ProjectExplorer::BuildStepList *cleanSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_CLEAN); GoBuildStep *build = new GoBuildStep(buildSteps); buildSteps->insertStep(0, build); GoBuildStep *cleanStep = new GoBuildStep(cleanSteps); cleanSteps->insertStep(0, cleanStep); cleanStep->setIsCleanStep(true); bc->setBuildDirectory(Utils::FileName::fromString(copy.buildDirectory.toString())); return bc; } bool GoBuildConfigurationFactory::canRestore(const ProjectExplorer::Target *parent, const QVariantMap &map) const { if (!canHandle(parent)) return false; return ProjectExplorer::idFromMap(map) == Constants::GO_BUILDCONFIGURATION_ID; } GoBuildConfiguration *GoBuildConfigurationFactory::restore(ProjectExplorer::Target *parent, const QVariantMap &map) { if (!canRestore(parent, map)) return 0; GoBuildConfiguration *bc = new GoBuildConfiguration(parent); if (bc->fromMap(map)) return bc; delete bc; return 0; } bool GoBuildConfigurationFactory::canClone(const ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *product) const { if (!canHandle(parent)) return false; return product->id() == Constants::GO_BUILDCONFIGURATION_ID; } GoBuildConfiguration *GoBuildConfigurationFactory::clone(ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *product) { if (!canClone(parent, product)) return 0; GoBuildConfiguration *old = static_cast(product); return new GoBuildConfiguration(parent, old); } bool GoBuildConfigurationFactory::canHandle(const ProjectExplorer::Target *t) const { QTC_ASSERT(t, return false); if (!t->project()->supportsKit(t->kit())) return false; return qobject_cast(t->project()); } GoBuildStep::GoBuildStep(ProjectExplorer::BuildStepList *bsl) : BuildStep(bsl,Constants::GO_GOSTEP_ID), m_future(0), m_process(0), m_outputParserChain(0), m_state(Init) { setIsCleanStep(false); } GoBuildStep::GoBuildStep(ProjectExplorer::BuildStepList *bsl, GoBuildStep *bs) : BuildStep(bsl,bs), m_future(0), m_process(0), m_outputParserChain(0), m_state(Init) { setIsCleanStep(bs->m_clean); } GoBuildStep::~GoBuildStep() { stopProcess(); if(m_outputParserChain) delete m_outputParserChain; } void GoBuildStep::setIsCleanStep(const bool set) { if(m_clean == set) return; m_clean = set; if(m_clean) setDisplayName(tr("Run Go clean")); else setDisplayName(tr("Run Go install")); } bool GoBuildStep::isCleanStep() const { return m_clean; } bool GoBuildStep::init() { m_tasks.clear(); ProjectExplorer::BuildConfiguration *bc = buildConfiguration(); if (!bc){ ProjectExplorer::Task t(ProjectExplorer::Task::Error ,tr("No valid BuildConfiguration set for step: %1").arg(displayName()) ,Utils::FileName(),-1 ,ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM); m_tasks.append(t); //GoBuildStep::run will stop if tasks exist return true; } ProjectExplorer::Kit* kit = bc->target()->kit(); GoLang::ToolChain* tc = GoLang::GoToolChainKitInformation::toolChain(kit); if(!tc){ ProjectExplorer::Task t(ProjectExplorer::Task::Error ,tr("No valid Go Toolchain set for kit: %1").arg(kit->displayName()) ,Utils::FileName(),-1 ,ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM); m_tasks.append(t); //GoBuildStep::run will stop if tasks exist return true; } ProjectExplorer::IOutputParser *parser = target()->kit()->createOutputParser(); if (parser) setOutputParser(parser); return true; } void GoBuildStep::run(QFutureInterface &fi) { m_future = &fi; if (m_tasks.size()) { foreach (const ProjectExplorer::Task& task, m_tasks) { addTask(task); } emit addOutput(tr("Configuration is invalid. Aborting build") ,ProjectExplorer::BuildStep::ErrorMessageOutput); handleFinished(false); return; } m_state = Init; fi.setProgressRange(0,2); startNextStep(); } ProjectExplorer::BuildStepConfigWidget *GoBuildStep::createConfigWidget() { return new ProjectExplorer::SimpleBuildStepConfigWidget(this); } void GoBuildStep::cancel() { stopProcess(); m_future->reportCanceled(); handleFinished(false); } bool GoBuildStep::fromMap(const QVariantMap &map) { if(!BuildStep::fromMap(map)) return false; setIsCleanStep(map.value(QLatin1String(GO_BUILDSTEP_ISCLEAN_KEYC),false).toBool()); return true; } QVariantMap GoBuildStep::toMap() const { QVariantMap map = BuildStep::toMap(); map.insert(QLatin1String(GO_BUILDSTEP_ISCLEAN_KEYC),m_clean); return map; } GoProject *GoBuildStep::goProject() const { return qobject_cast(target()->project()); } void GoBuildStep::onProcessFinished() { //make sure all data was processed onProcessStdErr(); onProcessStdOut(); if (m_outputParserChain) m_outputParserChain->flush(); if(m_process->exitCode() == 0 && m_process->exitStatus() == QProcess::NormalExit) emit addOutput(tr("The process %1 exited normally.").arg(m_process->program()), ProjectExplorer::BuildStep::MessageOutput); else emit addOutput(tr("The process %1 exited with errors.").arg(m_process->program()), ProjectExplorer::BuildStep::MessageOutput); startNextStep(); } void GoBuildStep::onProcessStdOut() { m_process->setReadChannel(QProcess::StandardOutput); while (m_process->canReadLine()) { QString line = QString::fromLocal8Bit(m_process->readLine()); if (m_outputParserChain) m_outputParserChain->stdOutput(filterLine(line)); emit addOutput(line, BuildStep::NormalOutput, BuildStep::DontAppendNewline); } } void GoBuildStep::onProcessStdErr() { m_process->setReadChannel(QProcess::StandardError); while (m_process->canReadLine()) { QString line = QString::fromLocal8Bit(m_process->readLine()); if (m_outputParserChain) m_outputParserChain->stdError(filterLine(line)); emit addOutput(line, BuildStep::ErrorOutput, BuildStep::DontAppendNewline); } } void GoBuildStep::startNextStep() { ProjectExplorer::BuildConfiguration *bc = buildConfiguration(); if(!bc) { cancel(); return; } Utils::Environment env = bc->environment(); // Force output to english for the parsers. Do this here and not in the toolchain's // addToEnvironment() to not screw up the users run environment. env.set(QStringLiteral("LC_ALL"), QStringLiteral("C")); env.prependOrSet(QStringLiteral("GOPATH"),bc->target()->project()->projectDirectory().toString(), Utils::OsSpecificAspects(Utils::HostOsInfo::hostOs()).pathListSeparator()); env.set(QStringLiteral("GOBIN") ,bc->target()->project()->projectDirectory().appendPath(QStringLiteral("bin")).toString()); ProjectExplorer::Kit* kit = bc->target()->kit(); GoLang::ToolChain* tc = GoLang::GoToolChainKitInformation::toolChain(kit); if(!tc) { cancel(); return; } ProjectExplorer::ProcessParameters params; params.setMacroExpander(bc->macroExpander()); //setup process parameters params.setWorkingDirectory(bc->buildDirectory().toString()); params.setCommand(tc->compilerCommand().toString()); params.setEnvironment(env); GoProject *pro = goProject(); if(!pro) { cancel(); return; } switch(m_state) { case Init: { m_state = GoGet; if(m_clean) { startNextStep(); return; } QStringList packages; foreach(GoBaseTargetItem *target,pro->buildTargets()) { GoPackageItem* pck = qobject_cast(target); if(!pck) continue; packages << pck->name(); } if(!packages.size()) { m_state = GoGet; startNextStep(); return; } QStringList arguments; arguments << QStringLiteral("get") << QStringLiteral("-d") //only download << QStringLiteral("-u") //update packages if possible << packages; params.setArguments(Utils::QtcProcess::joinArgs(arguments)); m_future->setProgressValueAndText(0,tr("Running go-get")); startProcess(params); emit addOutput(tr("Running command go %1").arg(Utils::QtcProcess::joinArgs(arguments)), ProjectExplorer::BuildStep::MessageOutput); break; } case GoGet:{ m_state = GoBuild; //only care about the last process output when not in clean mode if(!m_clean && !processSucceeded()) { handleFinished(false); return; } QStringList packages; foreach(GoBaseTargetItem *target,pro->buildTargets()) { GoApplicationItem* pck = qobject_cast(target); if(!pck) continue; packages << pck->name(); } QStringList arguments; if(!m_clean) { arguments << QStringLiteral("install") << QStringLiteral("-v") //verbose output << QStringLiteral("-x"); //show commands m_future->setProgressValueAndText(1,tr("Building")); } else { arguments << QStringLiteral("clean") << QStringLiteral("-i") << QStringLiteral("-r"); m_future->setProgressValueAndText(1,tr("Cleaning")); } arguments << packages.join(QStringLiteral(" ")); params.setArguments(Utils::QtcProcess::joinArgs(arguments)); startProcess(params); emit addOutput(tr("Running command go %1").arg(Utils::QtcProcess::joinArgs(arguments)), ProjectExplorer::BuildStep::MessageOutput); break; } case GoBuild:{ //m_future->setProgressValueAndText(2,tr("Finished")); handleFinished(processSucceeded()); break; } default:{ return; } } } void GoBuildStep::handleFinished(bool result) { stopProcess(); setOutputParser(0); m_state = Finished; m_tasks.clear(); m_future->reportResult(result); m_future = 0; emit finished(); } void GoBuildStep::startProcess(const ProjectExplorer::ProcessParameters ¶ms) { stopProcess(); qDebug()<<"Start "<setWorkingDirectory(params.effectiveWorkingDirectory()); m_process = new Utils::QtcProcess; connect(m_process,SIGNAL(readyReadStandardError()),this,SLOT(onProcessStdErr())); connect(m_process,SIGNAL(readyReadStandardOutput()),this,SLOT(onProcessStdOut())); connect(m_process,SIGNAL(finished(int)),this,SLOT(onProcessFinished())); #ifdef Q_OS_WIN m_process->setUseCtrlCStub(true); #endif m_process->setEnvironment(params.environment()); m_process->setWorkingDirectory(params.workingDirectory()); m_process->setCommand(params.effectiveCommand(), params.effectiveArguments()); m_process->start(); if (!m_process->waitForStarted()) { handleFinished(false); } } void GoBuildStep::stopProcess() { if (m_process) { m_process->disconnect(this); if(m_process->state() != QProcess::NotRunning) { m_process->terminate(); if(!m_process->waitForFinished(500)) m_process->kill(); } m_process->deleteLater(); m_process = 0; } } void GoBuildStep::setOutputParser(ProjectExplorer::IOutputParser *parser) { delete m_outputParserChain; m_outputParserChain = parser; if (m_outputParserChain) { connect(m_outputParserChain, SIGNAL(addOutput(QString,ProjectExplorer::BuildStep::OutputFormat)), this, SLOT(outputAdded(QString,ProjectExplorer::BuildStep::OutputFormat))); //connect(m_outputParserChain, SIGNAL(addTask(ProjectExplorer::Task)), // this, SLOT(taskAdded(ProjectExplorer::Task))); } } void GoBuildStep::outputAdded(const QString &string, ProjectExplorer::BuildStep::OutputFormat format) { emit addOutput(string, format, BuildStep::DontAppendNewline); } bool GoBuildStep::processSucceeded() const { if (m_outputParserChain && m_outputParserChain->hasFatalErrors()) return false; return m_process->exitCode() == 0 && m_process->exitStatus() == QProcess::NormalExit; } /*! * \class GoBuildStepFactory * Factory class to create Go buildsteps * build steps */ namespace { enum { GOSTEP_BUILDSUFFIX, GOSTEP_CLEANSUFFIX }; } QList GoBuildStepFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const { if(!canHandle(parent->target())) return QList(); if (parent->id() == ProjectExplorer::Constants::BUILDSTEPS_BUILD) return QList() << Core::Id(Constants::GO_GOSTEP_ID).withSuffix(GOSTEP_BUILDSUFFIX); else if(parent->id() == ProjectExplorer::Constants::BUILDSTEPS_CLEAN) return QList() << Core::Id(Constants::GO_GOSTEP_ID).withSuffix(GOSTEP_CLEANSUFFIX); return QList(); } /*! * \brief GoBuildConfigurationFactory::canHandle * checks if we can create buildconfigurations for the given target */ bool GoBuildStepFactory::canHandle(const ProjectExplorer::Target *t) const { QTC_ASSERT(t, return false); if (!t->project()->supportsKit(t->kit())) return false; return t->project()->id() == Core::Id(GoLang::Constants::GO_PROJECT_ID); } QString GoBuildStepFactory::displayNameForId(const Core::Id id) const { if (id == Core::Id(Constants::GO_GOSTEP_ID).withSuffix(GOSTEP_BUILDSUFFIX)) return tr("Run Go get/install", "Display name for GoStep id."); else if (id == Core::Id(Constants::GO_GOSTEP_ID).withSuffix(GOSTEP_CLEANSUFFIX)) return tr("Run Go clean", "Display name for GoStep clean id."); return QString(); } bool GoBuildStepFactory::canCreate(ProjectExplorer::BuildStepList *parent, const Core::Id id) const { if (canHandle(parent->target())) return availableCreationIds(parent).contains(id); return false; } ProjectExplorer::BuildStep *GoBuildStepFactory::create(ProjectExplorer::BuildStepList *parent, const Core::Id id) { if (!canCreate(parent, id)) return 0; if ( id == Core::Id(Constants::GO_GOSTEP_ID).withSuffix(GOSTEP_BUILDSUFFIX) ) { GoBuildStep *step = new GoBuildStep(parent); return step; } else if ( id == Core::Id(Constants::GO_GOSTEP_ID).withSuffix(GOSTEP_CLEANSUFFIX) ) { GoBuildStep *step = new GoBuildStep(parent); step->setIsCleanStep(true); return step; } return 0; } bool GoBuildStepFactory::canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const { if(!canHandle(parent->target())) return false; return ProjectExplorer::idFromMap(map) == Core::Id(Constants::GO_GOSTEP_ID); } ProjectExplorer::BuildStep *GoBuildStepFactory::restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) { if (!canRestore(parent, map)) return 0; ProjectExplorer::BuildStep* step = new GoBuildStep(parent); if(step->fromMap(map)) return step; delete step; return 0; } bool GoBuildStepFactory::canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) const { return canCreate(parent, product->id()); } ProjectExplorer::BuildStep *GoBuildStepFactory::clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) { if (!canClone(parent, product)) return 0; if(product->id() == Core::Id(Constants::GO_GOSTEP_ID)) return new GoBuildStep(parent,static_cast(product)); QTC_ASSERT(false,return 0); } } // namespace GoLang qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/toolchain.cpp0000644000015300001610000001060612562573357024655 0ustar pbuserpbgroup00000000000000#include "toolchain.h" #include "toolchainmanager.h" #include "toolchainconfigwidget.h" #include "golangconstants.h" #include #include #include #include #include #include static const char ID_KEY[] = "GoLang.ToolChain.Id"; static const char DISPLAY_NAME_KEY[] = "GoLang.ToolChain.DisplayName"; static const char AUTODETECT_KEY[] = "GoLang.ToolChain.Autodetect"; namespace GoLang { namespace Internal { // -------------------------------------------------------------------------- // ToolChainPrivate // -------------------------------------------------------------------------- class ToolChainPrivate { public: typedef ToolChain::Detection Detection; explicit ToolChainPrivate(const QString &id, Detection d) : m_detection(d) { m_id = createId(id); } static QString createId(const QString &id) { QString newId = id.left(id.indexOf(QLatin1Char(':'))); newId.append(QLatin1Char(':') + QUuid::createUuid().toString()); return newId; } QString m_id; Detection m_detection; mutable QString m_displayName; }; } // namespace Internal /*! \class GoLang::ToolChain \brief The ToolChain class represents a go tool chain. \sa GoLang::ToolChainManager */ // -------------------------------------------------------------------------- ToolChain::ToolChain(const QString &id, Detection d) : d(new Internal::ToolChainPrivate(id, d)) { } ToolChain::ToolChain(const ToolChain &other) : d(new Internal::ToolChainPrivate(other.d->m_id, ManualDetection)) { // leave the autodetection bit at false. d->m_displayName = QCoreApplication::translate("ProjectExplorer::ToolChain", "Clone of %1") .arg(other.displayName()); } /*! Used by the tool chain manager to load user-generated tool chains. Make sure to call this function when deriving. */ bool ToolChain::fromMap(const QVariantMap &data) { d->m_displayName = data.value(QLatin1String(DISPLAY_NAME_KEY)).toString(); // make sure we have new style ids: d->m_id = data.value(QLatin1String(ID_KEY)).toString(); const bool autoDetect = data.value(QLatin1String(AUTODETECT_KEY), false).toBool(); d->m_detection = autoDetect ? AutoDetectionFromSettings : ManualDetection; return true; } ToolChain::~ToolChain() { delete d; } QString ToolChain::displayName() const { if (d->m_displayName.isEmpty()) return typeDisplayName(); return d->m_displayName; } void ToolChain::setDisplayName(const QString &name) { if (d->m_displayName == name) return; d->m_displayName = name; toolChainUpdated(); } ToolChain::Detection ToolChain::detection() const { return d->m_detection; } QString ToolChain::id() const { return d->m_id; } bool ToolChain::canClone() const { return true; } /*! Used by the tool chain manager to save user-generated tool chains. Make sure to call this function when deriving. */ QVariantMap ToolChain::toMap() const { QVariantMap result; result.insert(QLatin1String(ID_KEY), id()); result.insert(QLatin1String(DISPLAY_NAME_KEY), displayName()); result.insert(QLatin1String(AUTODETECT_KEY), isAutoDetected()); return result; } /*! Used by the tool chain kit information to validate the kit. */ QList ToolChain::validateKit(const ProjectExplorer::Kit *) const { return QList(); } bool ToolChain::operator ==(const ToolChain &tc) const { if (this == &tc) return true; const QString thisId = id().left(id().indexOf(QLatin1Char(':'))); const QString tcId = tc.id().left(tc.id().indexOf(QLatin1Char(':'))); // We ignore displayname return thisId == tcId && isAutoDetected() == tc.isAutoDetected(); } void ToolChain::setDetection(ToolChain::Detection detect) { d->m_detection = detect; } void ToolChain::toolChainUpdated() { ToolChainManager::notifyAboutUpdate(this); } QString ToolChainFactory::idFromMap(const QVariantMap &data) { return data.value(QLatin1String(ID_KEY)).toString(); } void ToolChainFactory::idToMap(QVariantMap &data, const QString id) { data.insert(QLatin1String(ID_KEY), id); } void ToolChainFactory::autoDetectionToMap(QVariantMap &data, bool detected) { data.insert(QLatin1String(AUTODETECT_KEY), detected); } } // namespace GoLang qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/goprojectfileformat.cpp0000644000015300001610000001714412562573357026746 0ustar pbuserpbgroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "goprojectfileformat.h" #include "goprojectitem.h" #include "filefilteritems.h" #include #include #include #include enum { debug = false }; namespace { void setupFileFilterItem(GoLang::FileFilterBaseItem *fileFilterItem, const QmlJS::SimpleReaderNode::Ptr &node, const QString &defaultDir) { const QVariant directoryProperty = node->property(QLatin1String("directory")); if (directoryProperty.isValid()) fileFilterItem->setDirectory(directoryProperty.toString()); else fileFilterItem->setDirectory(defaultDir); const QVariant recursiveProperty = node->property(QLatin1String("recursive")); if (recursiveProperty.isValid()) fileFilterItem->setRecursive(recursiveProperty.toBool()); const QVariant pathsProperty = node->property(QLatin1String("paths")); if (pathsProperty.isValid()) fileFilterItem->setPathsProperty(pathsProperty.toStringList()); const QVariant filterProperty = node->property(QLatin1String("filter")); if (filterProperty.isValid()) fileFilterItem->setFilter(filterProperty.toString()); if (debug) qDebug() << "directory:" << directoryProperty << "recursive" << recursiveProperty << "paths" << pathsProperty; } } //namespace namespace GoLang { GoProjectItem *GoProjectFileFormat::parseProjectFile(const QString &fileName, QString *errorMessage) { QmlJS::SimpleReader simpleQmlJSReader; const QmlJS::SimpleReaderNode::Ptr rootNode = simpleQmlJSReader.readFile(fileName); if (!simpleQmlJSReader.errors().isEmpty() || !rootNode->isValid()) { qWarning() << "unable to parse:" << fileName; qWarning() << simpleQmlJSReader.errors(); if (errorMessage) *errorMessage = simpleQmlJSReader.errors().join(QLatin1String(", ")); return 0; } if (rootNode->name() == QLatin1String("GoProject")) { GoProjectItem *projectItem = new GoProjectItem(); foreach (const QmlJS::SimpleReaderNode::Ptr &prochildNode, rootNode->children()) { GoBaseTargetItem *targetItem = 0; if (prochildNode->name() == QLatin1String("Application")) { GoApplicationItem* appItem = new GoApplicationItem(projectItem); targetItem = appItem; const QVariant importPathsProperty = prochildNode->property(QLatin1String("qmlImportPaths")); if (importPathsProperty.isValid()) appItem->setImportPaths(importPathsProperty.toStringList()); projectItem->appendTarget(targetItem); } else if (prochildNode->name() == QLatin1String("Package")) { GoPackageItem* pckItem = new GoPackageItem(projectItem); targetItem = pckItem; projectItem->appendTarget(targetItem); } const QVariant nameProperty = prochildNode->property(QLatin1String("name")); if (nameProperty.isValid()) targetItem->setName(nameProperty.toString()); if(targetItem) { foreach (const QmlJS::SimpleReaderNode::Ptr &childNode, prochildNode->children()) { if (childNode->name() == QLatin1String("GoFiles")) { if (debug) qDebug() << "GoFiles"; GoFileFilterItem *qmlFileFilterItem = new GoFileFilterItem(targetItem); setupFileFilterItem(qmlFileFilterItem, childNode, QStringLiteral("src/")+nameProperty.toString()); targetItem->appendContent(qmlFileFilterItem); } else if (childNode->name() == QLatin1String("QmlFiles")) { if (debug) qDebug() << "QmlFiles"; QmlFileFilterItem *qmlFileFilterItem = new QmlFileFilterItem(targetItem); setupFileFilterItem(qmlFileFilterItem, childNode, QStringLiteral("src/")+nameProperty.toString()); targetItem->appendContent(qmlFileFilterItem); } else if (childNode->name() == QLatin1String("JavaScriptFiles")) { if (debug) qDebug() << "JavaScriptFiles"; JsFileFilterItem *jsFileFilterItem = new JsFileFilterItem(targetItem); setupFileFilterItem(jsFileFilterItem, childNode, QStringLiteral("src/")+nameProperty.toString()); targetItem->appendContent(jsFileFilterItem); } else if (childNode->name() == QLatin1String("ImageFiles")) { if (debug) qDebug() << "ImageFiles"; ImageFileFilterItem *imageFileFilterItem = new ImageFileFilterItem(targetItem); setupFileFilterItem(imageFileFilterItem, childNode, QStringLiteral("src/")+nameProperty.toString()); targetItem->appendContent(imageFileFilterItem); } else if (childNode->name() == QLatin1String("CssFiles")) { if (debug) qDebug() << "CssFiles"; CssFileFilterItem *cssFileFilterItem = new CssFileFilterItem(targetItem); setupFileFilterItem(cssFileFilterItem, childNode, QStringLiteral("src/")+nameProperty.toString()); targetItem->appendContent(cssFileFilterItem); } else if (childNode->name() == QLatin1String("Files")) { if (debug) qDebug() << "Files"; OtherFileFilterItem *otherFileFilterItem = new OtherFileFilterItem(targetItem); setupFileFilterItem(otherFileFilterItem, childNode, QStringLiteral("src/")+nameProperty.toString()); targetItem->appendContent(otherFileFilterItem); } else { qWarning() << "Unknown type:" << childNode->name(); } } } } return projectItem; } if (errorMessage) *errorMessage = tr("Invalid root element: %1").arg(rootNode->name()); return 0; } } // namespace QmlProjectManager qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/goproject.cpp0000644000015300001610000002663112562573362024672 0ustar pbuserpbgroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Author: Juhapekka Piiroinen */ #include "goproject.h" #include "goprojectfileformat.h" #include "goprojectmanager.h" #include "gokitinformation.h" #include "gotoolchain.h" #include #include #include #include #include #include #include #include #include #include #include namespace GoLang { using namespace Core; using namespace ProjectExplorer; GoProject::GoProject(Internal::Manager *manager, const QString &fileName) : m_manager(manager), m_fileName(fileName), m_defaultImport(UnknownImport), m_modelManager(QmlJS::ModelManagerInterface::instance()), m_activeTarget(0) { setId(Constants::GO_PROJECT_ID); setProjectContext(Context(Constants::GO_PROJECT_PROJECTCONTEXT)); setProjectLanguages(Context(Constants::LANG_GO)); QFileInfo fileInfo(m_fileName); m_projectName = fileInfo.completeBaseName(); m_file = new Internal::GoProjectFile(this, fileName); m_rootNode = new Internal::GoProjectNode(this, m_file); DocumentManager::addDocument(m_file, true); setRequiredKitMatcher(GoToolChainKitInformation::kitMatcher()); setPreferredKitMatcher(QtSupport::QtKitInformation::qtVersionMatcher( Core::FeatureSet(QtSupport::Constants::FEATURE_DESKTOP))); m_manager->registerProject(this); } GoProject::~GoProject() { m_manager->unregisterProject(this); DocumentManager::removeDocument(m_file); delete m_projectItem.data(); delete m_rootNode; } void GoProject::addedTarget(ProjectExplorer::Target *target) { connect(target, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration*)), this, SLOT(addedRunConfiguration(ProjectExplorer::RunConfiguration*))); foreach (ProjectExplorer::RunConfiguration *rc, target->runConfigurations()) addedRunConfiguration(rc); } void GoProject::onActiveTargetChanged(ProjectExplorer::Target *target) { if (m_activeTarget) disconnect(m_activeTarget, SIGNAL(kitChanged()), this, SLOT(onKitChanged())); m_activeTarget = target; if (m_activeTarget) connect(target, SIGNAL(kitChanged()), this, SLOT(onKitChanged())); // make sure e.g. the default qml imports are adapted refresh(Configuration); } void GoProject::onKitChanged() { // make sure e.g. the default qml imports are adapted refresh(Configuration); } void GoProject::addedRunConfiguration(ProjectExplorer::RunConfiguration *rc) { // The enabled state of qml runconfigurations can only be decided after // they have been added to a project //QmlProjectRunConfiguration *qmlrc = qobject_cast(rc); //if (qmlrc) // qmlrc->updateEnabled(); } QDir GoProject::projectDir() const { return projectFilePath().toFileInfo().dir(); } QString GoProject::filesFileName() const { return m_fileName; } static GoProject::QmlImport detectImport(const QString &qml) { static QRegExp qtQuick1RegExp(QLatin1String("import\\s+QtQuick\\s+1")); static QRegExp qtQuick2RegExp(QLatin1String("import\\s+QtQuick\\s+2")); if (qml.contains(qtQuick1RegExp)) return GoProject::QtQuick1Import; else if (qml.contains(qtQuick2RegExp)) return GoProject::QtQuick2Import; else return GoProject::UnknownImport; } void GoProject::parseProject(RefreshOptions options) { if (options & Files) { if (options & ProjectFile) delete m_projectItem.data(); if (!m_projectItem) { QString errorMessage; m_projectItem = GoProjectFileFormat::parseProjectFile(m_fileName, &errorMessage); if (m_projectItem) { connect(m_projectItem.data(), SIGNAL(filesChanged(QSet,QSet)), this, SLOT(refreshFiles(QSet,QSet))); } else { MessageManager::write(tr("Error while loading project file %1.").arg(m_fileName), MessageManager::NoModeSwitch); MessageManager::write(errorMessage); } } if (m_projectItem) { m_projectItem.data()->setSourceDirectory(projectDir().path()); m_modelManager->updateSourceFiles(m_projectItem.data()->files(), true); /* QString mainFilePath = m_projectItem.data()->mainFile(); if (!mainFilePath.isEmpty()) { mainFilePath = projectDir().absoluteFilePath(mainFilePath); Utils::FileReader reader; QString errorMessage; if (!reader.fetch(mainFilePath, &errorMessage)) { MessageManager::write(tr("Warning while loading project file %1.").arg(m_fileName)); MessageManager::write(errorMessage); } else { m_defaultImport = detectImport(QString::fromUtf8(reader.data())); } } */ } m_rootNode->refresh(); updateConfigurations(); } if (options & Configuration) { // update configuration } if (options & Files) emit fileListChanged(); } void GoProject::refresh(RefreshOptions options) { parseProject(options); if (options & Files) m_rootNode->refresh(); QmlJS::ModelManagerInterface *modelManager = QmlJS::ModelManagerInterface::instance(); if (!modelManager) return; QmlJS::ModelManagerInterface::ProjectInfo projectInfo = modelManager->defaultProjectInfoForProject(this); foreach(const QString &searchPath, customImportPaths()) { projectInfo.importPaths.maybeInsert(Utils::FileName::fromString(searchPath), QmlJS::Dialect::Qml); } m_modelManager->updateProjectInfo(projectInfo,this); } void GoProject::updateConfigurations() { foreach (Target *t, targets()) updateConfigurations(t); } bool GoProject::setupTarget(Target *t) { t->updateDefaultBuildConfigurations(); t->updateDefaultDeployConfigurations(); t->updateDefaultRunConfigurations(); return true; } void GoProject::updateConfigurations(Target *t) { //t->updateDefaultDeployConfigurations(); t->updateDefaultRunConfigurations(); if (t->runConfigurations().isEmpty()) { // Oh no, no run configuration, // create a custom executable run configuration t->addRunConfiguration(new QtSupport::CustomExecutableRunConfiguration(t)); } } QStringList GoProject::files() const { QStringList files; if (m_projectItem) files = m_projectItem.data()->files(); else files = m_files; return files; } bool GoProject::validProjectFile() const { return !m_projectItem.isNull(); } QStringList GoProject::customImportPaths() const { QStringList importPaths; //if (m_projectItem) // importPaths = m_projectItem.data()->importPaths(); return importPaths; } bool GoProject::addFiles(const QStringList &filePaths) { QStringList toAdd; foreach (const QString &filePath, filePaths) { if (!m_projectItem.data()->matchesFile(filePath)) toAdd << filePaths; } return toAdd.isEmpty(); } void GoProject::refreshProjectFile() { RefreshOptions opts(GoProject::ProjectFile | GoProject::Files); refresh(opts); } GoProject::QmlImport GoProject::defaultImport() const { return m_defaultImport; } QList GoProject::buildTargets() const { if(!m_projectItem) return QList(); return m_projectItem->commands(); } bool GoProject::requiresTargetPanel() const { return true; } bool GoProject::needsConfiguration() const { return targets().isEmpty(); } void GoProject::refreshFiles(const QSet &/*added*/, const QSet &removed) { refresh(Files); if (!removed.isEmpty()) m_modelManager->removeFiles(removed.toList()); } QString GoProject::displayName() const { return m_projectName; } IDocument *GoProject::document() const { return m_file; } ProjectExplorer::IProjectManager *GoProject::projectManager() const { return m_manager; } bool GoProject::supportsKit(ProjectExplorer::Kit *k, QString *errorMessage) const { Id deviceType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(k); if (deviceType != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) { if (errorMessage) *errorMessage = tr("Device type is not desktop."); return false; } QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k); if (!version) { if (errorMessage) *errorMessage = tr("No Qt version set in kit."); return false; } #if 0 if (version->qtVersion() < QtSupport::QtVersionNumber(4, 7, 0)) { if (errorMessage) *errorMessage = tr("Qt version is too old."); return false; } if (version->qtVersion() < QtSupport::QtVersionNumber(5, 0, 0) && defaultImport() == QtQuick2Import) { if (errorMessage) *errorMessage = tr("Qt version is too old."); return false; } #endif if (!GoToolChainKitInformation::toolChain(k)) { if (errorMessage) *errorMessage = tr("No Go toolchain is set in the Kit."); return false; } return true; } ProjectExplorer::ProjectNode *GoProject::rootProjectNode() const { return m_rootNode; } QStringList GoProject::files(FilesMode) const { return files(); } QString GoProject::applicationNames() const { QStringList apps; foreach(const GoBaseTargetItem* t,buildTargets()) { if(qobject_cast(t)) apps.append(t->name()); } return apps.join(QStringLiteral(" ")); } bool GoProject::fromMap(const QVariantMap &map) { if (!Project::fromMap(map)) return false; // refresh first - project information is used e.g. to decide the default RC's refresh(Everything); // addedTarget calls updateEnabled on the runconfigurations // which needs to happen after refresh foreach (Target *t, targets()) addedTarget(t); connect(this, SIGNAL(addedTarget(ProjectExplorer::Target*)), this, SLOT(addedTarget(ProjectExplorer::Target*))); connect(this, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)), this, SLOT(onActiveTargetChanged(ProjectExplorer::Target*))); // make sure we get updates on kit changes m_activeTarget = activeTarget(); if (m_activeTarget) connect(m_activeTarget, SIGNAL(kitChanged()), this, SLOT(onKitChanged())); return true; } } qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/filefilteritems.cpp0000644000015300001610000002372212562573357026067 0ustar pbuserpbgroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "filefilteritems.h" #include #include #include #include #include namespace GoLang { FileFilterBaseItem::FileFilterBaseItem(QObject *parent) : GoProjectContentItem(parent), m_recurse(RecurseDefault), m_dirWatcher(0) { m_updateFileListTimer.setSingleShot(true); m_updateFileListTimer.setInterval(50); connect(&m_updateFileListTimer, SIGNAL(timeout()), this, SLOT(updateFileListNow())); } Utils::FileSystemWatcher *FileFilterBaseItem::dirWatcher() { if (!m_dirWatcher) { m_dirWatcher = new Utils::FileSystemWatcher(1, this); // Separate id, might exceed OS limits. m_dirWatcher->setObjectName(QLatin1String("FileFilterBaseItemWatcher")); connect(m_dirWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(updateFileList())); } return m_dirWatcher; } QStringList FileFilterBaseItem::watchedDirectories() const { return m_dirWatcher ? m_dirWatcher->directories() : QStringList(); } QString FileFilterBaseItem::directory() const { return m_rootDir; } void FileFilterBaseItem::setDirectory(const QString &dirPath) { if (m_rootDir == dirPath) return; m_rootDir = dirPath; emit directoryChanged(); updateFileList(); } void FileFilterBaseItem::setDefaultDirectory(const QString &dirPath) { if (m_defaultDir == dirPath) return; m_defaultDir = dirPath; updateFileListNow(); } QString FileFilterBaseItem::filter() const { return m_filter; } void FileFilterBaseItem::setFilter(const QString &filter) { if (filter == m_filter) return; m_filter = filter; m_regExpList.clear(); m_fileSuffixes.clear(); foreach (const QString &pattern, filter.split(QLatin1Char(';'))) { if (pattern.isEmpty()) continue; // decide if it's a canonical pattern like *.x if (pattern.startsWith(QLatin1String("*."))) { const QString suffix = pattern.right(pattern.size() - 1); if (!suffix.contains(QLatin1Char('*')) && !suffix.contains(QLatin1Char('?')) && !suffix.contains(QLatin1Char('['))) { m_fileSuffixes << suffix; continue; } } m_regExpList << QRegExp(pattern, Qt::CaseInsensitive, QRegExp::Wildcard); } updateFileList(); } bool FileFilterBaseItem::recursive() const { bool recursive; if (m_recurse == Recurse) { recursive = true; } else if (m_recurse == DoNotRecurse) { recursive = false; } else { // RecurseDefault if (m_explicitFiles.isEmpty()) recursive = true; else recursive = false; } return recursive; } void FileFilterBaseItem::setRecursive(bool recurse) { bool oldRecursive = recursive(); if (recurse) m_recurse = Recurse; else m_recurse = DoNotRecurse; if (recurse != oldRecursive) updateFileList(); } QStringList FileFilterBaseItem::pathsProperty() const { return m_explicitFiles; } void FileFilterBaseItem::setPathsProperty(const QStringList &path) { m_explicitFiles = path; updateFileList(); } QStringList FileFilterBaseItem::files() const { return m_files.toList(); } /** Check whether filter matches a file path - regardless whether the file already exists or not. @param filePath: absolute file path */ bool FileFilterBaseItem::matchesFile(const QString &filePath) const { foreach (const QString &explicitFile, m_explicitFiles) { if (absolutePath(explicitFile) == filePath) return true; } const QString &fileName = QFileInfo(filePath).fileName(); if (!fileMatches(fileName)) return false; const QDir fileDir = QFileInfo(filePath).absoluteDir(); foreach (const QString &watchedDirectory, watchedDirectories()) { if (QDir(watchedDirectory) == fileDir) return true; } return false; } QString FileFilterBaseItem::absolutePath(const QString &path) const { if (QFileInfo(path).isAbsolute()) return path; return QDir(absoluteDir()).absoluteFilePath(path); } QString FileFilterBaseItem::absoluteDir() const { QString absoluteDir; if (QFileInfo(m_rootDir).isAbsolute()) absoluteDir = m_rootDir; else if (!m_defaultDir.isEmpty()) absoluteDir = m_defaultDir + QLatin1Char('/') + m_rootDir; return QDir::cleanPath(absoluteDir); } void FileFilterBaseItem::updateFileList() { if (!m_updateFileListTimer.isActive()) m_updateFileListTimer.start(); } void FileFilterBaseItem::updateFileListNow() { if (m_updateFileListTimer.isActive()) m_updateFileListTimer.stop(); const QString projectDir = absoluteDir(); if (projectDir.isEmpty()) return; QSet dirsToBeWatched; QSet newFiles; foreach (const QString &explicitPath, m_explicitFiles) { newFiles << absolutePath(explicitPath); } if ((!m_fileSuffixes.isEmpty() || !m_regExpList.isEmpty()) && m_explicitFiles.isEmpty()) newFiles += filesInSubTree(QDir(m_defaultDir), QDir(projectDir), &dirsToBeWatched); if (newFiles != m_files) { QSet addedFiles = newFiles; QSet removedFiles = m_files; QSet unchanged = newFiles; unchanged.intersect(m_files); addedFiles.subtract(unchanged); removedFiles.subtract(unchanged); m_files = newFiles; emit filesChanged(addedFiles, removedFiles); } // update watched directories const QSet oldDirs = watchedDirectories().toSet(); const QSet unwatchDirs = oldDirs - dirsToBeWatched; const QSet watchDirs = dirsToBeWatched - oldDirs; if (!unwatchDirs.isEmpty()) { QTC_ASSERT(m_dirWatcher, return); m_dirWatcher->removeDirectories(unwatchDirs.toList()); } if (!watchDirs.isEmpty()) dirWatcher()->addDirectories(watchDirs.toList(), Utils::FileSystemWatcher::WatchAllChanges); } bool FileFilterBaseItem::fileMatches(const QString &fileName) const { foreach (const QString &suffix, m_fileSuffixes) { if (fileName.endsWith(suffix, Qt::CaseInsensitive)) return true; } foreach (QRegExp filter, m_regExpList) { if (filter.exactMatch(fileName)) return true; } return false; } QSet FileFilterBaseItem::filesInSubTree(const QDir &rootDir, const QDir &dir, QSet *parsedDirs) { QSet fileSet; if (parsedDirs) parsedDirs->insert(dir.absolutePath()); foreach (const QFileInfo &file, dir.entryInfoList(QDir::Files)) { const QString fileName = file.fileName(); if (fileMatches(fileName)) fileSet.insert(file.absoluteFilePath()); } if (recursive()) { foreach (const QFileInfo &subDir, dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) { fileSet += filesInSubTree(rootDir, QDir(subDir.absoluteFilePath()), parsedDirs); } } return fileSet; } QmlFileFilterItem::QmlFileFilterItem(QObject *parent) : FileFilterBaseItem(parent) { setFilter(QLatin1String("*.qml")); } GoFileFilterItem::GoFileFilterItem(QObject *parent) : FileFilterBaseItem(parent) { setFilter(QLatin1String("*.go")); } JsFileFilterItem::JsFileFilterItem(QObject *parent) : FileFilterBaseItem(parent) { setFilter(QLatin1String("*.js")); } void JsFileFilterItem::setFilter(const QString &filter) { FileFilterBaseItem::setFilter(filter); emit filterChanged(); } ImageFileFilterItem::ImageFileFilterItem(QObject *parent) : FileFilterBaseItem(parent) { QString filter; // supported image formats according to QList extensions = QImageReader::supportedImageFormats(); foreach (const QByteArray &extension, extensions) { filter.append(QString::fromLatin1("*.%1;").arg(QString::fromLatin1(extension))); } setFilter(filter); } void ImageFileFilterItem::setFilter(const QString &filter) { FileFilterBaseItem::setFilter(filter); emit filterChanged(); } CssFileFilterItem::CssFileFilterItem(QObject *parent) : FileFilterBaseItem(parent) { setFilter(QLatin1String("*.css")); } void CssFileFilterItem::setFilter(const QString &filter) { FileFilterBaseItem::setFilter(filter); emit filterChanged(); } OtherFileFilterItem::OtherFileFilterItem(QObject *parent) : FileFilterBaseItem(parent) { } void OtherFileFilterItem::setFilter(const QString &filter) { FileFilterBaseItem::setFilter(filter); emit filterChanged(); } } // namespace QmlProjectManager qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/golangplugin.h0000644000015300001610000000120712562573357025025 0ustar pbuserpbgroup00000000000000#ifndef GOLANG_PLUGIN_H #define GOLANG_PLUGIN_H #include "golang_global.h" #include namespace GoLang { namespace Internal { class GoLangPlugin : public ExtensionSystem::IPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "GoLang.json") public: GoLangPlugin(); ~GoLangPlugin(); bool initialize(const QStringList &arguments, QString *errorString) override; void extensionsInitialized() override; ShutdownFlag aboutToShutdown() override; private slots: void restoreToolChains(); }; } // namespace Internal } // namespace Go #endif // GOLANG_PLUGIN_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/goprojectnode.h0000644000015300001610000000612612562573362025202 0ustar pbuserpbgroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Author: Juhapekka Piiroinen */ #ifndef GOPROJECTNODE_H #define GOPROJECTNODE_H #include #include "goproject.h" #include "goprojectmanager.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace GoLang { class GoProject; namespace Internal { class GoProjectNode : public ProjectExplorer::ProjectNode { public: GoProjectNode(GoProject *project, Core::IDocument *projectFile); Core::IDocument *projectFile() const; QString projectFilePath() const; virtual QList supportedActions(Node *node) const override; virtual bool canAddSubProject(const QString &proFilePath) const override; virtual bool addSubProjects(const QStringList &proFilePaths) override; virtual bool removeSubProjects(const QStringList &proFilePaths) override; virtual bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0) override; virtual bool removeFiles(const QStringList &filePaths, QStringList *notRemoved = 0) override; virtual bool deleteFiles(const QStringList &filePaths) override; virtual bool renameFile(const QString &filePath, const QString &newFilePath) override; void refresh(); private: FolderNode *findOrCreateFolderByName(const QString &filePath, ProjectExplorer::VirtualFolderNode* parent); FolderNode *findOrCreateFolderByName(const QStringList &components, int end, ProjectExplorer::VirtualFolderNode* virtualRoot); private: GoProject *m_project; Core::IDocument *m_projectFile; QHash m_folderByName; }; } } #endif // GOPROJECTNODE_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/filefilteritems.h0000644000015300001610000001216412562573357025532 0ustar pbuserpbgroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef FILEFILTERITEMS_H #define FILEFILTERITEMS_H #include "goprojectitem.h" #include #include #include QT_FORWARD_DECLARE_CLASS(QDir) namespace Utils { class FileSystemWatcher; } namespace GoLang { class FileFilterBaseItem : public GoProjectContentItem { Q_OBJECT Q_PROPERTY(QString directory READ directory WRITE setDirectory NOTIFY directoryChanged) Q_PROPERTY(bool recursive READ recursive WRITE setRecursive NOTIFY recursiveChanged) Q_PROPERTY(QStringList paths READ pathsProperty WRITE setPathsProperty) Q_PROPERTY(QStringList files READ files NOTIFY filesChanged DESIGNABLE false) public: FileFilterBaseItem(QObject *parent = 0); QString directory() const; void setDirectory(const QString &directoryPath); void setDefaultDirectory(const QString &directoryPath); QString filter() const; void setFilter(const QString &filter); bool recursive() const; void setRecursive(bool recursive); QStringList pathsProperty() const; void setPathsProperty(const QStringList &paths); virtual QStringList files() const; bool matchesFile(const QString &filePath) const; signals: void directoryChanged(); void recursiveChanged(); void pathsChanged(); void filesChanged(const QSet &added, const QSet &removed); private slots: void updateFileList(); void updateFileListNow(); private: QString absolutePath(const QString &path) const; QString absoluteDir() const; bool fileMatches(const QString &fileName) const; QSet filesInSubTree(const QDir &rootDir, const QDir &dir, QSet *parsedDirs = 0); Utils::FileSystemWatcher *dirWatcher(); QStringList watchedDirectories() const; QString m_rootDir; QString m_defaultDir; QString m_filter; // simple "*.png" patterns are stored in m_fileSuffixes, otherwise store in m_regExpList QList m_fileSuffixes; QList m_regExpList; enum RecursiveOption { Recurse, DoNotRecurse, RecurseDefault // not set explicitly }; RecursiveOption m_recurse; QStringList m_explicitFiles; QSet m_files; Utils::FileSystemWatcher *m_dirWatcher; QTimer m_updateFileListTimer; friend class ProjectItem; }; class QmlFileFilterItem : public FileFilterBaseItem { Q_OBJECT public: QmlFileFilterItem(QObject *parent = 0); }; class GoFileFilterItem : public FileFilterBaseItem { Q_OBJECT public: GoFileFilterItem(QObject *parent = 0); }; class JsFileFilterItem : public FileFilterBaseItem { Q_OBJECT Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged) void setFilter(const QString &filter); signals: void filterChanged(); public: JsFileFilterItem(QObject *parent = 0); }; class ImageFileFilterItem : public FileFilterBaseItem { Q_OBJECT Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged) void setFilter(const QString &filter); signals: void filterChanged(); public: ImageFileFilterItem(QObject *parent = 0); }; class CssFileFilterItem : public FileFilterBaseItem { Q_OBJECT Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged) void setFilter(const QString &filter); signals: void filterChanged(); public: CssFileFilterItem(QObject *parent = 0); }; class OtherFileFilterItem : public FileFilterBaseItem { Q_OBJECT Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged) void setFilter(const QString &filter); signals: void filterChanged(); public: OtherFileFilterItem(QObject *parent = 0); }; } // namespace QmlProjectManager #endif // FILEFILTERITEMS_HPROJECTITEM_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/goprojectitem.h0000644000015300001610000000741512562573357025221 0ustar pbuserpbgroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef QMLPROJECTITEM_H #define QMLPROJECTITEM_H #include #include #include namespace GoLang { class GoProjectContentItem : public QObject { // base class for all elements that should be direct children of Project element Q_OBJECT public: GoProjectContentItem(QObject *parent = 0) : QObject(parent) {} }; class GoBaseTargetItemPrivate; class GoBaseTargetItem : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(GoBaseTargetItem) Q_PROPERTY(QString sourceDirectory READ sourceDirectory NOTIFY sourceDirectoryChanged) Q_PROPERTY(QStringList importPaths READ importPaths WRITE setImportPaths NOTIFY importPathsChanged) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) public: GoBaseTargetItem(QObject *parent = 0); ~GoBaseTargetItem(); QString sourceDirectory() const; void setSourceDirectory(const QString &directoryPath); QStringList importPaths() const; void setImportPaths(const QStringList &paths); QStringList files() const; bool matchesFile(const QString &filePath) const; QString name() const; void setName(const QString &name); void appendContent(GoProjectContentItem* contentItem); signals: void qmlFilesChanged(const QSet &, const QSet &); void sourceDirectoryChanged(); void importPathsChanged(); void nameChanged(); protected: GoBaseTargetItemPrivate *d_ptr; }; class GoApplicationItem : public GoBaseTargetItem { Q_OBJECT public: GoApplicationItem(QObject *parent = 0); ~GoApplicationItem(); }; class GoPackageItem : public GoBaseTargetItem { Q_OBJECT public: GoPackageItem(QObject *parent = 0); ~GoPackageItem(); }; class GoProjectItem : public QObject { Q_OBJECT public: GoProjectItem(QObject *parent = 0); void appendTarget(GoBaseTargetItem* contentItem); QList commands () const; QStringList files() const; bool matchesFile(const QString &filePath) const; QString sourceDirectory() const; void setSourceDirectory(const QString &directoryPath); signals: void filesChanged(const QSet &, const QSet &); void sourceDirectoryChanged(); void importPathsChanged(); private: QList m_content; QString m_sourceDir; }; } // namespace QmlProjectManager #endif // QMLPROJECTITEM_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/toolchainmanager.h0000644000015300001610000000613412562573357025656 0ustar pbuserpbgroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2014 Canonical Ltd. ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef GOLANG_TOOLCHAINMANAGER_H #define GOLANG_TOOLCHAINMANAGER_H #include #include #include namespace Utils { class FileName; } namespace ProjectExplorer { class Abi; } namespace GoLang { class ToolChain; namespace Internal { class GoLangPlugin; } // -------------------------------------------------------------------------- // ToolChainManager // -------------------------------------------------------------------------- class ToolChainManager : public QObject { Q_OBJECT public: static QObject *instance(); ~ToolChainManager(); static QList toolChains(); static QList findToolChains(const ProjectExplorer::Abi &abi); static ToolChain *findToolChain(const QString &id); static bool isLoaded(); static bool registerToolChain(ToolChain *tc); static void deregisterToolChain(ToolChain *tc); public slots: void saveToolChains(); signals: void toolChainAdded(GoLang::ToolChain *); // Tool chain is still valid when this call happens! void toolChainRemoved(GoLang::ToolChain *); // Tool chain was updated. void toolChainUpdated(GoLang::ToolChain *); // Something changed. void toolChainsChanged(); // void toolChainsLoaded(); private: explicit ToolChainManager(QObject *parent = 0); // Make sure the this is only called after all // Tool chain Factories are registered! static void restoreToolChains(); static void notifyAboutUpdate(GoLang::ToolChain *); friend class Internal::GoLangPlugin; // for constructor friend class ToolChain; }; } // namespace GoLang #endif // GOLANG_TOOLCHAINMANAGER_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/GoProjectManager.mimetypes.xml0000644000015300001610000000043712562573357030116 0ustar pbuserpbgroup00000000000000 Go Project file qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/goapplicationwizard.cpp0000644000015300001610000001033212562573362026737 0ustar pbuserpbgroup00000000000000#include "goapplicationwizard.h" #include "gokitinformation.h" #include "goproject.h" #include "goprojectmanager.h" #include #include #include #include #include #include #include #include #include #include #include #include #include namespace GoLang { using namespace Internal; GoApplicationWizard::GoApplicationWizard() { } Core::BaseFileWizard *GoApplicationWizard::create(QWidget *parent, const Core::WizardDialogParameters &wizardDialogParameters) const { QTC_ASSERT(!parameters().isNull(), return 0); GoApplicationWizardDialog *projectDialog = new GoApplicationWizardDialog(this, parent, wizardDialogParameters); projectDialog->addTargetSetupPage(1); initProjectWizardDialog(projectDialog, wizardDialogParameters.defaultPath(), projectDialog->extensionPages()); projectDialog->setIntroDescription(tr("This wizard generates a Go Application project.")); return projectDialog; } bool GoApplicationWizard::postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage) const { const GoApplicationWizardDialog *dialog = qobject_cast(w); // Generate user settings foreach (const Core::GeneratedFile &file, l) if (file.attributes() & Core::GeneratedFile::OpenProjectAttribute) { dialog->writeUserFile(file.path()); break; } // Post-Generate: Open the projects/editors return ProjectExplorer::CustomProjectWizard::postGenerateOpen(l ,errorMessage); } GoApplicationWizardDialog::GoApplicationWizardDialog(const Core::BaseFileWizardFactory *factory, QWidget *parent, const Core::WizardDialogParameters ¶meters) : ProjectExplorer::BaseProjectWizardDialog(factory, parent, parameters) , m_targetSetupPage(0) { init(); } GoApplicationWizardDialog::~GoApplicationWizardDialog() { if (m_targetSetupPage && !m_targetSetupPage->parent()) delete m_targetSetupPage; } bool GoApplicationWizardDialog::writeUserFile(const QString &projectFileName) const { if (!m_targetSetupPage) return false; Internal::Manager *manager = ExtensionSystem::PluginManager::getObject(); Q_ASSERT(manager); GoProject *pro = new GoProject(manager, projectFileName); bool success = m_targetSetupPage->setupProject(pro); if (success) pro->saveSettings(); delete pro; return success; } void GoApplicationWizardDialog::init() { connect(this, SIGNAL(projectParametersChanged(QString,QString)), this, SLOT(generateProfileName(QString,QString))); } int GoApplicationWizardDialog::addTargetSetupPage(int id) { m_targetSetupPage = new ProjectExplorer::TargetSetupPage; const QString platform = selectedPlatform(); //prefer Qt Desktop or Platform Kit Core::FeatureSet features = Core::FeatureSet(QtSupport::Constants::FEATURE_DESKTOP); if (platform.isEmpty()) m_targetSetupPage->setPreferredKitMatcher(QtSupport::QtKitInformation::qtVersionMatcher(features)); else m_targetSetupPage->setPreferredKitMatcher(QtSupport::QtKitInformation::platformMatcher(platform)); //make sure only Go compatible Kits are shown m_targetSetupPage->setRequiredKitMatcher(GoToolChainKitInformation::kitMatcher()); resize(900, 450); if (id >= 0) setPage(id, m_targetSetupPage); else id = addPage(m_targetSetupPage); wizardProgress()->item(id)->setTitle(tr("Kits")); return id; } QList GoApplicationWizardDialog::selectedKits() const { if(m_targetSetupPage) return m_targetSetupPage->selectedKits(); return QList(); } void GoApplicationWizardDialog::generateProfileName(const QString &name, const QString &path) { if (!m_targetSetupPage) return; const QString proFile = QDir::cleanPath(path + QLatin1Char('/') + name + QLatin1Char('/') + name + QLatin1String(".goproject")); m_targetSetupPage->setProjectPath(proFile); } } // namespace GoLang qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/gotoolchain.h0000644000015300001610000000506412562573357024652 0ustar pbuserpbgroup00000000000000#ifndef GOLANG_INTERNAL_GOTOOLCHAIN_H #define GOLANG_INTERNAL_GOTOOLCHAIN_H #include "toolchain.h" namespace GoLang { namespace Internal { class GoToolChain : public ToolChain { public: GoToolChain(ToolChain::Detection detect); void setCompilerCommand(const Utils::FileName &path, const Utils::FileName &goRoot); QString version() const; void setTargetAbi(const ProjectExplorer::Abi &abi); QList supportedAbis () const; virtual QString defaultDisplayName() const; virtual Utils::FileName goRoot() const; // ToolChain interface virtual QString type() const override; virtual QString typeDisplayName() const override; virtual ProjectExplorer::Abi targetAbi() const override; virtual bool isValid() const override; virtual QList systemGoPaths() const override; virtual void addToEnvironment(Utils::Environment &env) const override; virtual Utils::FileName compilerCommand() const override; virtual ProjectExplorer::IOutputParser *outputParser() const override; virtual ToolChainConfigWidget *configurationWidget() override; virtual bool canClone() const override; virtual ToolChain *clone() const override; virtual QVariantMap toMap() const override; virtual QList validateKit(const ProjectExplorer::Kit *k) const override; static void addCommandPathToEnvironment(const Utils::FileName &command, Utils::Environment &env); static QString toString(ProjectExplorer::Abi::Architecture arch, int width); protected: GoToolChain(const GoToolChain &other); virtual bool fromMap(const QVariantMap &data) override; virtual QList detectSupportedAbis() const; void updateSupportedAbis() const; private: Utils::FileName m_compilerCommand; Utils::FileName m_goRoot; ProjectExplorer::Abi m_targetAbi; mutable QList m_headerPaths; mutable QList m_supportedAbis; friend class GoToolChainFactory; }; class GoToolChainFactory : public ToolChainFactory { Q_OBJECT public: GoToolChainFactory (); virtual QList autoDetect() override; virtual bool canCreate() override; virtual GoLang::ToolChain *create() override; virtual bool canRestore(const QVariantMap &data) override; virtual GoLang::ToolChain *restore(const QVariantMap &data) override; protected: virtual GoToolChain *createToolChain(bool autoDetect); }; } // namespace Internal } // namespace GoLang #endif // GOLANG_INTERNAL_GOTOOLCHAIN_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/gorunconfigurationfactory.h0000644000015300001610000000247012562573362027650 0ustar pbuserpbgroup00000000000000#ifndef GOLANG_INTERNAL_GORUNCONFIGURATIONFACTORY_H #define GOLANG_INTERNAL_GORUNCONFIGURATIONFACTORY_H #include namespace GoLang { namespace Internal { class GoRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory { public: GoRunConfigurationFactory(QObject *parent = 0); QList availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode = UserCreate) const override; QString displayNameForId(const Core::Id id) const override; bool canHandle(ProjectExplorer::Target *parent) const; bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const override; ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent, const QVariantMap &map) override; bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *product) const override; ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) override; bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const override; ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id) override; }; } // namespace Internal } // namespace GoLang #endif // GOLANG_INTERNAL_GORUNCONFIGURATIONFACTORY_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/goproject.h0000644000015300001610000001056612562573362024337 0ustar pbuserpbgroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Author: Juhapekka Piiroinen */ #ifndef GOLANGPROJECT_H #define GOLANGPROJECT_H #include "goprojectmanager.h" #include "goprojectfile.h" #include "goprojectnode.h" #include "golangconstants.h" #include "goprojectitem.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace GoLang { class GoProjectItem; namespace Internal { class Manager; class GoProjectFile; class GoProjectNode; } // namespace Internal class GoProject : public ProjectExplorer::Project { Q_OBJECT friend class Internal::GoProjectNode; public: GoProject(Internal::Manager *manager, const QString &filename); virtual ~GoProject(); QString filesFileName() const; QString displayName() const override; Core::IDocument *document() const override; ProjectExplorer::IProjectManager *projectManager() const override; bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage) const override; ProjectExplorer::ProjectNode *rootProjectNode() const override; QStringList files(FilesMode fileMode) const override; Q_INVOKABLE QString applicationNames () const; bool validProjectFile() const; enum RefreshOption { ProjectFile = 0x01, Files = 0x02, Configuration = 0x04, Everything = ProjectFile | Files | Configuration }; Q_DECLARE_FLAGS(RefreshOptions,RefreshOption) void refresh(RefreshOptions options); QDir projectDir() const; QStringList files() const; QStringList customImportPaths() const; bool addFiles(const QStringList &filePaths); void refreshProjectFile(); enum QmlImport { UnknownImport, QtQuick1Import, QtQuick2Import }; QmlImport defaultImport() const; QList buildTargets() const; // Project interface virtual bool requiresTargetPanel() const override; virtual bool needsConfiguration() const override; private slots: void refreshFiles(const QSet &added, const QSet &removed); void addedTarget(ProjectExplorer::Target *target); void onActiveTargetChanged(ProjectExplorer::Target *target); void onKitChanged(); void addedRunConfiguration(ProjectExplorer::RunConfiguration *); protected: bool fromMap(const QVariantMap &map); void updateConfigurations(ProjectExplorer::Target *t); void updateConfigurations(); // Project interface virtual bool setupTarget(ProjectExplorer::Target *t) override; private: // plain format void parseProject(RefreshOptions options); Internal::Manager *m_manager; QString m_fileName; Internal::GoProjectFile *m_file; QString m_projectName; QmlImport m_defaultImport; QmlJS::ModelManagerInterface *m_modelManager; ProjectExplorer::Target *m_activeTarget; // plain format QStringList m_files; QPointer m_projectItem; Internal::GoProjectNode *m_rootNode; }; } #endif // GOLANGPROJECT_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/gobuildconfiguration.h0000644000015300001610000001253112562573357026556 0ustar pbuserpbgroup00000000000000#ifndef GOLANG_INTERNAL_GOBUILDCONFIGURATION_H #define GOLANG_INTERNAL_GOBUILDCONFIGURATION_H #include #include #include #include #include namespace GoLang { class GoProject; class GoBuildConfiguration : public ProjectExplorer::BuildConfiguration { Q_OBJECT public: GoBuildConfiguration(ProjectExplorer::Target *target); GoBuildConfiguration(ProjectExplorer::Target *target, GoBuildConfiguration *other); // BuildConfiguration interface virtual ProjectExplorer::NamedWidget *createConfigWidget() override; virtual QList createSubConfigWidgets() override; virtual bool isEnabled() const override; virtual QString disabledReason() const override; virtual BuildType buildType() const override; protected: virtual void setBuildDirectory(const Utils::FileName &dir) override; // ProjectConfiguration interface public: virtual bool fromMap(const QVariantMap &map) override; virtual QVariantMap toMap() const override; friend class GoBuildConfigurationFactory; }; class GoBuildConfigurationFactory : public ProjectExplorer::IBuildConfigurationFactory { Q_OBJECT public: GoBuildConfigurationFactory(QObject *parent = 0); ~GoBuildConfigurationFactory(); // IBuildConfigurationFactory interface virtual int priority(const ProjectExplorer::Target *parent) const override; virtual QList availableBuilds(const ProjectExplorer::Target *parent) const override; virtual int priority(const ProjectExplorer::Kit *k, const QString &projectPath) const override; virtual QList availableSetups(const ProjectExplorer::Kit *k, const QString &projectPath) const override; virtual GoBuildConfiguration *create(ProjectExplorer::Target *parent, const ProjectExplorer::BuildInfo *info) const override; virtual bool canRestore(const ProjectExplorer::Target *parent, const QVariantMap &map) const override; virtual GoBuildConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map); virtual bool canClone(const ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *product) const override; virtual GoBuildConfiguration*clone(ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *product) override; private: virtual QList availableBuilds(const ProjectExplorer::Kit *kit, const QString &projectFilePath) const; bool canHandle(const ProjectExplorer::Target *t) const; }; class GoBuildStepFactory : public ProjectExplorer::IBuildStepFactory { Q_OBJECT public: // IBuildStepFactory interface virtual QList availableCreationIds(ProjectExplorer::BuildStepList *parent) const override; virtual QString displayNameForId(const Core::Id id) const override; virtual bool canCreate(ProjectExplorer::BuildStepList *parent, const Core::Id id) const override; virtual ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, const Core::Id id) override; virtual bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const override; virtual ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) override; virtual bool canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) const override; virtual ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) override; private: bool canHandle(const ProjectExplorer::Target *t) const; }; class GoBuildStep : public ProjectExplorer::BuildStep { Q_OBJECT public: enum State { Init, GoGet, GoBuild, Finished }; GoBuildStep(ProjectExplorer::BuildStepList *bsl); GoBuildStep(ProjectExplorer::BuildStepList *bsl, GoBuildStep *bs); ~GoBuildStep(); void setIsCleanStep (const bool set = true); bool isCleanStep () const; // BuildStep interface virtual bool init() override; virtual void run(QFutureInterface &fi) override; virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; virtual bool runInGuiThread() const override { return true; } virtual void cancel() override; // ProjectConfiguration interface virtual bool fromMap(const QVariantMap &map) override; virtual QVariantMap toMap() const override; GoProject *goProject () const; protected slots: void onProcessFinished (); void onProcessStdOut (); void onProcessStdErr (); void outputAdded(const QString &string, ProjectExplorer::BuildStep::OutputFormat format); protected: void startNextStep (); void handleFinished (bool result); void startProcess (const ProjectExplorer::ProcessParameters ¶ms); void stopProcess (); void setOutputParser (ProjectExplorer::IOutputParser *parser); bool processSucceeded () const; private: QList m_tasks; QFutureInterface *m_future; Utils::QtcProcess *m_process; ProjectExplorer::IOutputParser *m_outputParserChain; bool m_clean; State m_state; friend class GoBuildStepFactory; }; } // namespace GoLang #endif // GOLANG_INTERNAL_GOBUILDCONFIGURATION_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/gorunconfiguration.cpp0000644000015300001610000002056512562573362026620 0ustar pbuserpbgroup00000000000000#include "gorunconfiguration.h" #include "golangconstants.h" #include "goproject.h" #include "goprojectitem.h" #include #include #include #include #include #include #include #include #include #include #include #include namespace GoLang { const char USER_WORKING_DIRECTORY_KEYC[] = "GoLang.GoRunConfiguration.UserWorkingDirectory"; const char USE_TERMINAL_KEYC[] = "GoLang.GoRunConfiguration.UseTerminal"; const char COMMAND_KEYC[] = "GoLang.GoRunConfiguration.Command"; const char ARGUMENTS_KEYC[] = "GoLang.GoRunConfiguration.Arguments"; // Configuration widget GoRunConfigurationWidget::GoRunConfigurationWidget(GoRunConfiguration *goRC, QWidget *parent) : QWidget(parent), m_ignoreChange(false), m_goRc(goRC) { QFormLayout *fl = new QFormLayout(); fl->setMargin(0); fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); QLineEdit *argumentsLineEdit = new QLineEdit(); argumentsLineEdit->setText(goRC->commandLineArguments()); connect(argumentsLineEdit, SIGNAL(textChanged(QString)), this, SLOT(setArguments(QString))); fl->addRow(tr("Arguments:"), argumentsLineEdit); m_workingDirectoryEdit = new Utils::PathChooser(); m_workingDirectoryEdit->setExpectedKind(Utils::PathChooser::Directory); m_workingDirectoryEdit->setBaseDirectory(goRC->target()->project()->projectDirectory().toString()); m_workingDirectoryEdit->setPath(m_goRc->workingDirectory()); ProjectExplorer::EnvironmentAspect *aspect = goRC->extraAspect(); if (aspect) { connect(aspect, SIGNAL(environmentChanged()), this, SLOT(environmentWasChanged())); environmentWasChanged(); } m_workingDirectoryEdit->setPromptDialogTitle(tr("Select Working Directory")); QToolButton *resetButton = new QToolButton(); resetButton->setToolTip(tr("Reset to default")); resetButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_RESET))); QHBoxLayout *boxlayout = new QHBoxLayout(); boxlayout->addWidget(m_workingDirectoryEdit); boxlayout->addWidget(resetButton); fl->addRow(tr("Working directory:"), boxlayout); QCheckBox *runInTerminal = new QCheckBox; fl->addRow(tr("Run in Terminal"), runInTerminal); m_detailsContainer = new Utils::DetailsWidget(this); m_detailsContainer->setState(Utils::DetailsWidget::NoSummary); QWidget *m_details = new QWidget(m_detailsContainer); m_detailsContainer->setWidget(m_details); m_details->setLayout(fl); QVBoxLayout *vbx = new QVBoxLayout(this); vbx->setMargin(0); vbx->addWidget(m_detailsContainer); connect(m_workingDirectoryEdit, SIGNAL(changed(QString)), this, SLOT(setWorkingDirectory())); connect(resetButton, SIGNAL(clicked()), this, SLOT(resetWorkingDirectory())); connect(runInTerminal, SIGNAL(toggled(bool)), this, SLOT(runInTerminalToggled(bool))); connect(m_goRc, SIGNAL(workingDirectoryChanged()), this, SLOT(workingDirectoryChanged())); connect(m_goRc,SIGNAL(enabledChanged()),this,SLOT(onRcEnabledChanged())); onRcEnabledChanged(); } void GoRunConfigurationWidget::setWorkingDirectory() { if (m_ignoreChange) return; m_ignoreChange = true; m_goRc->setWorkingDirectory(m_workingDirectoryEdit->rawPath()); m_ignoreChange = false; } void GoRunConfigurationWidget::workingDirectoryChanged() { if (!m_ignoreChange) { m_ignoreChange = true; m_workingDirectoryEdit->setPath(m_goRc->workingDirectory()); m_ignoreChange = false; } } void GoRunConfigurationWidget::onRcEnabledChanged() { setEnabled(m_goRc->isEnabled()); } void GoRunConfigurationWidget::resetWorkingDirectory() { // This emits a signal connected to workingDirectoryChanged() // that sets the m_workingDirectoryEdit m_goRc->setWorkingDirectory(QString()); } void GoRunConfigurationWidget::runInTerminalToggled(bool toggled) { m_goRc->setRunMode(toggled ? ProjectExplorer::ApplicationLauncher::Console : ProjectExplorer::ApplicationLauncher::Gui); } void GoRunConfigurationWidget::environmentWasChanged() { ProjectExplorer::EnvironmentAspect *aspect = m_goRc->extraAspect(); QTC_ASSERT(aspect, return); m_workingDirectoryEdit->setEnvironment(aspect->environment()); } void GoRunConfigurationWidget::setArguments(const QString &args) { m_goRc->setCommandLineArguments(args); } GoRunConfiguration::GoRunConfiguration(ProjectExplorer::Target *t, const Core::Id &id) : LocalApplicationRunConfiguration(t,id), m_defaultWorkingDirectory(project()->projectDirectory().toString()), m_commandName(id.suffixAfter(Constants::GO_RUNCONFIG_ID)), m_runMode(ProjectExplorer::ApplicationLauncher::Gui) { setDefaultDisplayName(m_commandName); setDisplayName(m_commandName); addExtraAspect(new ProjectExplorer::LocalEnvironmentAspect(this)); } GoRunConfiguration::GoRunConfiguration(ProjectExplorer::Target *t, GoRunConfiguration *other) : LocalApplicationRunConfiguration(t,other), m_commandName(other->m_commandName), m_args(other->m_args) { } QString GoRunConfiguration::executable() const { foreach(const GoBaseTargetItem *t,project()->buildTargets()) { const GoApplicationItem *app = qobject_cast(t); if(t->name() == m_commandName) { return project()->projectDirectory().appendPath(QStringLiteral("bin")).appendPath(m_commandName).toString(); } } return QString(); } ProjectExplorer::ApplicationLauncher::Mode GoRunConfiguration::runMode() const { return m_runMode; } QString GoRunConfiguration::workingDirectory() const { QString wD = m_userWorkingDirectory.isEmpty() ? m_defaultWorkingDirectory : m_userWorkingDirectory; ProjectExplorer::EnvironmentAspect *aspect = extraAspect(); QTC_ASSERT(aspect, return QString()); return QDir::cleanPath(aspect->environment().expandVariables( macroExpander()->expand(wD))); } QString GoRunConfiguration::commandLineArguments() const { return m_args; } void GoRunConfiguration::addToBaseEnvironment(Utils::Environment &env) const { } QWidget *GoRunConfiguration::createConfigurationWidget() { return new GoRunConfigurationWidget(this); } bool GoRunConfiguration::fromMap(const QVariantMap &map) { if(!LocalApplicationRunConfiguration::fromMap(map)) return false; m_runMode = map.value(QLatin1String(USE_TERMINAL_KEYC)).toBool() ? ProjectExplorer::ApplicationLauncher::Console : ProjectExplorer::ApplicationLauncher::Gui; m_commandName = map.value(QLatin1String(COMMAND_KEYC)).toString(); m_args = map.value(QLatin1String(ARGUMENTS_KEYC)).toString(); setWorkingDirectory(map.value(QLatin1String(USER_WORKING_DIRECTORY_KEYC)).toString()); return true; } QVariantMap GoRunConfiguration::toMap() const { QVariantMap map(ProjectExplorer::LocalApplicationRunConfiguration::toMap()); if(map.isEmpty()) return map; map.insert(QLatin1String(USER_WORKING_DIRECTORY_KEYC), m_userWorkingDirectory); map.insert(QLatin1String(USE_TERMINAL_KEYC), m_runMode == ProjectExplorer::ApplicationLauncher::Console); map.insert(QLatin1String(COMMAND_KEYC), m_commandName); map.insert(QLatin1String(ARGUMENTS_KEYC), m_args); return map; } GoProject *GoRunConfiguration::project() const { GoProject *pro = qobject_cast(target()->project()); Q_ASSERT_X(pro,Q_FUNC_INFO,"Go Project can not be NULL"); return pro; } void GoRunConfiguration::setCommandName(const QString &cmdName) { m_commandName = cmdName; } void GoRunConfiguration::setWorkingDirectory(const QString &dir) { if( dir == workingDirectory() ) return; m_userWorkingDirectory = dir; emit workingDirectoryChanged(); } void GoRunConfiguration::setRunMode(ProjectExplorer::ApplicationLauncher::Mode mode) { if( mode == m_runMode ) return; m_runMode = mode; } void GoRunConfiguration::setCommandLineArguments(const QString &args) { m_args = args; } } // namespace GoLang qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/toolchainconfigwidget.cpp0000644000015300001610000000710112562573357027243 0ustar pbuserpbgroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "toolchainconfigwidget.h" #include "toolchain.h" #include #include #include #include #include namespace GoLang { ToolChainConfigWidget::ToolChainConfigWidget(ToolChain *tc) : m_toolChain(tc), m_errorLabel(0) { QTC_CHECK(tc); m_nameLineEdit = new QLineEdit(this); m_nameLineEdit->setText(tc->displayName()); m_mainLayout = new QFormLayout(this); m_mainLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); // for the Macs... m_mainLayout->addRow(tr("Name:"), m_nameLineEdit); connect(m_nameLineEdit, SIGNAL(textChanged(QString)), SIGNAL(dirty())); } void ToolChainConfigWidget::apply() { m_toolChain->setDisplayName(m_nameLineEdit->text()); applyImpl(); } void ToolChainConfigWidget::discard() { m_nameLineEdit->setText(m_toolChain->displayName()); discardImpl(); } bool ToolChainConfigWidget::isDirty() const { return m_nameLineEdit->text() != m_toolChain->displayName() || isDirtyImpl(); } ToolChain *ToolChainConfigWidget::toolChain() const { return m_toolChain; } void ToolChainConfigWidget::makeReadOnly() { m_nameLineEdit->setEnabled(false); makeReadOnlyImpl(); } void ToolChainConfigWidget::addErrorLabel() { if (!m_errorLabel) { m_errorLabel = new QLabel; m_errorLabel->setVisible(false); } m_mainLayout->addRow(m_errorLabel); } void ToolChainConfigWidget::setErrorMessage(const QString &m) { QTC_ASSERT(m_errorLabel, return); if (m.isEmpty()) { clearErrorMessage(); } else { m_errorLabel->setText(m); m_errorLabel->setStyleSheet(QLatin1String("background-color: \"red\"")); m_errorLabel->setVisible(true); } } void ToolChainConfigWidget::clearErrorMessage() { QTC_ASSERT(m_errorLabel, return); m_errorLabel->clear(); m_errorLabel->setStyleSheet(QString()); m_errorLabel->setVisible(false); } void ToolChainConfigWidget::applyImpl() { } void ToolChainConfigWidget::discardImpl() { } bool ToolChainConfigWidget::isDirtyImpl() const { return false; } void ToolChainConfigWidget::makeReadOnlyImpl() { } } // namespace GoLang qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/toolchainmanager.cpp0000644000015300001610000002453412562573357026215 0ustar pbuserpbgroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2014 Canonical Ltd. ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "toolchainmanager.h" #include "toolchain.h" #include #include #include #include #include #include #include #include #include static const char TOOLCHAIN_DATA_KEY[] = "GoToolChain."; static const char TOOLCHAIN_COUNT_KEY[] = "GoToolChain.Count"; static const char TOOLCHAIN_FILE_VERSION_KEY[] = "Version"; static const char TOOLCHAIN_FILENAME[] = "/qtcreator/gotoolchains.xml"; using namespace Utils; static FileName settingsFileName(const QString &path) { QFileInfo settingsLocation(Core::ICore::settings()->fileName()); return FileName::fromString(settingsLocation.absolutePath() + path); } namespace GoLang { namespace Internal { // -------------------------------------------------------------------------- // ToolChainManagerPrivate // -------------------------------------------------------------------------- class ToolChainManagerPrivate { public: ToolChainManagerPrivate() : m_writer(0) {} ~ToolChainManagerPrivate(); PersistentSettingsWriter *m_writer; QList m_toolChains; }; ToolChainManagerPrivate::~ToolChainManagerPrivate() { qDeleteAll(m_toolChains); m_toolChains.clear(); delete m_writer; } static ToolChainManager *m_instance = 0; static ToolChainManagerPrivate *d; } // namespace Internal using namespace Internal; // -------------------------------------------------------------------------- // ToolChainManager // -------------------------------------------------------------------------- ToolChainManager::ToolChainManager(QObject *parent) : QObject(parent) { Q_ASSERT(!m_instance); m_instance = this; d = new ToolChainManagerPrivate; connect(Core::ICore::instance(), SIGNAL(saveSettingsRequested()), this, SLOT(saveToolChains())); connect(this, SIGNAL(toolChainAdded(GoLang::ToolChain*)), this, SIGNAL(toolChainsChanged())); connect(this, SIGNAL(toolChainRemoved(GoLang::ToolChain*)), this, SIGNAL(toolChainsChanged())); connect(this, SIGNAL(toolChainUpdated(GoLang::ToolChain*)), this, SIGNAL(toolChainsChanged())); } ToolChainManager::~ToolChainManager() { delete d; m_instance = 0; } QObject *ToolChainManager::instance() { return m_instance; } static QList restoreFromFile(const FileName &fileName) { QList result; PersistentSettingsReader reader; if (!reader.load(fileName)) return result; QVariantMap data = reader.restoreValues(); // Check version: int version = data.value(QLatin1String(TOOLCHAIN_FILE_VERSION_KEY), 0).toInt(); if (version < 1) return result; QList factories = ExtensionSystem::PluginManager::getObjects(); int count = data.value(QLatin1String(TOOLCHAIN_COUNT_KEY), 0).toInt(); for (int i = 0; i < count; ++i) { const QString key = QString::fromLatin1(TOOLCHAIN_DATA_KEY) + QString::number(i); if (!data.contains(key)) break; const QVariantMap tcMap = data.value(key).toMap(); bool restored = false; foreach (ToolChainFactory *f, factories) { if (f->canRestore(tcMap)) { if (ToolChain *tc = f->restore(tcMap)) { result.append(tc); restored = true; break; } } } if (!restored) qWarning("Warning: Unable to restore compiler '%s' stored in %s.", qPrintable(ToolChainFactory::idFromMap(tcMap)), qPrintable(fileName.toUserOutput())); } return result; } void ToolChainManager::restoreToolChains() { QTC_ASSERT(!d->m_writer, return); d->m_writer = new PersistentSettingsWriter(settingsFileName(QLatin1String(TOOLCHAIN_FILENAME)), QLatin1String("QtCreatorGoToolChains")); QList tcsToRegister; QList tcsToCheck; // read all tool chains from SDK QFileInfo systemSettingsFile(Core::ICore::settings(QSettings::SystemScope)->fileName()); QList readTcs = restoreFromFile(FileName::fromString(systemSettingsFile.absolutePath() + QLatin1String(TOOLCHAIN_FILENAME))); // make sure we mark these as autodetected! foreach (ToolChain *tc, readTcs) tc->setDetection(ToolChain::AutoDetection); tcsToRegister = readTcs; // SDK TCs are always considered to be up-to-date, so no need to // recheck them. // read all tool chains from user file. FileName fileName = settingsFileName(QLatin1String(TOOLCHAIN_FILENAME)); readTcs = restoreFromFile(fileName); foreach (ToolChain *tc, readTcs) { if (tc->isAutoDetected()) tcsToCheck.append(tc); else tcsToRegister.append(tc); } readTcs.clear(); // Remove TCs configured by the SDK: foreach (ToolChain *tc, tcsToRegister) { for (int i = tcsToCheck.count() - 1; i >= 0; --i) { if (tcsToCheck.at(i)->id() == tc->id()) { delete tcsToCheck.at(i); tcsToCheck.removeAt(i); } } } // Then auto detect QList detectedTcs; QList factories = ExtensionSystem::PluginManager::getObjects(); foreach (ToolChainFactory *f, factories) detectedTcs.append(f->autoDetect()); // Find/update autodetected tool chains: ToolChain *toStore = 0; foreach (ToolChain *currentDetected, detectedTcs) { toStore = currentDetected; // Check whether we had this TC stored and prefer the old one with the old id, marked // as auto-detection. for (int i = 0; i < tcsToCheck.count(); ++i) { if (*(tcsToCheck.at(i)) == *currentDetected) { toStore = tcsToCheck.at(i); toStore->setDetection(ToolChain::AutoDetection); tcsToCheck.removeAt(i); delete currentDetected; break; } } tcsToRegister += toStore; } // Keep toolchains that were not rediscovered but are still executable and delete the rest foreach (ToolChain *tc, tcsToCheck) { if (!tc->isValid()) { qWarning() << QString::fromLatin1("ToolChain \"%1\" (%2) dropped since it is not valid") .arg(tc->displayName()).arg(tc->id()); delete tc; } else { tcsToRegister += tc; } } // Store manual tool chains foreach (ToolChain *tc, tcsToRegister) registerToolChain(tc); emit m_instance->toolChainsLoaded(); } void ToolChainManager::saveToolChains() { QVariantMap data; data.insert(QLatin1String(TOOLCHAIN_FILE_VERSION_KEY), 1); int count = 0; foreach (ToolChain *tc, d->m_toolChains) { if (tc->isValid()) { QVariantMap tmp = tc->toMap(); if (tmp.isEmpty()) continue; data.insert(QString::fromLatin1(TOOLCHAIN_DATA_KEY) + QString::number(count), tmp); ++count; } } data.insert(QLatin1String(TOOLCHAIN_COUNT_KEY), count); d->m_writer->save(data, Core::ICore::mainWindow()); // Do not save default debuggers! Those are set by the SDK! } QList ToolChainManager::toolChains() { return d->m_toolChains; } QList ToolChainManager::findToolChains(const ProjectExplorer::Abi &abi) { QList result; foreach (ToolChain *tc, d->m_toolChains) { ProjectExplorer::Abi targetAbi = tc->targetAbi(); if (targetAbi.isCompatibleWith(abi)) result.append(tc); } return result; } ToolChain *ToolChainManager::findToolChain(const QString &id) { if (id.isEmpty()) return 0; foreach (ToolChain *tc, d->m_toolChains) { if (tc->id() == id) return tc; } return 0; } bool ToolChainManager::isLoaded() { return d->m_writer; } void ToolChainManager::notifyAboutUpdate(ToolChain *tc) { if (!tc || !d->m_toolChains.contains(tc)) return; emit m_instance->toolChainUpdated(tc); } bool ToolChainManager::registerToolChain(ToolChain *tc) { QTC_ASSERT(d->m_writer, return false); if (!tc || d->m_toolChains.contains(tc)) return true; foreach (ToolChain *current, d->m_toolChains) { if (*tc == *current && !tc->isAutoDetected()) return false; QTC_ASSERT(current->id() != tc->id(), return false); } d->m_toolChains.append(tc); emit m_instance->toolChainAdded(tc); return true; } void ToolChainManager::deregisterToolChain(ToolChain *tc) { if (!tc || !d->m_toolChains.contains(tc)) return; d->m_toolChains.removeOne(tc); emit m_instance->toolChainRemoved(tc); delete tc; } } // namespace GoLang qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/goprojectfileformat.h0000644000015300001610000000352712562573357026413 0ustar pbuserpbgroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef QMLPROJECTFILEFORMAT_H #define QMLPROJECTFILEFORMAT_H #include #include namespace GoLang { class GoProjectItem; class GoProjectFileFormat { Q_DECLARE_TR_FUNCTIONS(QmlProjectManager::QmlProjectFileFormat) public: static GoProjectItem *parseProjectFile(const QString &fileName, QString *errorMessage = 0); }; } // namespace QmlProjectManager #endif // QMLPROJECTFILEFORMAT_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/GoLang.json.in0000644000015300001610000000066712562573362024642 0ustar pbuserpbgroup00000000000000{ \"Name\" : \"GoLang\", \"Version\" : \"$$QTCREATOR_VERSION\", \"CompatVersion\" : \"$$QTCREATOR_COMPAT_VERSION\", \"Vendor\" : \"Canonical\", \"Copyright\" : \"(C) Canonical Ltd.\", \"License\" : [\"LGPL\"], \"Category\" : \"Device Support\", \"Description\" : \"This plugin provides support for the Go programming language in QtCreator.\", \"Url\" : \"http://www.ubuntu.com\", $$dependencyList } qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/golang.pro0000644000015300001610000000220012562573357024151 0ustar pbuserpbgroup00000000000000include(../plugin.pri) DEFINES += GO_LIBRARY CONFIG += c++11 # Go files SOURCES += \ golangplugin.cpp \ goproject.cpp \ goprojectfile.cpp \ goprojectmanager.cpp \ goprojectnode.cpp \ filefilteritems.cpp \ goprojectfileformat.cpp \ goprojectitem.cpp \ toolchain.cpp \ toolchainmanager.cpp \ toolchainoptionspage.cpp \ toolchainconfigwidget.cpp \ gotoolchain.cpp \ gobuildconfiguration.cpp \ gokitinformation.cpp \ gorunconfigurationfactory.cpp \ gorunconfiguration.cpp \ goapplicationwizard.cpp HEADERS += \ golangplugin.h \ golangconstants.h \ golang_global.h \ goproject.h \ goprojectfile.h \ goprojectmanager.h \ goprojectnode.h \ filefilteritems.h \ goprojectfileformat.h \ goprojectitem.h \ toolchain.h \ toolchainmanager.h \ toolchainoptionspage.h \ toolchainconfigwidget.h \ gotoolchain.h \ gobuildconfiguration.h \ gokitinformation.h \ gorunconfigurationfactory.h \ gorunconfiguration.h \ goapplicationwizard.h OTHER_FILES += GoLang.pluginspec.in RESOURCES += \ golangplugin.qrc qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/goprojectfile.cpp0000644000015300001610000000402112562573362025517 0ustar pbuserpbgroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Author: Juhapekka Piiroinen */ #include "goprojectfile.h" using namespace GoLang::Internal; GoProjectFile::GoProjectFile(GoProject *parent, QString fileName) : Core::IDocument(parent), m_project(parent), m_fileName(fileName) { QTC_CHECK(m_project); QTC_CHECK(!fileName.isEmpty()); setFilePath(Utils::FileName::fromString(fileName)); setMimeType(QLatin1String(Constants::GO_PROJECT_MIMETYPE)); } bool GoProjectFile::save(QString *, const QString &, bool) { return false; } void GoProjectFile::rename(const QString &newName) { // Can't happen... Q_UNUSED(newName); Q_ASSERT(false); } QString GoProjectFile::fileName() const { return m_fileName; } QString GoProjectFile::defaultPath() const { return QString(); } QString GoProjectFile::suggestedFileName() const { return QString(); } bool GoProjectFile::isModified() const { return false; } bool GoProjectFile::isSaveAsAllowed() const { return false; } Core::IDocument::ReloadBehavior GoProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const { Q_UNUSED(state) Q_UNUSED(type) return BehaviorSilent; } bool GoProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType type) { Q_UNUSED(errorString) Q_UNUSED(flag) if (type == TypeContents) m_project->refreshProjectFile(); return true; } qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/goprojectmanager.cpp0000644000015300001610000000475612562573362026231 0ustar pbuserpbgroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Author: Juhapekka Piiroinen */ #include "goprojectmanager.h" #include "gokitinformation.h" #include #include using namespace GoLang::Internal; Manager::Manager() { QObject* sessionManager = ProjectExplorer::SessionManager::instance(); connect(sessionManager,SIGNAL(projectAdded(ProjectExplorer::Project*)),SLOT(onProjectAdded(ProjectExplorer::Project*))); } ProjectExplorer::Project* Manager::openProject(const QString &filePath, QString *errorString) { Utils::FileName fileName = Utils::FileName::fromString(filePath); QFileInfo fileInfo(filePath); foreach (ProjectExplorer::Project *pi, ProjectExplorer::SessionManager::projects()) { if (fileName == pi->document()->filePath()) { if (errorString) *errorString = tr("Failed opening project '%1': Project already open") .arg(QDir::toNativeSeparators(filePath)); return 0; } } if (fileInfo.isFile()) return new GoProject(this, filePath); *errorString = tr("Failed opening project '%1': Project file is not a file").arg(QDir::toNativeSeparators(filePath)); return 0; } void Manager::registerProject(GoProject *project) { m_projects.append(project); } void Manager::unregisterProject(GoProject *project) { m_projects.removeAll(project); } void *Manager::createKitMatcher() const { static ProjectExplorer::KitMatcher match = GoToolChainKitInformation::kitMatcher(); return reinterpret_cast(&match); } QString Manager::mimeType() const { qDebug()<projectManager()->mimeType(); qDebug() << mimeType; } qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/golang_global.h0000644000015300001610000000032712562573357025130 0ustar pbuserpbgroup00000000000000#ifndef GOLANG_GLOBAL_H #define GOLANG_GLOBAL_H #include #if defined(GO_LIBRARY) # define GOSHARED_EXPORT Q_DECL_EXPORT #else # define GOSHARED_EXPORT Q_DECL_IMPORT #endif #endif // GOLANG_GLOBAL_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/toolchain.h0000644000015300001610000000532212562573357024321 0ustar pbuserpbgroup00000000000000#ifndef GOLANG_INTERNAL_TOOLCHAIN_H #define GOLANG_INTERNAL_TOOLCHAIN_H #include "toolchain.h" #include #include #include #include namespace GoLang { namespace Internal { class GoLangPlugin; class ToolChainPrivate; } class ToolChainFactory; class ToolChainConfigWidget; class ToolChain { public: enum Detection { ManualDetection, AutoDetection, AutoDetectionFromSettings }; QString displayName() const; void setDisplayName(const QString &name); inline bool isAutoDetected() const { return detection() != ManualDetection; } ToolChain::Detection detection() const; QString id() const; virtual QString type() const = 0; virtual QString typeDisplayName() const = 0; virtual ProjectExplorer::Abi targetAbi() const = 0; virtual bool isValid() const = 0; virtual QList systemGoPaths( ) const = 0; virtual void addToEnvironment(Utils::Environment &env) const = 0; virtual Utils::FileName compilerCommand() const = 0; virtual ProjectExplorer::IOutputParser *outputParser() const = 0; virtual ToolChainConfigWidget *configurationWidget() = 0; virtual bool canClone() const; virtual ToolChain *clone() const = 0; virtual QVariantMap toMap() const; virtual QList validateKit(const ProjectExplorer::Kit *k) const; virtual bool operator ==(const ToolChain &tc) const; virtual ~ToolChain(); protected: explicit ToolChain(const QString &id, Detection d); explicit ToolChain(const ToolChain &other); virtual bool fromMap(const QVariantMap &data); void toolChainUpdated(); private: void setDetection(Detection detect); Internal::ToolChainPrivate *const d; friend class ToolChainManager; friend class ToolChainFactory; }; class ToolChainFactory : public QObject { Q_OBJECT public: Core::Id id() const { return m_id; } QString displayName() const { return m_displayName; } virtual QList autoDetect() = 0; virtual bool canCreate() = 0; virtual GoLang::ToolChain *create() = 0; virtual bool canRestore(const QVariantMap &data) = 0; virtual GoLang::ToolChain *restore(const QVariantMap &data) = 0; static QString idFromMap(const QVariantMap &data); static void idToMap(QVariantMap &data, const QString id); static void autoDetectionToMap(QVariantMap &data, bool detected); protected: void setId(Core::Id id) { m_id = id; } void setDisplayName(const QString &name) { m_displayName = name; } private: QString m_displayName; Core::Id m_id; }; } // namespace GoLang #endif // GOLANG_INTERNAL_TOOLCHAIN_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/gokitinformation.cpp0000644000015300001610000002265312562573362026261 0ustar pbuserpbgroup00000000000000#include "gokitinformation.h" #include "toolchain.h" #include "toolchainmanager.h" #include "golangconstants.h" #include #include #include #include #include #include #include #include namespace GoLang { // -------------------------------------------------------------------------- // ToolChainInformation: // -------------------------------------------------------------------------- GoToolChainKitInformation::GoToolChainKitInformation() { setObjectName(QLatin1String("GoToolChainInformation")); setId(GoToolChainKitInformation::id()); setPriority(30000); connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsLoaded()), this, SLOT(kitsWereLoaded())); } QVariant GoToolChainKitInformation::defaultValue(ProjectExplorer::Kit *k) const { Q_UNUSED(k); QList tcList = ToolChainManager::toolChains(); if (tcList.isEmpty()) return QString(); ProjectExplorer::ToolChain *gccTc = ProjectExplorer::ToolChainKitInformation::toolChain(k); if(!gccTc) return QString(); ProjectExplorer::Abi abi = gccTc->targetAbi(); foreach (ToolChain *tc, tcList) { if (tc->targetAbi() == abi) return tc->id(); } return QString(); } QList GoToolChainKitInformation::validate(const ProjectExplorer::Kit *k) const { QList result; const ToolChain* toolchain = toolChain(k); if (toolchain) { result << toolchain->validateKit(k); } return result; } void GoToolChainKitInformation::fix(ProjectExplorer::Kit *k) { QTC_ASSERT(ToolChainManager::isLoaded(), return); if (toolChain(k)) return; qWarning("No go tool chain set from kit \"%s\".", qPrintable(k->displayName())); QString defaultTc = defaultValue(k).toString(); setToolChain(k, (!defaultTc.isEmpty()) ? ToolChainManager::findToolChain(defaultTc) : 0 ); // make sure to clear out no longer known tool chains } void GoToolChainKitInformation::setup(ProjectExplorer::Kit *k) { QTC_ASSERT(ToolChainManager::isLoaded(), return); const QString id = k->value(GoToolChainKitInformation::id()).toString(); if (id.isEmpty()) return; ToolChain *tc = ToolChainManager::findToolChain(id); if (tc) return; // ID is not found: Might be an ABI string... foreach (ToolChain *current, ToolChainManager::toolChains()) { if (current->targetAbi().toString() == id) return setToolChain(k, current); } } ProjectExplorer::KitConfigWidget *GoToolChainKitInformation::createConfigWidget(ProjectExplorer::Kit *k) const { return new Internal::ToolChainInformationConfigWidget(k, this); } QString GoToolChainKitInformation::displayNamePostfix(const ProjectExplorer::Kit *k) const { ToolChain *tc = toolChain(k); return tc ? tc->displayName() : QString(); } ProjectExplorer::KitInformation::ItemList GoToolChainKitInformation::toUserOutput(const ProjectExplorer::Kit *k) const { ToolChain *tc = toolChain(k); return ItemList() << qMakePair(tr("Go - Compiler"), tc ? tc->displayName() : tr("None")); } void GoToolChainKitInformation::addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const { ToolChain *tc = toolChain(k); if (tc) tc->addToEnvironment(env); } ProjectExplorer::IOutputParser *GoToolChainKitInformation::createOutputParser(const ProjectExplorer::Kit *k) const { ToolChain *tc = toolChain(k); if (tc) return tc->outputParser(); return 0; } Core::Id GoToolChainKitInformation::id() { return "GoLang.Profile.GoToolChain"; } ToolChain *GoToolChainKitInformation::toolChain(const ProjectExplorer::Kit *k) { QTC_ASSERT(ToolChainManager::isLoaded(), return 0); if (!k) return 0; return ToolChainManager::findToolChain(k->value(GoToolChainKitInformation::id()).toString()); } void GoToolChainKitInformation::setToolChain(ProjectExplorer::Kit *k, ToolChain *tc) { k->setValue(GoToolChainKitInformation::id(), tc ? tc->id() : QString()); } ProjectExplorer::KitMatcher GoToolChainKitInformation::kitMatcher() { return ProjectExplorer::KitMatcher([](const ProjectExplorer::Kit *k){ if (!k->isValid()) return false; if (!GoToolChainKitInformation::toolChain(k)) return false; ProjectExplorer::IDevice::ConstPtr dev = ProjectExplorer::DeviceKitInformation::device(k); if (dev.isNull() || dev->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) return false; return true; }); } void GoToolChainKitInformation::kitsWereLoaded() { foreach (ProjectExplorer::Kit *k, ProjectExplorer::KitManager::kits()) fix(k); connect(ToolChainManager::instance(), SIGNAL(toolChainRemoved(GoLang::ToolChain*)), this, SLOT(toolChainRemoved(GoLang::ToolChain*))); connect(ToolChainManager::instance(), SIGNAL(toolChainUpdated(GoLang::ToolChain*)), this, SLOT(toolChainUpdated(GoLang::ToolChain*))); } void GoToolChainKitInformation::toolChainUpdated(GoLang::ToolChain *tc) { //foreach (ProjectExplorer::Kit *k, ProjectExplorer::KitManager::matchingKits(ToolChainMatcher(tc))) // notifyAboutUpdate(k); } void GoToolChainKitInformation::toolChainRemoved(GoLang::ToolChain *tc) { Q_UNUSED(tc); foreach (ProjectExplorer::Kit *k, ProjectExplorer::KitManager::kits()) fix(k); } namespace Internal { // -------------------------------------------------------------------------- // ToolChainInformationConfigWidget: // -------------------------------------------------------------------------- ToolChainInformationConfigWidget::ToolChainInformationConfigWidget(ProjectExplorer::Kit *k, const ProjectExplorer::KitInformation *ki) : KitConfigWidget(k, ki) { m_comboBox = new QComboBox; m_comboBox->setEnabled(false); m_comboBox->setToolTip(toolTip()); foreach (ToolChain *tc, ToolChainManager::toolChains()) toolChainAdded(tc); updateComboBox(); refresh(); connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(currentToolChainChanged(int))); m_manageButton = new QPushButton(tr("Manage...")); m_manageButton->setContentsMargins(0, 0, 0, 0); connect(m_manageButton, SIGNAL(clicked()), this, SLOT(manageToolChains())); QObject *tcm = ToolChainManager::instance(); connect(tcm, SIGNAL(toolChainAdded(GoLang::ToolChain*)), this, SLOT(toolChainAdded(GoLang::ToolChain*))); connect(tcm, SIGNAL(toolChainRemoved(GoLang::ToolChain*)), this, SLOT(toolChainRemoved(GoLang::ToolChain*))); connect(tcm, SIGNAL(toolChainUpdated(GoLang::ToolChain*)), this, SLOT(toolChainUpdated(GoLang::ToolChain*))); } ToolChainInformationConfigWidget::~ToolChainInformationConfigWidget() { delete m_comboBox; delete m_manageButton; } QString ToolChainInformationConfigWidget::displayName() const { return tr("Compiler:"); } QString ToolChainInformationConfigWidget::toolTip() const { return tr("The compiler to use for building go projects.
" "Make sure the compiler will produce binaries compatible with the target device, " "Qt version and other libraries used."); } void ToolChainInformationConfigWidget::refresh() { m_comboBox->setCurrentIndex(indexOf(GoToolChainKitInformation::toolChain(m_kit))); } void ToolChainInformationConfigWidget::makeReadOnly() { m_comboBox->setEnabled(false); } QWidget *ToolChainInformationConfigWidget::mainWidget() const { return m_comboBox; } QWidget *ToolChainInformationConfigWidget::buttonWidget() const { return m_manageButton; } void ToolChainInformationConfigWidget::toolChainAdded(GoLang::ToolChain *tc) { m_comboBox->addItem(tc->displayName(), tc->id()); updateComboBox(); } void ToolChainInformationConfigWidget::toolChainRemoved(GoLang::ToolChain *tc) { const int pos = indexOf(tc); if (pos < 0) return; m_comboBox->removeItem(pos); updateComboBox(); } void ToolChainInformationConfigWidget::toolChainUpdated(GoLang::ToolChain *tc) { const int pos = indexOf(tc); if (pos < 0) return; m_comboBox->setItemText(pos, tc->displayName()); } void ToolChainInformationConfigWidget::manageToolChains() { Core::ICore::showOptionsDialog(Constants::TOOLCHAIN_SETTINGS_PAGE_ID, Core::ICore::mainWindow()); } void ToolChainInformationConfigWidget::currentToolChainChanged(int idx) { const QString id = m_comboBox->itemData(idx).toString(); GoToolChainKitInformation::setToolChain(m_kit, ToolChainManager::findToolChain(id)); } void ToolChainInformationConfigWidget::updateComboBox() { // remove unavailable tool chain: int pos = indexOf(0); if (pos >= 0) m_comboBox->removeItem(pos); if (m_comboBox->count() == 0) { m_comboBox->addItem(tr(""), QString()); m_comboBox->setEnabled(false); } else { m_comboBox->setEnabled(true); } } int ToolChainInformationConfigWidget::indexOf(const GoLang::ToolChain *tc) { const QString id = tc ? tc->id() : QString(); for (int i = 0; i < m_comboBox->count(); ++i) { if (id == m_comboBox->itemData(i).toString()) return i; } return -1; } } // namespace Internal } // namespace GoLang qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/gorunconfigurationfactory.cpp0000644000015300001610000000731512562573362030206 0ustar pbuserpbgroup00000000000000#include "gorunconfigurationfactory.h" #include "gokitinformation.h" #include "goproject.h" #include "gorunconfiguration.h" #include "gotoolchain.h" #include #include #include namespace GoLang { namespace Internal { GoRunConfigurationFactory::GoRunConfigurationFactory(QObject *parent) : IRunConfigurationFactory(parent) { } QList GoRunConfigurationFactory::availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const { Q_UNUSED(mode); if (!canHandle(parent)) return QList(); QList list; //our tests already checked if the types match GoProject *pro = static_cast(parent->project()); foreach(const GoBaseTargetItem *t,pro->buildTargets()) { const GoApplicationItem *app = qobject_cast(t); if(!app) continue; Core::Id id(Constants::GO_RUNCONFIG_ID); list << id.withSuffix(app->name()); } return list; } QString GoRunConfigurationFactory::displayNameForId(const Core::Id id) const { QString suffix = id.suffixAfter(Constants::GO_RUNCONFIG_ID); return suffix; } bool GoRunConfigurationFactory::canHandle(ProjectExplorer::Target *parent) const { if (!parent->project()) return false; if (parent->project()->id() != Constants::GO_PROJECT_ID) return false; if (!parent->project()->supportsKit(parent->kit())) return false; GoLang::ToolChain *tc = GoLang::GoToolChainKitInformation::toolChain(parent->kit()); if (!tc || !ProjectExplorer::Abi::hostAbi().isCompatibleWith(tc->targetAbi())) return false; if(ProjectExplorer::DeviceKitInformation::deviceId(parent->kit()) != ProjectExplorer::Constants::DESKTOP_DEVICE_ID) return false; return true; } bool GoRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent, const Core::Id id) const { if (!canHandle(parent)) return false; return availableCreationIds(parent).contains(id); } bool GoRunConfigurationFactory::canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const { if (!parent) return false; if (!ProjectExplorer::idFromMap(map).toSetting().toByteArray().startsWith(Constants::GO_RUNCONFIG_ID )) return false; return true; } ProjectExplorer::RunConfiguration *GoRunConfigurationFactory::doCreate(ProjectExplorer::Target *parent, const Core::Id id) { if (!canCreate(parent, id)) return 0; QString suffix = id.suffixAfter(Constants::GO_RUNCONFIG_ID); if(suffix.isEmpty()) return 0; return new GoRunConfiguration(parent,id); } ProjectExplorer::RunConfiguration *GoRunConfigurationFactory::doRestore(ProjectExplorer::Target *parent, const QVariantMap &map) { if (!canRestore(parent, map)) return NULL; ProjectExplorer::RunConfiguration *conf = new GoRunConfiguration(parent,ProjectExplorer::idFromMap(map)); if(!conf) return NULL; if(!conf->fromMap(map)) { delete conf; return NULL; } return conf; } bool GoRunConfigurationFactory::canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *product) const { return canCreate(parent,product->id()); } ProjectExplorer::RunConfiguration *GoRunConfigurationFactory::clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) { if (!canClone(parent, source)) return NULL; return new GoRunConfiguration(parent,static_cast(source)); } } // namespace Internal } // namespace GoLang qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/gotoolchain.cpp0000644000015300001610000004041712562573362025202 0ustar pbuserpbgroup00000000000000#include "gotoolchain.h" #include "golangconstants.h" #include "toolchainconfigwidget.h" #include #include #include #include #include #include #include #include #include #include #include #include #include namespace GoLang { namespace Internal { static const char compilerCommandKeyC[] = "GoLang.GoToolChain.Path"; static const char goRootKeyC[] = "GoLang.GoToolChain.GoRoot"; static const char targetAbiKeyC[] = "GoLang.GoToolChain.TargetAbi"; static const char supportedAbisKeyC[] = "GoLang.GoToolChain.SupportedAbis"; static QByteArray runGo(const Utils::FileName &goGc, const QStringList &arguments, const QStringList &env) { if (goGc.isEmpty() || !goGc.toFileInfo().isExecutable()) return QByteArray(); QProcess go; // Force locale: This function is used only to detect settings inside the tool chain, so this is save. QStringList environment(env); environment.append(QLatin1String("LC_ALL=C")); go.setEnvironment(environment); go.start(goGc.toString(), arguments); if (!go.waitForStarted()) { qWarning("%s: Cannot start '%s': %s", Q_FUNC_INFO, qPrintable(goGc.toUserOutput()), qPrintable(go.errorString())); return QByteArray(); } go.closeWriteChannel(); if (!go.waitForFinished(10000)) { Utils::SynchronousProcess::stopProcess(go); qWarning("%s: Timeout running '%s'.", Q_FUNC_INFO, qPrintable(goGc.toUserOutput())); return QByteArray(); } if (go.exitStatus() != QProcess::NormalExit) { qWarning("%s: '%s' crashed.", Q_FUNC_INFO, qPrintable(goGc.toUserOutput())); return QByteArray(); } const QByteArray stdErr = go.readAllStandardError(); if (go.exitCode() != 0) { qWarning().nospace() << Q_FUNC_INFO << ": " << goGc.toUserOutput() << ' ' << arguments.join(QLatin1String(" ")) << " returned exit code " << go.exitCode() << ": " << stdErr; return QByteArray(); } QByteArray data = go.readAllStandardOutput(); if (!data.isEmpty() && !data.endsWith('\n')) data.append('\n'); data.append(stdErr); return data; } static QMap getGoEnv (const Utils::FileName &goGc, const QStringList &env) { QStringList arguments = QStringList()< goEnv; if(output.isEmpty()) return goEnv; QRegularExpression regExp(QStringLiteral("\\s?(\\w+)\\s?=\\s?\"(.*)\"")); QList lines = output.split('\n'); foreach(const QByteArray &line , lines ) { QRegularExpressionMatch match = regExp.match(QString::fromLatin1(line)); if(!match.hasMatch()) continue; if(match.lastCapturedIndex() != 2) continue; if(!goEnv.contains(match.captured(1))) goEnv.insert(match.captured(1),match.captured(2)); } return goEnv; } static QList guessGoAbi (const QString &goRoot) { QList result; QDir pkgDir(goRoot+QStringLiteral("/pkg")); if(!pkgDir.exists()) return QList(); QStringList abis = pkgDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); foreach(const QString &abi,abis) { QStringList parts = abi.split(QChar::fromLatin1('_')); //only support linux_arch entries for now if(parts[0] != QStringLiteral("linux") || parts.size() == 0 || parts.size() > 2) continue; ProjectExplorer::Abi::Architecture arch = ProjectExplorer::Abi::UnknownArchitecture; ProjectExplorer::Abi::OS os = ProjectExplorer::Abi::UnknownOS; ProjectExplorer::Abi::OSFlavor flavor = ProjectExplorer::Abi::UnknownFlavor; ProjectExplorer::Abi::BinaryFormat format = ProjectExplorer::Abi::UnknownFormat; int width = 0; int unknownCount = 0; //copied from gcc code, need to check how all the architectures are named in go foreach (const QString &p, parts) { if (p == QLatin1String("386") || p == QLatin1String("486") || p == QLatin1String("586") || p == QLatin1String("686") || p == QLatin1String("x86")) { arch = ProjectExplorer::Abi::X86Architecture; width = 32; } else if (p.startsWith(QLatin1String("arm"))) { arch = ProjectExplorer::Abi::ArmArchitecture; width = 32; } /*else if (p == QLatin1String("mipsel")) { arch = ProjectExplorer::Abi::MipsArchitecture; width = 32; } */else if (p == QLatin1String("x86_64") || p == QLatin1String("amd64")) { arch = ProjectExplorer::Abi::X86Architecture; width = 64; } /*else if (p == QLatin1String("powerpc64")) { arch = ProjectExplorer::Abi::PowerPCArchitecture; width = 64; } else if (p == QLatin1String("powerpc")) { arch = ProjectExplorer::Abi::PowerPCArchitecture; width = 32; } */ else if (p == QLatin1String("linux")) { os = ProjectExplorer::Abi::LinuxOS; if (flavor == ProjectExplorer::Abi::UnknownFlavor) flavor = ProjectExplorer::Abi::GenericLinuxFlavor; format = ProjectExplorer::Abi::ElfFormat; } else if (p.startsWith(QLatin1String("freebsd"))) { os = ProjectExplorer::Abi::BsdOS; if (flavor == ProjectExplorer::Abi::UnknownFlavor) flavor = ProjectExplorer::Abi::FreeBsdFlavor; format = ProjectExplorer::Abi::ElfFormat; } /*else if (p == QLatin1String("mingw32") || p == QLatin1String("win32") || p == QLatin1String("mingw32msvc")) { arch = ProjectExplorer::Abi::X86Architecture; os = ProjectExplorer::Abi::WindowsOS; flavor = ProjectExplorer::Abi::WindowsMSysFlavor; format = ProjectExplorer::Abi::PEFormat; } else if (p == QLatin1String("apple")) { os = ProjectExplorer::Abi::MacOS; flavor = ProjectExplorer::Abi::GenericMacFlavor; format = ProjectExplorer::Abi::MachOFormat; } */else { ++unknownCount; } } if(arch == ProjectExplorer::Abi::UnknownArchitecture) continue; result.append(ProjectExplorer::Abi(arch, os, flavor, format, width)); } return result; } static QList guessGoAbi (const Utils::FileName &goGc, const QStringList &env) { QMap goEnv = getGoEnv(goGc, env); QString rootDirKey = QStringLiteral("GOROOT"); if(goEnv.isEmpty() || !goEnv.contains(rootDirKey)) return QList(); return guessGoAbi(goEnv[rootDirKey]); } GoToolChain::GoToolChain(Detection detect) : ToolChain(QLatin1String(Constants::GO_TOOLCHAIN_ID),detect) { } GoToolChain::GoToolChain(const GoToolChain &other) : ToolChain(other), m_compilerCommand(other.m_compilerCommand), m_goRoot(other.m_goRoot), m_targetAbi(other.m_targetAbi), m_headerPaths(other.m_headerPaths), m_supportedAbis(other.m_supportedAbis) { } void GoToolChain::setCompilerCommand(const Utils::FileName &path, const Utils::FileName &goRoot) { if (path == m_compilerCommand && goRoot == m_goRoot) return; bool resetDisplayName = displayName() == defaultDisplayName(); m_compilerCommand = path; m_goRoot = goRoot; ProjectExplorer::Abi currentAbi = m_targetAbi; m_supportedAbis = detectSupportedAbis(); m_targetAbi = ProjectExplorer::Abi(); if (!m_supportedAbis.isEmpty()) { if (m_supportedAbis.contains(currentAbi)) m_targetAbi = currentAbi; else m_targetAbi = m_supportedAbis.at(0); } if (resetDisplayName) setDisplayName(defaultDisplayName()); // calls toolChainUpdated()! else toolChainUpdated(); } QString GoToolChain::type() const { return QString::fromLatin1(Constants::GO_TOOLCHAIN_ID); } QString GoToolChain::typeDisplayName() const { return QStringLiteral("Go toolchain"); } ProjectExplorer::Abi GoToolChain::targetAbi() const { return m_targetAbi; } bool GoToolChain::isValid() const { if (m_compilerCommand.isNull() || m_goRoot.isNull()) return false; QFileInfo fi = compilerCommand().toFileInfo(); QFileInfo dir = m_goRoot.toFileInfo(); return fi.isExecutable() && dir.isDir(); } QList GoToolChain::systemGoPaths() const { return QList(); } void GoToolChain::addToEnvironment(Utils::Environment &env) const { addCommandPathToEnvironment(m_compilerCommand,env); env.set(QStringLiteral("GOROOT"),goRoot().toString()); env.set(QStringLiteral("GOOS"),QStringLiteral("linux")); env.set(QStringLiteral("GOARCH"),toString(m_targetAbi.architecture(),m_targetAbi.wordWidth())); } Utils::FileName GoToolChain::compilerCommand() const { return m_compilerCommand; } void GoToolChain::setTargetAbi(const ProjectExplorer::Abi &abi) { if(m_targetAbi == abi) return; m_targetAbi = abi; toolChainUpdated(); } QList GoToolChain::supportedAbis() const { if(m_supportedAbis.isEmpty()) updateSupportedAbis(); return m_supportedAbis; } Utils::FileName GoToolChain::goRoot() const { return m_goRoot; } ProjectExplorer::IOutputParser *GoToolChain::outputParser() const { return 0; } ToolChainConfigWidget *GoToolChain::configurationWidget() { return new ToolChainConfigWidget(this); } bool GoToolChain::canClone() const { return true; } ToolChain *GoToolChain::clone() const { return new GoToolChain(*this); } QVariantMap GoToolChain::toMap() const { QVariantMap map = ToolChain::toMap(); map.insert(QLatin1String(compilerCommandKeyC), m_compilerCommand.toString()); map.insert(QLatin1String(goRootKeyC), m_goRoot.toString()); map.insert(QLatin1String(targetAbiKeyC), m_targetAbi.toString()); QStringList abiList; foreach (const ProjectExplorer::Abi &a, m_supportedAbis) abiList.append(a.toString()); map.insert(QLatin1String(supportedAbisKeyC), abiList); return map; } bool GoToolChain::fromMap(const QVariantMap &data) { if(!ToolChain::fromMap(data)) return false; m_compilerCommand = Utils::FileName::fromString(data.value(QLatin1String(compilerCommandKeyC)).toString()); m_goRoot = Utils::FileName::fromString(data.value(QLatin1String(goRootKeyC)).toString()); m_targetAbi = ProjectExplorer::Abi(data.value(QLatin1String(targetAbiKeyC)).toString()); QStringList abiList = data.value(QLatin1String(supportedAbisKeyC)).toStringList(); m_supportedAbis.clear(); foreach (const QString &a, abiList) { ProjectExplorer::Abi abi(a); if (!abi.isValid()) continue; m_supportedAbis.append(abi); } return true; } QList GoToolChain::validateKit(const ProjectExplorer::Kit *k) const { QList result; ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k); if(tc) { ProjectExplorer::Abi targetAbi = tc->targetAbi(); bool compMatch = targetAbi.isCompatibleWith(m_targetAbi); bool fullMatch = (targetAbi == m_targetAbi); QString message; if (!fullMatch) { if (!compMatch) message = QCoreApplication::translate("GoLang::GoToolChain", "The compiler '%1' (%2) cannot produce code for the Go version '%3' (%4)."); else message = QCoreApplication::translate("GoLang::GoToolChain", "The compiler '%1' (%2) may not produce code compatible with the Go version '%3' (%4)."); message = message.arg(tc->displayName(), targetAbi.toString(), displayName(), m_targetAbi.toString()); result << ProjectExplorer::Task(compMatch ? ProjectExplorer::Task::Warning : ProjectExplorer::Task::Error, message, Utils::FileName(), -1, ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM); } } return result; } QString GoToolChain::defaultDisplayName() const { if (!m_targetAbi.isValid()) return typeDisplayName(); return QCoreApplication::translate("GoLang::GoToolChain", "%1 (%2 %3 in %4)").arg(typeDisplayName(), ProjectExplorer::Abi::toString(m_targetAbi.architecture()), ProjectExplorer::Abi::toString(m_targetAbi.wordWidth()), compilerCommand().parentDir().toUserOutput()); } void GoToolChain::updateSupportedAbis() const { if (m_supportedAbis.isEmpty()) m_supportedAbis = detectSupportedAbis(); } QList GoToolChain::detectSupportedAbis() const { Utils::Environment env = Utils::Environment::systemEnvironment(); addToEnvironment(env); return guessGoAbi(m_compilerCommand, env.toStringList()); } void GoToolChain::addCommandPathToEnvironment(const Utils::FileName &command, Utils::Environment &env) { if (!command.isEmpty()) env.prependOrSetPath(command.parentDir().toString()); } QString GoToolChain::toString(ProjectExplorer::Abi::Architecture arch, int width) { switch (arch) { case ProjectExplorer::Abi::ArmArchitecture: return QStringLiteral("arm"); case ProjectExplorer::Abi::X86Architecture:{ if(width == 64) return QStringLiteral("amd64"); return QStringLiteral("386"); } case ProjectExplorer::Abi::UnknownArchitecture: // fall through! default: return QLatin1String("unknown"); } } GoToolChainFactory::GoToolChainFactory() { setId(Constants::GO_TOOLCHAIN_ID); setDisplayName(QStringLiteral("Go Toolchain")); } GoToolChain *GoToolChainFactory::createToolChain(bool autoDetect) { return new GoToolChain(autoDetect ? ToolChain::AutoDetection : ToolChain::ManualDetection); } QList GoToolChainFactory::autoDetect() { QList result; QString compiler = QStringLiteral("go"); Utils::Environment systemEnvironment = Utils::Environment::systemEnvironment(); const Utils::FileName compilerPath = systemEnvironment.searchInPath(compiler); if (compilerPath.isEmpty()) return result; GoToolChain::addCommandPathToEnvironment(compilerPath, systemEnvironment); QString rootKey = QStringLiteral("GOROOT"); QMap goEnv = getGoEnv(compilerPath,systemEnvironment.toStringList()); if(!goEnv.contains(rootKey)) return result; QList abiList = guessGoAbi(goEnv[rootKey]); foreach (const ProjectExplorer::Abi &abi, abiList) { QScopedPointer tc(createToolChain(true)); if (tc.isNull()) return result; tc->setCompilerCommand(compilerPath,Utils::FileName::fromString(goEnv[rootKey])); tc->setTargetAbi(abi); tc->setDisplayName(tc->defaultDisplayName()); // reset displayname result.append(tc.take()); } return result; } bool GoToolChainFactory::canCreate() { return true; } ToolChain *GoToolChainFactory::create() { return createToolChain(false); } bool GoToolChainFactory::canRestore(const QVariantMap &data) { return idFromMap(data).startsWith(QLatin1String(Constants::GO_TOOLCHAIN_ID) + QLatin1Char(':')); } ToolChain *GoToolChainFactory::restore(const QVariantMap &data) { if(!canRestore(data)) return 0; //use Manual detection here it will be overwritten anyway GoToolChain *tc = new GoToolChain(ToolChain::ManualDetection); if (tc->fromMap(data)) return tc; delete tc; return 0; } } // namespace Internal } // namespace GoLang qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/toolchainoptionspage.h0000644000015300001610000001114012562573357026565 0ustar pbuserpbgroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2014 Canonical Ltd. ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef GOLANG_INTERNAL_TOOLCHAINOPTIONSPAGE_H #define GOLANG_INTERNAL_TOOLCHAINOPTIONSPAGE_H #include #include #include QT_BEGIN_NAMESPACE class QItemSelectionModel; class QPushButton; class QTreeView; QT_END_NAMESPACE namespace Utils { class DetailsWidget; } namespace GoLang { class ToolChain; class ToolChainConfigWidget; class ToolChainFactory; namespace Internal { class ToolChainNode; // -------------------------------------------------------------------------- // ToolChainModel // -------------------------------------------------------------------------- class ToolChainModel : public QAbstractItemModel { Q_OBJECT public: explicit ToolChainModel(QObject *parent = 0); ~ToolChainModel(); QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; QModelIndex index(const QModelIndex &topIdx, ToolChain *) const; QModelIndex parent(const QModelIndex &index) const; int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; Qt::ItemFlags flags(const QModelIndex &index) const; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; ToolChain *toolChain(const QModelIndex &); int manualToolChains() const; ToolChainConfigWidget *widget(const QModelIndex &); bool isDirty() const; bool isDirty(ToolChain *) const; void apply(); void markForRemoval(ToolChain *); void markForAddition(ToolChain *); signals: void toolChainStateChanged(); private slots: void addToolChain(ToolChain *); void removeToolChain(ToolChain *); void setDirty(); private: QModelIndex index(ToolChainNode *, int column = 0) const; ToolChainNode *createNode(ToolChainNode *parent, ToolChain *tc, bool changed); ToolChainNode *m_root; ToolChainNode *m_autoRoot; ToolChainNode *m_manualRoot; QList m_toAddList; QList m_toRemoveList; }; // -------------------------------------------------------------------------- // ToolChainOptionsPage // -------------------------------------------------------------------------- class ToolChainOptionsPage : public Core::IOptionsPage { Q_OBJECT public: ToolChainOptionsPage(); QWidget *widget( ) override; void apply(); void finish(); bool matches(const QString &) const; private slots: void toolChainSelectionChanged(); void createToolChain(QObject *); void removeToolChain(); void updateState(); private: QModelIndex currentIndex() const; QPointer m_configWidget; QString m_searchKeywords; ToolChainModel *m_model; QList m_factories; QItemSelectionModel * m_selectionModel; QTreeView *m_toolChainView; Utils::DetailsWidget *m_container; QPushButton *m_addButton; QPushButton *m_cloneButton; QPushButton *m_delButton; }; } // namespace Internal } // namespace GoLang #endif // GOLANG_INTERNAL_TOOLCHAINOPTIONSPAGE_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/golangplugin.qrc0000644000015300001610000000016612562573357025366 0ustar pbuserpbgroup00000000000000 GoProjectManager.mimetypes.xml qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/gorunconfiguration.h0000644000015300001610000000440712562573362026262 0ustar pbuserpbgroup00000000000000#ifndef GOLANG_RUNCONFIGURATION_H #define GOLANG_RUNCONFIGURATION_H #include namespace Utils { class PathChooser; class DetailsWidget; } namespace GoLang { class GoProject; class GoRunConfiguration; class GoRunConfigurationWidget : public QWidget { Q_OBJECT public: explicit GoRunConfigurationWidget(GoRunConfiguration *goRc, QWidget *parent = 0); private slots: void setArguments(const QString &args); void setWorkingDirectory(); void resetWorkingDirectory(); void runInTerminalToggled(bool toggled); void environmentWasChanged(); void workingDirectoryChanged(); void onRcEnabledChanged(); private: void ctor(); bool m_ignoreChange; GoRunConfiguration *m_goRc; Utils::PathChooser *m_workingDirectoryEdit; Utils::DetailsWidget *m_detailsContainer; }; class GoRunConfiguration : public ProjectExplorer::LocalApplicationRunConfiguration { Q_OBJECT public: GoRunConfiguration(ProjectExplorer::Target *t, const Core::Id &id); GoRunConfiguration(ProjectExplorer::Target *t, GoRunConfiguration *other); GoProject *project () const; void setCommandName (const QString &cmdName); void setWorkingDirectory (const QString &dir); void setRunMode (ProjectExplorer::ApplicationLauncher::Mode mode); void setCommandLineArguments (const QString &args); // LocalApplicationRunConfiguration interface virtual QString executable() const override; virtual ProjectExplorer::ApplicationLauncher::Mode runMode() const override; virtual QString workingDirectory() const override; virtual QString commandLineArguments() const override; virtual void addToBaseEnvironment(Utils::Environment &env) const override; // RunConfiguration interface virtual QWidget *createConfigurationWidget() override; // ProjectConfiguration interface virtual bool fromMap(const QVariantMap &map) override; virtual QVariantMap toMap() const override; signals: void workingDirectoryChanged (); private: QString m_defaultWorkingDirectory; QString m_userWorkingDirectory; QString m_commandName; QString m_args; ProjectExplorer::ApplicationLauncher::Mode m_runMode; }; } // namespace GoLang #endif // GOLANG_RUNCONFIGURATION_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/golangconstants.h0000644000015300001610000000146412562573357025550 0ustar pbuserpbgroup00000000000000#ifndef GOLANGCONSTANTS_H #define GOLANGCONSTANTS_H namespace GoLang { namespace Constants { const char GO_PROJECT_MIMETYPE[] = "application/x-goproject"; const char GO_PROJECT_ID[] = "GoProjectManager.GoProject"; const char GO_PROJECT_PROJECTCONTEXT[] = "GoProject.ProjectContext"; const char GO_PROJECT_SUFFIX[] = ".goproject"; const char LANG_GO[] = "GOLANG"; const char GO_TOOLCHAIN_ID[] = "GoLang.Toolchain"; const char TOOLCHAIN_SETTINGS_PAGE_ID[] = "GoLang.SettingsPage"; const char GO_BUILDCONFIGURATION_ID[] = "GoLang.Buildconfiguration"; const char GO_GOSTEP_ID[] = "GoLang.BuildConfiguration.GoStep"; const char GO_RUNCONFIG_ID[] = "GoLang.GoRunConfiguration"; const char GO_SUPPORT_FEATURE[] = "GoLang.GoSupport"; } // namespace Go } // namespace Constants #endif // GOLANGCONSTANTS_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/goprojectitem.cpp0000644000015300001610000001601512562573357025550 0ustar pbuserpbgroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "goprojectitem.h" #include "filefilteritems.h" #include #include namespace GoLang { class GoBaseTargetItemPrivate : public QObject { Q_OBJECT public: QString sourceDirectory; QStringList importPaths; QStringList absoluteImportPaths; QString name; QList qmlFileFilters() const; // content property QList content; }; QList GoBaseTargetItemPrivate::qmlFileFilters() const { QList qmlFilters; for (int i = 0; i < content.size(); ++i) { GoProjectContentItem *contentElement = content.at(i); QmlFileFilterItem *qmlFileFilter = qobject_cast(contentElement); if (qmlFileFilter) qmlFilters << qmlFileFilter; } return qmlFilters; } GoBaseTargetItem::GoBaseTargetItem(QObject *parent) : QObject(parent), d_ptr(new GoBaseTargetItemPrivate) { // Q_D(QmlProjectItem); // // QmlFileFilter *defaultQmlFilter = new QmlFileFilter(this); // d->content.append(defaultQmlFilter); } GoBaseTargetItem::~GoBaseTargetItem() { delete d_ptr; } QString GoBaseTargetItem::sourceDirectory() const { Q_D(const GoBaseTargetItem); return d->sourceDirectory; } // kind of initialization void GoBaseTargetItem::setSourceDirectory(const QString &directoryPath) { Q_D(GoBaseTargetItem); if (d->sourceDirectory == directoryPath) return; d->sourceDirectory = directoryPath; for (int i = 0; i < d->content.size(); ++i) { GoProjectContentItem *contentElement = d->content.at(i); FileFilterBaseItem *fileFilter = qobject_cast(contentElement); if (fileFilter) { fileFilter->setDefaultDirectory(directoryPath); connect(fileFilter, SIGNAL(filesChanged(QSet,QSet)), this, SIGNAL(qmlFilesChanged(QSet,QSet))); } } setImportPaths(d->importPaths); emit sourceDirectoryChanged(); } QStringList GoBaseTargetItem::importPaths() const { Q_D(const GoBaseTargetItem); return d->absoluteImportPaths; } void GoBaseTargetItem::setImportPaths(const QStringList &importPaths) { Q_D(GoBaseTargetItem); if (d->importPaths != importPaths) d->importPaths = importPaths; // convert to absolute paths QStringList absoluteImportPaths; const QDir sourceDir(sourceDirectory()); foreach (const QString &importPath, importPaths) absoluteImportPaths += QDir::cleanPath(sourceDir.absoluteFilePath(importPath)); if (d->absoluteImportPaths == absoluteImportPaths) return; d->absoluteImportPaths = absoluteImportPaths; emit importPathsChanged(); } /* Returns list of absolute paths */ QStringList GoBaseTargetItem::files() const { Q_D(const GoBaseTargetItem); QStringList files; for (int i = 0; i < d->content.size(); ++i) { GoProjectContentItem *contentElement = d->content.at(i); FileFilterBaseItem *fileFilter = qobject_cast(contentElement); if (fileFilter) { foreach (const QString &file, fileFilter->files()) { if (!files.contains(file)) files << file; } } } return files; } /** Check whether the project would include a file path - regardless whether the file already exists or not. @param filePath: absolute file path to check */ bool GoBaseTargetItem::matchesFile(const QString &filePath) const { Q_D(const GoBaseTargetItem); for (int i = 0; i < d->content.size(); ++i) { GoProjectContentItem *contentElement = d->content.at(i); FileFilterBaseItem *fileFilter = qobject_cast(contentElement); if (fileFilter) { if (fileFilter->matchesFile(filePath)) return true; } } return false; } QString GoBaseTargetItem::name() const { Q_D(const GoBaseTargetItem); return d->name; } void GoBaseTargetItem::setName(const QString &name) { Q_D(GoBaseTargetItem); if (name == d->name) return; d->name = name; emit nameChanged(); } void GoBaseTargetItem::appendContent(GoProjectContentItem *contentItem) { Q_D(GoBaseTargetItem); d->content.append(contentItem); } GoProjectItem::GoProjectItem(QObject *parent) : QObject(parent) { } void GoProjectItem::appendTarget(GoBaseTargetItem *contentItem) { m_content.append(contentItem); connect(contentItem,SIGNAL(qmlFilesChanged(QSet,QSet)),this,SIGNAL(filesChanged(QSet,QSet))); } QList GoProjectItem::commands() const { return m_content; } QStringList GoProjectItem::files() const { QStringList files; foreach(GoBaseTargetItem* it, m_content) files += it->files(); return files; } bool GoProjectItem::matchesFile(const QString &filePath) const { foreach(GoBaseTargetItem* it, m_content) { if(it->matchesFile(filePath)) return true; } return false; } QString GoProjectItem::sourceDirectory() const { return m_sourceDir; } void GoProjectItem::setSourceDirectory(const QString &directoryPath) { foreach(GoBaseTargetItem* it, m_content) it->setSourceDirectory(directoryPath); m_sourceDir = directoryPath; } GoApplicationItem::GoApplicationItem(QObject *parent) : GoBaseTargetItem(parent) { } GoApplicationItem::~GoApplicationItem() { } GoPackageItem::GoPackageItem(QObject *parent) : GoBaseTargetItem(parent) { } GoPackageItem::~GoPackageItem() { } } // namespace QmlProjectManager #include "goprojectitem.moc" qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/goprojectfile.h0000644000015300001610000000414612562573362025174 0ustar pbuserpbgroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Author: Juhapekka Piiroinen */ #ifndef GOPROJECTFILE_H #define GOPROJECTFILE_H #include #include "golangconstants.h" #include "goproject.h" #include "goprojectmanager.h" #include #include #include #include #include #include #include #include #include #include #include #include namespace GoLang { class GoProject; namespace Internal { class GoProjectFile : public Core::IDocument { Q_OBJECT public: GoProjectFile(GoProject *parent, QString fileName); ~GoProjectFile() {} bool save(QString *errorString, const QString &fileName, bool autoSave) override; QString fileName() const; void rename(const QString &newName); QString defaultPath() const override; QString suggestedFileName() const override; bool isModified() const override; bool isSaveAsAllowed() const override; ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override; bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override; private: GoProject *m_project; QString m_fileName; }; } } #endif // GOPROJECTFILE_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/goapplicationwizard.h0000644000015300001610000000266412562573362026415 0ustar pbuserpbgroup00000000000000#ifndef GOLANG_GOAPPLICATIONWIZARD_H #define GOLANG_GOAPPLICATIONWIZARD_H #include #include #include QT_BEGIN_NAMESPACE class QLabel; QT_END_NAMESPACE namespace Utils { class PathChooser; } namespace GoLang { class GoApplicationWizard : public ProjectExplorer::CustomProjectWizard { Q_OBJECT public: GoApplicationWizard(); private: Core::BaseFileWizard *create(QWidget *parent, const Core::WizardDialogParameters &wizardDialogParameters) const override; bool postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, QString *errorMessage) const override; private: enum { targetPageId = 1 }; }; class GoApplicationWizardDialog : public ProjectExplorer::BaseProjectWizardDialog { Q_OBJECT public: explicit GoApplicationWizardDialog(const Core::BaseFileWizardFactory *factory, QWidget *parent, const Core::WizardDialogParameters ¶meters); virtual ~GoApplicationWizardDialog(); int addTargetSetupPage(int id = -1); QList selectedKits() const; bool writeUserFile(const QString &projectFileName) const; private slots: void generateProfileName(const QString &name, const QString &path); private: ProjectExplorer::TargetSetupPage *m_targetSetupPage; void init(); }; } // namespace GoLang #endif // GOLANG_GOAPPLICATIONWIZARD_H qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/golangplugin.cpp0000644000015300001610000000720012562573362025353 0ustar pbuserpbgroup00000000000000#include "golangplugin.h" #include "golangconstants.h" #include "goprojectmanager.h" #include "goproject.h" #include "toolchainmanager.h" #include "toolchainoptionspage.h" #include "gotoolchain.h" #include "gobuildconfiguration.h" #include "gokitinformation.h" #include "gorunconfigurationfactory.h" #include "goapplicationwizard.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace GoLang::Internal; class GoLangPluginFeatureProvider : public Core::IFeatureProvider { Core::FeatureSet availableFeatures(const QString & /* platform */) const { return Core::FeatureSet(Core::Feature(GoLang::Constants::GO_SUPPORT_FEATURE)); } QStringList availablePlatforms() const { return QStringList(); } QString displayNameForPlatform(const QString & /* platform */) const { return QString(); } }; GoLangPlugin::GoLangPlugin() { // Create your members } GoLangPlugin::~GoLangPlugin() { // Unregister objects from the plugin manager's object pool // Delete members } bool GoLangPlugin::initialize(const QStringList &arguments, QString *errorString) { // Register objects in the plugin manager's object pool // Load settings // Add actions to menus // Connect to other plugins' signals // In the initialize function, a plugin can be sure that the plugins it // depends on have initialized their members. Q_UNUSED(arguments) Q_UNUSED(errorString) using namespace Core; using namespace Utils; const QLatin1String mimetypesXml(":/goproject/GoProjectManager.mimetypes.xml"); MimeDatabase::addMimeTypes(mimetypesXml); addAutoReleasedObject(new Internal::Manager); addAutoReleasedObject(new ToolChainManager); addAutoReleasedObject(new Internal::ToolChainOptionsPage); addAutoReleasedObject(new GoToolChainFactory); addAutoReleasedObject(new GoBuildConfigurationFactory); addAutoReleasedObject(new GoBuildStepFactory); addAutoReleasedObject(new GoRunConfigurationFactory); Core::IWizardFactory::registerFeatureProvider(new GoLangPluginFeatureProvider); addAutoReleasedObject(new ProjectExplorer::CustomWizardMetaFactory (QLatin1String("goapp-project"), Core::IWizardFactory::ProjectWizard)); ProjectExplorer::KitManager::registerKitInformation(new GoToolChainKitInformation); connect(ProjectExplorer::ToolChainManager::instance(),SIGNAL(toolChainsLoaded()),this,SLOT(restoreToolChains())); return true; } void GoLangPlugin::extensionsInitialized() { // Retrieve objects from the plugin manager's object pool // In the extensionsInitialized function, a plugin can be sure that all // plugins that depend on it are completely initialized. } ExtensionSystem::IPlugin::ShutdownFlag GoLangPlugin::aboutToShutdown() { // Save settings // Disconnect from signals that are not needed during shutdown // Hide UI (if you add UI that is not in the main window directly) return SynchronousShutdown; } void GoLangPlugin::restoreToolChains() { //this has to be called after Projectexplorer has initialized the toolchains, but before the Kits are loaded ToolChainManager::restoreToolChains(); } qtcreator-plugin-go-3.5.0+15.10.20150812.1/src/golang/toolchainoptionspage.cpp0000644000015300001610000005022412562573362027122 0ustar pbuserpbgroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "toolchainoptionspage.h" #include "toolchain.h" #include "toolchainconfigwidget.h" #include "toolchainmanager.h" #include "golangconstants.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace GoLang { namespace Internal { class ToolChainNode { public: explicit ToolChainNode(ToolChainNode *p, ToolChain *tc = 0, bool c = false) : parent(p), toolChain(tc), changed(c) { if (p) p->childNodes.append(this); widget = tc ? tc->configurationWidget() : 0; if (widget && tc->isAutoDetected()) widget->makeReadOnly(); } ~ToolChainNode() { // Do not delete tool chain, we do not own it. for (int i = childNodes.size(); --i >= 0; ) { ToolChainNode *child = childNodes.at(i); child->parent = 0; delete child; } if (parent) parent->childNodes.removeOne(this); } ToolChainNode *parent; QList childNodes; ToolChain *toolChain; ToolChainConfigWidget *widget; bool changed; }; // -------------------------------------------------------------------------- // ToolChainModel // -------------------------------------------------------------------------- ToolChainModel::ToolChainModel(QObject *parent) : QAbstractItemModel(parent) { connect(static_cast(ToolChainManager::instance()), &ToolChainManager::toolChainAdded, this, &ToolChainModel::addToolChain); connect(static_cast(ToolChainManager::instance()), &ToolChainManager::toolChainRemoved, this, &ToolChainModel::removeToolChain); m_root = new ToolChainNode(0); m_autoRoot = new ToolChainNode(m_root); m_manualRoot = new ToolChainNode(m_root); foreach (ToolChain *tc, ToolChainManager::toolChains()) addToolChain(tc); } ToolChainModel::~ToolChainModel() { delete m_root; } QModelIndex ToolChainModel::index(int row, int column, const QModelIndex &parent) const { if (!parent.isValid()) { if (row >= 0 && row < m_root->childNodes.count()) return createIndex(row, column, m_root->childNodes.at(row)); } ToolChainNode *node = static_cast(parent.internalPointer()); if (row < node->childNodes.count() && column < 2) return createIndex(row, column, static_cast(node->childNodes.at(row))); else return QModelIndex(); } QModelIndex ToolChainModel::index(const QModelIndex &topIdx, ToolChain *tc) const { ToolChainNode *current = m_root; if (topIdx.isValid()) current = static_cast(topIdx.internalPointer()); QTC_ASSERT(current, return QModelIndex()); if (current->toolChain == tc) return topIdx; for (int i = 0; i < current->childNodes.count(); ++i) { QModelIndex result = index(index(current->childNodes.at(i)), tc); if (result.isValid()) return result; } return QModelIndex(); } QModelIndex ToolChainModel::parent(const QModelIndex &idx) const { ToolChainNode *node = static_cast(idx.internalPointer()); if (node->parent == m_root) return QModelIndex(); return index(node->parent); } int ToolChainModel::rowCount(const QModelIndex &parent) const { if (!parent.isValid()) return m_root->childNodes.count(); ToolChainNode *node = static_cast(parent.internalPointer()); return node->childNodes.count(); } int ToolChainModel::columnCount(const QModelIndex &parent) const { Q_UNUSED(parent); return 2; } QVariant ToolChainModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); ToolChainNode *node = static_cast(index.internalPointer()); QTC_ASSERT(node, return QVariant()); if (node == m_autoRoot && index.column() == 0 && role == Qt::DisplayRole) return tr("Auto-detected"); if (node == m_manualRoot && index.column() == 0 && role == Qt::DisplayRole) return tr("Manual"); if (node->toolChain) { if (role == Qt::FontRole) { QFont f = QApplication::font(); if (node->changed) f.setBold(true); return f; } if (role == Qt::DisplayRole) { if (index.column() == 0) return node->toolChain->displayName(); return node->toolChain->typeDisplayName(); } if (role == Qt::ToolTipRole) { return tr("ABI: %1") .arg(node->changed ? tr("not up-to-date") : node->toolChain->targetAbi().toString()); } } return QVariant(); } Qt::ItemFlags ToolChainModel::flags(const QModelIndex &index) const { if (!index.isValid()) return 0; ToolChainNode *node = static_cast(index.internalPointer()); Q_ASSERT(node); if (!node->toolChain) return Qt::ItemIsEnabled; return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } QVariant ToolChainModel::headerData(int section, Qt::Orientation orientation, int role) const { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) return section == 0 ? tr("Name") : tr("Type"); return QVariant(); } ToolChain *ToolChainModel::toolChain(const QModelIndex &index) { if (!index.isValid()) return 0; ToolChainNode *node = static_cast(index.internalPointer()); Q_ASSERT(node); return node->toolChain; } int ToolChainModel::manualToolChains() const { return m_manualRoot->childNodes.count(); } ToolChainConfigWidget *ToolChainModel::widget(const QModelIndex &index) { if (!index.isValid()) return 0; ToolChainNode *node = static_cast(index.internalPointer()); Q_ASSERT(node); return node->widget; } bool ToolChainModel::isDirty() const { foreach (ToolChainNode *n, m_manualRoot->childNodes) { if (n->changed) return true; } return false; } bool ToolChainModel::isDirty(ToolChain *tc) const { foreach (ToolChainNode *n, m_manualRoot->childNodes) { if (n->toolChain == tc && n->changed) return true; } return false; } void ToolChainModel::setDirty() { ToolChainConfigWidget *w = qobject_cast(sender()); foreach (ToolChainNode *n, m_manualRoot->childNodes) { if (n->widget == w) { n->changed = true; emit dataChanged(index(n, 0), index(n, columnCount(QModelIndex()))); } } } void ToolChainModel::apply() { // Remove unused tool chains: QList nodes = m_toRemoveList; foreach (ToolChainNode *n, nodes) { Q_ASSERT(!n->parent); ToolChainManager::deregisterToolChain(n->toolChain); } Q_ASSERT(m_toRemoveList.isEmpty()); // Update tool chains: foreach (ToolChainNode *n, m_manualRoot->childNodes) { Q_ASSERT(n); if (n->changed) { Q_ASSERT(n->toolChain); if (n->widget) n->widget->apply(); n->changed = false; emit dataChanged(index(n, 0), index(n, columnCount(QModelIndex()))); } } // Add new (and already updated) tool chains QStringList removedTcs; nodes = m_toAddList; foreach (ToolChainNode *n, nodes) { if (!ToolChainManager::registerToolChain(n->toolChain)) removedTcs << n->toolChain->displayName(); } // foreach (ToolChainNode *n, m_toAddList) { markForRemoval(n->toolChain); } qDeleteAll(m_toAddList); if (removedTcs.count() == 1) { QMessageBox::warning(0, tr("Duplicate Compilers Detected"), tr("The following compiler was already configured:
" " %1
" "It was not configured again.") .arg(removedTcs.at(0))); } else if (!removedTcs.isEmpty()) { QMessageBox::warning(0, tr("Duplicate Compilers Detected"), tr("The following compilers were already configured:
" " %1
" "They were not configured again.") .arg(removedTcs.join(QLatin1String(",
 ")))); } } void ToolChainModel::markForRemoval(ToolChain *tc) { ToolChainNode *node = 0; foreach (ToolChainNode *n, m_manualRoot->childNodes) { if (n->toolChain == tc) { node = n; break; } } if (node) { emit beginRemoveRows(index(m_manualRoot), m_manualRoot->childNodes.indexOf(node), m_manualRoot->childNodes.indexOf(node)); m_manualRoot->childNodes.removeOne(node); node->parent = 0; if (m_toAddList.contains(node)) { delete node->toolChain; node->toolChain = 0; m_toAddList.removeOne(node); delete node; } else { m_toRemoveList.append(node); } emit endRemoveRows(); } } void ToolChainModel::markForAddition(ToolChain *tc) { int pos = m_manualRoot->childNodes.size(); emit beginInsertRows(index(m_manualRoot), pos, pos); ToolChainNode *node = createNode(m_manualRoot, tc, true); m_toAddList.append(node); emit endInsertRows(); } QModelIndex ToolChainModel::index(ToolChainNode *node, int column) const { if (node == m_root) return QModelIndex(); if (node->parent == m_root) return index(m_root->childNodes.indexOf(node), column, QModelIndex()); else return index(node->parent->childNodes.indexOf(node), column, index(node->parent)); } ToolChainNode *ToolChainModel::createNode(ToolChainNode *parent, ToolChain *tc, bool changed) { ToolChainNode *node = new ToolChainNode(parent, tc, changed); if (node->widget) connect(node->widget, SIGNAL(dirty()), this, SLOT(setDirty())); return node; } void ToolChainModel::addToolChain(ToolChain *tc) { QList nodes = m_toAddList; foreach (ToolChainNode *n, nodes) { if (n->toolChain == tc) { m_toAddList.removeOne(n); // do not delete n: Still used elsewhere! return; } } ToolChainNode *parent = m_manualRoot; if (tc->isAutoDetected()) parent = m_autoRoot; int row = parent->childNodes.count(); beginInsertRows(index(parent), row, row); createNode(parent, tc, false); endInsertRows(); emit toolChainStateChanged(); } void ToolChainModel::removeToolChain(ToolChain *tc) { QList nodes = m_toRemoveList; foreach (ToolChainNode *n, nodes) { if (n->toolChain == tc) { m_toRemoveList.removeOne(n); delete n; return; } } ToolChainNode *parent = m_manualRoot; if (tc->isAutoDetected()) parent = m_autoRoot; int row = 0; ToolChainNode *node = 0; foreach (ToolChainNode *current, parent->childNodes) { if (current->toolChain == tc) { node = current; break; } ++row; } beginRemoveRows(index(parent), row, row); parent->childNodes.removeAt(row); delete node; endRemoveRows(); emit toolChainStateChanged(); } // -------------------------------------------------------------------------- // ToolChainOptionsPage // -------------------------------------------------------------------------- ToolChainOptionsPage::ToolChainOptionsPage() : m_model(0), m_selectionModel(0), m_toolChainView(0), m_container(0), m_addButton(0), m_cloneButton(0), m_delButton(0) { setId(Constants::TOOLCHAIN_SETTINGS_PAGE_ID); setDisplayName(tr("Go-Compilers")); setCategory(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY); setDisplayCategory(QCoreApplication::translate("ProjectExplorer", ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_TR_CATEGORY)); setCategoryIcon(QLatin1String(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY_ICON)); } QWidget *ToolChainOptionsPage::widget( ) { // Actual page setup: if(!m_configWidget) { m_configWidget = new QWidget; m_toolChainView = new QTreeView(m_configWidget); m_toolChainView->setUniformRowHeights(true); m_toolChainView->header()->setStretchLastSection(false); m_addButton = new QPushButton(tr("Add"), m_configWidget); m_cloneButton = new QPushButton(tr("Clone"), m_configWidget); m_delButton = new QPushButton(tr("Remove"), m_configWidget); m_container = new Utils::DetailsWidget(m_configWidget); m_container->setState(Utils::DetailsWidget::NoSummary); m_container->setVisible(false); QVBoxLayout *buttonLayout = new QVBoxLayout(); buttonLayout->setSpacing(6); buttonLayout->setContentsMargins(0, 0, 0, 0); buttonLayout->addWidget(m_addButton); buttonLayout->addWidget(m_cloneButton); buttonLayout->addWidget(m_delButton); buttonLayout->addItem(new QSpacerItem(10, 40, QSizePolicy::Minimum, QSizePolicy::Expanding)); QVBoxLayout *verticalLayout = new QVBoxLayout(); verticalLayout->addWidget(m_toolChainView); verticalLayout->addWidget(m_container); QHBoxLayout *horizontalLayout = new QHBoxLayout(m_configWidget); horizontalLayout->addLayout(verticalLayout); horizontalLayout->addLayout(buttonLayout); Q_ASSERT(!m_model); m_model = new ToolChainModel(m_configWidget); connect(m_model, SIGNAL(toolChainStateChanged()), this, SLOT(updateState())); m_toolChainView->setModel(m_model); m_toolChainView->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); m_toolChainView->header()->setSectionResizeMode(1, QHeaderView::Stretch); m_toolChainView->expandAll(); m_selectionModel = m_toolChainView->selectionModel(); connect(m_selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(toolChainSelectionChanged())); connect(ToolChainManager::instance(), SIGNAL(toolChainsChanged()), this, SLOT(toolChainSelectionChanged())); // Get toolchainfactories: m_factories = ExtensionSystem::PluginManager::getObjects(); // Set up add menu: QMenu *addMenu = new QMenu(m_addButton); QSignalMapper *mapper = new QSignalMapper(addMenu); connect(mapper, SIGNAL(mapped(QObject*)), this, SLOT(createToolChain(QObject*))); foreach (ToolChainFactory *factory, m_factories) { if (factory->canCreate()) { QAction *action = new QAction(addMenu); action->setText(factory->displayName()); connect(action, SIGNAL(triggered()), mapper, SLOT(map())); mapper->setMapping(action, static_cast(factory)); addMenu->addAction(action); } } connect(m_cloneButton, SIGNAL(clicked()), mapper, SLOT(map())); mapper->setMapping(m_cloneButton, static_cast(0)); m_addButton->setMenu(addMenu); connect(m_delButton, SIGNAL(clicked()), this, SLOT(removeToolChain())); // setup keywords: if (m_searchKeywords.isEmpty()) { QLatin1Char sep(' '); QTextStream stream(&m_searchKeywords); stream << tr("Compilers"); foreach (ToolChainFactory *f, m_factories) stream << sep << f->displayName(); m_searchKeywords.remove(QLatin1Char('&')); } } updateState(); return m_configWidget; } void ToolChainOptionsPage::apply() { if (m_model) m_model->apply(); } void ToolChainOptionsPage::finish() { disconnect(ToolChainManager::instance(), SIGNAL(toolChainsChanged()), this, SLOT(toolChainSelectionChanged())); if(m_configWidget) { delete m_configWidget; } // children of m_configWidget m_model = 0; m_container = 0; m_selectionModel = 0; m_toolChainView = 0; m_addButton = 0; m_cloneButton = 0; m_delButton = 0; } bool ToolChainOptionsPage::matches(const QString &s) const { return m_searchKeywords.contains(s, Qt::CaseInsensitive); } void ToolChainOptionsPage::toolChainSelectionChanged() { if (!m_container) return; QModelIndex current = currentIndex(); QWidget *oldWidget = m_container->takeWidget(); // Prevent deletion. if (oldWidget) oldWidget->setVisible(false); QWidget *currentTcWidget = current.isValid() ? m_model->widget(current) : 0; m_container->setWidget(currentTcWidget); m_container->setVisible(currentTcWidget != 0); updateState(); } void ToolChainOptionsPage::createToolChain(QObject *factoryObject) { ToolChain *tc = 0; ToolChainFactory *factory = static_cast(factoryObject); if (!factory) { // Copy current item! ToolChain *oldTc = m_model->toolChain(currentIndex()); if (!oldTc) return; tc = oldTc->clone(); } else { QTC_CHECK(factory->canCreate()); tc = factory->create(); } if (!tc) return; m_model->markForAddition(tc); QModelIndex newIdx = m_model->index(QModelIndex(), tc); m_selectionModel->select(newIdx, QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); } void ToolChainOptionsPage::removeToolChain() { ToolChain *tc = m_model->toolChain(currentIndex()); if (!tc) return; m_model->markForRemoval(tc); } void ToolChainOptionsPage::updateState() { if (!m_cloneButton || !m_model || !m_delButton) return; bool canCopy = false; bool canDelete = false; ToolChain *tc = m_model->toolChain(currentIndex()); if (tc) { canCopy = tc->isValid() && tc->canClone(); canDelete = tc->detection() != ToolChain::AutoDetection; } m_cloneButton->setEnabled(canCopy); m_delButton->setEnabled(canDelete); } QModelIndex ToolChainOptionsPage::currentIndex() const { if (!m_selectionModel) return QModelIndex(); QModelIndexList idxs = m_selectionModel->selectedRows(); if (idxs.count() != 1) return QModelIndex(); return idxs.at(0); } } // namespace Internal } // namespace GoLang qtcreator-plugin-go-3.5.0+15.10.20150812.1/LGPL_EXCEPTION.txt0000644000015300001610000000224312562573357023046 0ustar pbuserpbgroup00000000000000Digia Qt LGPL Exception version 1.1 As an additional permission to the GNU Lesser General Public License version 2.1, the object code form of a "work that uses the Library" may incorporate material from a header file that is part of the Library. You may distribute such object code under terms of your choice, provided that: (i) the header files of the Library have not been modified; and (ii) the incorporated material is limited to numerical parameters, data structure layouts, accessors, macros, inline functions and templates; and (iii) you comply with the terms of Section 6 of the GNU Lesser General Public License version 2.1. Moreover, you may apply this exception to a modified version of the Library, provided that such modification does not involve copying material from the Library into the modified Library's header files unless such material is limited to (i) numerical parameters; (ii) data structure layouts; (iii) accessors; and (iv) small macros, templates and inline functions of five lines or less in length. Furthermore, you are not required to apply this additional permission to a modified version of the Library.