Greetings,
Issue:
- In C++ sources, performing a reformat removes #include "header.h"
declarations.
What happens:
- It appears AS is attempting to do something similar to java-side
"Organize Imports" during the code style reformatting.
- However, it often removes necessary includes and frequently strips
out all #include statements.
Test case:
# Create new C++ class "Test.h", "Test.cpp"
#- Default template should add `#include "Test.h"` to top of Test.cpp
# Do not compile yet
# Modify Test.h/.cpp in some manner (eg, add empty constructor method)
# Switch to Test.cpp source file
# Reformat (Code :: Reformat Code)
# Watch the #include "Test.h" disappear
#- "Undo" will bring the #include back but, also, undo the formatting
too.
Environment:
- OSX Yosemite
- AS v1.5.0 (stable channel)
- classpath: com.android.tools.build:gradle-experimental:0.3.0-alpha5
-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-all.zip
Java editor performs "Code Reformat" and "Organize Imports" as separate
operations.
Whereas it seems the AS C++ Reformat combines both operations.
- Prefer these be separate for C++ code too
- Or a manner of disabling "organize includes" during the reformat.
Additional note:
- It is entirely possible the "organize includes" for C++ is failing
due to NDK build settings in my build.gradle script.
-- For instance, perhaps Android Studio doesn't know the root of
include paths. Or perhaps it doesn't until after _successfully_ compiling
the CPP sources?
After compile sources _successfully_ AND have something in .H which is used
by .CPP it sometimes works - ie, leaves #includes alone (or is content with
them as is).
- When it _does_ revise header includes (extremely rare success) it
creates extremely wonky statements
-- Example: #include
"/Applications/AndroidStudio/SomethingElseHere/../../../../Long/Path/To/Project/Jni/Dir/../../../../Redirection/To/Cpp/Source/Location/Test.h"
Granted, I place my CPP sources in a "non-AS-standard" location - ie, NOT
under AS the project 'jni' default. But I imagine with all the
cross-platform development out there that this approach is not atypical -
CPP codebase located in a common location and referenced by Xcode, Visual
Studio, and Android Studio IDEs.
--
You received this message because you are subscribed to the Google Groups
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.