forked from eclipse-jdt/eclipse.jdt.core
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Populate build state for each Javac build to support incremental build
- Loading branch information
1 parent
206803d
commit 22ef37e
Showing
6 changed files
with
226 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/JavacVirtualClassFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Microsoft Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Microsoft Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.jdt.internal.javac; | ||
|
||
import org.eclipse.jdt.internal.compiler.ClassFile; | ||
import org.eclipse.jdt.internal.compiler.VirtualClassFile; | ||
|
||
import com.sun.tools.javac.code.Symbol.PackageSymbol; | ||
import com.sun.tools.javac.tree.JCTree.JCClassDecl; | ||
|
||
public class JavacVirtualClassFile extends VirtualClassFile { | ||
JCClassDecl jcClass; | ||
|
||
public JavacVirtualClassFile(JCClassDecl jcClass, ClassFile parentFile) { | ||
this.jcClass = jcClass; | ||
this.isNestedType = !(jcClass.sym.owner instanceof PackageSymbol); | ||
this.enclosingClassFile = parentFile; | ||
} | ||
|
||
@Override | ||
public char[][] getCompoundName() { | ||
String fullName = this.jcClass.sym.flatName().toString(); | ||
String[] names = fullName.split("\\."); | ||
char[][] compoundNames = new char[names.length][]; | ||
for (int i = 0; i < names.length; i++) { | ||
compoundNames[i] = names[i].toCharArray(); | ||
} | ||
|
||
return compoundNames; | ||
} | ||
|
||
@Override | ||
public char[] fileName() { | ||
String fullName = this.jcClass.sym.flatName().toString(); | ||
String compoundName = fullName.replace('.', '/'); | ||
return compoundName.toCharArray(); | ||
} | ||
|
||
@Override | ||
public boolean hasStructuralChanges() { | ||
// TODO keep it as structural changes for each class update, | ||
// and might consider to optimize it later. | ||
return true; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/VirtualClassFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Microsoft Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Microsoft Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.jdt.internal.compiler; | ||
|
||
/** | ||
* Represents a virtual class file that may not contain any actual bytes | ||
* but still encapsulates certain class-related properties such as the | ||
* file name and nested type status. | ||
* | ||
* Clients typically use this class when opting for an alternative compiler | ||
* like Javac to return the generated class files state to the project builder. | ||
* | ||
* @since 3.38 | ||
*/ | ||
public class VirtualClassFile extends ClassFile { | ||
|
||
/** | ||
* Return whether the class file contains structural changes. This flag | ||
* is typically used by the incremental builder to decide whether | ||
* dependent classes need recompilation when the class file is modified. | ||
* Only structural changes will require recompilation of dependent classes. | ||
* | ||
* Structural changes are: | ||
* - modifiers changes for the class, the this.fields or the this.methods | ||
* - signature changes for this.fields or this.methods. | ||
* - changes in the number of this.fields or this.methods | ||
* - changes for field constants | ||
* - changes for thrown exceptions | ||
* - change for the super class or any super interfaces | ||
* - changes for member types name or modifiers | ||
*/ | ||
public boolean hasStructuralChanges() { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters