We have a C++Builder XE project (VCL Forms Application) that has a few dozen forms and units in it. Whenever a file belonging to the project is added, deleted, or renamed, the IDE should do two things:
A call to USEFORM macro is added to or altered in the Project Source file (ProjectName.cpp) if the affected unit is a form or frame
A CppCompile element in the project file (ProjectName.cbproj) is added or altered
However instead of just doing the necessary changes, the IDE shuffles some of the existing USEFORMs and CppCompile records, even if they aren't affected by the changes. If I add a Unit (cpp and header file), the USEFORMs are shuffled even when that wouldn't require any changes to the Project Source, only to the cbproj-file.
I don't see a specific pattern on how the new order is formed. If I edit or rename a single unit, about half of the USEFORMs seem to change position and just a couple or none of the CppCompile records. If a change is made to a copy of the project in two different machines, most of the changes seem to be similar, but not all. This indicates that the reordering is not random.
The behaviour causes problems when using Subversion to merge changes, because it forces to manually resolve conflicts inflicted by the changing order.
So the question is: What might be causing the foregoing behaviour and how to get rid of it?
I haven't been able to find a proper solution to the problem, but here's a simple method for making it slightly less annoying:
Adopt a policy of never committing the random IDE-generated changes to the version control repository. Whenever you make changes to code that trigger mixing up the files, revert all unnecessary changes in ProjectName.cpp and ProjectName.cbproj. At this point it is still fairly easy, as you know which parts of the files actually should have changed. That way, the manual labour is carried out when it still requires the minimal amount of work. Additionally, the work has to be carried out only once, in contrast to leaving the changes untouched, in which case the work has to be repeated every time someone merges the changes.
Related
SUMMARY:
I need the most efficient workflow to individually edit over 200 files, and have them automatically disappear from the search results as they are updated.
DETAILS:
I am in the process of adding logging throughout a legacy system, and need to update over 200 files, each with their own custom code. I need to edit them one by one, and would like for the updated files to automatically disappear from my working search results after I have completed each one. The idea is to know how many and which ones still need to be updated as I slowly work through them all.
I already had to do something similar a few months ago, but on a much smaller scale, and I used an old-school HACK to do it. I did a search and replace for my keyword, and intentionally misspelled it. I then used the misspelled keyword for my search, and corrected it when editing each file, hence automatically removing it from the list. It "works", but is obviously a TOTAL HACK.
I recently started using IntelliJ IDEA, and am not yet familiar with the more advanced features like Find in File Scopes, Search Structurally, Search Templates, etc., but I am sure there HAS to be a "correct" way to do this in IntelliJ, and I just don't know how.
I am currently using "Find in Files" to work through the list, and recently found "All Changed Files" in the Scope list, which is actually the EXACT OPPOSITE of what I need. Is there a way to show "All UNCHANGED Files"??? That would work PERFECTLY in a pinch! But really, I would rather learn the CORRECT way to do this in IntelliJ.
Thanks!
When I save a method and get back to it later, all of my variable names become temp and all of my parameters becomes arg and the code indentation get changed.
Any thoughts on how I can fix this?
The behaviour that you are experiencing is not code formatting at all. You immage is experiencing an issue where it can't access original source code. Thus it uses a backup solution and decomples method bytecode. During the compilation process the variable names are erased, so they can't be re-created during the decompilation, and generic substitudes are used instead.
Now, why you are missing sources is another question. First of all it's important to check if you get some exceptions. Often these happen when you open or save your image, but also thaty may occur when you save methods.
Depending on the Pharo version you may be missing .changes or .sources files. This often happens when you more an image without moving other supporting files.
IntelliJ has a "safe write" option (quotes theirs, for some reason) which, on save, instead of simply updating the file, writes to a temporary file, then deletes the original, then renames the temporary file to the original's name. I hear that vim also does this.
I know this causes problems with programs that are watching the file. Sometimes such programs see the delete, but never see the update, for example.
But what advantages are there? IntelliJ's docs say that there are advantages that would be lost if you turned it off. There must be some reason this option is the default.
It took me a looong time to figure out this was how intellij operated and that it was causing some chronic issues I was facing, and took me even longer to figure out it was an option I could turn off. Now that I have that option, I'd like to know if the cure is worse than the disease, so to speak.
The safe write prevents you from data loss in case something goes wrong during the update. Just think of your computer or Intellij crashing while you are saving the file. You might lose the file completely then. But with safe write you would lose your recent changes only. After the updated version of your file is written to disk without errors, the old version can be replaced. This way you have a valid file version at any point of time during the update process, so no crash or whatever could make you lose all your work on that file. The worst thing which could happen is the loss of your recent changes.
I have two targets in my project with overlapping classes.
I converted one target to arc and now I can't convert second target, beacues files common with first target are already converted. Unchecking these files during conversion not working.
Please help!
I've run into similar problems in the past. The solutions that I came up with weren't particularly elegant, but they did work.
If the second target has a small amount of changes over the first, you can go in to Xcode and change the Objective-C Automatic Reference Counting setting to YES for the second project and then manually fix the problems. This works OK for a small number of files, but isn't as comprehensive.
For significant changes, I ended up using my source control system (Perforce in my case, but git, hg, whatever should work fine) to temporarily roll back my changes for the first target and re-apply them to the second target so that I could use the automated tools, then I did a diff between the files that were changed in both runs to make sure that the changes were the same (I don't recall any differences).
So. The most painless method I figured out was to add second target as build dependency to the first one. Select both in conversion dialogue, and then remove this dependency after conversion. It 100% works.
I have an old VW3/ENVY image with a parcel loaded as unmanaged code (exactly the situation Mastering ENVY/DEVELOPER warns against). Unfortunately, this problem happened a long time ago and it's too late to just "go back" to an image without the parcel loaded.
Apparently, there is a way to solve this problem (we have one development image where this has been solved, and there are normal configuration maps that contain the exact same code as the unmanaged parcel but they can't be loaded), but the exact way has long since been forgotten (and there are some problems with taking that particular dev image as the base for a new runtime image, so I need to find out how how to do it again).
In theory, it should be possible to remove the parcel and reload the code from a configuration map. In practice, all normal ways (using the ParcelBrowser or directly calling UnmanagedCode>>remove) fail. I even tried manually removing the offending selectors from the method dictionary, but past a certain point (involving a call to #primBecome:) the whole image hangs completely (I can't even drop into the debugger). I started hacking the instances of the classes and methods, hoping I'd trick ENVY into thinking that these particular methods are normal versioned code, but without any success yet.
Are there any smalltalk/envy gurus around that still remember enough of VW 3 to provide me with any pointers?
Status update
After a week of trying to solve the problem I finally made it, at least partially, so in case anyone's interested...
First, I had to fix file pointers for the umnanaged code (otherwise, all everything that tried to touch the methods would throw an exception). It looks like ENVY extends Parcel so that, in theory, all integer file pointers are changed to ENVY's void filepointer when loaded, but in my case, I had to do it manually (a Parcel provides enumeration for all selectors it defines). Another way would be to tweak the filePointer code, but that can't easily be done automatically on every image where it's needed.
Then, the parcel can be discarded, which drops the parcel information, but keeps the code. The official "Discard" mechanism needs to have a valid changes file (which envy doesn't use so it has to be set manually, and reset afterwards) and the parcel source (which we fortunately had).
To be able to make any changes to the methods (either manually, or via loading an application or class from ENVY), they need to get rid of their unmanaged status. This can be done by manually tweaking TheClass>>applicationAssocs (I also got rid of all references to the classes in UnmanagedCode sich as timestamps, and removed the reference to the discarded parcel). I actually had some info on how to get to this point from my boss, but I haven't been able to understand the instructions until I almost figured it out by myself.
This finally allowed me to load and reload all the Applications that contained the classes. In theory. In practice, the image still hung completely whenever I tried to load a newer version of the Application (that contained the code formerly in the parcel).
It turned out that the crashes had absolutely nothing to do with the code being unmanaged, but with the fact that the parcel in question modified InputState>>process:, where it caused an exception due to a missing and/or uninitialized class variable (the InputState>>initialize method wasn't called until after the new process: method was in place). I had to modify the Notifier class to dump all exceptions to a file to find out what was going on. Adding the class variable to the source of the class (instead of adding it via reflection), suspending the input processing thread via toBeLoadedCode and starting it again in the loaded method and creating a new version of the application solved even this problem.
Now everything works, in theory. In practice it's still unusable, because reloading the WindowSystem or VisualworksBase applications causes their initialization blocks to run, and a whole lot of settings are reset to their defaults - fonts and font sizes, window colors, UI settings... And there doesn't seem to be any way to just save the settings to a file and load them later on, or just to see what all the settings are (either the official Settings menu doesn't show everything, or we have a heavily tweaked image... so much for reconstructing it from scratch). But that's a completely different question.
Well, normally the recommendation would be that you should be able to rebuild your development image from scratch by loading your code from the repository. But if you had that, then the answer would be simple, just discard that image and reload. I think it's been long enough that I've lost whatever knowledge I've had about how to mess with the internal structures to get it back, and it sounds like you've tried a lot of things. So, although it might be painful, figuring out the recipe to rebuild your development image by loading stuff from the repository sounds like it may be your best bet. It probably isn't all that horrible, there just might be a few dependencies on the image state, or special doits that need to be executed.
You also probably need to validate what's in the repository against what's in the image you're working from. If there was unmanaged code loaded and then someone modified it and saved it, it's not clear to me that it would have been saved to ENVY. So you probably want to audit everything that was unmanaged code and if it's been changed, save that to a repository edition.
Sorry I don't have any better answers.