aboutsummaryrefslogtreecommitdiffstats
path: root/ide_common
Commit message (Collapse)AuthorAgeFilesLines
* Speed up loadPublicResources()Tor Norbye2012-03-221-34/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The FrameworkResources method which loads in the public resources takes about ~500ms of the target loading time. This changeset optimizes this down to < 50ms using the following three optimizations: 1) Precompute a map from names to ResourceItems before processing the public names. Before this, it would search sequentially through the name list, which when done n times meant O(n^2); we can construct the map in O(n) and then perform n lookups in O(1) => O(n). Also, be smart about which maps we precompute names for: the ResourceType.PUBLIC and ResourceType.DECLARE_STYLEABLE types have about 2,000 items, none of which are public, so skip precomputing maps for these two. (However, keep the linear search around such that if any are exported in the future the code will work correctly. Similarly, we know "roughly" the size of the final public maps, so initialize them in the right size range such that they don't have to do any internal resize+copy operations as we insert into them. 2) In android-15 there are 1500 new <java-symbol> elements in the public xml file, which were being processed, doubling the number of exported symbols. Limit the processing to only the <public> tags. 3) Switch from DOM parsing to pull parsing. This helps since more than half the file consists of <java-symbol> elements, and we can ignore whitespace and id attributes etc, so there is much less object creation involved. Change-Id: I4761e1182b9bc0c50fe94aea7dcd9690754c7908
* Properly support attr ns when used in styles.Xavier Ducrohet2012-03-162-11/+46
| | | | | | | | | | | | | Previously we just stripped the namespace prefix when reading attribute names in styles and declare-styleables. This was bad if one created a declare-styleable mixing platform and app attributes that were named the same. This change is Eclipse side only and prevents ADT crashed (due to stack overflows) but the rendering won't be correct. An updated version of layoutlib using API 8 is necessary. Change-Id: I3029f3e06cdd96cd46af511bb029bc5274b935ad
* Add info about when qualifiers were added to the platform.Xavier Ducrohet2012-03-1622-0/+189
| | | | | | | | This is a first step where we setup the info. Next step is to actually use the info when calling ResourceRepository.getConfiguredResources Change-Id: I03c20ad0ec7a53ec8219316cc4af7a59155ef34a
* Make sure to remove obsolete id from the res repo after a delete.Xavier Ducrohet2012-02-221-2/+2
| | | | Change-Id: I5a42a436dd9d21a632af175a860a85aa1d3b5a1d
* Fix locale handling of uppercase/lowercaseTor Norbye2012-01-062-2/+5
| | | | | | | | | | | | | | | | | This changeset fixes issue 23747: i and İ character problem in turkish operating Systems... and probably many other bugs in the Turkish locale. Basically, we had a lot of String.toLowerCase() and String.toUpperCase() calls. This performs locale sensitive conversions, which in many cases is NOT what we want; for "machine readable" conversions we should be using Locale.US which performs no special cases. For more, see http://developer.android.com/reference/java/util/Locale.html#default_locale Change-Id: I996b0e70fb377e8dae484c5811deb8bc9afb684c
* Add @NonNull annotation and configure Eclipse settingsTor Norbye2011-12-221-1/+13
| | | | | | | | | | | | | | This changeset adds a new @NonNull annotation, to match our existing @Nullable annotation, and it adds configuration settings for Eclipse 3.8 / Eclipse 4.2 which configures the new null analysis there to use our own annotations. Note that the annotations only have source retention so there is no extra size or class-loading overhead. (To use findbugs you'll need to temporarily change retention to class-level.) In upcoming CL's I'll use these annotations to clarify the Lint API and other APIs. Change-Id: I99096d8b8a7e25ef002624d592da7700195a5872
* Update SDK codebase to JDK 6Tor Norbye2011-12-2110-4/+28
| | | | | | | | | | | | | | | | | | | | | This changeset makes the SDK codebase compile with source=1.6 (which means it also requires JDK 6). This means that methods implementing an interface requires @Override's. It also means we can start using APIs like the ArrayDeque class and methods like String#isEmpty(). This changeset looks big but the change is trivial: it's basically adding @Override in all the places that need it, along with some other automatic Eclipse cleanup in certain files (such as reordering imports where they were incorrectly ordered (because older versions of Eclipse didn't always handle inner classes right)), as well as cleaning up trailing whitespace and removing some $NON-NLS-1$ markers on lines where there aren't any string literals anymore. This changeset also sets the source and target JDK level to 6 in the Eclipse compiler .settings file, and synchronizes this file to all the other Eclipse SDK projects. Change-Id: I6a9585aa44c3dee9a5c00739ab22fbdbcb9f8275
* Lint Architecture Changes: Configurations, Categories, etc.Tor Norbye2011-11-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset makes various architectural changes to lint: (1) Add configurations, which are basically user preferences for lint in a given project, such as providing a custom severity for an issue, or disabling a specific warning in a specific file. In Eclipse, there is a project configuration (stored in lint.xml in each project), as well as a global configuration (stored using Eclipse preference data). Project configurations inherit from the global configuration. The options dialog now shows up both as a project property page (showing the issue state for the project configuration), as well as a normal preference page (showing the global or "fallback" configuraiton). I also changed the Options UI for issues from a Table to a TreeViewer to add in category nodes, and changed the checkbox UI to have a custom severity toggle instead. The lint quickfixes also now have 3 suppression options: * Ignore in this file * Ignore in this project * Disable check (2) Change detectors to be registered by class and instantiated for each lint run rather than having a fixed list of detectors get reused over and over. Turns out that since some detectors store state, this prevented lints from running concurrently since the two runs could stomp each other's state. To do this effectively I've also switched from a DetectorRegistry to an IssueRegistry, which contains the global list of available issues and each issue can point to the class detecting the issue (and these are created on the fly based on parameters like scope.) (3) Explicit Categories. Categories used to just be a string property on issues; now it's an explicit class with both a name and an explanation, with parents to allow nesting (such that for example the Usability category has an Icons sub category), and finally the category class provides sorting. Categories also show up in the HTML Report now as separate sections. (4) Other API changes: * I changed the package containing APIs for lint clients to an explicit "client" package * Moved the LintConstants class up from lint-checks to lint-api and added a LintUtils class which contains many generic methods that were spread around in specific detectors. * The detectors are now talking to a wrapper client rather than directly to lint clients, such that the wrapper client can filter out results on disabled checks etc, which means that tools can assume they always get correct reports and don't have to worry about improperly written detectors. * I renamed ToolContext to LintClient. * I got rid of the "isEnabled" state, which was a bit redundant with the severity since severity has a Severity.IGNORE value. * I added a LintListener interface, which notifies about progress (and the CLI tool will print "."'s for each processed file unless suppressed with -q). * A new dispose method on the parser interface to for example allow IDEs to lock/unlock read models on underlying data. (5) I added a toolbar action for running Lint on the currently selected project. I also added an --xml export option intended for use with CI plugins. Change-Id: Icadd9b2d14d075234d97b31398806111af747b7b
* Clean up layout and menu file scanning codeTor Norbye2011-09-028-103/+330
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset fixes some issues around the new lazy scanning of layout and menu files. First, it partly fixes "19657: AAPT errors aren't shown when adding an error to a valid XML file". With the new optimization of not running aapt on layout files where no ids have changed, we would no longer pick up changes where an invalid or nonexistent resource is added. We now perform some basic validation of resources as well as XML parsing errors. Second, it fixes a bug in the id before and after comparison used to determine if aapt needs to run: The code would call map.keySet() before and after the ids were added, but this resolved to the same keyset so the equals comparison was always true regardless of the content. Third, it fixes an infinite loop issue with library projects, and avoids doing unnecessary classpath modifications when there are no changed projects. Finally, it changes the "needsId" flag. The state of whether aapt needs to be run was stored per repository, and there is a bug where it does not get cleared properly which can yield a compilation loop. This changeset introduces a new "ScanningContext" object which is passed down to the various resource file updater methods. This context object now holds the needsId state object (which is renamed to "needsFullAapt"), and it is also the object where errors can be registered. Change-Id: I5632612c2d93e2f10f0803e9223921adb67602be
* Fix NPE in ResourceFolder when deleting foldersTor Norbye2011-09-011-4/+6
| | | | | | | | | | | | This CL fixes an NPE I was hitting when deleting resource folders in an Android project - looks like the children list is populated lazily and dispose does not account for this java.lang.NullPointerException at ResourceFolder.dispose(ResourceFolder.java:131) at ResourceRepository.removeFolder(ResourceRepository.java:146) Change-Id: I96974c68b4ef13e6e348efd6269270d4525322ab
* Precompilation only executes AAPT when necessaryJosiah Gaskin2011-08-184-10/+94
| | | | | | | | | | | | | | | | | | | This change adds resource tracking to the ResourceManager. Each ResourceRepository now has new methods: void markForIdRefresh() to set the repository as "dirty" boolean needsIdRefresh() to check whether the repository is dirty void setIdsRefreshed() to set the repository as "clean" During the precompilation step, the PreCompiler will query the ResourceManager to see if any of the repositories included in the build are marked as dirty. AAPT will only be run if one or more dirty repositories are found. Repositories are marked as clean when R.java is regenerated and IDs are set in ProjectResources. Change-Id: I575ab819702508eacd247b282c3de8979f2f0ab9
* Fix NPETor Norbye2011-08-041-3/+5
| | | | Change-Id: I044342e5aa6b3aaa87efdcc79bbcb3db93190252
* ADT Resource Repo stores IDs and Called OnceJosiah Gaskin2011-08-013-1/+276
| | | | | | | | | | | | | | | | | | This change makes ADT parse out @+id declarations from layout and menu files and store them in its ResourceRepository. This eliminates the need to merge in IDs from the generated R.java in order to have a complete repository of resources. In order to do this, a new type of ResourceFile is created: IdGeneratingResourceFile which is used for xml files in menu/ and layout/. Also includes an IdResourceParser which finds all the declared IDs in an XML. This change also includes a change to the ResourceMananger to process raw deltas that can be provided either from the PreCompilerBuilder or from the GlobalProjectManager. This is to avoid duplicate deltas being passed to ResourceManager when autobuilding. Change-Id: I1c705a5f5a01ce7daa3eb76f14bd6cb9e11b5248
* merge from tools_r12The Android Open-Source Project2011-06-281-2/+4
|\ | | | | | | Change-Id: I83911d9ee56e5d44045a5ecbd28647a551f8ea79
| * Guard against a possible NPE when the rendering fails.Xavier Ducrohet2011-06-281-2/+4
| | | | | | | | Change-Id: I8b0a0c65f2b0d7b7faf10224ac2945081605c5c4
| * Merge df07f53c from master to r12. do not merge.Xavier Ducrohet2011-06-141-1/+3
| | | | | | | | | | | | | | | | Fix parsing of the styleable enum/flag attribute values. Better handling for hexa value > 0x7FFFFFFF Change-Id: I1cbbed8f9d3ce9f1b7396e2d34c7bd33dc18e70f
| * Merge 9d342967 from master to r12. do not merge.Xavier Ducrohet2011-06-143-9/+28
| | | | | | | | | | | | Fix broken equals() in new qualifiers. Change-Id: Id083d11a2941d120ca6fd9438a5a12ed7502ab92
* | Fix value parser to handle attr values not in declare-styleable.Xavier Ducrohet2011-06-243-43/+68
| | | | | | | | | | | | | | Also change the layoutlib sample code to properly get the list of framework attr flag/enum values. Change-Id: Ie0bf126a0fab574d94d0f86b7b2f8581cf4eaae3
* | Sample code to use the layout rendering library.Xavier Ducrohet2011-06-231-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is very basic sample code showing how to render a layout. This explains how to load the resources, create Folderconfig, ResourceResolver, and how to call the LayoutLibrary to do an actual render. There are some big limitations: - can't render custom views because there's nothing compiling them and generating the compiled R.class file. - not all features of ADT are present because there are things that don't make sense outside of an editor (render in context, expand empty layouts, etc...) Change-Id: I0c8676ebfbff27f0e9412bb4b13193ce64082372
* | Merge "Fix parsing of the styleable enum/flag attribute values."Xavier Ducrohet2011-06-141-1/+3
|\ \
| * | Fix parsing of the styleable enum/flag attribute values.Xavier Ducrohet2011-06-141-1/+3
| |/ | | | | | | | | | | Better handling for hexa value > 0x7FFFFFFF Change-Id: If0c2ed23847a720431bceee95f8b264ceb967e3e
* | Fix broken equals() in new qualifiers.Xavier Ducrohet2011-06-143-9/+28
|/ | | | Change-Id: Ide197a390c3d9de8d4e30a8f99f0a32a6ad2191d
* Revert ScreenLayoutSize to ScreenSize.Xavier Ducrohet2011-06-093-29/+29
| | | | | | | | | | | | I hadn't noticed that LayoutLib actually uses ScrenSize through the tools-common-prebuilt.jar, so this API is (somewhat*) frozen. * Somewhat because LayoutLib.jar actually only uses Density and ScreenSize but not the other enums (yet?) so the rename of DockMode is not a problem. Change-Id: Ida3360b0111abd96d2a27c16833b282706774fb6
* Renamed some resource enum/qualifiers to be more consistent with the platform.Xavier Ducrohet2011-06-098-95/+95
| | | | Change-Id: I9c5ea5183e115582e0b805ca3ec75aad70e4a65c
* Merge "Add support for the new width/height resource qualifiers."Xavier Ducrohet2011-06-096-20/+655
|\
| * Add support for the new width/height resource qualifiers.Xavier Ducrohet2011-06-096-20/+655
| | | | | | | | | | | | Also add Television to the dock mode (which is really UI Mode). Change-Id: I97e3fbea1806a32d8267d8e462211add2b122ed0
* | Fix various warningsTor Norbye2011-06-091-1/+8
|/ | | | | | | | | | | | | I ran the latest version of findbugs on our codebase and fixed some (not all!) of the warnings. I also ran with Eclipse 3.7 RC3 and updated our compiler warning settings for the new warnings that are available. I also fixed some DOS line endings in some files (formatted with CRLF instead of LF). Change-Id: I9a9d34a9b60f2cb609245793815d96a4587007b0
* Add proper styleable support.Xavier Ducrohet2011-06-072-24/+55
| | | | Change-Id: I2dc79e71521f93d798fd4a9b33aa59979bef379d
* Improve error message when ADT is older than layoutlib.Xavier Ducrohet2011-06-031-2/+3
| | | | Change-Id: I1d52201c58f9fb92a87fd42585b653bf37730032
* Detect and add special warning for wrong themesTor Norbye2011-05-231-5/+14
| | | | | | | | | | | | | | | | | | | If you open a layout designed for a particular theme in another theme, you can get many confusing error messages. Instead of "attribute missing" it may tell you that it failed to convert a resource to a color or drawable, and so on. To help guide users to the root problem (wrong theme chosen) this changeset detects the scenario where theme attributes can't be resolved, and when these are found the top of the error log will start with a bold message stating that theme resources were not found and to check whether the correct theme is chosen. To do this, the resource resolver emits a new sub-type of the resource missing tag into the error log, which is used in the IDE to prefix the errors with the special error message. Change-Id: Ic29c9af37da4b5cc2c9fb1ca5670c8b8f79bf852
* Fix issue with resource repository when using librariesXavier Ducrohet2011-05-201-1/+2
| | | | Change-Id: I1a3e5ba9ac6e930d4be2daedff9691862f975408
* Add method to LayoutLibrary to query layoutlib api level and rev.Xavier Ducrohet2011-05-191-0/+27
| | | | Change-Id: Ib70e560e7d0be88305383aac18726858d91990ae
* Add baseline/margins to ViewInfo.Xavier Ducrohet2011-05-161-25/+160
| | | | | | | Also make it so that older layoutlib that are using API5 return the value through reflection (done in LayoutLibrary.) Change-Id: I3a32666e525f0f1d37a13e670d1d1c659b8e2027
* Add getViewBaseline to the LayoutLibrary class.Xavier Ducrohet2011-04-181-0/+17
| | | | Change-Id: I29caadc8cb31c4a3aab0863a4fec16534b9bc900
* Move getViewParent/Index from RenderSession to Bridge.Xavier Ducrohet2011-04-061-1/+35
| | | | | | Also update the IProjectCallback to handle expandableListView. Change-Id: I36ca8733182bbd9d169fee3e709ebc532fef7b1e
* Pick layout themes from manifest registrations and target SDKTor Norbye2011-04-041-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset changes the way the layout editor picks themes when a layout is opened. It used to just pick the first available theme in the theme chooser. Now it performs the following checks, in order: * Does this layout have a persisted theme setting from a previous run of the tool? If yes, use it. * Can the activity for this layout be determined? If so, look at the manifest registration for the corresponding activity, and if it specifies a theme, use it. * If not, does the manifest specify a default theme for the project? If so, use it. * If not, is the target SDK version (or the minimum SDK version, if the target is not specified) at least API level 11 or higher? If so, the default theme is "Theme.Holo" * If not, the default theme is "Theme". * If the file to be opened is included from some other layout, use the no-decorations versions of the default layouts, e.g. Theme.NoTitleBar or Theme.Holo.NoActionBar. * At the end of this resolution, the computed theme is stored as the persisted theme setting for this layout, so the above algorithm will only be computed once. We might want to tweak this such that it distinguishes between a default computation of a theme and a manual user choice of a theme. * If the file is opened as "Show Included In" (e.g. rendered within an outer file) then the theme chosen is the one for the outer file. During startup, this information will be asked for each and every layout being reopened, so there is now a "ManifestInfo" class attached to the project which keeps manifest information around. It checks the timestamp of the AndroidManifest.xml file and refreshes its information lazily if necessary. All themes mentioned in the manifest are listed in a special section at the top of the theme chooser (below the entry for the default computed described above). The code to look up the associated Activity of a layout is using a simple heuristic: it looks for usages of the corresponding R.layout field, and prefers references from methods called onCreate or in classes whose superclass name ends with Activity. I tried a different approach where I searched for usages of Activity.setContentView(int) but this failed to identify a number of cases where the activity was doing some simple logic and didn't pass the layout id directly as a parameter in setContentView, so I went back to the basic approach. Change-Id: Ibd3c0f089fefe38e6e6c607d65524990699c86d3
* Extract Style RefactoringTor Norbye2011-03-311-1/+1
| | | | | | | | | | | | | | | Adds a new refactoring, "Extract Style", which will show the user the attributes for the current selected elements (or if invoked from an editor context, the attributes overlapping the current caret or editor selection). The user can select which attributes to extract, and these are then added as a new style in the styles.xml file in the project (which is created if necessary). The user can optionally replace the attributes that were extracted, and the user can also optionally set the style attribute on the elements to the new style. (Both are on by default.) This is integrated with the refactoring quick assistant as well. Change-Id: I0504e86a824b00730482607150a879ff28233618
* Add go to declaration support for styles and embedded textTor Norbye2011-03-211-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset adds support to the Go To Declaration code for styles. Style strings are a bit different from resource URLs - they can have an @android: prefix, but they don't specify a resource type. For example, go to declaration can now jump to the value in the parent attribute: <style name="BrowserTheme" parent="@android:Theme.Black"> This will show the Theme.Black style definition in the SDK's styles.xml document. In addition, the hyperlink resolver can now also link to fragments of an attribute value. In particular, in the above, if you point anywhere to the left of the ".", only the @android:Theme range will be selected. This lets you go to parents, since styles inherit from other styles by adding to them with dots. Third, the hyperlink resolver can now link to resource urls that is in the content part of XML documents (e.g. a text node, not an element name or attribute value). As an example, you can now jump to the color defined inside this style element: <style name="CustomTheme" parent="android:Theme.Light"> <item name="android:bg">@color/custom_theme_color</item> </style> Finally, this changeset adds unit/plugin tests for the hyperlink resolver, which asserts the expected list of matches, and the expected editor context when the default link is opened. Change-Id: I73757ec78405f7c711e13387d0bb046f698799f1
* Merge "Fix unit tests from the previous refactor."Xavier Ducrohet2011-03-1817-0/+960
|\
| * Fix unit tests from the previous refactor.Xavier Ducrohet2011-03-1817-0/+960
| | | | | | | | Change-Id: I464fe3f94e701e619b474f82aaf84ee04d158e71
* | Merge "Move classes to ide-common"Xavier Ducrohet2011-03-1832-0/+4718
|\ \ | |/
| * Move classes to ide-commonXavier Ducrohet2011-03-1732-0/+4718
| | | | | | | | | | | | | | | | | | ResourceFolder/File and children classes (single/multi file) ResourceItem and children classes ResourceRepository (base and framework, project stays in ADT for now) All the ResourceQualifiers and FolderConfiguration Change-Id: I5adc9bdc4886a8fa0ab44860763d594cf7af4bd5
* | Merge "Add missing notice files."Xavier Ducrohet2011-03-171-0/+190
|\ \ | |/ |/|
| * Add missing notice files.Xavier Ducrohet2011-03-151-0/+190
| | | | | | | | | | | | | | | | | | | | Also fix some makefiles to make sure the notices are picked up. - move the makefile outside of the source folder. - resources are now in the source folder directly instead of being inside src/resources. It's much simpler. Change-Id: Ica8ee4c2bc8a9b035d23fc914d4137cdca7e567d
* | Disable the "unecessary else" warning.Raphael Moll2011-03-171-1/+1
|/ | | | | | | | This can be a matter of personal taste, but I find it a lot more readable to write an if {} else {} sometimes, and it's perfectly valid, so really it shouldn't be marked as a warning. Change-Id: Iac1b9bd5f9602b5018f7432422e0a083f4836490
* Add specifc warnings config for most sdk eclipse projects.Xavier Ducrohet2011-03-141-0/+64
| | | | Change-Id: I9837714c5673d43fa7108b16ab264f1017c4bd3d
* Resource management refactoring and clean-up.Xavier Ducrohet2011-03-081-47/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - (I)ResourceRepository is now a common class instead of an interface. This contains most of the code to control a repository (which was extracted from ProjectResources) ProjectResources extends it adding minor features such as library support, and inline ID definition. FrameworkResources extends it adding support for public resources (which used to be duplicated and dispersed in weird places). Changed the way resources are reloaded on resource change event. Instead of marking the resources as modified (using Resource.touch()), the resources are now parsed as the files are processed during the resource delta visitor. This makes more sense as there are now other listeners to the resource changes (hyperlinks) that access the resource list in their listeners, which wouldn't work previously. This also makes the code cleaner as the previous method had to query the repo for items and return a list of new ones, which was kinda crappy. The new code is much simpler, as is the post update process. - ResourceItem is now the base class for resource items. It includes all the small methods that were added by all the child classes or interfaces. Project/ConfigurableResourceItem are merged into the based class. IIdResourceItem and IdResourceItem are gone and replaced by a simpler InlineResourceItem. FrameworkResourceItem is a simple override for framework resources. - Also improved the API of a bit for the resource repository, making more use of unmodifiable lists and emptyList/Map() Change-Id: Ie3ac1995213fed66153c7e7ecbdd170ec257be62
* Remove some non needed asserts.Xavier Ducrohet2011-02-221-1/+0
| | | | Change-Id: Ib12b25d7c7a6630075cfe4f5e757a10673305220
* Fix possible NPE in legacy callback support.Xavier Ducrohet2011-02-061-1/+5
| | | | Change-Id: I5faa155393466e1bc4b2fc1e9417cde91a8be456
* Add to layoutlib the ability to simply render a Drawable.Xavier Ducrohet2011-02-041-7/+23
| | | | | | | | | | | RenderParams is now a base class. SessionParams extends it (and contains the layout and the rendering mode which are not part of the base class). DrawableParams is used for the new action and adds a reference to a ResourceValue. Change-Id: Ieacf4da91fda95df1d25a32ae0953bd9d8028113